MCPcopy
hub / github.com/jackc/pgx / QueryContext

Method QueryContext

stdlib/sql.go:506–530  ·  view source on GitHub ↗
(ctx context.Context, query string, argsV []driver.NamedValue)

Source from the content-addressed store, hash-verified

504}
505
506func (c *Conn) QueryContext(ctx context.Context, query string, argsV []driver.NamedValue) (driver.Rows, error) {
507 if c.conn.IsClosed() {
508 return nil, driver.ErrBadConn
509 }
510
511 args := make([]any, 1+len(argsV))
512 args[0] = databaseSQLResultFormats
513 convertNamedArguments(args[1:], argsV)
514
515 rows, err := c.conn.Query(ctx, query, args...)
516 if err != nil {
517 if pgconn.SafeToRetry(err) {
518 return nil, driver.ErrBadConn
519 }
520 return nil, err
521 }
522
523 // Preload first row because otherwise we won't know what columns are available when database/sql asks.
524 more := rows.Next()
525 if err = rows.Err(); err != nil {
526 rows.Close()
527 return nil, err
528 }
529 return &Rows{conn: c, rows: rows, skipNext: true, skipNextMore: more}, nil
530}
531
532func (c *Conn) Ping(ctx context.Context) error {
533 if c.conn.IsClosed() {

Callers 3

QueryContextMethod · 0.45

Calls 7

SafeToRetryFunction · 0.92
convertNamedArgumentsFunction · 0.85
QueryMethod · 0.65
NextMethod · 0.65
ErrMethod · 0.65
CloseMethod · 0.65
IsClosedMethod · 0.45

Tested by 2