<feed xmlns='http://www.w3.org/2005/Atom'>
<title>go/src/database/sql/sql.go, branch bench-before</title>
<subtitle>Fork of Go programming language with my patches.</subtitle>
<id>http://git.kilabit.info/go/atom?h=bench-before</id>
<link rel='self' href='http://git.kilabit.info/go/atom?h=bench-before'/>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/'/>
<updated>2023-11-27T15:48:25Z</updated>
<entry>
<title>all: fix field names</title>
<updated>2023-11-27T15:48:25Z</updated>
<author>
<name>cui fliter</name>
<email>imcusg@gmail.com</email>
</author>
<published>2023-11-18T05:51:35Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=0d018b49e33b1383dc0ae5cc968e800dffeeaf7d'/>
<id>urn:sha1:0d018b49e33b1383dc0ae5cc968e800dffeeaf7d</id>
<content type='text'>
Change-Id: I3ad7a50707486ebdbbd676b3581df6e3ed0fd3a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/543476
Auto-Submit: Dmitri Shuralyov &lt;dmitshur@golang.org&gt;
TryBot-Result: Gopher Robot &lt;gobot@golang.org&gt;
Reviewed-by: Keith Randall &lt;khr@google.com&gt;
Reviewed-by: Keith Randall &lt;khr@golang.org&gt;
Reviewed-by: Dmitri Shuralyov &lt;dmitshur@google.com&gt;
Run-TryBot: shuang cui &lt;imcusg@gmail.com&gt;
</content>
</entry>
<entry>
<title>database/sql: add godoc links</title>
<updated>2023-10-23T09:04:12Z</updated>
<author>
<name>Olivier Mengué</name>
<email>olivier.mengue@gmail.com</email>
</author>
<published>2023-04-19T19:29:59Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=6ba6e72e39ac5be92f604832640c3131ad3d0ade'/>
<id>urn:sha1:6ba6e72e39ac5be92f604832640c3131ad3d0ade</id>
<content type='text'>
Add godoc links in database/sql and database/sql/driver.

Change-Id: I96ed79645a7cc656f5d23450ba3cfe005b04b31a
Reviewed-on: https://go-review.googlesource.com/c/go/+/486815
LUCI-TryBot-Result: Go LUCI &lt;golang-scoped@luci-project-accounts.iam.gserviceaccount.com&gt;
Reviewed-by: Ian Lance Taylor &lt;iant@google.com&gt;
Reviewed-by: Benny Siegert &lt;bsiegert@gmail.com&gt;
</content>
</entry>
<entry>
<title>database: add available godoc link</title>
<updated>2023-10-18T19:51:24Z</updated>
<author>
<name>cui fliter</name>
<email>imcusg@gmail.com</email>
</author>
<published>2023-10-13T05:07:28Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=d1cb2483b70827f8f2f839fe7b0f140c910fc5b7'/>
<id>urn:sha1:d1cb2483b70827f8f2f839fe7b0f140c910fc5b7</id>
<content type='text'>
Change-Id: I6150858f1186edc6cebd38ff166d57287fa430f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/535078
Reviewed-by: Carlos Amedee &lt;carlos@golang.org&gt;
Reviewed-by: Ian Lance Taylor &lt;iant@google.com&gt;
Run-TryBot: shuang cui &lt;imcusg@gmail.com&gt;
TryBot-Result: Gopher Robot &lt;gobot@golang.org&gt;
Auto-Submit: Ian Lance Taylor &lt;iant@google.com&gt;
</content>
</entry>
<entry>
<title>database/sql: use the built-in min function</title>
<updated>2023-10-03T19:29:35Z</updated>
<author>
<name>mstmdev</name>
<email>mstmdev@gmail.com</email>
</author>
<published>2023-09-25T08:43:18Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=1b5cfc6ca62c421f12b0ef70daeb1efd03327636'/>
<id>urn:sha1:1b5cfc6ca62c421f12b0ef70daeb1efd03327636</id>
<content type='text'>
Change-Id: Ib6a0e1e1583e45e3d239455e8b131c81602b2d5d
GitHub-Last-Rev: dc82635562a7fb4488f374d7a9ed26b29310e918
GitHub-Pull-Request: golang/go#63200
Reviewed-on: https://go-review.googlesource.com/c/go/+/530875
Reviewed-by: qiulaidongfeng &lt;2645477756@qq.com&gt;
Reviewed-by: Ian Lance Taylor &lt;iant@google.com&gt;
Reviewed-by: Michael Pratt &lt;mpratt@google.com&gt;
Auto-Submit: Ian Lance Taylor &lt;iant@google.com&gt;
LUCI-TryBot-Result: Go LUCI &lt;golang-scoped@luci-project-accounts.iam.gserviceaccount.com&gt;
</content>
</entry>
<entry>
<title>database/sql: use reflect.TypeFor for known types</title>
<updated>2023-08-08T20:57:57Z</updated>
<author>
<name>Ian Lance Taylor</name>
<email>iant@golang.org</email>
</author>
<published>2023-08-01T19:37:15Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=6d8d88a70716bd35708748ba4e0110bdcd9520f3'/>
<id>urn:sha1:6d8d88a70716bd35708748ba4e0110bdcd9520f3</id>
<content type='text'>
For #60088

Change-Id: Ib05ba3d456b22f7370459037b3d263c4b3ebe3b1
Reviewed-on: https://go-review.googlesource.com/c/go/+/514975
Reviewed-by: Daniel Theophanes &lt;kardianos@gmail.com&gt;
Run-TryBot: Ian Lance Taylor &lt;iant@google.com&gt;
TryBot-Result: Gopher Robot &lt;gobot@golang.org&gt;
Reviewed-by: Ian Lance Taylor &lt;iant@google.com&gt;
Run-TryBot: Ian Lance Taylor &lt;iant@golang.org&gt;
Auto-Submit: Ian Lance Taylor &lt;iant@google.com&gt;
Reviewed-by: Michael Knyszek &lt;mknyszek@google.com&gt;
</content>
</entry>
<entry>
<title>database/sql: add Null[T]</title>
<updated>2023-08-07T14:26:37Z</updated>
<author>
<name>Inada Naoki</name>
<email>songofacandy@gmail.com</email>
</author>
<published>2023-08-05T16:22:48Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=8a6acecfab2879ba4e26487c99f204ede8b3d935'/>
<id>urn:sha1:8a6acecfab2879ba4e26487c99f204ede8b3d935</id>
<content type='text'>
Generic version of NullString, NullInt64, etc.

Fixes #60370

Change-Id: I166a05a6126e8b8571db5cbb026303bb6551d56b
GitHub-Last-Rev: 3c8d2d5141c36f034d2124e19ee090620363ba24
GitHub-Pull-Request: golang/go#60677
Reviewed-on: https://go-review.googlesource.com/c/go/+/501700
Reviewed-by: Jonathan Amsterdam &lt;jba@google.com&gt;
TryBot-Result: Gopher Robot &lt;gobot@golang.org&gt;
Run-TryBot: Ian Lance Taylor &lt;iant@golang.org&gt;
Reviewed-by: Russ Cox &lt;rsc@golang.org&gt;
</content>
</entry>
<entry>
<title>src/database/sql: run gofmt</title>
<updated>2023-07-07T20:48:55Z</updated>
<author>
<name>Than McIntosh</name>
<email>thanm@google.com</email>
</author>
<published>2023-07-07T20:33:39Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=894d24d617bb72d6e1bed7b143f9f7a0ac16b844'/>
<id>urn:sha1:894d24d617bb72d6e1bed7b143f9f7a0ac16b844</id>
<content type='text'>
Run gofmt on a source file.

Change-Id: I180d5cc7425fc5d8e9cf63005ac692f361beb1ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/508497
Run-TryBot: Than McIntosh &lt;thanm@google.com&gt;
Reviewed-by: Eli Bendersky &lt;eliben@google.com&gt;
TryBot-Result: Gopher Robot &lt;gobot@golang.org&gt;
</content>
</entry>
<entry>
<title>database/sql: prevent internal context error from being returned from Rows.Err()</title>
<updated>2023-07-05T17:10:36Z</updated>
<author>
<name>zikaeroh</name>
<email>zikaeroh@gmail.com</email>
</author>
<published>2023-06-23T00:09:21Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=cd6676126b7e663e6202e98e2f235fff20d5e858'/>
<id>urn:sha1:cd6676126b7e663e6202e98e2f235fff20d5e858</id>
<content type='text'>
CL 497675 modified Rows such that context errors are propagated through
Rows.Err(). This caused an issue where calling Close meant that an
internal cancellation error would (eventually) be returned from Err:

1. A caller makes a query using a cancellable context.
2. initContextClose sees that either the query context or the
   transaction context can be canceled, so will need to spawn a
   goroutine to capture their errors.
3. initContextClose derives a context from the query context via
   WithCancel and sets rs.cancel.
4. When a user calls Close, rs.cancel is called. awaitDone's ctx is
   cancelled, which is good, since we don't want it to hang forever.
5. This internal cancellation (after CL 497675) has its error saved on
   contextDone.
6. Later, calling Err will return the error in contextDone if present.

This leads to a race condition depending on how quickly Err is called
after Close.

The docs for Close and Err state that calling Close should have no
affect on the return result for Err. So, a potential fix is to ensure
that awaitDone does not save the error when the cancellation comes from
a Close via rs.cancel.

This CL does that, using a new context not derived from the query
context, whose error is ignored as the query context's error used to be
before the original bugfix.

The included test fails before the CL, and passes afterward.

Fixes #60932

Change-Id: I2bf4c549efd83d62b86e298c9c45ebd06a3ad89a
Reviewed-on: https://go-review.googlesource.com/c/go/+/505397
Auto-Submit: Russ Cox &lt;rsc@golang.org&gt;
Run-TryBot: Russ Cox &lt;rsc@golang.org&gt;
TryBot-Result: Gopher Robot &lt;gobot@golang.org&gt;
Reviewed-by: Russ Cox &lt;rsc@golang.org&gt;
Reviewed-by: Dmitri Shuralyov &lt;dmitshur@google.com&gt;
Reviewed-by: Brad Fitzpatrick &lt;bradfitz@golang.org&gt;
</content>
</entry>
<entry>
<title>database/sql: fix regression from earlier RawBytes fix</title>
<updated>2023-05-26T03:06:19Z</updated>
<author>
<name>Brad Fitzpatrick</name>
<email>bradfitz@golang.org</email>
</author>
<published>2023-05-25T21:52:01Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=145eec87683b4f09491bd4c6fc6448b920f4f4f3'/>
<id>urn:sha1:145eec87683b4f09491bd4c6fc6448b920f4f4f3</id>
<content type='text'>
The earlier CL 497675 for #60304 introduced a behavior change
that, while not strictly a bug, caused a bunch of test failures
in a large codebase. Rather than add behavior changes in a 10 year
old package, revert to the old behavior: a context cancelation
between Rows.Next reporting false and a call to Rows.Err should
not result in Rows.Err returning the context error.

That behavior was accidentally added in CL 497675 as part of changing
how contexts and Rows iteration worked.

Updates #60304
Updates #53970

Change-Id: I22f8a6a6b0b5a94b430576cf50e015efd01ec652
Reviewed-on: https://go-review.googlesource.com/c/go/+/498398
Run-TryBot: Brad Fitzpatrick &lt;bradfitz@golang.org&gt;
Reviewed-by: Russ Cox &lt;rsc@golang.org&gt;
Reviewed-by: Ian Lance Taylor &lt;iant@google.com&gt;
TryBot-Result: Gopher Robot &lt;gobot@golang.org&gt;
</content>
</entry>
<entry>
<title>database/sql: make RawBytes safely usable with contexts</title>
<updated>2023-05-24T04:00:19Z</updated>
<author>
<name>Brad Fitzpatrick</name>
<email>bradfitz@golang.org</email>
</author>
<published>2023-05-23T22:12:47Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=298fe517a9333c05143a8a8e1f9d5499f0c6e59b'/>
<id>urn:sha1:298fe517a9333c05143a8a8e1f9d5499f0c6e59b</id>
<content type='text'>
sql.RawBytes was added the very first Go release, Go 1. Its docs
say:

&gt; RawBytes is a byte slice that holds a reference to memory owned by
&gt; the database itself. After a Scan into a RawBytes, the slice is only
&gt; valid until the next call to Next, Scan, or Close.

That "only valid until the next call" bit was true at the time,
until contexts were added to database/sql in Go 1.8.

In the past ~dozen releases it's been unsafe to use QueryContext with
a context that might become Done to get an *sql.Rows that's scanning
into a RawBytes. The Scan can succeed, but then while the caller's
reading the memory, a database/sql-managed goroutine can see the
context becoming done and call Close on the database/sql/driver and
make the caller's view of the RawBytes memory no longer valid,
introducing races, crashes, or database corruption. See #60304
and #53970 for details.

This change does the minimal surgery on database/sql to make it safe
again: Rows.Scan was already acquiring a mutex to check whether the
rows had been closed, so this change make Rows.Scan notice whether
*RawBytes was used and, if so, doesn't release the mutex on exit
before returning. That mean it's still locked while the user code
operates on the RawBytes memory and the concurrent context-watching
goroutine to close the database still runs, but if it fires, it then
gets blocked on the mutex until the next call to a Rows method (Next,
NextResultSet, Err, Close).

Updates #60304
Updates #53970 (earlier one I'd missed)

Change-Id: Ie41c0c6f32c24887b2f53ec3686c2aab73a1bfff
Reviewed-on: https://go-review.googlesource.com/c/go/+/497675
TryBot-Result: Gopher Robot &lt;gobot@golang.org&gt;
Reviewed-by: Ian Lance Taylor &lt;iant@google.com&gt;
Run-TryBot: Brad Fitzpatrick &lt;bradfitz@golang.org&gt;
Auto-Submit: Ian Lance Taylor &lt;iant@google.com&gt;
Reviewed-by: Russ Cox &lt;rsc@golang.org&gt;
</content>
</entry>
</feed>
