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)
| 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. |
| 472 | func (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 | |
| 490 | func (c *Conn) exec(ctx context.Context, sql string, arguments ...any) (commandTag pgconn.CommandTag, err error) { |
| 491 | mode := c.config.DefaultQueryExecMode |
no test coverage detected