mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
exp/sql: close Rows on EOF
Fixes #2624 R=rsc CC=golang-dev https://golang.org/cl/5530068
This commit is contained in:
parent
25cf9bdea6
commit
4435c8bf2a
3 changed files with 31 additions and 11 deletions
|
|
@ -549,8 +549,8 @@ func (s *Stmt) Exec(args ...interface{}) (Result, error) {
|
|||
// statement, a function to call to release the connection, and a
|
||||
// statement bound to that connection.
|
||||
func (s *Stmt) connStmt() (ci driver.Conn, releaseConn func(), si driver.Stmt, err error) {
|
||||
if s.stickyErr != nil {
|
||||
return nil, nil, nil, s.stickyErr
|
||||
if err = s.stickyErr; err != nil {
|
||||
return
|
||||
}
|
||||
s.mu.Lock()
|
||||
if s.closed {
|
||||
|
|
@ -726,6 +726,9 @@ func (rs *Rows) Next() bool {
|
|||
rs.lastcols = make([]interface{}, len(rs.rowsi.Columns()))
|
||||
}
|
||||
rs.lasterr = rs.rowsi.Next(rs.lastcols)
|
||||
if rs.lasterr == io.EOF {
|
||||
rs.Close()
|
||||
}
|
||||
return rs.lasterr == nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue