From: drh Date: Wed, 23 Jun 2010 22:00:35 +0000 (+0000) Subject: Fix and/or improve comments in wal.c. No code changes. X-Git-Tag: version-3.7.2~241 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cd28508e5876eb173d4cdcdbd5104f6b497a32bf;p=thirdparty%2Fsqlite.git Fix and/or improve comments in wal.c. No code changes. FossilOrigin-Name: ee9991be082202c6637adb47affc777e7917be04 --- diff --git a/manifest b/manifest index 42a42ac8b9..3396c68a2c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,8 @@ -C Add\stest\scase\sfor\sSQLITE_FULL\serrors\sto\spagerfault.test.\sRemove\sa\sNEVER\smacro\sin\spager.c\sthat\sthis\shits. -D 2010-06-23T19:27:36 +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +C Fix\sand/or\simprove\scomments\sin\swal.c.\s\sNo\scode\schanges. +D 2010-06-23T22:00:36 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in a5cad1f8f3e021356bfcc6c77dc16f6f1952bbc3 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -226,7 +229,7 @@ F src/vdbeblob.c 258a6010ba7a82b72b327fb24c55790655689256 F src/vdbemem.c 2a82f455f6ca6f78b59fb312f96054c04ae0ead1 F src/vdbetrace.c 864cef96919323482ebd9986f2132435115e9cc2 F src/vtab.c a0f8a40274e4261696ef57aa806de2776ab72cda -F src/wal.c 563b7030efc55fe1ef105bd865876f2bf74f281b +F src/wal.c 51b5d2259d86a26125007d3d788da5a2a2715b1a F src/wal.h 4ace25262452d17e7d3ec970c89ee17794004008 F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f F src/where.c 1c895bef33d0dfc7ed90fb1f74120435d210ea56 @@ -825,7 +828,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 1727a81fed65bebfea43e0bda271584096d82785 -R 7a852c823aafd5a6b2955a7dd5f8280a -U dan -Z 7f4e2d2171817ab7dccd91b04d1a7459 +P 3e9680c4c18140d083b24e05a21ea6792aef2487 +R 128d792d7f9b9a40582f4d46c120cca4 +U drh +Z 369983deae2c52862083f493477e4ceb +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.6 (GNU/Linux) + +iD8DBQFMIoQHoxKgR168RlERAkTMAJ4y6IEC74XLF+DMxIuBS7Lmcv3IqQCeJXdd +wPN5UVQx6y4hhnn2sGwnj/w= +=O5UN +-----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index a33a53c493..cd54b0bdbc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3e9680c4c18140d083b24e05a21ea6792aef2487 \ No newline at end of file +ee9991be082202c6637adb47affc777e7917be04 \ No newline at end of file diff --git a/src/wal.c b/src/wal.c index 83dd758378..bbd2546eb5 100644 --- a/src/wal.c +++ b/src/wal.c @@ -31,7 +31,7 @@ ** used to determine which frames within the WAL are valid and which ** are leftovers from prior checkpoints. ** -** The WAL header is 24 bytes in size and consists of the following six +** The WAL header is 32 bytes in size and consists of the following eight ** big-endian 32-bit unsigned integer values: ** ** 0: Magic number. 0x377f0682 or 0x377f0683 @@ -45,7 +45,7 @@ ** ** Immediately following the wal-header are zero or more frames. Each ** frame consists of a 24-byte frame-header followed by a bytes -** of page data. The frame-header is broken into 6 big-endian 32-bit unsigned +** of page data. The frame-header is six big-endian 32-bit unsigned ** integer values, as follows: ** ** 0: Page number. @@ -81,6 +81,11 @@ ** s1 += x[i+1] + s0; ** endfor ** +** Note that s0 and s1 are both weighted checksums using fibonacci weights +** in reverse order (the largest fibonacci weight occurs on the first element +** of the sequence being summed.) The s1 value spans all 32-bit +** terms of the sequence whereas s0 omits the final term. +** ** On a checkpoint, the WAL is first VFS.xSync-ed, then valid content of the ** WAL is transferred into the database, then the database is VFS.xSync-ed. ** The VFS.xSync operations serve as write barriers - all writes launched @@ -1076,16 +1081,19 @@ static int walIndexRecover(Wal *pWal){ pWal->szPage = szPage; pWal->nCkpt = sqlite3Get4byte(&aBuf[12]); memcpy(&pWal->hdr.aSalt, &aBuf[16], 8); + + /* Verify that the WAL header checksum is correct */ walChecksumBytes(pWal->hdr.bigEndCksum==SQLITE_BIGENDIAN, aBuf, WAL_HDRSIZE-2*4, 0, pWal->hdr.aFrameCksum ); - if( pWal->hdr.aFrameCksum[0]!=sqlite3Get4byte(&aBuf[24]) || pWal->hdr.aFrameCksum[1]!=sqlite3Get4byte(&aBuf[28]) ){ goto finished; } + /* Verify that the version number on the WAL format is one that + ** are able to understand */ version = sqlite3Get4byte(&aBuf[4]); if( version!=WAL_MAX_VERSION ){ rc = SQLITE_CANTOPEN_BKPT;