From 94d8ccd6bc8270b7069fbd310eabd863e974015b Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Sat, 18 May 2024 16:14:42 +0900 Subject: [PATCH] fix interpolateParams --- connection.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/connection.go b/connection.go index 3e8fb5722..42a873406 100644 --- a/connection.go +++ b/connection.go @@ -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 @@ -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