]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Merge the fix for [a1fa75cbdd02] from the experimental branch. Also
authordrh <drh@noemail.net>
Fri, 16 Dec 2011 15:38:52 +0000 (15:38 +0000)
committerdrh <drh@noemail.net>
Fri, 16 Dec 2011 15:38:52 +0000 (15:38 +0000)
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

1  2 
manifest
manifest.uuid
src/wal.c
test/walpersist.test

diff --cc manifest
index cbedf29e4bd88a067f472950aad3f204a994cb52,61d5f87ce3327616eb9dfee46ad2445da8e7852e..66736fbb7389d91f0961f0eca5dc3d004fe7435e
+++ 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 b02a3e69b10d2b50014e839e07a1281a016698de,3218c8eac2720c96532e1dd43192a9349858f52b..689e39e8ad533d50777bae02c2f1acd3cfa7faaf
@@@ -1,1 -1,1 +1,1 @@@
- b1005ef46cc2b46dd8e448ae1a9a9508bd5666ab
 -6492af76ea6585a1b377d69751af930c0ccfe688
++09ccc4a1be7ba81890f10aac6623dd90dab4f990
diff --cc src/wal.c
index 209c9097521c9c94071d605da0b92609a0006cf9,e3f9cd114960e3b64ae3ef53107a1008511f7d6b..0fae6cbc7440af97adb8dcac01f792c8532ac2f0
+++ 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);
++        }
        }
      }
  
index bf65bd1e1387a3b268bfd0870b7d3789d529bbb8,bf65bd1e1387a3b268bfd0870b7d3789d529bbb8..ecb8f36408659bdefd3a41217d0b99a847f17b7d
@@@ -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