-
-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The first query after "pragma key" returns error #36
Comments
I can reproduce the phenomenon, but at the moment I have no explanation. However, if you remove the line It also works without removing the first I will look into this issue within the next couple of days and will try to find out why it happens and how it can be possibly solved. |
With multi cipher |
As a workaround you could close ( Nevertheless I will check as said what's causing the observed behavior. |
Well, the observed behavior is caused by the fact that SQLite uses a cache to avoid disk I/O. In this case the cache still contains data that were decrypted with the wrong key. I applied a fix in commit ab5df84 to clear the cache after setting a new passphrase. This solves the issue. However, in my humble opinion a database connection should be closed after getting the error |
Thanks!
This command sequence is near by how my GUI app intends to use a cipher. An user selects a database via Open dialog control, the database is opened and checked on encryption (first P.S. I assumed that is a cache error, but I didn't find any suitable sqlite3 API function myself. |
If the database is in fact encrypted, you get the error
Of course, I understand how you intend to proceed. However, I disagree that closing the connection is inappropriate. If SQLite tells you that the database file seems not to be a database file - either because it is indeed no database file or because it is an encrypted database file, it is a natural thing to do to close the connection. The procedure could be similar to the following pseudo code: bool openSuccess = false;
bool cancelled = false;
do
{
if (!(cancelled = showDialogWithOptionalCipherConfigAndPassphrase()))
{
openDatabaseConnectionWithGivenParameters(); /* open + pragmas */
if (!(openSuccess = testConnection())) /* select from sqlite_master */
{
closeDatabaseConnection();
}
}
}
while (!openSuccess && !cancelled);
Well, there isn't a public function for clearing the cache. And it wouldn't be a good idea to interfere with SQLite's cache management anyway - at least in general. In our case clearing the cache (with an internal function) does no harm (i.e. to performance), because the passphrase has to be specified right after opening the database connection. That is, usually you will have just the first database page in the cache at most. |
MinGW32, Win7x64, Release page dll.
The text was updated successfully, but these errors were encountered: