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

Method ExecSQL

dumpling/export/conn.go:88–108  ·  view source on GitHub ↗

ExecSQL defines exec statement, and connect to real DB.

(tctx *tcontext.Context, canRetryFunc func(sql.Result, error) error, query string, args ...any)

Source from the content-addressed store, hash-verified

86
87// ExecSQL defines exec statement, and connect to real DB.
88func (conn *BaseConn) ExecSQL(tctx *tcontext.Context, canRetryFunc func(sql.Result, error) error, query string, args ...any) error {
89 retryTime := 0
90 err := utils.WithRetry(tctx, func() (err error) {
91 retryTime++
92 if retryTime > 1 && conn.rebuildConnFn != nil {
93 conn.DBConn, err = conn.rebuildConnFn(conn.DBConn, false)
94 if err != nil {
95 return
96 }
97 }
98 res, err := conn.DBConn.ExecContext(tctx, query, args...)
99 if err = canRetryFunc(res, err); err != nil {
100 tctx.L().Info("cannot execute query", zap.Int("retryTime", retryTime), zap.String("sql", query),
101 zap.Any("args", args), zap.Error(err))
102 return err
103 }
104 return nil
105 }, conn.backOffer)
106 conn.backOffer.Reset()
107 return err
108}

Callers 1

SelectTiDBRowIDFunction · 0.80

Calls 6

WithRetryFunction · 0.92
ExecContextMethod · 0.65
StringMethod · 0.65
ErrorMethod · 0.65
ResetMethod · 0.65
LMethod · 0.45

Tested by

no test coverage detected