Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix a problem causing false corruption reports following recovery of a *-wal file that contains one or more transactions and a *-wal2 file that contains a valid header but no valid transactions. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | wal2 |
Files: | files | file ages | folders |
SHA3-256: |
f6eafb65a43c650b065abe4a59e329c9 |
User & Date: | dan 2022-06-27 21:42:45.196 |
Context
2022-08-22
| ||
15:57 | Merge all recent trunk enhancements into the wal2 branch. (check-in: 0b7578bf3d user: drh tags: wal2) | |
2022-06-27
| ||
21:43 | Merge in fix for wal2 recovery. (check-in: 41d4f14bc6 user: dan tags: begin-concurrent-pnu-wal2) | |
21:42 | Fix a problem causing false corruption reports following recovery of a *-wal file that contains one or more transactions and a *-wal2 file that contains a valid header but no valid transactions. (check-in: f6eafb65a4 user: dan tags: wal2) | |
2022-06-25
| ||
16:53 | Merge version 3.39.0 into the wal2 branch. (check-in: ad3a7005e7 user: drh tags: wal2) | |
Changes
Changes to src/wal.c.
︙ | ︙ | |||
1823 1824 1825 1826 1827 1828 1829 | if( rc==SQLITE_OK ){ volatile WalCkptInfo *pInfo; if( isOpen(pWal->apWalFd[1]) ){ /* The case where *-wal2 may follow *-wal */ if( nCkpt2<=0x0F && nCkpt2==nCkpt1+1 ){ | > | > | | 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 | if( rc==SQLITE_OK ){ volatile WalCkptInfo *pInfo; if( isOpen(pWal->apWalFd[1]) ){ /* The case where *-wal2 may follow *-wal */ if( nCkpt2<=0x0F && nCkpt2==nCkpt1+1 ){ 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); walidxSetMxFrame(&pWal->hdr, 1, pWal->hdr.mxFrame); walidxSetMxFrame(&pWal->hdr, 0, hdr.mxFrame); }else{ pWal->hdr = hdr; } }else /* When *-wal may follow *-wal2 */ if( (nCkpt2==0x0F && nCkpt1==0) || (nCkpt2<0x0F && nCkpt2==nCkpt1-1) ){ 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); walidxSetMxFrame(&pWal->hdr, 1, hdr.mxFrame); }else{ walidxSetFile(&pWal->hdr, 1); walidxSetMxFrame(&pWal->hdr, 1, pWal->hdr.mxFrame); |
︙ | ︙ |
Added test/wal2recover3.test.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | # 2022 June 28 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing the operation of the library in # "PRAGMA journal_mode=WAL2" mode. # set testdir [file dirname $argv0] source $testdir/tester.tcl source $testdir/lock_common.tcl source $testdir/malloc_common.tcl source $testdir/wal_common.tcl set testprefix wal2recover3 ifcapable !wal {finish_test ; return } do_execsql_test 1.0 { CREATE TABLE t1(x); CREATE TABLE t2(x); PRAGMA journal_mode = wal2; PRAGMA wal_autocheckpoint = 0; PRAGMA journal_size_limit = 10000; } {wal2 0 10000} do_execsql_test 1.1 { WITH s(i) AS ( VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<1500 ) INSERT INTO t1 SELECT i FROM s; WITH s(i) AS ( VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<1500 ) INSERT INTO t2 SELECT i FROM s; } db_save_and_close set fd [open sv_test.db-wal2 r+] seek $fd 4000 puts -nonewline $fd 0 close $fd db_restore_and_reopen do_execsql_test 1.2 { SELECT sql FROM sqlite_schema; } {{CREATE TABLE t1(x)} {CREATE TABLE t2(x)}} finish_test |