/ Check-in [2a897b9e]
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:Avoid create a stack from in sqlite3BackupUpdate() in the common case where the first argument is NULL.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 2a897b9e94acaf1fd91e9f8e94fa52e01694f011
User & Date: drh 2015-07-01 19:59:36
Context
2015-07-02
01:38
Add the --shrink-memory option to the speedtest1 test program. check-in: c9ddbd88 user: drh tags: trunk
2015-07-01
19:59
Avoid create a stack from in sqlite3BackupUpdate() in the common case where the first argument is NULL. check-in: 2a897b9e user: drh tags: trunk
17:53
Simplification of PRAGMA integrity_check logic. Make sure that the depth of the right-most subtree is correct. Size reduction and performance increase, with no change in output. check-in: 550705fc user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/backup.c.

   681    681   ** to be updated with the new data before the backup operation is
   682    682   ** complete.
   683    683   **
   684    684   ** It is assumed that the mutex associated with the BtShared object
   685    685   ** corresponding to the source database is held when this function is
   686    686   ** called.
   687    687   */
   688         -void sqlite3BackupUpdate(sqlite3_backup *pBackup, Pgno iPage, const u8 *aData){
   689         -  sqlite3_backup *p;                   /* Iterator variable */
   690         -  for(p=pBackup; p; p=p->pNext){
          688  +static SQLITE_NOINLINE void backupUpdate(
          689  +  sqlite3_backup *p,
          690  +  Pgno iPage,
          691  +  const u8 *aData
          692  +){
          693  +  assert( p!=0 );
          694  +  do{
   691    695       assert( sqlite3_mutex_held(p->pSrc->pBt->mutex) );
   692    696       if( !isFatalError(p->rc) && iPage<p->iNext ){
   693    697         /* The backup process p has already copied page iPage. But now it
   694    698         ** has been modified by a transaction on the source pager. Copy
   695    699         ** the new data into the backup.
   696    700         */
   697    701         int rc;
................................................................................
   700    704         rc = backupOnePage(p, iPage, aData, 1);
   701    705         sqlite3_mutex_leave(p->pDestDb->mutex);
   702    706         assert( rc!=SQLITE_BUSY && rc!=SQLITE_LOCKED );
   703    707         if( rc!=SQLITE_OK ){
   704    708           p->rc = rc;
   705    709         }
   706    710       }
   707         -  }
          711  +  }while( (p = p->pNext)!=0 );
          712  +}
          713  +void sqlite3BackupUpdate(sqlite3_backup *pBackup, Pgno iPage, const u8 *aData){
          714  +  if( pBackup ) backupUpdate(pBackup, iPage, aData);
   708    715   }
   709    716   
   710    717   /*
   711    718   ** Restart the backup process. This is called when the pager layer
   712    719   ** detects that the database has been modified by an external database
   713    720   ** connection. In this case there is no way of knowing which of the
   714    721   ** pages that have been copied into the destination database are still