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 {
return c.execPrepared(ctx, sd, arguments)
}
if simpleProtocol {
return c.execSimpleProtocol(ctx, sql, arguments)
}
if len(arguments) == 0 {
return c.execSimpleProtocol(ctx, sql, arguments)
}
@@ -624,7 +624,9 @@ optionLoop:
rows := c.getRows(ctx, sql, args)
var err error
if simpleProtocol {
sd, ok := c.preparedStatements[sql]
if simpleProtocol && !ok {
sql, err = c.sanitizeForSimpleQuery(sql, args...)
if err != nil {
rows.fatal(err)
@@ -646,7 +648,6 @@ optionLoop:
c.eqb.Reset()
sd, ok := c.preparedStatements[sql]
if !ok {
if c.stmtcache != nil {
sd, err = c.stmtcache.Get(ctx, sql)