diff options
author | dan <dan@noemail.net> | 2011-10-21 14:27:32 +0000 |
---|---|---|
committer | dan <dan@noemail.net> | 2011-10-21 14:27:32 +0000 |
commit | 1a83bc5b1aa45ef2d2c31d2929a7d92b477eab9f (patch) | |
tree | 930079adf0024248af8b9fbbccca196011db4dfe /src | |
parent | d337c5bde89344df122e2853c7547aad39356757 (diff) | |
download | sqlite-1a83bc5b1aa45ef2d2c31d2929a7d92b477eab9f.tar.gz sqlite-1a83bc5b1aa45ef2d2c31d2929a7d92b477eab9f.zip |
If an error occurs while writing to the database file during a VACUUM, discard the contents of the in-memory cache. This is required as if the database is a zipvfs database, the contents of the cache may be inconsistent with respect to the database as stored on disk.
FossilOrigin-Name: 07159e84b40b01fa40cac5fad1f433888e5984f8
Diffstat (limited to 'src')
-rw-r--r-- | src/backup.c | 2 | ||||
-rw-r--r-- | src/pager.c | 7 | ||||
-rw-r--r-- | src/pager.h | 1 |
3 files changed, 10 insertions, 0 deletions
diff --git a/src/backup.c b/src/backup.c index 893a40e4d..bdf96bd8e 100644 --- a/src/backup.c +++ b/src/backup.c @@ -704,6 +704,8 @@ int sqlite3BtreeCopyFile(Btree *pTo, Btree *pFrom){ rc = sqlite3_backup_finish(&b); if( rc==SQLITE_OK ){ pTo->pBt->pageSizeFixed = 0; + }else{ + sqlite3PagerClearCache(sqlite3BtreePager(b.pDest)); } assert( sqlite3BtreeIsInTrans(pTo)==0 ); diff --git a/src/pager.c b/src/pager.c index 421a7094f..63dda3ddf 100644 --- a/src/pager.c +++ b/src/pager.c @@ -6836,6 +6836,13 @@ int sqlite3PagerCloseWal(Pager *pPager){ return rc; } +/* +** Unless this is an in-memory or temporary database, clear the pager cache. +*/ +void sqlite3PagerClearCache(Pager *pPager){ + if( !MEMDB && pPager->tempFile==0 ) pager_reset(pPager); +} + #ifdef SQLITE_HAS_CODEC /* ** This function is called by the wal module when writing page content diff --git a/src/pager.h b/src/pager.h index 540557248..e36e6c2e8 100644 --- a/src/pager.h +++ b/src/pager.h @@ -156,6 +156,7 @@ int sqlite3PagerNosync(Pager*); void *sqlite3PagerTempSpace(Pager*); int sqlite3PagerIsMemdb(Pager*); void sqlite3PagerCacheStat(Pager *, int, int, int *); +void sqlite3PagerClearCache(Pager *); /* Functions used to truncate the database file. */ void sqlite3PagerTruncateImage(Pager*,Pgno); |