Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign updatabase/sql: all named []byte types get driver memory like RawBytes #13905
Comments
ianlancetaylor
added this to the Go1.6Maybe milestone
Jan 11, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
|
CC @bradfitz |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
gofish
Jan 14, 2016
A temporary workaround may be an explicit cast to *[]byte.
This passes the test:
convertAssign((*[]byte)(&u),v)For json.RawMessage:
var msg json.RawMessage
row := db.QueryRow(`SELECT '{}'::json`)
err := row.Scan((*[]byte)(&msg))
...
gofish
commented
Jan 14, 2016
|
A temporary workaround may be an explicit cast to This passes the test: convertAssign((*[]byte)(&u),v)For json.RawMessage: var msg json.RawMessage
row := db.QueryRow(`SELECT '{}'::json`)
err := row.Scan((*[]byte)(&msg))
... |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
ianlancetaylor
Jan 25, 2016
Contributor
This is not a regression, and we are late in the release cycle, so postponing until 1.7.
|
This is not a regression, and we are late in the release cycle, so postponing until 1.7. |
ianlancetaylor
modified the milestones:
Go1.7,
Go1.6Maybe
Jan 25, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
gopherbot
commented
Apr 23, 2016
|
CL https://golang.org/cl/22393 mentions this issue. |
gopherbot
closed this
in
4e0cd1e
Apr 30, 2016
golang
locked and limited conversation to collaborators
Apr 30, 2017
gopherbot
added
the
FrozenDueToAge
label
Apr 30, 2017
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
jmoiron commentedJan 11, 2016
I added this test to src/database/sql/convert_test.go:
The problem is line 207 of convert.go; in this case, dest is assignable the src pointer, so it just assigns it instead of cloning it. The documentation doesn't actually make any promises about where memory is going to come from when you call
Scan, but it seems obvious from the code that RawBytes was supposed to be treated specially as it gets driver memory via a different code path. Having that behavior inadvertently for non-RawBytes named[]bytetypes seems like an oversight.This patch fixes it, though it may potentially be present for other types or in line 217.
I signed the CLA and wouldn't mind going through the contribution process, though I've never done so.