diff --git a/manifest b/manifest index 5a2fb1eb3e..0d1905e7e0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\sall\sthe\slatest\strunk/wal2\senhancements\sand\sfixes\sinto\sthe\sbedrock\sbranch. -D 2024-12-16T13:38:33.681 +C Merge\sdivergence-reduction\schanges\sinto\sthe\sbedrock\sbranch. +D 2024-12-16T18:29:31.774 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md e108e1e69ae8e8a59e93c455654b8ac9356a11720d3345df2a4743e9590fb20d @@ -854,7 +854,7 @@ F src/upsert.c 215328c3f91623c520ec8672c44323553f12caeb4f01b1090ebdca99fdf7b4f1 F src/utf.c 8b29d9a5956569ea2700f869669b8ef67a9662ee5e724ff77ab3c387e27094ba F src/util.c e5f6a5eeaa26b69054a43bbd0048cfe3d2851f6961052b35aed8f695df922850 F src/vacuum.c 25e407a6dc8b288fa4295b3d92fa9ce9318503e84df53cdf403a50fccbc1ba31 -F src/vdbe.c 310284edd21f8471f945038a8fce25da0e025b568ebde5c16b11b32a956641e0 +F src/vdbe.c f567c19f5029f3e221931ced6436c718a1609d2de7fb158de57eac1a0f1e61ce F src/vdbe.h 9676348d342bd04e21e384c63b57224171ce84fac77853357334ef94c4d33cf4 F src/vdbeInt.h bf294a0c8fc4cc80779e74b04b8bd82c6e1197b3137cefe0b16cdf002fc7dfd6 F src/vdbeapi.c 38c252a202d70b56cfb734460bc888ddbd581afec1a10cd4d6c894c9e0b5baea @@ -866,7 +866,7 @@ F src/vdbetrace.c fe0bc29ebd4e02c8bc5c1945f1d2e6be5927ec12c06d89b03ef2a4def34bf8 F src/vdbevtab.c fc46b9cbd759dc013f0b3724549cc0d71379183c667df3a5988f7e2f1bd485f3 F src/vtab.c 316cd48e9320660db3047cd306cd056e4361180cebb4d0f10a39244e10c11422 F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9 -F src/wal.c 3dfcce08758eec841bab07320c2b4e495c1c0621c2fd6327b3c3b19f52da48b6 +F src/wal.c 964c785ac8324de1ae742c44aa72ddd4401d4abab11ef6999aec21d7221b3e67 F src/wal.h 8d02ab8c2a93a941f5898eb3345bf711c1d3f8f86f4be8d5428fb6c074962d8a F src/walker.c d5006d6b005e4ea7302ad390957a8d41ed83faa177e412f89bc5600a7462a014 F src/where.c 9ad3dea8003a8913da6a4ca8322e2fe30773f46e88a0d4fbf9db13bdb999efa2 @@ -2239,8 +2239,8 @@ F tool/version-info.c 3b36468a90faf1bbd59c65fd0eb66522d9f941eedd364fabccd7227350 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh 49a486c5069de041aedcbde4de178293e0463ae9918ecad7539eedf0ec77a139 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P eb8449ea9ac8e29425f7127535a1db328d56c86382919fb1fcf42324b71de013 eab619453abf6979962a68d298c44553ef0d9eb18112e61420d4de8a9c16f620 -R 0be70ab68e68f62d1526e079bfae1838 +P a0cf2621c4586ddfa43ec5a2a6469ddb8528adff78a80063be007cf76cf8d98a caadbe0c0c3dee411140df7d13f6e8275f9c13562bb384be38520ee2305c32bd +R 69e1b203e08eb71e1b73ec7264118057 U drh -Z 5899f9e916b0dbf68fc97b35b2f61daf +Z a1145c781041a58de3461e5eb972096e # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 74e8550b33..1b7f0dc3cb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a0cf2621c4586ddfa43ec5a2a6469ddb8528adff78a80063be007cf76cf8d98a +ec5d7025cba9f4acaea984d5ec29b05b7f4b01f0e36e5287f27a16895ec42bf7 diff --git a/src/vdbe.c b/src/vdbe.c index 39caa0967d..2cccf71090 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -7995,34 +7995,34 @@ case OP_JournalMode: { /* out2 */ (eNew==PAGER_JOURNALMODE_WAL ? "into" : "out of") ); goto abort_due_to_error; - } - - if( isWalMode(eOld) ){ - /* If leaving WAL mode, close the log file. If successful, the call - ** to PagerCloseWal() checkpoints and deletes the write-ahead-log - ** file. An EXCLUSIVE lock may still be held on the database file - ** after a successful return. - */ - rc = sqlite3PagerCloseWal(pPager, db); - if( rc==SQLITE_OK ){ - sqlite3PagerSetJournalMode(pPager, eNew); + }else{ + + if( isWalMode(eOld) ){ + /* If leaving WAL mode, close the log file. If successful, the call + ** to PagerCloseWal() checkpoints and deletes the write-ahead-log + ** file. An EXCLUSIVE lock may still be held on the database file + ** after a successful return. + */ + rc = sqlite3PagerCloseWal(pPager, db); + if( rc==SQLITE_OK ){ + sqlite3PagerSetJournalMode(pPager, eNew); + } + }else if( eOld==PAGER_JOURNALMODE_MEMORY ){ + /* Cannot transition directly from MEMORY to WAL. Use mode OFF + ** as an intermediate */ + sqlite3PagerSetJournalMode(pPager, PAGER_JOURNALMODE_OFF); + } + + /* Open a transaction on the database file. Regardless of the journal + ** mode, this transaction always uses a rollback journal. + */ + assert( sqlite3BtreeTxnState(pBt)!=SQLITE_TXN_WRITE ); + if( rc==SQLITE_OK ){ + /* 1==rollback, 2==wal, 3==wal2 */ + rc = sqlite3BtreeSetVersion(pBt, + 1 + isWalMode(eNew) + (eNew==PAGER_JOURNALMODE_WAL2) + ); } - }else if( eOld==PAGER_JOURNALMODE_MEMORY ){ - /* Cannot transition directly from MEMORY to WAL. Use mode OFF - ** as an intermediate */ - sqlite3PagerSetJournalMode(pPager, PAGER_JOURNALMODE_OFF); - } - - /* Open a transaction on the database file. Regardless of the journal - ** mode, this transaction always uses a rollback journal. - */ - assert( sqlite3BtreeTxnState(pBt)!=SQLITE_TXN_WRITE ); - if( rc==SQLITE_OK ){ - /* 1==rollback, 2==wal, 3==wal2 */ - rc = sqlite3BtreeSetVersion(pBt, - 1 + isWalMode(eNew) + (eNew==PAGER_JOURNALMODE_WAL2) - ); - } } #endif /* ifndef SQLITE_OMIT_WAL */ diff --git a/src/wal.c b/src/wal.c index 1f2db82f05..fc0a24510f 100644 --- a/src/wal.c +++ b/src/wal.c @@ -884,7 +884,6 @@ struct WalIterator { sizeof(ht_slot)*HASHTABLE_NSLOT + HASHTABLE_NPAGE*sizeof(u32) \ ) - /* ** Structured Exception Handling (SEH) is a Windows-specific technique ** for catching exceptions raised while accessing memory-mapped files. @@ -991,6 +990,7 @@ static void sehInjectFault(Wal *pWal){ # define SEH_SET_ON_ERROR(X,Y) #endif /* ifdef SQLITE_USE_SEH */ + /* ** Obtain a pointer to the iPage'th page of the wal-index. The wal-index ** is broken into pages of WALINDEX_PGSZ bytes. Wal-index pages are @@ -3759,15 +3759,16 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int *pCnt){ pWal->readLock = eLock; } assert( pWal->minFrame==0 && walFramePage(pWal->minFrame)==0 ); - }else{ + }else + { u32 mxReadMark; /* Largest aReadMark[] value */ int mxI; /* Index of largest aReadMark[] value */ int i; /* Loop counter */ u32 mxFrame; /* Wal frame to lock to */ if( !useWal && pInfo->nBackfill==pWal->hdr.mxFrame - #ifdef SQLITE_ENABLE_SNAPSHOT +#ifdef SQLITE_ENABLE_SNAPSHOT && ((pWal->bGetSnapshot==0 && pWal->pSnapshot==0) || pWal->hdr.mxFrame==0) - #endif +#endif ){ /* The WAL has been completely backfilled (or it is empty). ** and can be safely ignored. @@ -3783,7 +3784,7 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int *pCnt){ ** snapshot. Since holding READ_LOCK(0) prevents a checkpoint from ** happening, this is usually correct. ** - ** However, if frames have been appended to the log (or if the log + ** However, if frames have been appended to the log (or if the log ** is wrapped and written for that matter) before the READ_LOCK(0) ** is obtained, that is not necessarily true. A checkpointer may ** have started to backfill the appended frames but crashed before @@ -3807,11 +3808,11 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int *pCnt){ mxReadMark = 0; mxI = 0; mxFrame = pWal->hdr.mxFrame; - #ifdef SQLITE_ENABLE_SNAPSHOT +#ifdef SQLITE_ENABLE_SNAPSHOT if( pWal->pSnapshot && pWal->pSnapshot->mxFramepSnapshot->mxFrame; } - #endif +#endif for(i=1; iaReadMark+i); SEH_INJECT_FAULT; if( mxReadMark<=thisMark && thisMark<=mxFrame ){ @@ -3854,7 +3855,6 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int *pCnt){ #endif assert((rc&0xFF)!=SQLITE_BUSY||rc==SQLITE_BUSY||rc==SQLITE_BUSY_TIMEOUT); return (rc&0xFF)==SQLITE_BUSY ? WAL_RETRY : rc; - } /* Now that the read-lock has been obtained, check that neither the ** value in the aReadMark[] array or the contents of the wal-index @@ -3876,9 +3876,9 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int *pCnt){ ** to read any frames earlier than minFrame from the wal file - they ** can be safely read directly from the database file. ** - ** Because a ShmBarrier() call is made between taking the copy of + ** Because a ShmBarrier() call is made between taking the copy of ** nBackfill and checking that the wal-header in shared-memory still - ** matches the one cached in pWal->hdr, it is guaranteed that the + ** matches the one cached in pWal->hdr, it is guaranteed that the ** checkpointer that set nBackfill was not working with a wal-index ** header newer than that cached in pWal->hdr. If it were, that could ** cause a problem. The checkpointer could omit to checkpoint @@ -4151,7 +4151,6 @@ int sqlite3WalBeginReadTransaction(Wal *pWal, int *pChanged){ return rc; } - /* ** Finish with a read transaction. All this does is release the ** read-lock. @@ -4693,7 +4692,6 @@ static int walLockForCommit( } } } - pWal->nPriorFrame = walGetPriorFrame(&pWal->hdr); return rc; } @@ -5039,7 +5037,6 @@ static int walRestartLog(Wal *pWal){ ** to the wal file. */ rc = walUpgradeReadlock(pWal); } - pWal->nPriorFrame = walGetPriorFrame(&pWal->hdr); return rc; } @@ -5440,7 +5437,6 @@ static int walFrames( return rc; } - /* ** Write a set of frames to the log. The caller must hold the write-lock ** on the log file (obtained using sqlite3WalBeginWriteTransaction()). @@ -5566,7 +5562,7 @@ int sqlite3WalCheckpoint( }else{ rc = walCheckpoint(pWal, db, eMode2, xBusy2, pBusyArg, sync_flags,zBuf); } - + /* If no error occurred, set the output variables. */ if( rc==SQLITE_OK || rc==SQLITE_BUSY ){ if( pnLog ){ @@ -5660,7 +5656,6 @@ int sqlite3WalCallback(Wal *pWal){ */ int sqlite3WalExclusiveMode(Wal *pWal, int op){ int rc; - assert( pWal->writeLock==0 ); assert( pWal->exclusiveMode!=WAL_HEAPMEMORY_MODE || op==-1 ); @@ -5723,7 +5718,7 @@ int sqlite3WalSnapshotGet(Wal *pWal, sqlite3_snapshot **ppSnapshot){ assert( pWal->readLock>=0 && pWal->writeLock==0 ); - if( memcmp(&pWal->hdr.aFrameCksum[0],aZero,8)==0 ){ + if( memcmp(&pWal->hdr.aFrameCksum[0],aZero,16)==0 ){ *ppSnapshot = 0; return SQLITE_ERROR; } @@ -5806,7 +5801,7 @@ int sqlite3WalSnapshotCheck(Wal *pWal, sqlite3_snapshot *pSnapshot){ } } } - SEH_EXCEPT( rc = walHandleException(pWal) ); + SEH_EXCEPT( rc = walHandleException(pWal); ) return rc; }