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

Method Exec

conn.go:472–488  ·  conn.go::Conn.Exec

Exec executes sql. sql can be either a prepared statement name or an SQL string. arguments should be referenced positionally from the sql string as $1, $2, etc.

(ctx context.Context, sql string, arguments ...any)

Source from the content-addressed store, hash-verified

470// Exec executes sql. sql can be either a prepared statement name or an SQL string. arguments should be referenced
471// positionally from the sql string as $1, $2, etc.
472func (c *Conn) Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error) {
473 if c.queryTracer != nil {
474 ctx = c.queryTracer.TraceQueryStart(ctx, c, TraceQueryStartData{SQL: sql, Args: arguments})
475 }
476
477 if err := c.deallocateInvalidatedCachedStatements(ctx); err != nil {
478 return pgconn.CommandTag{}, err
479 }
480
481 commandTag, err := c.exec(ctx, sql, arguments...)
482
483 if c.queryTracer != nil {
484 c.queryTracer.TraceQueryEnd(ctx, c, TraceQueryEndData{CommandTag: commandTag, Err: err})
485 }
486
487 return commandTag, err
488}
489
490func (c *Conn) exec(ctx context.Context, sql string, arguments ...any) (commandTag pgconn.CommandTag, err error) {
491 mode := c.config.DefaultQueryExecMode

Callers 1

BeginTxMethod · 0.95

Calls 4

execMethod · 0.95
TraceQueryStartMethod · 0.65
TraceQueryEndMethod · 0.65

Tested by

no test coverage detected