Skip to content

Commit 594deca

Browse files
author
Maciej Zimnoch
committed
Review fixes
1 parent 4cd9b07 commit 594deca

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

connection_go18.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ func (mc *mysqlConn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver
4646
return nil, errors.New("mysql: read-only transactions not supported")
4747
}
4848

49+
if err := mc.watchCancel(ctx); err != nil {
50+
return nil, err
51+
}
52+
53+
defer mc.finish()
54+
4955
if sql.IsolationLevel(opts.Isolation) != sql.LevelDefault {
5056
level, err := mapIsolationLevel(opts.Isolation)
5157
if err != nil {
@@ -55,15 +61,9 @@ func (mc *mysqlConn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver
5561
if err != nil {
5662
return nil, err
5763
}
58-
mc.finish()
59-
}
60-
61-
if err := mc.watchCancel(ctx); err != nil {
62-
return nil, err
6364
}
6465

6566
tx, err := mc.Begin()
66-
mc.finish()
6767
if err != nil {
6868
return nil, err
6969
}

0 commit comments

Comments
 (0)