Skip to content

Commit 94d8ccd

Browse files
committed
fix interpolateParams
1 parent db0cc0e commit 94d8ccd

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

connection.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,10 @@ func (mc *mysqlConn) interpolateParams(query string, args []driver.Value) (strin
207207
if err != nil {
208208
// can not take the buffer. Something must be wrong with the connection
209209
mc.cleanup()
210-
return "", err
210+
// interpolateParams would be called before sending any query.
211+
// So its safe to retry.
212+
mc.log(err)
213+
return "", driver.ErrBadConn
211214
}
212215
buf = buf[:0]
213216
argPos := 0
@@ -355,10 +358,10 @@ func (mc *mysqlConn) Query(query string, args []driver.Value) (driver.Rows, erro
355358

356359
func (mc *mysqlConn) query(query string, args []driver.Value) (*textRows, error) {
357360
handleOk := mc.clearResult()
358-
359361
if mc.closed.Load() {
360362
return nil, driver.ErrBadConn
361363
}
364+
362365
if len(args) != 0 {
363366
if !mc.cfg.InterpolateParams {
364367
return nil, driver.ErrSkip

0 commit comments

Comments
 (0)