Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(212)

Unified Diff: src/pkg/exp/sql/sql_test.go

Issue 5533077: code review 5533077: sql: fix potential corruption in QueryRow.Scan into a *... (Closed)
Patch Set: diff -r 29382b5af719 https://go.googlecode.com/hg/ Created 12 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/pkg/exp/sql/sql.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pkg/exp/sql/sql_test.go
===================================================================
--- a/src/pkg/exp/sql/sql_test.go
+++ b/src/pkg/exp/sql/sql_test.go
@@ -21,10 +21,10 @@
t.Fatalf("exec wipe: %v", err)
}
if name == "people" {
- exec(t, db, "CREATE|people|name=string,age=int32,dead=bool")
- exec(t, db, "INSERT|people|name=Alice,age=?", 1)
- exec(t, db, "INSERT|people|name=Bob,age=?", 2)
- exec(t, db, "INSERT|people|name=Chris,age=?", 3)
+ exec(t, db, "CREATE|people|name=string,age=int32,photo=blob,dead=bool")
+ exec(t, db, "INSERT|people|name=Alice,age=?,photo=APHOTO", 1)
+ exec(t, db, "INSERT|people|name=Bob,age=?,photo=BPHOTO", 2)
+ exec(t, db, "INSERT|people|name=Chris,age=?,photo=CPHOTO", 3)
}
return db
}
@@ -132,6 +132,16 @@
if age != 1 {
t.Errorf("expected age 1, got %d", age)
}
+
+ var photo []byte
+ err = db.QueryRow("SELECT|people|photo|name=?", "Alice").Scan(&photo)
+ if err != nil {
+ t.Fatalf("photo QueryRow+Scan: %v", err)
+ }
+ want := []byte("APHOTO")
+ if !reflect.DeepEqual(photo, want) {
+ t.Errorf("photo = %q; want %q", photo, want)
+ }
}
func TestStatementErrorAfterClose(t *testing.T) {
« no previous file with comments | « src/pkg/exp/sql/sql.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b