Skip to content

Commit

Permalink
Merge pull request #29 from mattn/master
Browse files Browse the repository at this point in the history
Merge upstream
  • Loading branch information
otoolep authored May 10, 2024
2 parents 3bf5982 + 3c0390b commit 0c35ea2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
24 changes: 16 additions & 8 deletions sqlite3.go
Original file line number Diff line number Diff line change
Expand Up @@ -881,14 +881,16 @@ func (c *SQLiteConn) exec(ctx context.Context, query string, args []driver.Named
// consume the number of arguments used in the current
// statement and append all named arguments not
// contained therein
stmtArgs = append(stmtArgs, args[start:start+na]...)
for i := range args {
if (i < start || i >= na) && args[i].Name != "" {
stmtArgs = append(stmtArgs, args[i])
if len(args[start:start+na]) > 0 {
stmtArgs = append(stmtArgs, args[start:start+na]...)
for i := range args {
if (i < start || i >= na) && args[i].Name != "" {
stmtArgs = append(stmtArgs, args[i])
}
}
for i := range stmtArgs {
stmtArgs[i].Ordinal = i + 1
}
}
for i := range stmtArgs {
stmtArgs[i].Ordinal = i + 1
}
res, err = s.(*SQLiteStmt).exec(ctx, stmtArgs)
if err != nil && err != driver.ErrSkip {
Expand Down Expand Up @@ -1683,7 +1685,7 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) {
}
}

// Forgein Keys
// Foreign Keys
if foreignKeys > -1 {
if err := exec(fmt.Sprintf("PRAGMA foreign_keys = %d;", foreignKeys)); err != nil {
C.sqlite3_close_v2(db)
Expand Down Expand Up @@ -1912,6 +1914,7 @@ func (s *SQLiteStmt) Close() error {
if rv != C.SQLITE_OK {
return s.c.lastError()
}
s.c = nil
runtime.SetFinalizer(s, nil)
return nil
}
Expand Down Expand Up @@ -2017,6 +2020,7 @@ func (s *SQLiteStmt) query(ctx context.Context, args []driver.NamedValue) (drive
closed: false,
ctx: ctx,
}
runtime.SetFinalizer(rows, (*SQLiteRows).Close)

return rows, nil
}
Expand Down Expand Up @@ -2062,6 +2066,7 @@ func (s *SQLiteStmt) exec(ctx context.Context, args []driver.NamedValue) (driver
err error
}
resultCh := make(chan result)
defer close(resultCh)
go func() {
r, err := s.execSync(args)
resultCh <- result{r, err}
Expand Down Expand Up @@ -2128,6 +2133,8 @@ func (rc *SQLiteRows) Close() error {
return rc.s.c.lastError()
}
rc.s.mu.Unlock()
rc.s = nil
runtime.SetFinalizer(rc, nil)
return nil
}

Expand Down Expand Up @@ -2174,6 +2181,7 @@ func (rc *SQLiteRows) Next(dest []driver.Value) error {
return rc.nextSyncLocked(dest)
}
resultCh := make(chan error)
defer close(resultCh)
go func() {
resultCh <- rc.nextSyncLocked(dest)
}()
Expand Down
1 change: 1 addition & 0 deletions sqlite3_libsqlite3.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ package sqlite3
#cgo openbsd LDFLAGS: -lsqlite3
#cgo solaris LDFLAGS: -lsqlite3
#cgo windows LDFLAGS: -lsqlite3
#cgo zos LDFLAGS: -lsqlite3
*/
import "C"
2 changes: 1 addition & 1 deletion sqlite3_opt_userauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ var (
// combination is incorrect or unknown.
//
// If the SQLITE_USER table is not present in the database file, then
// this interface is a harmless no-op returnning SQLITE_OK.
// this interface is a harmless no-op returning SQLITE_OK.
func (c *SQLiteConn) Authenticate(username, password string) error {
rv := c.authenticate(username, password)
switch rv {
Expand Down

0 comments on commit 0c35ea2

Please sign in to comment.