| 504 | } |
| 505 | |
| 506 | func (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 | |
| 532 | func (c *Conn) Ping(ctx context.Context) error { |
| 533 | if c.conn.IsClosed() { |