Commit 77b73a52 authored by gwenn's avatar gwenn

Ensure statements are reset before being cached.

parent dbfe8195
...@@ -56,6 +56,10 @@ func (c *cache) release(s *Stmt) error { ...@@ -56,6 +56,10 @@ func (c *cache) release(s *Stmt) error {
if c.maxSize <= 0 || len(s.tail) > 0 || s.Busy() { if c.maxSize <= 0 || len(s.tail) > 0 || s.Busy() {
return s.finalize() return s.finalize()
} }
if err := s.Reset(); err != nil {
s.finalize()
return err
}
c.m.Lock() c.m.Lock()
defer c.m.Unlock() defer c.m.Unlock()
c.l.PushFront(s) c.l.PushFront(s)
......
...@@ -371,10 +371,7 @@ func (c *Conn) Exists(query string, args ...interface{}) (bool, error) { ...@@ -371,10 +371,7 @@ func (c *Conn) Exists(query string, args ...interface{}) (bool, error) {
if err != nil { if err != nil {
return false, err return false, err
} }
defer func() { defer s.Finalize()
s.Reset()
s.Finalize()
}()
return s.Next() return s.Next()
} }
...@@ -385,10 +382,7 @@ func (c *Conn) OneValue(query string, value interface{}, args ...interface{}) er ...@@ -385,10 +382,7 @@ func (c *Conn) OneValue(query string, value interface{}, args ...interface{}) er
if err != nil { if err != nil {
return err return err
} }
defer func() { defer s.Finalize()
s.Reset()
s.Finalize()
}()
b, err := s.Next() b, err := s.Next()
if err != nil { if err != nil {
return err return err
......
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