diff options
author | drh <drh@noemail.net> | 2020-07-27 20:16:37 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2020-07-27 20:16:37 +0000 |
commit | f31230af12ecec3f21e6527f1fb11791ceec7eab (patch) | |
tree | 21230a37a450c18c0caed2e0116fb0859471a8fa /src/wal.c | |
parent | cddfc3922c45aec91133f22c85cb3fc461ef67b8 (diff) | |
download | sqlite-f31230af12ecec3f21e6527f1fb11791ceec7eab.tar.gz sqlite-f31230af12ecec3f21e6527f1fb11791ceec7eab.zip |
On recovery, always overwrite the old with the new, even if they are the same.
Add ALWAYS() macros on branches currently thought to be unreachable, pending
additional testing.
FossilOrigin-Name: 7052cf1d533f6404d0f45cf0b3e8a11c1ee27eccb64680a7fd308c8da7cbd544
Diffstat (limited to 'src/wal.c')
-rw-r--r-- | src/wal.c | 16 |
1 files changed, 6 insertions, 10 deletions
@@ -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; } |