Merge upstream - #47
Merged
Merged
Conversation
…aint-op-types Add missing virtual table constraint op constants
- 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
Eliminate unnecessary bounds checks in hot paths
[codex] optimize sqlite bind fast path
[codex] batch row column fetches in Next
Raise minimum Go version to 1.21
Reduce sqlite bind overhead
- 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
Move extern declarations for _sqlite3_*_blocking functions before _sqlite3_exec_no_args which references them. Remove unused _sqlite3_prepare_v2_nolen function.
reduce CGO call overhead for exec and bind paths
stmtCacheSize is immutable after connection open, so checking it before the lock avoids mutex overhead when cache is not enabled.
When stmtCacheSize <= 0, stmtCacheCount >= stmtCacheSize is always true, so the explicit check is unnecessary.
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.
prepareWithCache now delegates to prepare and sets cacheKey afterward, removing the useCache boolean parameter.
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.
Clarify that each connection in the sql.DB pool maintains its own independent statement cache.
[codex] add opt-in statement cache
Updated security policy to reflect supported versions and reporting guidelines.
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 mattn#1390
…-panic Fix panic when querying input with no SQL (only comments/whitespace)
evict least-recently-used stmt when cache is full
Upgrade SQLite to version 3053000
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.