1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Enhance the scrub utility program so that it does a FULL checkpoint prior to

starting the backup, to ensure that the database file content matches what needs
to be backed up without having to look at the WAL file.

FossilOrigin-Name: ab1c5ce50f139070d7a322f43132a93c8af2ed68
This commit is contained in:
drh
2016-05-17 21:17:51 +00:00
parent 8884d99926
commit 0d2c3a0e11
3 changed files with 15 additions and 8 deletions

View File

@ -164,13 +164,20 @@ static void scrubBackupOpenSrc(ScrubState *p){
sqlite3_errmsg(p->dbSrc));
return;
}
p->rcErr = sqlite3_exec(p->dbSrc, "BEGIN", 0, 0, 0);
p->rcErr = sqlite3_exec(p->dbSrc, "SELECT 1 FROM sqlite_master; BEGIN;",
0, 0, 0);
if( p->rcErr ){
scrubBackupErr(p,
"cannot start a read transaction on the source database: %s",
sqlite3_errmsg(p->dbSrc));
return;
}
rc = sqlite3_wal_checkpoint_v2(p->dbSrc, "main", SQLITE_CHECKPOINT_FULL,
0, 0);
if( rc ){
scrubBackupErr(p, "cannot checkpoint the source database");
return;
}
pStmt = scrubBackupPrepare(p, p->dbSrc, "PRAGMA page_size");
if( pStmt==0 ) return;
rc = sqlite3_step(pStmt);