diff options
author | dan <dan@noemail.net> | 2013-02-25 13:31:30 +0000 |
---|---|---|
committer | dan <dan@noemail.net> | 2013-02-25 13:31:30 +0000 |
commit | f2874b0e1db874502a8b772bdd20101ffa3847e7 (patch) | |
tree | 7a76f342ea9c1979ee4f005554755548935f6a74 /src/backup.c | |
parent | d5d0f6432ce1cf89327a35d4fb7566176a58193d (diff) | |
parent | 295fc442b50042644870cfd41d99619512eb2172 (diff) | |
download | sqlite-f2874b0e1db874502a8b772bdd20101ffa3847e7.tar.gz sqlite-f2874b0e1db874502a8b772bdd20101ffa3847e7.zip |
Merge the incr-vacuum-opt branch with the trunk.
FossilOrigin-Name: 26e235b7a4cd4d0dc9725774d70174c4d369cb98
Diffstat (limited to 'src/backup.c')
-rw-r--r-- | src/backup.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/backup.c b/src/backup.c index d3614b88c..71a8a1a3e 100644 --- a/src/backup.c +++ b/src/backup.c @@ -462,7 +462,6 @@ int sqlite3_backup_step(sqlite3_backup *p, int nPage){ nDestTruncate = nSrcPage * (pgszSrc/pgszDest); } assert( nDestTruncate>0 ); - sqlite3PagerTruncateImage(pDestPager, nDestTruncate); if( pgszSrc<pgszDest ){ /* If the source page-size is smaller than the destination page-size, @@ -476,6 +475,8 @@ int sqlite3_backup_step(sqlite3_backup *p, int nPage){ */ const i64 iSize = (i64)pgszSrc * (i64)nSrcPage; sqlite3_file * const pFile = sqlite3PagerFile(pDestPager); + Pgno iPg; + int nDstPage; i64 iOff; i64 iEnd; @@ -486,13 +487,26 @@ int sqlite3_backup_step(sqlite3_backup *p, int nPage){ && iSize>=PENDING_BYTE && iSize<=PENDING_BYTE+pgszDest )); - /* This call ensures that all data required to recreate the original + /* This block ensures that all data required to recreate the original ** database has been stored in the journal for pDestPager and the ** journal synced to disk. So at this point we may safely modify ** the database file in any way, knowing that if a power failure ** occurs, the original database will be reconstructed from the ** journal file. */ - rc = sqlite3PagerCommitPhaseOne(pDestPager, 0, 1); + sqlite3PagerPagecount(pDestPager, &nDstPage); + for(iPg=nDestTruncate; rc==SQLITE_OK && iPg<=(Pgno)nDstPage; iPg++){ + if( iPg!=PENDING_BYTE_PAGE(p->pDest->pBt) ){ + DbPage *pPg; + rc = sqlite3PagerGet(pDestPager, iPg, &pPg); + if( rc==SQLITE_OK ){ + rc = sqlite3PagerWrite(pPg); + sqlite3PagerUnref(pPg); + } + } + } + if( rc==SQLITE_OK ){ + rc = sqlite3PagerCommitPhaseOne(pDestPager, 0, 1); + } /* Write the extra pages and truncate the database file as required */ iEnd = MIN(PENDING_BYTE + pgszDest, iSize); @@ -519,6 +533,7 @@ int sqlite3_backup_step(sqlite3_backup *p, int nPage){ rc = sqlite3PagerSync(pDestPager); } }else{ + sqlite3PagerTruncateImage(pDestPager, nDestTruncate); rc = sqlite3PagerCommitPhaseOne(pDestPager, 0, 0); } |