1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-05 15:55:57 +03:00

Fix a bug whereby an old snapshot could be checkpointed (and subsequent transactions discarded) if the last connection to disconnect from a WAL database happended to be holding an out-of-date wal-index header.

FossilOrigin-Name: d0c0034b0baa83046c1d6b94c886f7039e4e06f5
This commit is contained in:
dan
2010-05-06 17:28:08 +00:00
parent 6e5b37faef
commit b7d53f54ae
4 changed files with 82 additions and 20 deletions

View File

@@ -370,6 +370,19 @@ static int walIndexEntry(u32 iFrame){
);
}
/*
** Return the minimum mapping size in bytes that can be used to read the
** wal-index up to and including frame iFrame. If iFrame is the last frame
** in a block of 256 frames, the returned byte-count includes the space
** required by the 256-byte index block.
*/
static int walMappingSize(u32 iFrame){
return ( WALINDEX_LOCK_OFFSET + WALINDEX_LOCK_RESERVED
+ iFrame*sizeof(u32)
+ (iFrame>>8)*256
);
}
/*
** Release our reference to the wal-index memory map, if we are holding
** it.
@@ -835,7 +848,7 @@ int sqlite3WalClose(
*/
rc = sqlite3OsLock(pFd, SQLITE_LOCK_EXCLUSIVE);
if( rc==SQLITE_OK ){
rc = walCheckpoint(pWal, pFd, sync_flags, nBuf, zBuf);
rc = sqlite3WalCheckpoint(pWal, pFd, sync_flags, nBuf, zBuf, 0, 0);
if( rc==SQLITE_OK ){
isDelete = 1;
}