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

Function SelectTiDBRowID

dumpling/export/sql.go:565–581  ·  view source on GitHub ↗

SelectTiDBRowID checks whether this table has _tidb_rowid column

(tctx *tcontext.Context, db *BaseConn, database, table string)

Source from the content-addressed store, hash-verified

563
564// SelectTiDBRowID checks whether this table has _tidb_rowid column
565func 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
584func GetSuitableRows(avgRowLength uint64) uint64 {

Callers 2

TestSelectTiDBRowIDFunction · 0.85
dumpTableMetaFunction · 0.85

Calls 5

ExecSQLMethod · 0.80
escapeStringFunction · 0.70
ToLowerMethod · 0.65
ErrorMethod · 0.65
ContainsMethod · 0.65

Tested by 1

TestSelectTiDBRowIDFunction · 0.68