[go] database/sql: ensure Null* types have Valid=false when Scan returns error

0 views
Skip to first unread message

Gopher Robot (Gerrit)

unread,
Feb 6, 2026, 3:11:04 PM (2 days ago) Feb 6
to Ravi Sastry Kadali, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Dmitri Shuralyov, Dmitri Shuralyov, Michael Pratt, Go LUCI, Emmanuel Odeke, Daniel Theophanes, golang-co...@googlegroups.com

Gopher Robot submitted the change

Change information

Commit message:
database/sql: ensure Null* types have Valid=false when Scan returns error

The Scan methods for NullString, NullInt64, NullInt32, NullFloat64,
NullBool, and NullTime set Valid=true before calling convertAssign.
If convertAssign returns an error, Valid remains true, which creates
an inconsistent state where Valid=true but err!=nil.

Fix by setting Valid only after successful conversion.

Fixes #45662
Change-Id: I855a20abbe517ed017f7c9b8f5603b17bd9d487d
Auto-Submit: Sean Liao <se...@liao.dev>
Reviewed-by: Dmitri Shuralyov <dmit...@google.com>
Reviewed-by: Sean Liao <se...@liao.dev>
Reviewed-by: Michael Pratt <mpr...@google.com>
Files:
  • M src/database/sql/sql.go
  • M src/database/sql/sql_test.go
Change size: M
Delta: 2 files changed, 170 insertions(+), 14 deletions(-)
Branch: refs/heads/master
Submit Requirements:
  • requirement satisfiedCode-Review: +2 by Sean Liao, +1 by Michael Pratt, +1 by Dmitri Shuralyov
  • requirement satisfiedTryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I855a20abbe517ed017f7c9b8f5603b17bd9d487d
Gerrit-Change-Number: 739160
Gerrit-PatchSet: 3
Gerrit-Owner: Ravi Sastry Kadali <ravis...@gmail.com>
Gerrit-Reviewer: Daniel Theophanes <kard...@gmail.com>
Gerrit-Reviewer: Dmitri Shuralyov <dmit...@google.com>
Gerrit-Reviewer: Emmanuel Odeke <emma...@orijtech.com>
Gerrit-Reviewer: Gopher Robot <go...@golang.org>
Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
Gerrit-Reviewer: Sean Liao <se...@liao.dev>
Gerrit-CC: Dmitri Shuralyov <dmit...@golang.org>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages