]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
On recovery, always overwrite the old with the new, even if they are the same.
authordrh <drh@noemail.net>
Mon, 27 Jul 2020 20:16:37 +0000 (20:16 +0000)
committerdrh <drh@noemail.net>
Mon, 27 Jul 2020 20:16:37 +0000 (20:16 +0000)
Add ALWAYS() macros on branches currently thought to be unreachable, pending
additional testing.

FossilOrigin-Name: 7052cf1d533f6404d0f45cf0b3e8a11c1ee27eccb64680a7fd308c8da7cbd544

manifest
manifest.uuid
src/wal.c

index 4299199941fa954dcb17295d679fc17629d83e21..d06cad05e5933b6d25d9f07108860d5371576bdb 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sa\scouple\sof\stest\sscripts\sto\smatch\sthe\snew\swal\srecovery\sbehaviour\son\sthis\sbranch.
-D 2020-07-27T15:05:20.842
+C On\srecovery,\salways\soverwrite\sthe\sold\swith\sthe\snew,\seven\sif\sthey\sare\sthe\ssame.\nAdd\sALWAYS()\smacros\son\sbranches\scurrently\sthought\sto\sbe\sunreachable,\spending\nadditional\stesting.
+D 2020-07-27T20:16:37.459
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -619,7 +619,7 @@ F src/vdbetrace.c fa3bf238002f0bbbdfb66cc8afb0cea284ff9f148d6439bc1f6f2b4c3b7143
 F src/vdbevtab.c ee5b4c902fdda2230f9503ac7b84c6d614c91e8f6f4dc1633e2e8dfef8ffb144
 F src/vtab.c 5f5fc793092f53bbdfde296c50f563fb7bda58cf48e9cf6a8bdfbc5abd409845
 F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
-F src/wal.c e409134fb951703a39be98b338c619d51f3e07762fa82e588f1fa0c7c5d862e9
+F src/wal.c 5d62c14b7865586cf012ba9e2cafc92313a61cbb1824106a3ac49f2ef957e8bc
 F src/wal.h c3aa7825bfa2fe0d85bef2db94655f99870a285778baa36307c0a16da32b226a
 F src/walker.c 3df26a33dc4f54e8771600fb7fdebe1ece0896c2ad68c30ab40b017aa4395049
 F src/where.c 2ea911238674e9baaeddf105dddabed92692a01996073c4d4983f9a7efe481f9
@@ -1878,7 +1878,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P cf962d213abe1b55ebbcfecf1de9d5d61709509d1ce3cbd56d8cf4c9ad65e5a9
-R ebe6827bc20f72ccd734ec811c796054
-U dan
-Z 36a51a01bccca5b769bdcaf4fbb60dd7
+P 3af61e83532f76f0f3252a28663415d37b096ddf05a9c58fa79303933c09abce
+R 90cfb5314d321e24c6c38b0cec33d99b
+U drh
+Z 7af3dd79e9571635c50343a91786c8f5
index cf926efb1b03df5ae1e3fe5358aab8094d8c8d33..04e79db75ea8765b43cfc0c0b5042504af437fc5 100644 (file)
@@ -1 +1 @@
-3af61e83532f76f0f3252a28663415d37b096ddf05a9c58fa79303933c09abce
\ No newline at end of file
+7052cf1d533f6404d0f45cf0b3e8a11c1ee27eccb64680a7fd308c8da7cbd544
\ No newline at end of file
index d0fe49f643cf25d1720d19254d183133a28c4c70..262824e59fd617fc4aa13bbffe7b13cfcf45e840 100644 (file)
--- a/src/wal.c
+++ b/src/wal.c
@@ -1062,7 +1062,7 @@ static int walIndexAppend(Wal *pWal, u32 iFrame, u32 iPage){
   /* Assuming the wal-index file was successfully mapped, populate the
   ** page number array and hash table entry.
   */
-  if( rc==SQLITE_OK ){
+  if( ALWAYS(rc==SQLITE_OK) ){
     int iKey;                     /* Hash table key */
     int idx;                      /* Value to write to hash-table slot */
     int nCollide;                 /* Number of hash collisions */
@@ -1247,6 +1247,7 @@ static int walIndexRecover(Wal *pWal){
       int iFrame;                 /* Index of last frame read */
       int iLast = MIN(iLastFrame, HASHTABLE_NPAGE_ONE+iPg*HASHTABLE_NPAGE);
       int iFirst = 1 + (iPg==0?0:HASHTABLE_NPAGE_ONE+(iPg-1)*HASHTABLE_NPAGE);
+      int nHdr, nHdr32;
       rc = walIndexPage(pWal, iPg, (volatile u32**)&aShare);
       if( rc ) break;
       pWal->apWiData[iPg] = aPrivate;
@@ -1262,7 +1263,7 @@ static int walIndexRecover(Wal *pWal){
         isValid = walDecodeFrame(pWal, &pgno, &nTruncate, aData, aFrame);
         if( !isValid ) break;
         rc = walIndexAppend(pWal, iFrame, pgno);
-        if( rc!=SQLITE_OK ) break;
+        if( NEVER(rc!=SQLITE_OK) ) break;
 
         /* If nTruncate is non-zero, this is a commit record. */
         if( nTruncate ){
@@ -1276,14 +1277,9 @@ static int walIndexRecover(Wal *pWal){
         }
       }
       pWal->apWiData[iPg] = aShare;
-
-      {
-        int nHdr = (iPg==0 ? WALINDEX_HDR_SIZE : 0);
-        int nHdr32 = nHdr / sizeof(u32);
-        if( memcpy(&aShare[nHdr32], &aPrivate[nHdr32], WALINDEX_PGSZ-nHdr) ){
-          memcpy(&aShare[nHdr32], &aPrivate[nHdr32], WALINDEX_PGSZ-nHdr);
-        }
-      }
+      nHdr = (iPg==0 ? WALINDEX_HDR_SIZE : 0);
+      nHdr32 = nHdr / sizeof(u32);
+      memcpy(&aShare[nHdr32], &aPrivate[nHdr32], WALINDEX_PGSZ-nHdr);
       if( iFrame<=iLast ) break;
     }