]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
When attempting to restart a wal file, make any required calls to sqlite3_randomness... checkpoint-truncate
authordan <dan@noemail.net>
Tue, 2 Dec 2014 19:35:09 +0000 (19:35 +0000)
committerdan <dan@noemail.net>
Tue, 2 Dec 2014 19:35:09 +0000 (19:35 +0000)
FossilOrigin-Name: 6ee08769f0ffbb3d620c66b89180ece7782dc820

manifest
manifest.uuid
src/wal.c

index 35fb1bb478432d76977ee50fe2be8a7b829277b3..0caddab954d09db28a9d968c56e2716a5531d34d 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\sthe\sSQLITE_CHECKPOINT_TRUNCATE\soption.
-D 2014-12-02T19:04:54.595
+C When\sattempting\sto\srestart\sa\swal\sfile,\smake\sany\srequired\scalls\sto\ssqlite3_randomness()\sbefore\swaiting\son\sor\schecking\sfor\swal\sfile\sreaders.\sThis\srestores\sthe\sbehaviour\sexhibited\sby\sthe\strunk.
+D 2014-12-02T19:35:09.278
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in a226317fdf3f4c895fb3cfedc355b4d0868ce1fb
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -301,7 +301,7 @@ F src/vdbemem.c 31d8eabb0cd78bfeab4e5124c7363c3e9e54db9f
 F src/vdbesort.c 42c166f7ca78cb643c7f4e4bdfa83c59d363d1a6
 F src/vdbetrace.c 7e4222955e07dd707a2f360c0eb73452be1cb010
 F src/vtab.c c08ec66f45919eaa726bf88aa53eb08379d607f9
-F src/wal.c f09818db7ba6e31d7a681eb99f801a7722c731d9
+F src/wal.c e396f31038aa01b9de95584b703692716275aedc
 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4
 F src/walker.c c253b95b4ee44b21c406e2a1052636c31ea27804
 F src/where.c a0b16f9d78321cb340a977287d19f826555c7d3b
@@ -1223,10 +1223,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 61b31e771430f490fc2c4cef55046debc4a5f4f5
-R 837049ab8d5153c1422981d3f48166e4
-T *branch * checkpoint-truncate
-T *sym-checkpoint-truncate *
-T -sym-trunk *
+P 8e20a43419e46b6b9d1f60ec7ea420bbfb3ef358
+R 54481572fc28e1041792401f62b71701
 U dan
-Z ce82007701b4a39f21164e74e2380c4f
+Z a7c4df9879a4ca8a80f8224dd87c78e4
index 9aff9e9fbc03e95d539b9865abaae5fea8508ca8..4930bb9b1521d66d7e64be1d8744b70c502df1c4 100644 (file)
@@ -1 +1 @@
-8e20a43419e46b6b9d1f60ec7ea420bbfb3ef358
\ No newline at end of file
+6ee08769f0ffbb3d620c66b89180ece7782dc820
\ No newline at end of file
index 849b776743f1c02b6b6f21bf883514e628516052..b88ece88b8f8ae726cc23aea908b3d384e423051 100644 (file)
--- a/src/wal.c
+++ b/src/wal.c
@@ -1635,15 +1635,19 @@ static int walPagesize(Wal *pWal){
 ** This function updates the shared-memory structures so that the next
 ** client to write to the database (which may be this one) does so by
 ** writing frames into the start of the log file.
+**
+** The value of parameter salt1 is used as the aSalt[1] value in the 
+** new wal-index header. It should be passed a pseudo-random value (i.e. 
+** one obtained from sqlite3_randomness()).
 */
-static void walRestartHdr(Wal *pWal){
+static void walRestartHdr(Wal *pWal, u32 salt1){
   volatile WalCkptInfo *pInfo = walCkptInfo(pWal);
   int i;                          /* Loop counter */
   u32 *aSalt = pWal->hdr.aSalt;   /* Big-endian salt values */
   pWal->nCkpt++;
   pWal->hdr.mxFrame = 0;
   sqlite3Put4byte((u8*)&aSalt[0], 1 + sqlite3Get4byte((u8*)&aSalt[0]));
-  sqlite3_randomness(4, &aSalt[1]);
+  memcpy(&pWal->hdr.aSalt[1], &salt1, 4);
   walIndexWriteHdr(pWal);
   pInfo->nBackfill = 0;
   pInfo->aReadMark[1] = 0;
@@ -1813,6 +1817,8 @@ static int walCheckpoint(
     if( pInfo->nBackfill<pWal->hdr.mxFrame ){
       rc = SQLITE_BUSY;
     }else if( eMode>=SQLITE_CHECKPOINT_RESTART ){
+      u32 salt1;
+      sqlite3_randomness(4, &salt1);
       assert( mxSafeFrame==pWal->hdr.mxFrame );
       rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(1), WAL_NREADER-1);
       if( rc==SQLITE_OK ){
@@ -1828,7 +1834,7 @@ static int walCheckpoint(
           ** the wal-index header do not match the contents of the 
           ** file-system. To avoid this, update the wal-index header to
           ** indicate that the log file contains zero valid frames.  */
-          walRestartHdr(pWal);
+          walRestartHdr(pWal, salt1);
           rc = sqlite3OsTruncate(pWal->pWalFd, 0);
         }
         walUnlockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1);
@@ -2649,7 +2655,7 @@ static int walRestartLog(Wal *pWal){
         ** at this point. But updating the actual wal-index header is also
         ** safe and means there is no special case for sqlite3WalUndo()
         ** to handle if this transaction is rolled back.  */
-        walRestartHdr(pWal);
+        walRestartHdr(pWal, salt1);
         walUnlockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1);
       }else if( rc!=SQLITE_BUSY ){
         return rc;