diff options
| author | Matt Dee <mdee@hioscar.com> | 2017-08-08 15:58:27 -0400 |
|---|---|---|
| committer | Daniel Theophanes <kardianos@gmail.com> | 2017-08-09 20:06:20 +0000 |
| commit | bd08803680792b553dc78d5b5006ebedadaaccf0 (patch) | |
| tree | 1a45005de948b3f27af29b899a9b4dcd31ab2db4 /src/database/sql/ctxutil.go | |
| parent | d401c427b29f48d5cbc5092e62c20aa8524ce356 (diff) | |
| download | go-bd08803680792b553dc78d5b5006ebedadaaccf0.tar.xz | |
database/sql: fail on unsupported options when context is un-cancellable
Currently, the check for `ctx.Done() == context.Background().Done()`
comes before the check to see if we are ignoring any options. That
check should be done earlier, so that the options are not silently
ignored.
Fixes #21350
Change-Id: I3704e4209854c7d99f3f92498bae831cabc7e419
Reviewed-on: https://go-review.googlesource.com/53970
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/database/sql/ctxutil.go')
| -rw-r--r-- | src/database/sql/ctxutil.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/database/sql/ctxutil.go b/src/database/sql/ctxutil.go index bd652b5462..b73ee86594 100644 --- a/src/database/sql/ctxutil.go +++ b/src/database/sql/ctxutil.go @@ -107,10 +107,6 @@ func ctxDriverBegin(ctx context.Context, opts *TxOptions, ci driver.Conn) (drive return ciCtx.BeginTx(ctx, dopts) } - if ctx.Done() == context.Background().Done() { - return ci.Begin() - } - if opts != nil { // Check the transaction level. If the transaction level is non-default // then return an error here as the BeginTx driver value is not supported. @@ -125,6 +121,10 @@ func ctxDriverBegin(ctx context.Context, opts *TxOptions, ci driver.Conn) (drive } } + if ctx.Done() == context.Background().Done() { + return ci.Begin() + } + txi, err := ci.Begin() if err == nil { select { |
