/ Check-in [ab1c5ce5]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment: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.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | scrub-backup
Files: files | file ages | folders
SHA1: ab1c5ce50f139070d7a322f43132a93c8af2ed68
User & Date: drh 2016-05-17 21:17:51
Context
2016-05-18
21:03
Add the "scrub" utility program that simultaneously backs-up a live database and erases all deleted content. check-in: c981ab2a user: drh tags: trunk
2016-05-17
21:17
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. Closed-Leaf check-in: ab1c5ce5 user: drh tags: scrub-backup
17:11
Merge the latest changes from trunk. check-in: 5021dfe1 user: drh tags: scrub-backup
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/misc/scrub.c.

   160    160                    SQLITE_OPEN_READWRITE |
   161    161                    SQLITE_OPEN_URI | SQLITE_OPEN_PRIVATECACHE, 0);
   162    162     if( p->rcErr ){
   163    163       scrubBackupErr(p, "cannot open source database: %s",
   164    164                         sqlite3_errmsg(p->dbSrc));
   165    165       return;
   166    166     }
   167         -  p->rcErr = sqlite3_exec(p->dbSrc, "BEGIN", 0, 0, 0);
          167  +  p->rcErr = sqlite3_exec(p->dbSrc, "SELECT 1 FROM sqlite_master; BEGIN;",
          168  +                          0, 0, 0);
   168    169     if( p->rcErr ){
   169    170       scrubBackupErr(p,
   170    171          "cannot start a read transaction on the source database: %s",
   171    172          sqlite3_errmsg(p->dbSrc));
   172    173       return;
          174  +  }
          175  +  rc = sqlite3_wal_checkpoint_v2(p->dbSrc, "main", SQLITE_CHECKPOINT_FULL,
          176  +                                 0, 0);
          177  +  if( rc ){
          178  +    scrubBackupErr(p, "cannot checkpoint the source database");
          179  +    return;
   173    180     }
   174    181     pStmt = scrubBackupPrepare(p, p->dbSrc, "PRAGMA page_size");
   175    182     if( pStmt==0 ) return;
   176    183     rc = sqlite3_step(pStmt);
   177    184     if( rc==SQLITE_ROW ){
   178    185       p->szPage = sqlite3_column_int(pStmt, 0);
   179    186     }else{