aboutsummaryrefslogtreecommitdiff
path: root/sqlite3.go
diff options
context:
space:
mode:
authormattn <mattn.jp@gmail.com>2015-03-19 13:29:43 +0900
committermattn <mattn.jp@gmail.com>2015-03-19 13:29:43 +0900
commit5253daf8561a6ca5015fd5ce79e4367912146be9 (patch)
tree1d7600172f86ac75b7695c17e694321cd402d05e /sqlite3.go
parentApply -lpthread withou windows. (diff)
downloadgolite-5253daf8561a6ca5015fd5ce79e4367912146be9.tar.gz
golite-5253daf8561a6ca5015fd5ce79e4367912146be9.tar.xz
Next() should wait while BUSY or LOCKED because return value is bool
Diffstat (limited to 'sqlite3.go')
-rw-r--r--sqlite3.go26
1 files changed, 17 insertions, 9 deletions
diff --git a/sqlite3.go b/sqlite3.go
index 4cdc4d5..91aea8f 100644
--- a/sqlite3.go
+++ b/sqlite3.go
@@ -463,12 +463,14 @@ func (r *SQLiteResult) RowsAffected() (int64, error) {
func (s *SQLiteStmt) Exec(args []driver.Value) (driver.Result, error) {
if err := s.bind(args); err != nil {
C.sqlite3_reset(s.s)
+ C.sqlite3_clear_bindings(s.s)
return nil, err
}
rv := C.sqlite3_step(s.s)
if rv != C.SQLITE_ROW && rv != C.SQLITE_OK && rv != C.SQLITE_DONE {
err := s.c.lastError()
C.sqlite3_reset(s.s)
+ C.sqlite3_clear_bindings(s.s)
return nil, err
}
@@ -507,16 +509,22 @@ func (rc *SQLiteRows) Columns() []string {
// Move cursor to next.
func (rc *SQLiteRows) Next(dest []driver.Value) error {
- rv := C.sqlite3_step(rc.s.s)
- if rv == C.SQLITE_DONE {
- return io.EOF
- }
- if rv != C.SQLITE_ROW {
- rv = C.sqlite3_reset(rc.s.s)
- if rv != C.SQLITE_OK {
- return rc.s.c.lastError()
+ for {
+ rv := C.sqlite3_step(rc.s.s)
+ if rv == C.SQLITE_DONE {
+ return io.EOF
+ }
+ if rv == C.SQLITE_ROW {
+ break
+ }
+ if rv != C.SQLITE_BUSY && rv != C.SQLITE_LOCKED {
+ err := rc.s.c.lastError()
+ C.sqlite3_reset(rc.s.s)
+ if rc.nc > 0 {
+ C.sqlite3_clear_bindings(rc.s.s)
+ }
+ return err
}
- return nil
}
if rc.decltype == nil {