Skip to content

Commit 9aae8e2

Browse files
author
Maciej Zimnoch
committed
Review fixes
1 parent 4cd9b07 commit 9aae8e2

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

connection_go18.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,21 @@ 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+
4953
if sql.IsolationLevel(opts.Isolation) != sql.LevelDefault {
5054
level, err := mapIsolationLevel(opts.Isolation)
5155
if err != nil {
56+
mc.finish()
5257
return nil, err
5358
}
5459
err = mc.exec("SET TRANSACTION ISOLATION LEVEL " + level)
5560
if err != nil {
61+
mc.finish()
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()

0 commit comments

Comments
 (0)