From: drh Date: Fri, 16 Dec 2011 15:38:52 +0000 (+0000) Subject: Merge the fix for [a1fa75cbdd02] from the experimental branch. Also X-Git-Tag: mountain-lion~8^2~35 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=eed42505986947580d15bd130d7c83110c4c0b33;p=thirdparty%2Fsqlite.git Merge the fix for [a1fa75cbdd02] from the experimental branch. Also fix the persistent-wal mode feature of truncating the WAL on close so that it always truncates the WAL to zero bytes. FossilOrigin-Name: 09ccc4a1be7ba81890f10aac6623dd90dab4f990 --- eed42505986947580d15bd130d7c83110c4c0b33 diff --cc manifest index cbedf29e4b,61d5f87ce3..66736fbb73 --- a/manifest +++ b/manifest @@@ -1,5 -1,5 +1,5 @@@ - C Improved\slogging\sof\smaster-journal\sname\sconflicts. - D 2011-12-16T15:11:39.468 -C Experimental\sfix\sfor\s[a1fa75cbdd]. -D 2011-12-16T13:24:27.257 ++C Merge\sthe\sfix\sfor\s[a1fa75cbdd02]\sfrom\sthe\sexperimental\sbranch.\s\sAlso\nfix\sthe\spersistent-wal\smode\sfeature\sof\struncating\sthe\sWAL\son\sclose\sso\sthat\nit\salways\struncates\sthe\sWAL\sto\szero\sbytes. ++D 2011-12-16T15:38:52.854 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5b4a3e12a850b021547e43daf886b25133b44c07 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@@ -250,7 -250,7 +250,7 @@@ F src/vdbemem.c 2fc78b3e0fabcc1eaa23cd7 F src/vdbesort.c 468d43c057063e54da4f1988b38b4f46d60e7790 F src/vdbetrace.c d6e50e04e1ec498150e519058f617d91b8f5c843 F src/vtab.c e9318d88feac85be8e27ee783ac8f5397933fc8a - F src/wal.c 7e6e7fe68ee649505dca38c8ab83eda0d0d96ae5 -F src/wal.c dc5c0606db24a1c6b982de212bfbf6e56ac1c01c ++F src/wal.c 8575f2bdaed48e7ffbea8608b614bb7abd382a54 F src/wal.h 66b40bd91bc29a5be1c88ddd1f5ade8f3f48728a F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f F src/where.c af623942514571895818b9b7ae11db95ae3b3d88 @@@ -918,7 -919,7 +919,7 @@@ F test/walfault.test efb0d5724893133e71 F test/walhook.test ed00a40ba7255da22d6b66433ab61fab16a63483 F test/walmode.test 4022fe03ae6e830583672caa101f046438a0473c F test/walnoshm.test 84ca10c544632a756467336b7c3b864d493ee496 --F test/walpersist.test 710b1b6cf6f8333e984f437724d1fa9e0511c5aa ++F test/walpersist.test 4d308b7f16470e85cb389636e59c455fe6b3a61a F test/walro.test e6bb27762c9f22601cbb8bff6e0acfd124e74b63 F test/walshared.test 6dda2293880c300baf5d791c307f653094585761 F test/walslow.test e7be6d9888f83aa5d3d3c7c08aa9b5c28b93609a @@@ -983,7 -984,10 +984,7 @@@ F tool/tostr.awk e75472c2f98dd76e06b8c9 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 - P cf3bccc2e944cd2dd3efb8554682994a06115f16 - R 9cdd098939326e460c36a0ff01e82e7f -P 322bd15f97143d39b3a88d5f6cf7afb454e0666e -R c026e9599d51ae1a18c03cd1d5a83b3e -T *branch * experimental -T *sym-experimental * -T -sym-trunk * -U dan -Z 172fee4764ec1b8014a478816f19a037 ++P b1005ef46cc2b46dd8e448ae1a9a9508bd5666ab 6492af76ea6585a1b377d69751af930c0ccfe688 ++R 5e90bbe7156facb03e2de52b2217bc8c +U drh - Z f579d2bc7a13e23fcc9e8ceaf02a267f ++Z 290df3a9d2eb83a09d72442af4b2f315 diff --cc manifest.uuid index b02a3e69b1,3218c8eac2..689e39e8ad --- a/manifest.uuid +++ b/manifest.uuid @@@ -1,1 -1,1 +1,1 @@@ - b1005ef46cc2b46dd8e448ae1a9a9508bd5666ab -6492af76ea6585a1b377d69751af930c0ccfe688 ++09ccc4a1be7ba81890f10aac6623dd90dab4f990 diff --cc src/wal.c index 209c909752,e3f9cd1149..0fae6cbc74 --- a/src/wal.c +++ b/src/wal.c @@@ -1824,18 -1823,18 +1823,29 @@@ int sqlite3WalClose */ rc = sqlite3OsLock(pWal->pDbFd, SQLITE_LOCK_EXCLUSIVE); if( rc==SQLITE_OK ){ -- int bPersistWal = -1; if( pWal->exclusiveMode==WAL_NORMAL_MODE ){ pWal->exclusiveMode = WAL_EXCLUSIVE_MODE; } rc = sqlite3WalCheckpoint( pWal, SQLITE_CHECKPOINT_PASSIVE, 0, 0, sync_flags, nBuf, zBuf, 0, 0 ); -- sqlite3OsFileControl(pWal->pDbFd, SQLITE_FCNTL_PERSIST_WAL, &bPersistWal); -- if( rc==SQLITE_OK && bPersistWal!=1 ){ -- isDelete = 1; - }else{ - walLimitSize(pWal); - }else if( pWal->mxWalSize>=0 ){ - walLimitSize(pWal, pWal->mxWalSize); ++ if( rc==SQLITE_OK ){ ++ int bPersist = -1; ++ sqlite3OsFileControl(pWal->pDbFd, SQLITE_FCNTL_PERSIST_WAL, &bPersist); ++ if( bPersist!=1 ){ ++ /* Try to delete the WAL file if the checkpoint completed and ++ ** fsyned (rc==SQLITE_OK) and if we are not in persistent-wal ++ ** mode (!bPersist) */ ++ isDelete = 1; ++ }else if( pWal->mxWalSize>=0 ){ ++ /* Try to truncate the WAL file to zero bytes if the checkpoint ++ ** completed and fsynced (rc==SQLITE_OK) and we are in persistent ++ ** WAL mode (bPersist) and if the PRAGMA journal_size_limit is a ++ ** non-negative value (pWal->mxWalSize>=0). Note that we truncate ++ ** to zero bytes as truncating to the journal_size_limit might ++ ** leave a corrupt WAL file on disk. */ ++ walLimitSize(pWal, 0); ++ } } } diff --cc test/walpersist.test index bf65bd1e13,bf65bd1e13..ecb8f36408 --- a/test/walpersist.test +++ b/test/walpersist.test @@@ -68,7 -68,7 +68,10 @@@ do_test walpersist-1.11 } {1 1 1} # Make sure the journal_size_limit works to limit the size of the --# persisted wal file. ++# persisted wal file. In persistent-wal mode, any non-negative ++# journal_size_limit causes the WAL file to be truncated to zero bytes ++# when closing. ++# forcedelete test.db test.db-shm test.db-wal do_test walpersist-2.1 { sqlite3 db test.db @@@ -85,7 -85,7 +88,7 @@@ do_test walpersist-2.2 { file_control_persist_wal db 1 db close -- file size test.db-wal --} {12000} ++ concat [file exists test.db-wal] [file size test.db-wal] ++} {1 0} finish_test