feat(engine): PRAGMA dispatcher + auto_vacuum knob (SQLR-13)#115
Merged
Conversation
Adds the first SQL-level PRAGMA, exposing the SQLR-10 auto-VACUUM threshold to SDK / FFI / MCP consumers (which can't reach Connection::set_auto_vacuum_threshold directly). New src/sql/pragma.rs pre-tokenizes PRAGMA statements before sqlparser sees them, so we accept bare OFF / NONE — sqlparser-rs's pragma-value parser only allows numbers and quoted strings, which would silently reject the classic SQLite idiom. Reuses Database::set_auto_vacuum_threshold for range validation so out-of-range values surface as a typed error instead of saturating. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
PRAGMAto SQLRite, surfacing the SQLR-10 auto-VACUUM threshold to SDK / FFI / MCP consumers that can't reachConnection::set_auto_vacuum_thresholddirectly.src/sql/pragma.rspre-tokenizesPRAGMAstatements before sqlparser sees them — sqlparser-rs's pragma-value parser only accepts numbers and quoted strings, so bareOFF/NONE(the classic SQLite idiom) would silently fail without this. ReusesDatabase::set_auto_vacuum_thresholdfor range validation; out-of-range values produce a typed error rather than saturating.What's new at the SQL surface
Out-of-range numerics,
NaN/±∞, and unknown identifiers likeWAL/FULLare rejected with a typed error — the trigger never silently saturates or falls back to a default.Acceptance criteria (from SQLR-13)
conn.execute("PRAGMA auto_vacuum = 0.5;")works and is reflected byconn.auto_vacuum_threshold()conn.execute("PRAGMA auto_vacuum = OFF;")disables the triggerconn.execute("PRAGMA auto_vacuum;")returns a single-row result set (rendered prettytable inCommandOutput.rendered, consistent with how SQLite renders it)src/sql/pager/mod.rsmirror the SQLR-10 setter coverage but routed through SQLOut of scope (deferred per task description)
Connection::prepare("PRAGMA …"). Prepare goes through sqlparser, which rejects bareOFF.Connection::executeis the supported entry point — the AC only requires that path.journal_mode,synchronous,cache_size, …). Dispatcher is in place; new pragmas plug in as a single match arm inexecute_pragma.Test plan
cargo build --workspace --exclude sqlrite-desktop --exclude sqlrite-python --exclude sqlrite-nodejs --exclude sqlrite-benchmarks --all-targetscleancargo fmt --all -- --checkcleancargo clippy --workspace …no new warnings (pre-existing FFI / MCP warnings unchanged)cargo test --workspace …— 501 engine + 19 MCP protocol + others, all greensrc/sql/pragma.rscover parser shapes, value variants, malformed inputs, and the auto_vacuum handlersrc/sql/pager/mod.rscover the SQL route end-to-end, including a real auto-VACUUM trigger driven entirely byPRAGMA(OFF keeps file at HWM, high threshold suppresses, re-armed PRAGMA fires after a second drop)Docs
PRAGMA auto_vacuumsrc/sql/pragma.rs🤖 Generated with Claude Code