From 6ee3e6746e6b5a0f4099d0553120ceead9f9fc38 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Sat, 3 Feb 2024 01:43:10 +0900 Subject: [PATCH 1/3] close channel --- sqlite3.go | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/sqlite3.go b/sqlite3.go index a16d8abf..4b3b6cab 100644 --- a/sqlite3.go +++ b/sqlite3.go @@ -875,14 +875,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 { @@ -1906,6 +1908,7 @@ func (s *SQLiteStmt) Close() error { if rv != C.SQLITE_OK { return s.c.lastError() } + s.c = nil runtime.SetFinalizer(s, nil) return nil } @@ -2011,6 +2014,7 @@ func (s *SQLiteStmt) query(ctx context.Context, args []driver.NamedValue) (drive closed: false, ctx: ctx, } + runtime.SetFinalizer(rows, (*SQLiteRows).Close) return rows, nil } @@ -2056,6 +2060,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} @@ -2122,6 +2127,8 @@ func (rc *SQLiteRows) Close() error { return rc.s.c.lastError() } rc.s.mu.Unlock() + rc.s = nil + runtime.SetFinalizer(rc, nil) return nil } @@ -2168,6 +2175,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) }() From 18cdded9007a93b8bc1de151da21b1a1280be722 Mon Sep 17 00:00:00 2001 From: pomadev Date: Wed, 21 Feb 2024 16:06:43 +0900 Subject: [PATCH 2/3] fix: some typos --- sqlite3.go | 2 +- sqlite3_opt_userauth.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sqlite3.go b/sqlite3.go index 4b3b6cab..ed2a9e2a 100644 --- a/sqlite3.go +++ b/sqlite3.go @@ -1679,7 +1679,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) diff --git a/sqlite3_opt_userauth.go b/sqlite3_opt_userauth.go index de9630c2..76d84016 100644 --- a/sqlite3_opt_userauth.go +++ b/sqlite3_opt_userauth.go @@ -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 { From 3c0390b77cba9a7eaee4102e1ca6a35c14e2de7c Mon Sep 17 00:00:00 2001 From: Dustin Ward Date: Tue, 30 Apr 2024 13:15:32 -0400 Subject: [PATCH 3/3] add support for libsqlite3 on z/OS --- sqlite3_libsqlite3.go | 1 + 1 file changed, 1 insertion(+) diff --git a/sqlite3_libsqlite3.go b/sqlite3_libsqlite3.go index 95cc7c0b..6ef23086 100644 --- a/sqlite3_libsqlite3.go +++ b/sqlite3_libsqlite3.go @@ -18,5 +18,6 @@ package sqlite3 #cgo openbsd LDFLAGS: -lsqlite3 #cgo solaris LDFLAGS: -lsqlite3 #cgo windows LDFLAGS: -lsqlite3 +#cgo zos LDFLAGS: -lsqlite3 */ import "C"