]> Cypherpunks repositories - gostls13.git/commit
database/sql: Use Tx.ctx in Tx non-context methods
authorBulat Gaifullin <gaifullinbf@gmail.com>
Tue, 6 Jun 2017 17:20:06 +0000 (20:20 +0300)
committerDaniel Theophanes <kardianos@gmail.com>
Wed, 7 Jun 2017 21:15:36 +0000 (21:15 +0000)
commitef0f7fb92b9458d7d35ee3c10ae853e3dc3077eb
tree0e1f71465a909e605704253f798e7051981d6590
parentb7c51c5fefcbe6e8d21ce0c5e058b1f9cf7ea6ab
database/sql: Use Tx.ctx in Tx non-context methods

The Tx methods Query and Exec uses context.Background()
even Tx was created by context.
This patch enables using Tx.ctx in all Tx methods
which do not has context arg.
Backward compatibility:
- If Tx has created without context, nothing changes.
- If Tx has created with context and non-context method is called:
  - If context is expired, the execution fails,
    but it can fail on Commit or Rollback as well,
    so in terms of whole transaction - nothing changes.
  - If context is not expired, nothing changes too.

Fixes #20098
Change-Id: I9570a2deaace5875bb4c5dcf7b3a084a6bcd0d00
Reviewed-on: https://go-review.googlesource.com/44956
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/database/sql/sql.go
src/database/sql/sql_test.go