aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormattn <mattn.jp@gmail.com>2016-02-01 14:34:37 +0900
committermattn <mattn.jp@gmail.com>2016-02-01 14:34:37 +0900
commitc5aee9649735e8dadac55eb968ccebd9fa29a881 (patch)
treed984cc8023dffd95fd37fc6ed293ba80f973592a
parentMerge pull request #268 from ianlancetaylor/handle (diff)
parentbind: pass &v[0] in direct call to C (diff)
downloadgolite-c5aee9649735e8dadac55eb968ccebd9fa29a881.tar.gz
golite-c5aee9649735e8dadac55eb968ccebd9fa29a881.tar.xz
Merge pull request #267 from ianlancetaylor/go16
bind: pass &v[0] in direct call to C
-rw-r--r--sqlite3.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/sqlite3.go b/sqlite3.go
index 964acbb..0a6f136 100644
--- a/sqlite3.go
+++ b/sqlite3.go
@@ -815,11 +815,11 @@ func (s *SQLiteStmt) bind(args []driver.Value) error {
case float64:
rv = C.sqlite3_bind_double(s.s, n, C.double(v))
case []byte:
- var p *byte
- if len(v) > 0 {
- p = &v[0]
+ if len(v) == 0 {
+ rv = C._sqlite3_bind_blob(s.s, n, nil, 0)
+ } else {
+ rv = C._sqlite3_bind_blob(s.s, n, unsafe.Pointer(&v[0]), C.int(len(v)))
}
- rv = C._sqlite3_bind_blob(s.s, n, unsafe.Pointer(p), C.int(len(v)))
case time.Time:
b := []byte(v.Format(SQLiteTimestampFormats[0]))
rv = C._sqlite3_bind_text(s.s, n, (*C.char)(unsafe.Pointer(&b[0])), C.int(len(b)))