mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
database/sql: clarify when statement in transaction is closed
Fixes #16346. Change-Id: Ie75a4ae7011036dd2c1f121a7a5e38d10177721e Reviewed-on: https://go-review.googlesource.com/33296 Reviewed-by: Daniel Theophanes <kardianos@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
26069e1981
commit
b75b9e1d65
1 changed files with 6 additions and 6 deletions
|
|
@ -1436,8 +1436,8 @@ func (tx *Tx) Rollback() error {
|
||||||
|
|
||||||
// Prepare creates a prepared statement for use within a transaction.
|
// Prepare creates a prepared statement for use within a transaction.
|
||||||
//
|
//
|
||||||
// The returned statement operates within the transaction and can no longer
|
// The returned statement operates within the transaction and will be closed
|
||||||
// be used once the transaction has been committed or rolled back.
|
// when the transaction has been committed or rolled back.
|
||||||
//
|
//
|
||||||
// To use an existing prepared statement on this transaction, see Tx.Stmt.
|
// To use an existing prepared statement on this transaction, see Tx.Stmt.
|
||||||
//
|
//
|
||||||
|
|
@ -1506,8 +1506,8 @@ func (tx *Tx) Prepare(query string) (*Stmt, error) {
|
||||||
// ...
|
// ...
|
||||||
// res, err := tx.StmtContext(ctx, updateMoney).Exec(123.45, 98293203)
|
// res, err := tx.StmtContext(ctx, updateMoney).Exec(123.45, 98293203)
|
||||||
//
|
//
|
||||||
// The returned statement operates within the transaction and can no longer
|
// The returned statement operates within the transaction and will be closed
|
||||||
// be used once the transaction has been committed or rolled back.
|
// when the transaction has been committed or rolled back.
|
||||||
func (tx *Tx) StmtContext(ctx context.Context, stmt *Stmt) *Stmt {
|
func (tx *Tx) StmtContext(ctx context.Context, stmt *Stmt) *Stmt {
|
||||||
// TODO(bradfitz): optimize this. Currently this re-prepares
|
// TODO(bradfitz): optimize this. Currently this re-prepares
|
||||||
// each time. This is fine for now to illustrate the API but
|
// each time. This is fine for now to illustrate the API but
|
||||||
|
|
@ -1551,8 +1551,8 @@ func (tx *Tx) StmtContext(ctx context.Context, stmt *Stmt) *Stmt {
|
||||||
// ...
|
// ...
|
||||||
// res, err := tx.Stmt(updateMoney).Exec(123.45, 98293203)
|
// res, err := tx.Stmt(updateMoney).Exec(123.45, 98293203)
|
||||||
//
|
//
|
||||||
// The returned statement operates within the transaction and can no longer
|
// The returned statement operates within the transaction and will be closed
|
||||||
// be used once the transaction has been committed or rolled back.
|
// when the transaction has been committed or rolled back.
|
||||||
func (tx *Tx) Stmt(stmt *Stmt) *Stmt {
|
func (tx *Tx) Stmt(stmt *Stmt) *Stmt {
|
||||||
return tx.StmtContext(context.Background(), stmt)
|
return tx.StmtContext(context.Background(), stmt)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue