aboutsummaryrefslogtreecommitdiff
path: root/src/backup.c
diff options
context:
space:
mode:
authordan <dan@noemail.net>2011-01-25 18:19:24 +0000
committerdan <dan@noemail.net>2011-01-25 18:19:24 +0000
commit4d26d585d6167c933bfc596e1cece107cb639871 (patch)
treee1548bfe818c44e167d332551327449a02b6b437 /src/backup.c
parent534a58a76d22f39d88fa94ee0f80ad9a64038a0a (diff)
downloadsqlite-4d26d585d6167c933bfc596e1cece107cb639871.tar.gz
sqlite-4d26d585d6167c933bfc596e1cece107cb639871.zip
Add a missing call to sqlite3PagerSync() removed by [ce552d975] to the backup code.
FossilOrigin-Name: 1965b85318c1fac62fae9691059021b298c17dde
Diffstat (limited to 'src/backup.c')
-rw-r--r--src/backup.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/backup.c b/src/backup.c
index 7258b26aa..5d8ea7f3f 100644
--- a/src/backup.c
+++ b/src/backup.c
@@ -449,6 +449,16 @@ int sqlite3_backup_step(sqlite3_backup *p, int nPage){
nDestTruncate==(int)(PENDING_BYTE_PAGE(p->pDest->pBt)-1)
&& iSize>=PENDING_BYTE && iSize<=PENDING_BYTE+pgszDest
));
+
+ /* This call 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);
+
+ /* Write the extra pages and truncate the database file as required. */
iEnd = MIN(PENDING_BYTE + pgszDest, iSize);
for(
iOff=PENDING_BYTE+pgszSrc;
@@ -465,10 +475,12 @@ int sqlite3_backup_step(sqlite3_backup *p, int nPage){
sqlite3PagerUnref(pSrcPg);
}
if( rc==SQLITE_OK ){
- rc = sqlite3PagerCommitPhaseOne(pDestPager, 0, 1);
- if( rc==SQLITE_OK ){
- rc = backupTruncateFile(pFile, iSize);
- }
+ rc = backupTruncateFile(pFile, iSize);
+ }
+
+ /* Sync the database file to disk. */
+ if( rc==SQLITE_OK ){
+ rc = sqlite3PagerSync(pDestPager);
}
}else{
rc = sqlite3PagerCommitPhaseOne(pDestPager, 0, 0);