Commit 0aa47b3f authored by gwenn's avatar gwenn

Prevent blank statements from being cached.

parent b5f02770
...@@ -135,7 +135,7 @@ func (c *Conn) Prepare(cmd string, args ...interface{}) (*Stmt, error) { ...@@ -135,7 +135,7 @@ func (c *Conn) Prepare(cmd string, args ...interface{}) (*Stmt, error) {
return s, nil return s, nil
} }
s, err := c.prepare(cmd, args...) s, err := c.prepare(cmd, args...)
if s != nil { if s != nil && s.stmt != nil {
s.Cacheable = true s.Cacheable = true
} }
return s, err return s, err
......
...@@ -489,3 +489,12 @@ func TestIntOnArch64(t *testing.T) { ...@@ -489,3 +489,12 @@ func TestIntOnArch64(t *testing.T) {
assert.Equal(t, i, r, "int truncated") assert.Equal(t, i, r, "int truncated")
} }
} }
func TestBlankQuery(t *testing.T) {
db := open(t)
defer checkClose(db, t)
s, err := db.Prepare("")
checkNoError(t, err, "prepare error: %s")
defer checkFinalize(s, t)
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment