@@ -256,9 +256,7 @@ func (s *stmt) Query(args []driver.Value) (driver.Rows, error) {
256
256
}
257
257
258
258
func (s * stmt ) ExecContext (ctx context.Context , args []driver.NamedValue ) (driver.Result , error ) {
259
- // Use QueryContext to setup bindings.
260
- // No need to close rows: that simply resets the statement, exec does the same.
261
- _ , err := s .QueryContext (ctx , args )
259
+ err := s .setupBindings (ctx , args )
262
260
if err != nil {
263
261
return nil , err
264
262
}
@@ -272,11 +270,20 @@ func (s *stmt) ExecContext(ctx context.Context, args []driver.NamedValue) (drive
272
270
}
273
271
274
272
func (s * stmt ) QueryContext (ctx context.Context , args []driver.NamedValue ) (driver.Rows , error ) {
275
- err := s .Stmt . ClearBindings ( )
273
+ err := s .setupBindings ( ctx , args )
276
274
if err != nil {
277
275
return nil , err
278
276
}
279
277
278
+ return & rows {ctx , s .Stmt , s .Conn }, nil
279
+ }
280
+
281
+ func (s * stmt ) setupBindings (ctx context.Context , args []driver.NamedValue ) error {
282
+ err := s .Stmt .ClearBindings ()
283
+ if err != nil {
284
+ return err
285
+ }
286
+
280
287
var ids [3 ]int
281
288
for _ , arg := range args {
282
289
ids := ids [:0 ]
@@ -315,11 +322,10 @@ func (s *stmt) QueryContext(ctx context.Context, args []driver.NamedValue) (driv
315
322
}
316
323
}
317
324
if err != nil {
318
- return nil , err
325
+ return err
319
326
}
320
327
}
321
-
322
- return & rows {ctx , s .Stmt , s .Conn }, nil
328
+ return nil
323
329
}
324
330
325
331
func (s * stmt ) CheckNamedValue (arg * driver.NamedValue ) error {
0 commit comments