1
0
mirror of https://github.com/golang/go synced 2024-11-17 05:24:53 -07:00

database/sql: save Close error into lasterr

This commit is contained in:
Jinzhu 2022-05-19 10:26:57 +08:00
parent 47c80b1e56
commit 59a1fb6d18

View File

@ -2989,9 +2989,7 @@ func (rs *Rows) Next() bool {
if doClose { if doClose {
err := rs.Close() err := rs.Close()
if err != nil { if err != nil {
withLock(rs.closemu.RLocker(), func() { rs.Close()
rs.lasterr = rs.lasterrOrErrLocked(err)
})
} }
} }
return ok return ok
@ -3337,6 +3335,8 @@ func (rs *Rows) close(err error) error {
rs.closeStmt.Close() rs.closeStmt.Close()
} }
rs.releaseConn(err) rs.releaseConn(err)
rs.lasterr = rs.lasterrOrErrLocked(err)
return err return err
} }