fix conversion back to original journal_mode after migration

This commit is contained in:
Stephen Lombardo 2018-09-21 14:47:14 -04:00
parent 20d80b3a89
commit f177869fca
2 changed files with 35 additions and 3 deletions

View File

@ -1359,11 +1359,11 @@ migrate:
#endif
CODEC_TRACE("renamed migration database %s to main database %s: %d\n", migrated_db_filename, db_filename, rc);
rc = sqlite3OsOpen(db->pVfs, migrated_db_filename, srcfile, SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE, &oflags);
rc = sqlite3OsOpen(db->pVfs, migrated_db_filename, srcfile, SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|SQLITE_OPEN_MAIN_DB, &oflags);
CODEC_TRACE("reopened migration database: %d\n", rc);
if( rc!=SQLITE_OK ) goto handle_error;
rc = sqlite3OsOpen(db->pVfs, db_filename, destfile, SQLITE_OPEN_READWRITE, &oflags);
rc = sqlite3OsOpen(db->pVfs, db_filename, destfile, SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|SQLITE_OPEN_MAIN_DB, &oflags);
CODEC_TRACE("reopened main database: %d\n", rc);
if( rc!=SQLITE_OK ) goto handle_error;

View File

@ -2098,11 +2098,43 @@ do_test migrate-3-0-database-to-current-format {
execsql {
PRAGMA key = 'testkey';
SELECT count(*) FROM sqlite_master;
PRAGMA journal_mode;
}
} {1}
} {1 delete}
db close
file delete -force test.db
do_test migrate-wal-database-to-current {
file copy -force $sampleDir/sqlcipher-3.0-testkey.db test.db
sqlite_orig db test.db
set rc {}
lappend rc [execsql {
PRAGMA key = 'testkey';
PRAGMA cipher_page_size = 1024; PRAGMA kdf_iter = 64000; PRAGMA cipher_hmac_algorithm = HMAC_SHA1; PRAGMA cipher_kdf_algorithm = PBKDF2_HMAC_SHA1;
PRAGMA journal_mode = wal;
}]
db close
sqlite_orig db test.db
lappend rc [execsql {
PRAGMA key = 'testkey';
PRAGMA cipher_migrate;
PRAGMA journal_mode;
}]
db close
sqlite_orig db test.db
lappend rc [execsql {
PRAGMA key = 'testkey';
SELECT count(*) FROM sqlite_master;
PRAGMA journal_mode;
}]
} {wal {0 wal} {1 wal}}
db close
file delete -force test.db
do_test key-database-by-name {
sqlite_orig db test.db
execsql {