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

Method QuerySQL

dumpling/export/conn.go:32–53  ·  view source on GitHub ↗

QuerySQL defines query statement, and connect to real DB.

(tctx *tcontext.Context, handleOneRow func(*sql.Rows) error, reset func(), query string, args ...any)

Source from the content-addressed store, hash-verified

30
31// QuerySQL defines query statement, and connect to real DB.
32func (conn *BaseConn) QuerySQL(tctx *tcontext.Context, handleOneRow func(*sql.Rows) error, reset func(), query string, args ...any) error {
33 retryTime := 0
34 err := utils.WithRetry(tctx, func() (err error) {
35 retryTime++
36 if retryTime > 1 && conn.rebuildConnFn != nil {
37 conn.DBConn, err = conn.rebuildConnFn(conn.DBConn, false)
38 if err != nil {
39 return
40 }
41 }
42 err = simpleQueryWithArgs(tctx, conn.DBConn, handleOneRow, query, args...)
43 if err != nil {
44 tctx.L().Info("cannot execute query", zap.Int("retryTime", retryTime), zap.String("sql", query),
45 zap.Any("args", args), zap.Error(err))
46 reset()
47 return err
48 }
49 return nil
50 }, conn.backOffer)
51 conn.backOffer.Reset()
52 return err
53}
54
55// QuerySQLWithColumns defines query statement, and connect to real DB and get results for special column names
56func (conn *BaseConn) QuerySQLWithColumns(tctx *tcontext.Context, columns []string, query string, args ...any) ([][]string, error) {

Callers 12

ShowCreateDatabaseFunction · 0.80
ShowCreateTableFunction · 0.80
ShowCreateViewFunction · 0.80
ShowCreateSequenceFunction · 0.80
GetColumnTypesFunction · 0.80
detectEstimateRowsFunction · 0.80
GetPartitionNamesFunction · 0.80
selectTiDBTableSampleFunction · 0.80
selectTiDBTableRegionFunction · 0.80

Calls 6

WithRetryFunction · 0.92
simpleQueryWithArgsFunction · 0.85
StringMethod · 0.65
ErrorMethod · 0.65
ResetMethod · 0.65
LMethod · 0.45

Tested by

no test coverage detected