Repository navigation
fix: SQLite scripts, safe schema reads, row cap - #934
Merged
Merged
Conversation
The SQLite executor handed the whole script to rusqlite's prepare, which compiles only the first statement and ignores the rest, so a script ran its first statement and reported success. The script is now split as SQLite splits it: a port of sqlite3_complete's state machine that respects strings, quoted names, comments and trigger bodies. Each statement is prepared after the previous one has run and gets its own result, carrying its text in a new `sql` field. The first failure stops the run and is reported with its statement index and the results of the statements before it, as the MySQL path does. The mock splits with the same state machine. Closes #928 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WTypK4RjzzdjoFxd3qk14g
get_columns built `PRAGMA table_info("{}")` and the row count in
get_tables built `SELECT COUNT(*) FROM "{}"`, both without doubling a
`"` in the name, so an odd name broke the read and a crafted name in an
opened file could inject SQL. Columns now come from pragma_table_info
with the name bound; the count quotes the name properly against main.
get_indexes parsed the CREATE INDEX text, which split expression
indexes and COLLATE/DESC columns wrongly. It now reads
pragma_index_list (user-created indexes only) and pragma_index_xinfo
(key columns in key order, an expression as "<expression>").
Closes #929
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WTypK4RjzzdjoFxd3qk14g
The failed-statement highlight split every script with the MySQL splitter, so a SQLite trigger body cut at its inner semicolons and the statement text and "N of M" count went wrong. The SQLite splitter moves from the mock into src/lib/sqlite-split.ts, shared by the mock and the result store, which now picks the splitter by connection kind. Closes #932 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WTypK4RjzzdjoFxd3qk14g
The SQLite executor read every row and never set rows_truncated, so a SELECT * on a large table loaded it all and sent it over IPC. sqlite_execute now takes the row limit and page offset execute_query takes, applies them while stepping, stops on low free memory as the MySQL executor does, and reports truncation_reason. Paging works on SQLite tabs as a result, where the offset used to be ignored. Each result also reports in_transaction from is_autocommit(), mapped to QueryResult.transaction by the data source. Closes #933 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WTypK4RjzzdjoFxd3qk14g
Merged
Merged
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.
SQLite fixes, done by two
implementer-rustlanes.Closes #928
Closes #929
Closes #932
Closes #933
Changes
mas-sqlite/src/split.rsis a pure-Rust copy of SQLite's ownsqlite3_completestate machine. It does not split inside strings, quoted names or comments, and keeps a trigger body (BEGIN … END) as one statement.SqliteQueryResultgainssql, the text of that statement.statementIndexandcompletedResults, as MySQL does.get_columnsusespragma_table_info(?1)with the name bound.". Before, a crafted table name in an opened file could inject SQL; a test shows that a name built to run a DROP no longer does.pragma_index_list/pragma_index_xinfo, not from parsingCREATE INDEXtext.failedStatementOfnow splits SQLite scripts with a shared TS SQLite splitter (src/lib/sqlite-split.ts); the mock uses the same splitter.sqlite_executetakeslimitandoffset. The executor stops at the limit and setstruncation_reason.is_autocommit()). The TX badge stays MySQL-only for now, because one SQLite connection is shared by every tab.sysinfomoves into the workspace dependencies.Tests
;inside strings,RETURNING, limit, offset, memory guard, transaction state;"and;, DESC and COLLATE columns, an expression index, and the injection attempt.cargo fmtand clippy with-D warningsare clean.cargo test -p mas-sqliteand-p sqlpilotpass.npm run test:unitpasses (3741 tests). After merging main,npm run type-checkandvitestonsrc/{dev,lib,stores}pass.npm run linthas 0 errors.npx dprint checkis clean.Generated by Claude Code