aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordan <dan@noemail.net>2010-06-02 18:59:03 +0000
committerdan <dan@noemail.net>2010-06-02 18:59:03 +0000
commit6e6bd5658f1fa8ab3780a309b42acab4de00e7d9 (patch)
tree52f0cf34970165226726328bb1707a0408269b8e /src
parent10ec894c3a07e21c164e5589324165eba01ea1bd (diff)
downloadsqlite-6e6bd5658f1fa8ab3780a309b42acab4de00e7d9.tar.gz
sqlite-6e6bd5658f1fa8ab3780a309b42acab4de00e7d9.zip
Fix a problem with rolling back to a savepoint opened before the writer decided to wrap the log file.
FossilOrigin-Name: 6b4aed6aae7dc9e92807d27375cbe1e83c15841b
Diffstat (limited to 'src')
-rw-r--r--src/wal.c16
-rw-r--r--src/wal.h2
2 files changed, 15 insertions, 3 deletions
diff --git a/src/wal.c b/src/wal.c
index 807622774..bc2d6ff46 100644
--- a/src/wal.c
+++ b/src/wal.c
@@ -2110,6 +2110,7 @@ void sqlite3WalSavepoint(Wal *pWal, u32 *aWalData){
aWalData[0] = pWal->hdr.mxFrame;
aWalData[1] = pWal->hdr.aFrameCksum[0];
aWalData[2] = pWal->hdr.aFrameCksum[1];
+ aWalData[3] = pWal->nCkpt;
}
/*
@@ -2120,9 +2121,19 @@ void sqlite3WalSavepoint(Wal *pWal, u32 *aWalData){
*/
int sqlite3WalSavepointUndo(Wal *pWal, u32 *aWalData){
int rc = SQLITE_OK;
+
assert( pWal->writeLock );
+ assert( aWalData[3]!=pWal->nCkpt || aWalData[0]<=pWal->hdr.mxFrame );
+
+ if( aWalData[3]!=pWal->nCkpt ){
+ /* This savepoint was opened immediately after the write-transaction
+ ** was started. Right after that, the writer decided to wrap around
+ ** to the start of the log. Update the savepoint values to match.
+ */
+ aWalData[0] = 0;
+ aWalData[3] = pWal->nCkpt;
+ }
- assert( aWalData[0]<=pWal->hdr.mxFrame );
if( aWalData[0]<pWal->hdr.mxFrame ){
rc = walIndexMap(pWal, walMappingSize(pWal->hdr.mxFrame));
pWal->hdr.mxFrame = aWalData[0];
@@ -2130,9 +2141,10 @@ int sqlite3WalSavepointUndo(Wal *pWal, u32 *aWalData){
pWal->hdr.aFrameCksum[1] = aWalData[2];
if( rc==SQLITE_OK ){
walCleanupHash(pWal);
- walIndexUnmap(pWal);
}
}
+
+ walIndexUnmap(pWal);
return rc;
}
diff --git a/src/wal.h b/src/wal.h
index 32aade1d0..34710a408 100644
--- a/src/wal.h
+++ b/src/wal.h
@@ -36,7 +36,7 @@
# define sqlite3WalCallback(z) 0
#else
-#define WAL_SAVEPOINT_NDATA 3
+#define WAL_SAVEPOINT_NDATA 4
/* Connection to a write-ahead log (WAL) file.
** There is one object of this type for each pager.