Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sql.RawBytes corruption issue #1523

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 14 additions & 13 deletions driver_test.go
Expand Up @@ -3183,25 +3183,26 @@ func TestRawBytesAreNotModified(t *testing.T) {
if err != nil {
dbt.Fatal(err)
}
defer rows.Close()

var b int
var raw sql.RawBytes
for rows.Next() {
if err := rows.Scan(&b, &raw); err != nil {
dbt.Fatal(err)
}
if !rows.Next() {
dbt.Fatal("expected at least one row")
}
if err := rows.Scan(&b, &raw); err != nil {
dbt.Fatal(err)
}

before := string(raw)
// Ensure cancelling the query does not corrupt the contents of `raw`
cancel()
time.Sleep(time.Microsecond * 100)
after := string(raw)
before := string(raw)
// Ensure cancelling the query does not corrupt the contents of `raw`
cancel()
time.Sleep(time.Microsecond * 100)
after := string(raw)

if before != after {
dbt.Fatalf("the backing storage for sql.RawBytes has been modified (i=%v)", i)
}
if before != after {
dbt.Fatalf("the backing storage for sql.RawBytes has been modified (i=%v)", i)
}
rows.Close()
}()
}
})
Expand Down