@@ -14,9 +14,9 @@ import (
1414)
1515
1616type tx struct {
17- conn * conn
18- beginCtx context.Context
19- tx table.Transaction
17+ conn * conn
18+ txCtx context.Context
19+ tx table.Transaction
2020}
2121
2222var (
@@ -45,9 +45,9 @@ func (c *conn) beginTx(ctx context.Context, txOptions driver.TxOptions) (current
4545 return nil , badconn .Map (xerrors .WithStackTrace (err ))
4646 }
4747 c .currentTx = & tx {
48- conn : c ,
49- beginCtx : ctx ,
50- tx : transaction ,
48+ conn : c ,
49+ txCtx : ctx ,
50+ tx : transaction ,
5151 }
5252 return c .currentTx , nil
5353}
@@ -71,7 +71,7 @@ func (tx *tx) checkTxState() error {
7171}
7272
7373func (tx * tx ) Commit () (finalErr error ) {
74- onDone := trace .DatabaseSQLOnTxCommit (tx .conn .trace , & tx .beginCtx , stack .FunctionID (0 ), tx )
74+ onDone := trace .DatabaseSQLOnTxCommit (tx .conn .trace , & tx .txCtx , stack .FunctionID (0 ), tx )
7575 defer func () {
7676 onDone (finalErr )
7777 }()
@@ -81,15 +81,15 @@ func (tx *tx) Commit() (finalErr error) {
8181 defer func () {
8282 tx .conn .currentTx = nil
8383 }()
84- _ , err := tx .tx .CommitTx (tx .beginCtx )
84+ _ , err := tx .tx .CommitTx (tx .txCtx )
8585 if err != nil {
8686 return badconn .Map (xerrors .WithStackTrace (err ))
8787 }
8888 return nil
8989}
9090
9191func (tx * tx ) Rollback () (finalErr error ) {
92- onDone := trace .DatabaseSQLOnTxRollback (tx .conn .trace , & tx .beginCtx , stack .FunctionID (0 ), tx )
92+ onDone := trace .DatabaseSQLOnTxRollback (tx .conn .trace , & tx .txCtx , stack .FunctionID (0 ), tx )
9393 defer func () {
9494 onDone (finalErr )
9595 }()
@@ -99,7 +99,7 @@ func (tx *tx) Rollback() (finalErr error) {
9999 defer func () {
100100 tx .conn .currentTx = nil
101101 }()
102- err := tx .tx .Rollback (tx .beginCtx )
102+ err := tx .tx .Rollback (tx .txCtx )
103103 if err != nil {
104104 return badconn .Map (xerrors .WithStackTrace (err ))
105105 }
@@ -109,7 +109,7 @@ func (tx *tx) Rollback() (finalErr error) {
109109func (tx * tx ) QueryContext (ctx context.Context , query string , args []driver.NamedValue ) (
110110 _ driver.Rows , finalErr error ,
111111) {
112- onDone := trace .DatabaseSQLOnTxQuery (tx .conn .trace , & ctx , stack .FunctionID (0 ), & tx .beginCtx , tx , query , true )
112+ onDone := trace .DatabaseSQLOnTxQuery (tx .conn .trace , & ctx , stack .FunctionID (0 ), tx .txCtx , tx , query , true )
113113 defer func () {
114114 onDone (finalErr )
115115 }()
@@ -147,7 +147,7 @@ func (tx *tx) QueryContext(ctx context.Context, query string, args []driver.Name
147147func (tx * tx ) ExecContext (ctx context.Context , query string , args []driver.NamedValue ) (
148148 _ driver.Result , finalErr error ,
149149) {
150- onDone := trace .DatabaseSQLOnTxExec (tx .conn .trace , & ctx , stack .FunctionID (0 ), & tx .beginCtx , tx , query , true )
150+ onDone := trace .DatabaseSQLOnTxExec (tx .conn .trace , & ctx , stack .FunctionID (0 ), tx .txCtx , tx , query , true )
151151 defer func () {
152152 onDone (finalErr )
153153 }()
@@ -177,18 +177,18 @@ func (tx *tx) ExecContext(ctx context.Context, query string, args []driver.Named
177177}
178178
179179func (tx * tx ) PrepareContext (ctx context.Context , query string ) (_ driver.Stmt , finalErr error ) {
180- onDone := trace .DatabaseSQLOnTxPrepare (tx .conn .trace , & ctx , stack .FunctionID (0 ), & tx .beginCtx , tx , query )
180+ onDone := trace .DatabaseSQLOnTxPrepare (tx .conn .trace , & ctx , stack .FunctionID (0 ), & tx .txCtx , tx , query )
181181 defer func () {
182182 onDone (finalErr )
183183 }()
184184 if ! tx .conn .isReady () {
185185 return nil , badconn .Map (xerrors .WithStackTrace (errNotReadyConn ))
186186 }
187187 return & stmt {
188- conn : tx .conn ,
189- processor : tx ,
190- prepareCtx : ctx ,
191- query : query ,
192- trace : tx .conn .trace ,
188+ conn : tx .conn ,
189+ processor : tx ,
190+ stmtCtx : ctx ,
191+ query : query ,
192+ trace : tx .conn .trace ,
193193 }, nil
194194}
0 commit comments