/ Check-in [612e2599]
Login

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

Overview
Comment:On a backup from a smaller to a larger page size, do not begin committing the transaction until the source pages after the pending byte have been copied.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 612e2599d3e1a17c268402fce018a53dee6dffe1
User & Date: drh 2011-01-16 22:37:09
Context
2011-01-17
02:24
Add back an ALWAYS() to regain full test coverage. check-in: b93f6f3e user: drh tags: trunk
2011-01-16
22:37
On a backup from a smaller to a larger page size, do not begin committing the transaction until the source pages after the pending byte have been copied. check-in: 612e2599 user: drh tags: trunk
00:56
Make sure the change-counter and SQLite-version fields of the header are set correctly even when doing a VACUUM with locking_mode=EXCLUSIVE. Ticket [5d863f876ee9561b]. check-in: 04fa1e16 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/backup.c.

   437    437           **
   438    438           **   * Data stored on the pages immediately following the 
   439    439           **     pending-byte page in the source database may need to be
   440    440           **     copied into the destination database.
   441    441           */
   442    442           const i64 iSize = (i64)pgszSrc * (i64)nSrcPage;
   443    443           sqlite3_file * const pFile = sqlite3PagerFile(pDestPager);
          444  +        i64 iOff;
          445  +        i64 iEnd;
   444    446   
   445    447           assert( pFile );
   446    448           assert( (i64)nDestTruncate*(i64)pgszDest >= iSize || (
   447    449                 nDestTruncate==(int)(PENDING_BYTE_PAGE(p->pDest->pBt)-1)
   448    450              && iSize>=PENDING_BYTE && iSize<=PENDING_BYTE+pgszDest
   449    451           ));
   450         -        if( SQLITE_OK==(rc = sqlite3PagerCommitPhaseOne(pDestPager, 0, 1))
   451         -         && SQLITE_OK==(rc = backupTruncateFile(pFile, iSize))
   452         -         && SQLITE_OK==(rc = sqlite3PagerSync(pDestPager))
          452  +        iEnd = MIN(PENDING_BYTE + pgszDest, iSize);
          453  +        for(
          454  +          iOff=PENDING_BYTE+pgszSrc; 
          455  +          rc==SQLITE_OK && iOff<iEnd; 
          456  +          iOff+=pgszSrc
   453    457           ){
   454         -          i64 iOff;
   455         -          i64 iEnd = MIN(PENDING_BYTE + pgszDest, iSize);
   456         -          for(
   457         -            iOff=PENDING_BYTE+pgszSrc; 
   458         -            rc==SQLITE_OK && iOff<iEnd; 
   459         -            iOff+=pgszSrc
   460         -          ){
   461         -            PgHdr *pSrcPg = 0;
   462         -            const Pgno iSrcPg = (Pgno)((iOff/pgszSrc)+1);
   463         -            rc = sqlite3PagerGet(pSrcPager, iSrcPg, &pSrcPg);
   464         -            if( rc==SQLITE_OK ){
   465         -              u8 *zData = sqlite3PagerGetData(pSrcPg);
   466         -              rc = sqlite3OsWrite(pFile, zData, pgszSrc, iOff);
   467         -            }
   468         -            sqlite3PagerUnref(pSrcPg);
          458  +          PgHdr *pSrcPg = 0;
          459  +          const Pgno iSrcPg = (Pgno)((iOff/pgszSrc)+1);
          460  +          rc = sqlite3PagerGet(pSrcPager, iSrcPg, &pSrcPg);
          461  +          if( rc==SQLITE_OK ){
          462  +            u8 *zData = sqlite3PagerGetData(pSrcPg);
          463  +            rc = sqlite3OsWrite(pFile, zData, pgszSrc, iOff);
          464  +          }
          465  +          sqlite3PagerUnref(pSrcPg);
          466  +        }
          467  +        if( rc==SQLITE_OK ){
          468  +          rc = sqlite3PagerCommitPhaseOne(pDestPager, 0, 1);
          469  +          if( rc==SQLITE_OK ){
          470  +            rc = backupTruncateFile(pFile, iSize);
   469    471             }
   470    472           }
   471    473         }else{
   472    474           rc = sqlite3PagerCommitPhaseOne(pDestPager, 0, 0);
   473    475         }
   474    476     
   475    477         /* Finish committing the transaction to the destination database. */