From 224815d665ab9f872c6bc0d9dad1101cc5ec6b1a Mon Sep 17 00:00:00 2001 From: mattn Date: Mon, 12 Mar 2012 14:20:55 +0900 Subject: [PATCH] merged #11 close #11 --- sqlite3.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/sqlite3.go b/sqlite3.go index 02e7107..e3ce711 100644 --- a/sqlite3.go +++ b/sqlite3.go @@ -91,6 +91,12 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) { if db == nil { return nil, errors.New("sqlite succeeded without returning a database") } + + rv = C.sqlite3_busy_timeout(db, 500) + if rv != C.SQLITE_OK { + return nil, errors.New(C.GoString(C.sqlite3_errmsg(db))) + } + return &SQLiteConn{db}, nil } @@ -174,7 +180,7 @@ func (s *SQLiteStmt) bind(args []driver.Value) error { rv = C.sqlite3_bind_int(s.s, n, C.int(v)) case bool: if bool(v) { - rv = C.sqlite3_bind_int(s.s, n, -1) + rv = C.sqlite3_bind_int(s.s, n, 1) } else { rv = C.sqlite3_bind_int(s.s, n, 0) } @@ -233,7 +239,11 @@ type SQLiteRows struct { } func (rc *SQLiteRows) Close() error { - return rc.s.Close() + rv := C.sqlite3_reset(rc.s.s) + if rv != C.SQLITE_OK { + return errors.New(C.GoString(C.sqlite3_errmsg(rc.s.c.db))) + } + return nil } func (rc *SQLiteRows) Columns() []string {