SQLite

Check-in [612e2599d3]
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
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 612e2599d3e1a17c268402fce018a53dee6dffe1
User & Date: drh 2011-01-16 22:37:09.511
Context
2011-01-17
02:24
Add back an ALWAYS() to regain full test coverage. (check-in: b93f6f3e67 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: 612e2599d3 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: 04fa1e1690 user: drh tags: trunk)
Changes
Side-by-Side Diff Ignore Whitespace Patch
Changes to src/backup.c.
437
438
439
440
441
442
443


444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468



















469
470
471
472
473
474
475
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451



















452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477







+
+






-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







        **
        **   * Data stored on the pages immediately following the 
        **     pending-byte page in the source database may need to be
        **     copied into the destination database.
        */
        const i64 iSize = (i64)pgszSrc * (i64)nSrcPage;
        sqlite3_file * const pFile = sqlite3PagerFile(pDestPager);
        i64 iOff;
        i64 iEnd;

        assert( pFile );
        assert( (i64)nDestTruncate*(i64)pgszDest >= iSize || (
              nDestTruncate==(int)(PENDING_BYTE_PAGE(p->pDest->pBt)-1)
           && iSize>=PENDING_BYTE && iSize<=PENDING_BYTE+pgszDest
        ));
        if( SQLITE_OK==(rc = sqlite3PagerCommitPhaseOne(pDestPager, 0, 1))
         && SQLITE_OK==(rc = backupTruncateFile(pFile, iSize))
         && SQLITE_OK==(rc = sqlite3PagerSync(pDestPager))
        ){
          i64 iOff;
          i64 iEnd = MIN(PENDING_BYTE + pgszDest, iSize);
          for(
            iOff=PENDING_BYTE+pgszSrc; 
            rc==SQLITE_OK && iOff<iEnd; 
            iOff+=pgszSrc
          ){
            PgHdr *pSrcPg = 0;
            const Pgno iSrcPg = (Pgno)((iOff/pgszSrc)+1);
            rc = sqlite3PagerGet(pSrcPager, iSrcPg, &pSrcPg);
            if( rc==SQLITE_OK ){
              u8 *zData = sqlite3PagerGetData(pSrcPg);
              rc = sqlite3OsWrite(pFile, zData, pgszSrc, iOff);
            }
            sqlite3PagerUnref(pSrcPg);
        iEnd = MIN(PENDING_BYTE + pgszDest, iSize);
        for(
          iOff=PENDING_BYTE+pgszSrc; 
          rc==SQLITE_OK && iOff<iEnd; 
          iOff+=pgszSrc
        ){
          PgHdr *pSrcPg = 0;
          const Pgno iSrcPg = (Pgno)((iOff/pgszSrc)+1);
          rc = sqlite3PagerGet(pSrcPager, iSrcPg, &pSrcPg);
          if( rc==SQLITE_OK ){
            u8 *zData = sqlite3PagerGetData(pSrcPg);
            rc = sqlite3OsWrite(pFile, zData, pgszSrc, iOff);
          }
          sqlite3PagerUnref(pSrcPg);
        }
        if( rc==SQLITE_OK ){
          rc = sqlite3PagerCommitPhaseOne(pDestPager, 0, 1);
          if( rc==SQLITE_OK ){
            rc = backupTruncateFile(pFile, iSize);
          }
        }
      }else{
        rc = sqlite3PagerCommitPhaseOne(pDestPager, 0, 0);
      }
  
      /* Finish committing the transaction to the destination database. */