1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-10 01:02:56 +03:00

Merge in fix for wal2 recovery.

FossilOrigin-Name: 41d4f14bc657f361976c51e1e0d38d2dd2440127fd230f80a1eb8f2a03bc9325
This commit is contained in:
dan
2022-06-27 21:43:33 +00:00
4 changed files with 65 additions and 10 deletions

View File

@@ -1830,7 +1830,8 @@ static int walIndexRecover(Wal *pWal){
if( isOpen(pWal->apWalFd[1]) ){
/* The case where *-wal2 may follow *-wal */
if( nCkpt2<=0x0F && nCkpt2==nCkpt1+1 ){
if( sqlite3Get4byte((u8*)(&pWal->hdr.aSalt[0]))==hdr.aFrameCksum[0]
if( pWal->hdr.mxFrame
&& sqlite3Get4byte((u8*)(&pWal->hdr.aSalt[0]))==hdr.aFrameCksum[0]
&& sqlite3Get4byte((u8*)(&pWal->hdr.aSalt[1]))==hdr.aFrameCksum[1]
){
walidxSetFile(&pWal->hdr, 1);
@@ -1843,7 +1844,8 @@ static int walIndexRecover(Wal *pWal){
/* When *-wal may follow *-wal2 */
if( (nCkpt2==0x0F && nCkpt1==0) || (nCkpt2<0x0F && nCkpt2==nCkpt1-1) ){
if( sqlite3Get4byte((u8*)(&hdr.aSalt[0]))==pWal->hdr.aFrameCksum[0]
if( hdr.mxFrame
&& sqlite3Get4byte((u8*)(&hdr.aSalt[0]))==pWal->hdr.aFrameCksum[0]
&& sqlite3Get4byte((u8*)(&hdr.aSalt[1]))==pWal->hdr.aFrameCksum[1]
){
SWAP(WalIndexHdr, pWal->hdr, hdr);