Commit Graph

1052 Commits

Author SHA1 Message Date
Jakob Borg
904664d0b0 avoid out of bounds write in unlock_notify_wait on 64 bit platforms
While `C.sizeof_unit` is 4, we convert to a Go uint and write it to the
pointer. The Go uint is eight bytes on 64 bit platforms.

Signed-off-by: Jakob Borg <jakob@kastelo.net>
2026-05-19 12:47:48 +02:00
mattn
20826e87d8 Merge pull request #1394 from mattn/sqlite-amalgamation-3053000
Upgrade SQLite to version 3053000
2026-04-29 18:20:20 +09:00
Yasuhiro Matsumoto
2d4d220883 fix changelog URL when minor or patch version is zero 2026-04-29 18:13:23 +09:00
Yasuhiro Matsumoto
3761cf7ca6 Upgrade SQLite to version 3053000 2026-04-29 18:09:13 +09:00
mattn
1aa7317331 Merge pull request #1388 from mattn/stmt-cache-lru
evict least-recently-used stmt when cache is full
2026-04-29 17:21:47 +09:00
mattn
c719e205f4 Merge pull request #1392 from mattn/fix-issue-1390-query-comment-panic
Fix panic when querying input with no SQL (only comments/whitespace)
2026-04-29 16:13:09 +09:00
Yasuhiro Matsumoto
869e516d63 fix panic when querying input with no SQL (only comments/whitespace)
sqlite3_prepare_v2 returns SQLITE_OK with a NULL statement handle when
the input contains no SQL. exec() already handled this; query() forwarded
the NULL handle to bind(), which crashed in sqlite3_clear_bindings(NULL).

Make query() skip NULL statements like exec() does, and make SQLiteRows
safe against a nil underlying statement so the empty-rows return value
does not crash.

Closes #1390
2026-04-29 15:54:05 +09:00
Yasuhiro Matsumoto
66902381f2 extract finalizeCachedStmt helper and drop redundant tail reset 2026-04-14 14:23:22 +09:00
Yasuhiro Matsumoto
59e8e756b9 only set stmt cacheKey when cache is enabled 2026-04-14 14:14:47 +09:00
Yasuhiro Matsumoto
2badb4cfef use slice len/cap for stmt cache instead of separate counters 2026-04-14 14:13:43 +09:00
Yasuhiro Matsumoto
7716c20f00 evict LRU stmt when stmt cache is full 2026-04-11 20:47:55 +09:00
mattn
58e032d79a Revise SECURITY.md for version support and reporting
Updated security policy to reflect supported versions and reporting guidelines.
2026-04-10 16:17:13 +09:00
Yasuhiro Matsumoto
1627011105 add _stmt_cache_size to DSN parameters table in README 2026-04-08 22:32:40 +09:00
mattn
5df13a0e80 Merge pull request #1387 from mattn/codex/stmt-cache
[codex] add opt-in statement cache
2026-04-08 22:29:35 +09:00
Yasuhiro Matsumoto
e302e5cb8c document that _stmt_cache_size is per connection
Clarify that each connection in the sql.DB pool maintains its own
independent statement cache.
2026-04-08 13:43:47 +09:00
Yasuhiro Matsumoto
867dcbfbdc move reset/clear into putCachedStmt and always finalize on failure
This avoids an unnecessary reset when the cache is full, guarantees
a statement cannot enter the cache without being reset/cleared, and
fixes a leak where sqlite3_finalize was not called when reset failed.
2026-04-08 13:42:26 +09:00
Yasuhiro Matsumoto
0e58fa4d72 simplify prepareWithCache to call prepare instead of duplicating logic
prepareWithCache now delegates to prepare and sets cacheKey
afterward, removing the useCache boolean parameter.
2026-04-08 13:41:29 +09:00
Yasuhiro Matsumoto
e9f47da5c5 do not bail out on finalize error in closeCachedStmtsLocked
Finalize all cached statements even if one fails. Leaving a
finalized statement in the cache map would be a use-after-finalize
bug per SQLite documentation.
2026-04-08 13:40:21 +09:00
Yasuhiro Matsumoto
325cb8d5d9 remove redundant stmtCacheSize check in putCachedStmt
When stmtCacheSize <= 0, stmtCacheCount >= stmtCacheSize is always
true, so the explicit check is unnecessary.
2026-04-08 13:39:22 +09:00
Yasuhiro Matsumoto
061c2a5f43 check stmtCacheSize before acquiring mutex in takeCachedStmt
stmtCacheSize is immutable after connection open, so checking it
before the lock avoids mutex overhead when cache is not enabled.
2026-04-08 13:38:45 +09:00
Yasuhiro Matsumoto
efa9b1c75d add opt-in statement cache 2026-04-07 14:08:53 +09:00
mattn
8d12439413 Merge pull request #1386 from mattn/perf/reduce-cgo-overhead
reduce CGO call overhead for exec and bind paths
2026-04-06 22:36:14 +09:00
Yasuhiro Matsumoto
89f4bbe489 fix build with SQLITE_ENABLE_UNLOCK_NOTIFY
Move extern declarations for _sqlite3_*_blocking functions before
_sqlite3_exec_no_args which references them. Remove unused
_sqlite3_prepare_v2_nolen function.
2026-04-06 22:29:28 +09:00
Yasuhiro Matsumoto
49540487ae reduce CGO call overhead for exec and bind paths
- Add _sqlite3_exec_no_args() C function that combines prepare+step+finalize
  into a single CGO crossing for parameterless exec (most common case)
- Add _sqlite3_reset_clear() C function that combines sqlite3_reset and
  sqlite3_clear_bindings into a single CGO crossing
- Use semaphore channel instead of result struct channel in context-aware
  exec/Next paths to reduce allocations
- Use time.AppendFormat with stack buffer to avoid heap allocation in
  time.Time binding
- Optimize bindNamedIndices to reuse a single buffer instead of 3
  separate C.CString allocations
- Remove intermediate bindIndices slice allocation in named parameter
  binding path
- Pass explicit query length to sqlite3_prepare_v2 to avoid C-side strlen

benchstat (n=8):

  BenchmarkExec:   -29.44% sec/op, -50% B/op, -33% allocs/op
  BenchmarkQuery:  -9.83% sec/op
  BenchmarkParams: -6.38% sec/op
  geomean:         -6.72% sec/op
2026-04-06 22:22:20 +09:00
mattn
4a311ff7de Merge pull request #1385 from mattn/perf/reduce-bind-overhead
Reduce sqlite bind overhead
2026-04-06 21:38:56 +09:00
Yasuhiro Matsumoto
61c5b98535 reduce sqlite bind overhead 2026-04-06 21:30:35 +09:00
mattn
f92973809d Merge pull request #1384 from mattn/raise-go121-cleanup
Raise minimum Go version to 1.21
2026-04-03 22:09:55 +09:00
Yasuhiro Matsumoto
efae5e7686 raise minimum Go version to 1.21 2026-04-03 17:41:32 +09:00
mattn
b23d54cb76 Merge pull request #1383 from mattn/codex/next-row-batch-fetch
[codex] batch row column fetches in Next
2026-04-03 17:39:28 +09:00
Yasuhiro Matsumoto
e1557be6ce batch row column fetches in Next 2026-04-03 12:47:30 +09:00
mattn
cc39db7160 Merge pull request #1382 from mattn/codex/sqlite3-bind-fastpath
[codex] optimize sqlite bind fast path
2026-04-03 12:00:00 +09:00
Yasuhiro Matsumoto
9a908a9fd0 optimize sqlite bind fast path 2026-04-03 11:47:49 +09:00
mattn
edadafaf61 Merge pull request #1381 from mattn/eliminate-bounds-checks
Eliminate unnecessary bounds checks in hot paths
2026-03-30 12:57:50 +09:00
Yasuhiro Matsumoto
8f9f86ea43 Eliminate unnecessary bounds checks in hot paths
- Replace len(args[start:start+na]) > 0 with na > 0 to avoid slice bounds check
- Use range loops instead of manual index loops for cols/decltype slices
- Use range variable v.Ordinal instead of re-indexing args[i].Ordinal
- Add bounds hint for decltype access in nextSyncLocked loop
2026-03-30 12:48:09 +09:00
mattn
0d2388125f Merge pull request #1379 from theimpostor/pr-1322-missing-constraint-op-types
Add missing virtual table constraint op constants
2026-03-19 13:39:43 +09:00
theimpostor
84bdc43851 add missing index constraint op types 2026-03-18 17:40:17 -05:00
mattn
57e50071ab Merge pull request #1313 from Jaculabilis/json-example
Fix json example
2026-03-17 02:31:23 +09:00
Yasuhiro Matsumoto
bb8d0b2a05 Bump Go test matrix versions from 1.23-1.25 to 1.24-1.26 2026-03-17 02:19:02 +09:00
Yasuhiro Matsumoto
bc7436edad Bump GitHub Actions versions to latest 2026-03-17 02:19:02 +09:00
Yasuhiro Matsumoto
0f12d4e815 Ensure Close always removes runtime finalizer to prevent memory leak
Fixes #1319
2026-03-17 02:19:02 +09:00
Yasuhiro Matsumoto
d71eda82d4 Fix upgrade.sh: add already-up-to-date check and fix changelog URL format 2026-03-17 01:41:11 +09:00
Yasuhiro Matsumoto
4ea2a9fb44 Upgrade SQLite to version 3051003 2026-03-17 01:41:11 +09:00
Yasuhiro Matsumoto
8c99a68554 Call sqlite3_clear_bindings() in bind() to reset parameters
Closes #1063
2026-03-17 01:23:59 +09:00
Yasuhiro Matsumoto
5a1f4d3045 use unsafe.Slice 2026-03-04 09:27:38 +09:00
Yasuhiro Matsumoto
8366a001c1 create pull-request 2026-03-04 09:14:31 +09:00
Yasuhiro Matsumoto
208733130e add script to create pull-request 2026-01-16 17:19:36 +09:00
Yasuhiro Matsumoto
a5108832c7 Upgrade SQLite to version 3051002 2026-01-16 17:19:17 +09:00
Daniël Sonck
dce6b34a89 Add percentile extension 2026-01-01 23:03:41 +09:00
Yasuhiro Matsumoto
3c885a9512 Upgrade SQLite to version 3051001 2026-01-01 23:00:27 +09:00
Yasuhiro Matsumoto
3e773a9be5 update github workflows 2026-01-01 22:56:17 +09:00