go/src/database/sql
Daniel Theophanes c026845bd2 database/sql: record the context error in Rows if canceled
Previously it was intended that Rows.Scan would return
an error and Rows.Err would return nil. This was problematic
because drivers could not differentiate between a normal
Rows.Close or a context cancel close.

The alternative is to require drivers to return a Scan to return
an error if the driver is closed while there are still rows to be read.
This is currently not how several drivers currently work and may be
difficult to detect when there are additional rows.

At the same time guard the the Rows.lasterr and prevent a close
while a Rows operation is active.

For the drivers that do not have Context methods, do not check for
context cancelation after the operation, but before for any operation
that may modify the database state.

Fixes #18961

Change-Id: I49a25318ecd9f97a35d5b50540ecd850c01cfa5e
Reviewed-on: https://go-review.googlesource.com/36485
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-02-08 18:30:39 +00:00
..
driver database/sql: do not store Tx options in Context 2016-12-14 18:13:13 +00:00
convert.go database/sql: document expectations for named parameters 2016-12-01 16:52:12 +00:00
convert_test.go database/sql: accept nil pointers to Valuers implemented on value receivers 2016-10-17 15:26:25 +00:00
ctxutil.go database/sql: record the context error in Rows if canceled 2017-02-08 18:30:39 +00:00
doc.txt
example_test.go all: minor vet fixes 2016-10-24 17:27:37 +00:00
fakedb_test.go database/sql: document expectations for named parameters 2016-12-01 16:52:12 +00:00
sql.go database/sql: record the context error in Rows if canceled 2017-02-08 18:30:39 +00:00
sql_test.go database/sql: record the context error in Rows if canceled 2017-02-08 18:30:39 +00:00