Skip to content

Merge upstream - #55

Merged
otoolep merged 12 commits into
masterfrom
merge-upstream
Nov 6, 2026
Merged

otoolep merged 12 commits into
masterfrom
merge-upstream

Conversation

@otoolep

@otoolep otoolep commented Nov 6, 2026

Copy link
Copy Markdown
Member

No description provided.

mattn and others added 12 commits September 21, 2026 01:51
Next() previously crossed into C once to step and again to read the
row's columns. Step and fetch the values in a single
_sqlite3_step_values call, mirroring the fused first-step path, and
keep the step output parameters on the statement instead of allocating
escaping locals on every query.

Saves one CGO crossing per row and one allocation per query. On the
:memory: BenchmarkPreparedRows the 1000-row cases improve 7-10%; on
the WAL file DB fair benchmarks (single-row QueryRow) the time is
unchanged and allocations drop by one per query.
Fuse step and column fetch into one CGO crossing in Next
sqlite3_set_authorizer takes db->mutex, while query cancellation takes
c.mu before calling sqlite3_interrupt. Holding c.mu across the call
could block cancellation of a running query, so use authorizerMu.
…authorizers

fix: release replaced authorizer callbacks
…lose

SQLite dereferences the connection handle without checking it, so every
*SQLiteConn method that passes c.db into the C API segfaulted once Close
had released the handle and set it to nil. This is reachable from
ordinary code: a connection captured from a ConnectHook outlives the
*sql.DB, and calling any of these methods on it killed the process.

Guard the affected methods with the existing dbConnOpen helper, which
reads the handle under mu and is not held across the C call, so it does
not reintroduce the lock-order inversion that RegisterAuthorizer avoids
with its own mutex. Methods that return an error report errConnClosed,
the callback registrations that have no error to report become no-ops,
and the accessors report a documented zero value.

Affected: RegisterCollation, RegisterCommitHook, RegisterRollbackHook,
RegisterUpdateHook, RegisterAuthorizer, RegisterFunc,
RegisterAggregator, AutoCommit, GetFilename, GetLimit, SetLimit,
SetFileControlInt and SetFileControlInt64.
Return an error instead of crashing when a connection is used after Close
Since 4954048, Exec without arguments takes a fast path that steps each
statement without checking its parameters, so a statement whose
arguments are missing ran with them bound as NULL instead of failing
with "not enough args to execute query". Leave such a statement
unexecuted in that path and return the same error as the regular path.

Fixes mattn#1470
…ng-params

Report missing arguments when Exec has no arguments
@otoolep
otoolep merged commit 1c8ff63 into master Nov 6, 2026
3 checks passed
@otoolep
otoolep deleted the merge-upstream branch November 6, 2026 03:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants