From 59a1fb6d18c0c0ba443331fe8e0bbcc5d624c18e Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Thu, 19 May 2022 10:26:57 +0800 Subject: [PATCH] database/sql: save Close error into lasterr --- src/database/sql/sql.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/database/sql/sql.go b/src/database/sql/sql.go index 34d7aac3cf2..2146d96dc59 100644 --- a/src/database/sql/sql.go +++ b/src/database/sql/sql.go @@ -2989,9 +2989,7 @@ func (rs *Rows) Next() bool { if doClose { err := rs.Close() if err != nil { - withLock(rs.closemu.RLocker(), func() { - rs.lasterr = rs.lasterrOrErrLocked(err) - }) + rs.Close() } } return ok @@ -3337,6 +3335,8 @@ func (rs *Rows) close(err error) error { rs.closeStmt.Close() } rs.releaseConn(err) + + rs.lasterr = rs.lasterrOrErrLocked(err) return err }