(tctx *tcontext.Context, conn *sql.Conn)
| 202 | } |
| 203 | |
| 204 | func (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 | |
| 234 | func (td *tableData) Rows() SQLRowIter { |
| 235 | // should be initialized lazily since it calls rows.Next() which might close the rows when |
nothing calls this directly
no test coverage detected