@@ -135,23 +135,12 @@ func (c *conn) PrepareContext(ctx context.Context, query string) (_ driver.Stmt,
135135 }, nil
136136}
137137
138- func (c * conn ) ExecContext (ctx context.Context , query string , args []driver.NamedValue ) (_ driver.Result , err error ) {
138+ func (c * conn ) execContext (ctx context.Context , query string , args []driver.NamedValue ) (_ driver.Result , err error ) {
139139 m := queryModeFromContext (ctx , c .defaultQueryMode )
140140 onDone := trace .DatabaseSQLOnConnExec (c .trace , & ctx , query , m .String (), retry .IsIdempotent (ctx ))
141141 defer func () {
142142 onDone (err )
143143 }()
144- if c .isClosed () {
145- return nil , errClosedConn
146- }
147- if c .currentTx != nil {
148- if m != DataQueryMode {
149- return nil , xerrors .WithStackTrace (
150- fmt .Errorf ("query mode `%s` not supported with currentTx" , m .String ()),
151- )
152- }
153- return c .currentTx .ExecContext (ctx , query , args )
154- }
155144 switch m {
156145 case DataQueryMode :
157146 var res result.Result
@@ -185,23 +174,32 @@ func (c *conn) ExecContext(ctx context.Context, query string, args []driver.Name
185174 }
186175}
187176
177+ func (c * conn ) ExecContext (ctx context.Context , query string , args []driver.NamedValue ) (_ driver.Result , err error ) {
178+ if c .isClosed () {
179+ return nil , errClosedConn
180+ }
181+ if c .currentTx != nil {
182+ return c .currentTx .ExecContext (ctx , query , args )
183+ }
184+ return c .execContext (ctx , query , args )
185+ }
186+
188187func (c * conn ) QueryContext (ctx context.Context , query string , args []driver.NamedValue ) (_ driver.Rows , err error ) {
189- m := queryModeFromContext (ctx , c .defaultQueryMode )
190- onDone := trace .DatabaseSQLOnConnExec (c .trace , & ctx , query , m .String (), retry .IsIdempotent (ctx ))
191- defer func () {
192- onDone (err )
193- }()
194188 if c .isClosed () {
195189 return nil , errClosedConn
196190 }
197191 if c .currentTx != nil {
198- if m != DataQueryMode {
199- return nil , xerrors .WithStackTrace (
200- fmt .Errorf ("query mode `%s` not supported with currentTx" , m .String ()),
201- )
202- }
203192 return c .currentTx .QueryContext (ctx , query , args )
204193 }
194+ return c .queryContext (ctx , query , args )
195+ }
196+
197+ func (c * conn ) queryContext (ctx context.Context , query string , args []driver.NamedValue ) (_ driver.Rows , err error ) {
198+ m := queryModeFromContext (ctx , c .defaultQueryMode )
199+ onDone := trace .DatabaseSQLOnConnExec (c .trace , & ctx , query , m .String (), retry .IsIdempotent (ctx ))
200+ defer func () {
201+ onDone (err )
202+ }()
205203 switch m {
206204 case DataQueryMode :
207205 var res result.Result
0 commit comments