fix(db import): query each PRAGMA individually so checks survive sqlite3 format changes#1037
Open
ada-powerful wants to merge 1 commit into
Open
Conversation
…te3 output-format changes (tursodatabase#1030) `sqliteFileIntegrityChecks` ran one `.mode line` query and string-matched the result for `j = wal` / `j: wal` etc. The dual-separator check works today, but it depends on whatever line formatter sqlite3 happens to emit, and breaks again the next time that format moves (which is exactly what tursodatabase#1030 reports for sqlite3 3.50). Switch to one short query per pragma using `-batch -noheader -list "select * from pragma_X"`, which returns just the value with no surrounding key, separator, or column header. Compare the trimmed value to the expected literal. Robust to any future sqlite3 output mode changes. Adds: - `readPragma(file, pragma)` helper next to `runQuickCheck`. - `TestReadPragma` covering journal_mode, page_size, auto_vacuum, encoding, and the nonexistent-file error path. - `TestSqliteFileIntegrityChecks` covering the happy path and two failure modes (non-WAL DB, 8KB page size). Verified against system sqlite3 3.46.1 in CI Docker image; passes existing `TestRunQuickCheck` suite.
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.
Fixes #1030.
Problem
turso db importrunssqliteFileIntegrityChecks, which executes one.mode linequery and string-matches the resulting text forj = wal/j: waletc. The dual-separator check covers today's=vs:split, but it depends entirely on whatever line formatter sqlite3 happens to emit. When sqlite3 changes that format again, the check breaks again — and it has already broken once, between 3.49 and 3.50.Fix
Query each pragma with its own short statement:
That returns just
wal— no key, no separator, no column header — regardless of how.mode lineis formatted in any future sqlite3 version. Compare the trimmed value against the expected literal.Added a
readPragma(file, pragma)helper next torunQuickCheckand refactoredsqliteFileIntegrityChecksto call it four times. Same error messages, same exit conditions, format-independent.Tests
Verified against system sqlite3 3.46.1 in golang:1.25 CI image. Existing
TestRunQuickCheckcontinues to pass.Disclosure
This PR was prepared by an AI agent (Claude Opus 4.7) under direct human review. Happy to address any feedback.