aboutsummaryrefslogtreecommitdiff
path: root/sqlite3.go
diff options
context:
space:
mode:
authormattn <mattn.jp@gmail.com>2013-09-09 12:28:34 +0900
committermattn <mattn.jp@gmail.com>2013-09-09 12:28:34 +0900
commit77ebf39cf9610451887667b4cc6415e3aae6f98c (patch)
tree5c973b9d9fc092663b66217e96060cda099a93f9 /sqlite3.go
parentFixes test (diff)
downloadgolite-77ebf39cf9610451887667b4cc6415e3aae6f98c.tar.gz
golite-77ebf39cf9610451887667b4cc6415e3aae6f98c.tar.xz
Fixes Execer/Queryer
Diffstat (limited to 'sqlite3.go')
-rw-r--r--sqlite3.go37
1 files changed, 19 insertions, 18 deletions
diff --git a/sqlite3.go b/sqlite3.go
index 6598e02..d0f02e3 100644
--- a/sqlite3.go
+++ b/sqlite3.go
@@ -136,50 +136,48 @@ func (c *SQLiteConn) AutoCommit() bool {
// Implements Execer
func (c *SQLiteConn) Exec(query string, args []driver.Value) (driver.Result, error) {
+ var res driver.Result
for {
- ds, err := c.Prepare(query)
+ s, err := c.Prepare(query)
if err != nil {
return nil, err
}
- s := ds.(*SQLiteStmt)
na := s.NumInput()
- res, err := s.Exec(args[:na])
- args = args[na:]
- if err != nil {
+ res, err = s.Exec(args[:na])
+ if err != nil && err != driver.ErrSkip {
s.Close()
return nil, err
}
- if s.t == "" {
+ args = args[na:]
+ tail := s.(*SQLiteStmt).t
+ if tail == "" {
return res, nil
}
s.Close()
- query = s.t
+ query = tail
}
}
// Implements Queryer
func (c *SQLiteConn) Query(query string, args []driver.Value) (driver.Rows, error) {
+ var rows driver.Rows
for {
- ds, err := c.Prepare(query)
+ s, err := c.Prepare(query)
if err != nil {
return nil, err
}
- s := ds.(*SQLiteStmt)
na := s.NumInput()
- rows, err := s.Query(args[:na])
- args = args[na:]
- if err != nil {
+ rows, err = s.Query(args[:na])
+ if err != nil && err != driver.ErrSkip {
s.Close()
return nil, err
}
- if s.t == "" {
+ args = args[na:]
+ tail := s.(*SQLiteStmt).t
+ if tail == "" {
return rows, nil
}
- if rows != nil {
- rows.Close()
- }
- s.Close()
- query = s.t
+ query = tail
}
}
@@ -418,6 +416,9 @@ func (s *SQLiteStmt) Exec(args []driver.Value) (driver.Result, error) {
// Close the rows.
func (rc *SQLiteRows) Close() error {
+ if rc.s.closed {
+ return nil
+ }
rv := C.sqlite3_reset(rc.s.s)
if rv != C.SQLITE_OK {
return ErrNo(rv)