Repository navigation
Refuse PRAGMA cipher_migrate on a read-only main database - #631
Open
LucaCappelletti94 wants to merge 1 commit into
Open
LucaCappelletti94 wants to merge 1 commit into
LucaCappelletti94 wants to merge 1 commit into
Conversation
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.
A connection opened read-only through the URI parameters
mode=roorimmutable=1runsPRAGMA cipher_migrateto success and rewrites the database file.db->openFlagsis recorded before the URI is parsed and never carriesmode=ro, so theATTACHof the-migratedfile, the export and the rename onto the main file all go through. WithSQLITE_OPEN_READONLYthe migration fails only because thatATTACHcannot create the-migratedfile, which returnsSQLITE_CANTOPENand leaves the connection in the deferred error state.The main btree is read-only on all three routes, so the check reads it once the legacy format has been detected and before any file is created. It returns
SQLITE_READONLYand exits throughcleanuplike the other checks that run before the database is touched, which leaves the file unchanged and the connection usable. A read-only connection on a database already in the current format still gets 0, since nothing needs to be written. ForSQLITE_OPEN_READONLYthe result changes from 14 to 8 on purpose, so every read-only route reports the same cause.