MCPcopy
hub / github.com/go-sql-driver/mysql / PrepareContext

Method PrepareContext

connection.go:667–685  ·  view source on GitHub ↗
(ctx context.Context, query string)

Source from the content-addressed store, hash-verified

665}
666
667func (mc *mysqlConn) PrepareContext(ctx context.Context, query string) (driver.Stmt, error) {
668 if err := mc.watchCancel(ctx); err != nil {
669 return nil, err
670 }
671
672 stmt, err := mc.Prepare(query)
673 mc.finish()
674 if err != nil {
675 return nil, err
676 }
677
678 select {
679 default:
680 case <-ctx.Done():
681 stmt.Close()
682 return nil, ctx.Err()
683 }
684 return stmt, nil
685}
686
687func (stmt *mysqlStmt) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error) {
688 dargs, err := namedValueToValue(args)

Callers 5

TestContextCancelPrepareFunction · 0.80
benchmarkQueryContextFunction · 0.80
benchmarkExecContextFunction · 0.80

Calls 4

watchCancelMethod · 0.95
PrepareMethod · 0.95
finishMethod · 0.95
CloseMethod · 0.45

Tested by 5

TestContextCancelPrepareFunction · 0.64
benchmarkQueryContextFunction · 0.64
benchmarkExecContextFunction · 0.64