aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordan <dan@noemail.net>2010-04-29 14:51:33 +0000
committerdan <dan@noemail.net>2010-04-29 14:51:33 +0000
commit31c03907fd41d9be65f74efaf38b69ae98cb8411 (patch)
tree6af8e6dbd21d9fb9bd557679ca7400efd48db348 /src
parentb4e3a6f72f38be188f5b13933306df2fd0f491b6 (diff)
downloadsqlite-31c03907fd41d9be65f74efaf38b69ae98cb8411.tar.gz
sqlite-31c03907fd41d9be65f74efaf38b69ae98cb8411.zip
Fix a but in the WAL checkpoint code causing SQLite to use an inconsistent cache in a subsequent transaction.
FossilOrigin-Name: d1cadeed4eea20d8892726cc8c69f4f3f57d0cd4
Diffstat (limited to 'src')
-rw-r--r--src/wal.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/wal.c b/src/wal.c
index c7478d0e8..8a8f4043d 100644
--- a/src/wal.c
+++ b/src/wal.c
@@ -1880,6 +1880,7 @@ int sqlite3WalCheckpoint(
void *pBusyHandlerArg /* Argument to pass to xBusyHandler */
){
int rc; /* Return code */
+ int isChanged = 0; /* True if a new wal-index header is loaded */
assert( !pLog->isLocked );
@@ -1899,10 +1900,19 @@ int sqlite3WalCheckpoint(
}
/* Copy data from the log to the database file. */
- rc = logSummaryReadHdr(pLog, 0);
+ rc = logSummaryReadHdr(pLog, &isChanged);
if( rc==SQLITE_OK ){
rc = logCheckpoint(pLog, pFd, sync_flags, zBuf);
}
+ if( isChanged ){
+ /* If a new wal-index header was loaded before the checkpoint was
+ ** performed, then the pager-cache associated with log pLog is now
+ ** out of date. So zero the cached wal-index header to ensure that
+ ** next time the pager opens a snapshot on this database it knows that
+ ** the cache needs to be reset.
+ */
+ memset(&pLog->hdr, 0, sizeof(LogSummaryHdr));
+ }
/* Release the locks. */
logLockRegion(pLog, LOG_REGION_A|LOG_REGION_B|LOG_REGION_C, LOG_UNLOCK);