SelectTiDBRowID checks whether this table has _tidb_rowid column
(tctx *tcontext.Context, db *BaseConn, database, table string)
| 563 | |
| 564 | // SelectTiDBRowID checks whether this table has _tidb_rowid column |
| 565 | func SelectTiDBRowID(tctx *tcontext.Context, db *BaseConn, database, table string) (bool, error) { |
| 566 | tiDBRowIDQuery := fmt.Sprintf("SELECT _tidb_rowid from `%s`.`%s` LIMIT 1", escapeString(database), escapeString(table)) |
| 567 | hasImplictRowID := false |
| 568 | err := db.ExecSQL(tctx, func(_ sql.Result, err error) error { |
| 569 | if err != nil { |
| 570 | hasImplictRowID = false |
| 571 | errMsg := strings.ToLower(err.Error()) |
| 572 | if strings.Contains(errMsg, fmt.Sprintf("%d", errno.ErrBadField)) { |
| 573 | return nil |
| 574 | } |
| 575 | return errors.Annotatef(err, "sql: %s", tiDBRowIDQuery) |
| 576 | } |
| 577 | hasImplictRowID = true |
| 578 | return nil |
| 579 | }, tiDBRowIDQuery) |
| 580 | return hasImplictRowID, err |
| 581 | } |
| 582 | |
| 583 | // GetSuitableRows gets suitable rows for each table |
| 584 | func GetSuitableRows(avgRowLength uint64) uint64 { |