Skip to content

Commit

Permalink
fix interpolateParams
Browse files Browse the repository at this point in the history
  • Loading branch information
methane committed May 18, 2024
1 parent db0cc0e commit 94d8ccd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,10 @@ func (mc *mysqlConn) interpolateParams(query string, args []driver.Value) (strin
if err != nil {
// can not take the buffer. Something must be wrong with the connection
mc.cleanup()
return "", err
// interpolateParams would be called before sending any query.
// So its safe to retry.
mc.log(err)
return "", driver.ErrBadConn
}
buf = buf[:0]
argPos := 0
Expand Down Expand Up @@ -355,10 +358,10 @@ func (mc *mysqlConn) Query(query string, args []driver.Value) (driver.Rows, erro

func (mc *mysqlConn) query(query string, args []driver.Value) (*textRows, error) {
handleOk := mc.clearResult()

if mc.closed.Load() {
return nil, driver.ErrBadConn
}

if len(args) != 0 {
if !mc.cfg.InterpolateParams {
return nil, driver.ErrSkip
Expand Down

0 comments on commit 94d8ccd

Please sign in to comment.