aboutsummaryrefslogtreecommitdiff
path: root/src/pager.c
diff options
context:
space:
mode:
authordan <dan@noemail.net>2016-09-01 09:35:20 +0000
committerdan <dan@noemail.net>2016-09-01 09:35:20 +0000
commitd0d49b9ca3c106e972ca724c7202a81182f4260f (patch)
treed081a6737d8f46741ea5ba73ac5b86332697c535 /src/pager.c
parenta87070a2716fde5569db592c0cebfd7d3578f968 (diff)
downloadsqlite-d0d49b9ca3c106e972ca724c7202a81182f4260f.tar.gz
sqlite-d0d49b9ca3c106e972ca724c7202a81182f4260f.zip
If SQLITE_ENABLE_ZIPVFS is defined, journal_mode=off is configured and a savepoint or statement rollback is attempted, move the pager into the error state to prevent the transaction from being committed. This makes it safe to use journal_mode=off with zipvfs under some conditions.
FossilOrigin-Name: 38d31e189e7c7899e14455f2c083aa676ce4d4c0
Diffstat (limited to 'src/pager.c')
-rw-r--r--src/pager.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/pager.c b/src/pager.c
index cd8d1204b..dfa512b48 100644
--- a/src/pager.c
+++ b/src/pager.c
@@ -6656,7 +6656,11 @@ int sqlite3PagerOpenSavepoint(Pager *pPager, int nSavepoint){
** savepoint. If no errors occur, SQLITE_OK is returned.
*/
int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint){
- int rc = pPager->errCode; /* Return code */
+ int rc = pPager->errCode;
+
+#ifdef SQLITE_ENABLE_ZIPVFS
+ if( op==SAVEPOINT_RELEASE ) rc = SQLITE_OK;
+#endif
assert( op==SAVEPOINT_RELEASE || op==SAVEPOINT_ROLLBACK );
assert( iSavepoint>=0 || op==SAVEPOINT_ROLLBACK );
@@ -6697,6 +6701,20 @@ int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint){
rc = pagerPlaybackSavepoint(pPager, pSavepoint);
assert(rc!=SQLITE_DONE);
}
+
+#ifdef SQLITE_ENABLE_ZIPVFS
+ /* If the cache has been modified but the savepoint cannot be rolled
+ ** back journal_mode=off, put the pager in the error state. This way,
+ ** if the VFS used by this pager includes ZipVFS, the entire transaction
+ ** can be rolled back at the ZipVFS level. */
+ else if(
+ pPager->journalMode==PAGER_JOURNALMODE_OFF
+ && pPager->eState>=PAGER_WRITER_CACHEMOD
+ ){
+ pPager->errCode = SQLITE_ABORT;
+ pPager->eState = PAGER_ERROR;
+ }
+#endif
}
return rc;