MCPcopy
hub / github.com/pingcap/tidb / Start

Method Start

dumpling/export/ir_impl.go:204–232  ·  view source on GitHub ↗
(tctx *tcontext.Context, conn *sql.Conn)

Source from the content-addressed store, hash-verified

202}
203
204func (td *tableData) Start(tctx *tcontext.Context, conn *sql.Conn) error {
205 tctx.L().Debug("try to start tableData", zap.String("query", td.query))
206 rows, err := conn.QueryContext(tctx, td.query)
207 if err != nil {
208 return errors.Annotatef(err, "sql: %s", td.query)
209 }
210 if err = rows.Err(); err != nil {
211 return errors.Annotatef(err, "sql: %s", td.query)
212 }
213 td.SQLRowIter = nil
214 td.rows = rows
215 if td.needColTypes {
216 ns, err := rows.Columns()
217 if err != nil {
218 return errors.Trace(err)
219 }
220 td.colLen = len(ns)
221 td.colTypes = make([]string, 0, td.colLen)
222 colTps, err := rows.ColumnTypes()
223 if err != nil {
224 return errors.Trace(err)
225 }
226 for _, c := range colTps {
227 td.colTypes = append(td.colTypes, c.DatabaseTypeName())
228 }
229 }
230
231 return nil
232}
233
234func (td *tableData) Rows() SQLRowIter {
235 // should be initialized lazily since it calls rows.Next() which might close the rows when

Callers

nothing calls this directly

Calls 5

StringMethod · 0.65
QueryContextMethod · 0.65
ColumnsMethod · 0.65
ColumnTypesMethod · 0.65
LMethod · 0.45

Tested by

no test coverage detected