BeginTx implements driver.ConnBeginTx interface
(ctx context.Context, opts driver.TxOptions)
| 608 | |
| 609 | // BeginTx implements driver.ConnBeginTx interface |
| 610 | func (mc *mysqlConn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error) { |
| 611 | if mc.closed.Load() { |
| 612 | return nil, driver.ErrBadConn |
| 613 | } |
| 614 | |
| 615 | if err := mc.watchCancel(ctx); err != nil { |
| 616 | return nil, err |
| 617 | } |
| 618 | defer mc.finish() |
| 619 | |
| 620 | if sql.IsolationLevel(opts.Isolation) != sql.LevelDefault { |
| 621 | level, err := mapIsolationLevel(opts.Isolation) |
| 622 | if err != nil { |
| 623 | return nil, err |
| 624 | } |
| 625 | err = mc.exec("SET TRANSACTION ISOLATION LEVEL " + level) |
| 626 | if err != nil { |
| 627 | return nil, err |
| 628 | } |
| 629 | } |
| 630 | |
| 631 | return mc.begin(opts.ReadOnly) |
| 632 | } |
| 633 | |
| 634 | func (mc *mysqlConn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error) { |
| 635 | dargs, err := namedValueToValue(args) |