diff options
| author | Daniel Theophanes <kardianos@gmail.com> | 2018-04-20 13:18:09 -0700 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2018-05-11 20:28:02 +0000 |
| commit | 94280237f4863db90e442481c5cc4edfd13389a9 (patch) | |
| tree | 0f34767e8886ac96bb771c3a1e6702580e25bf98 /src/database/sql | |
| parent | 4122319e5a6e5fd4e1f1fcab3b2981df91bc05ad (diff) | |
| download | go-94280237f4863db90e442481c5cc4edfd13389a9.tar.xz | |
database/sql: add note to Scanner that the database owns values
It was unclear that users must copy values out of the src value
for value types like []byte.
Fixes #24492
Change-Id: I99ad61e0ad0075b9efc5ee4e0d067f752f91b8fa
Reviewed-on: https://go-review.googlesource.com/108535
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/database/sql')
| -rw-r--r-- | src/database/sql/sql.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/database/sql/sql.go b/src/database/sql/sql.go index 3a6390d970..96d7742a3c 100644 --- a/src/database/sql/sql.go +++ b/src/database/sql/sql.go @@ -301,6 +301,10 @@ type Scanner interface { // // An error should be returned if the value cannot be stored // without loss of information. + // + // Reference types such as []byte are only valid until the next call to Scan + // and should not be retained. Their underlying memory is owned by the driver. + // If retention is necessary, copy their values before the next call to Scan. Scan(src interface{}) error } |
