| 454 | } |
| 455 | |
| 456 | func (c *Conn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error) { |
| 457 | if c.conn.IsClosed() { |
| 458 | return nil, driver.ErrBadConn |
| 459 | } |
| 460 | |
| 461 | var pgxOpts pgx.TxOptions |
| 462 | switch sql.IsolationLevel(opts.Isolation) { |
| 463 | case sql.LevelDefault: |
| 464 | case sql.LevelReadUncommitted: |
| 465 | pgxOpts.IsoLevel = pgx.ReadUncommitted |
| 466 | case sql.LevelReadCommitted: |
| 467 | pgxOpts.IsoLevel = pgx.ReadCommitted |
| 468 | case sql.LevelRepeatableRead, sql.LevelSnapshot: |
| 469 | pgxOpts.IsoLevel = pgx.RepeatableRead |
| 470 | case sql.LevelSerializable: |
| 471 | pgxOpts.IsoLevel = pgx.Serializable |
| 472 | default: |
| 473 | return nil, fmt.Errorf("unsupported isolation: %v", opts.Isolation) |
| 474 | } |
| 475 | |
| 476 | if opts.ReadOnly { |
| 477 | pgxOpts.AccessMode = pgx.ReadOnly |
| 478 | } |
| 479 | |
| 480 | tx, err := c.conn.BeginTx(ctx, pgxOpts) |
| 481 | if err != nil { |
| 482 | return nil, err |
| 483 | } |
| 484 | |
| 485 | return wrapTx{ctx: ctx, tx: tx}, nil |
| 486 | } |
| 487 | |
| 488 | func (c *Conn) ExecContext(ctx context.Context, query string, argsV []driver.NamedValue) (driver.Result, error) { |
| 489 | if c.conn.IsClosed() { |