2
0

Fix SimpleProtocol with prepared statement

This commit is contained in:
Jinzhu
2020-08-31 15:03:21 +08:00
committed by Jack Christensen
parent 43ce317556
commit 5b06f03d0a
+7 -6
View File
@@ -473,14 +473,14 @@ optionLoop:
} }
} }
if simpleProtocol {
return c.execSimpleProtocol(ctx, sql, arguments)
}
if sd, ok := c.preparedStatements[sql]; ok { if sd, ok := c.preparedStatements[sql]; ok {
return c.execPrepared(ctx, sd, arguments) return c.execPrepared(ctx, sd, arguments)
} }
if simpleProtocol {
return c.execSimpleProtocol(ctx, sql, arguments)
}
if len(arguments) == 0 { if len(arguments) == 0 {
return c.execSimpleProtocol(ctx, sql, arguments) return c.execSimpleProtocol(ctx, sql, arguments)
} }
@@ -624,7 +624,9 @@ optionLoop:
rows := c.getRows(ctx, sql, args) rows := c.getRows(ctx, sql, args)
var err error var err error
if simpleProtocol { sd, ok := c.preparedStatements[sql]
if simpleProtocol && !ok {
sql, err = c.sanitizeForSimpleQuery(sql, args...) sql, err = c.sanitizeForSimpleQuery(sql, args...)
if err != nil { if err != nil {
rows.fatal(err) rows.fatal(err)
@@ -646,7 +648,6 @@ optionLoop:
c.eqb.Reset() c.eqb.Reset()
sd, ok := c.preparedStatements[sql]
if !ok { if !ok {
if c.stmtcache != nil { if c.stmtcache != nil {
sd, err = c.stmtcache.Get(ctx, sql) sd, err = c.stmtcache.Get(ctx, sql)