Update header comments in wal.c to correctly describe the WAL file format.

Update the locking region offsets in os_unix.c and os_win.c and add assert()
statement to verify that the locking region offsets are correct.

FossilOrigin-Name: 40030c0739f821ea8ee188c28c579507f10448bc
This commit is contained in:
drh 2010-05-25 13:40:03 +00:00
parent ca6b5baba4
commit 1b78eaf0ba
5 changed files with 42 additions and 16 deletions

View File

@ -1,5 +1,8 @@
C If\sa\swriter\sexits\sunexpectedly\sin\sthe\smiddle\sof\sa\stransaction,\shave\sthe\sfollowing\swriter\sremove\sany\swal-index\shash-table\sentries\sleft\sby\sthe\sinterrupted\stransaction.
D 2010-05-25T10:50:57
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
C Update\sheader\scomments\sin\swal.c\sto\scorrectly\sdescribe\sthe\sWAL\sfile\sformat.\nUpdate\sthe\slocking\sregion\soffsets\sin\sos_unix.c\sand\sos_win.c\sand\sadd\sassert()\nstatement\sto\sverify\sthat\sthe\slocking\sregion\soffsets\sare\scorrect.
D 2010-05-25T13:40:04
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in a5cad1f8f3e021356bfcc6c77dc16f6f1952bbc3
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -152,8 +155,8 @@ F src/os.c 2285265f7e8035ba77e8e8ec93adf3c3c61fc60e
F src/os.h efcc7f0072ae362b44eab8588b43a943da61504e
F src/os_common.h a8f95b81eca8a1ab8593d23e94f8a35f35d4078f
F src/os_os2.c 665876d5eec7585226b0a1cf5e18098de2b2da19
F src/os_unix.c 35ace483789db8ede92acc46134930c2c4267645
F src/os_win.c 1e44ee84210b59db1e098bbbc66f6dee68e20d5f
F src/os_unix.c a5771c3fcf78d0f2f5f547accff662c9bda8a32e
F src/os_win.c e300c8f85c1be853f977e50f9292e61a396e6a33
F src/pager.c 5d693cc6273c5406a21f1a2afa18309457273549
F src/pager.h 76466c3a5af56943537f68b1f16567101a0cd1d0
F src/parse.y ace5c7a125d9f2a410e431ee3209034105045f7e
@ -224,7 +227,7 @@ F src/vdbeblob.c 5327132a42a91e8b7acfb60b9d2c3b1c5c863e0e
F src/vdbemem.c 2a82f455f6ca6f78b59fb312f96054c04ae0ead1
F src/vdbetrace.c 864cef96919323482ebd9986f2132435115e9cc2
F src/vtab.c a0f8a40274e4261696ef57aa806de2776ab72cda
F src/wal.c d75a06a34fbe9106a839f2c1d4d775d2f37f4a97
F src/wal.c 5088dfa9a5ea5f8aa327b358b80672396992d807
F src/wal.h 111c6f3efd83fe2fc707b29e26431e8eff4c6f28
F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f
F src/where.c 75fee9e255b62f773fcadd1d1f25b6f63ac7a356
@ -815,7 +818,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
P 54c1718e6d15a20414cae15895eb5e83217722e2
R 5c5f25e7e1cef98008c39244dc94b13e
U dan
Z b5e4f418b379e4c3437beb0f2d82e4a1
P ed77556adcdf7011b95b9969b360269fb2ebe4e5
R d1d0d5bbdebcfd93e05be5bb82cdf6b0
U drh
Z 63d8bb07d3b847ec0a884fd3ce5b83ec
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFL+9M3oxKgR168RlERAp9EAJ9sX7O50F3hu2LSBgFSErDe7ZDCeQCdGj/h
+YdECuKggMpxgNPvINVevPU=
=HX/i
-----END PGP SIGNATURE-----

View File

@ -1 +1 @@
ed77556adcdf7011b95b9969b360269fb2ebe4e5
40030c0739f821ea8ee188c28c579507f10448bc

View File

@ -3186,7 +3186,7 @@ struct unixShm {
/*
** Constants used for locking
*/
#define UNIX_SHM_BASE 32 /* Byte offset of the first lock byte */
#define UNIX_SHM_BASE 80 /* Byte offset of the first lock byte */
#define UNIX_SHM_DMS 0x01 /* Mask for Dead-Man-Switch lock */
#define UNIX_SHM_A 0x10 /* Mask for region locks... */
#define UNIX_SHM_B 0x20

View File

@ -1271,7 +1271,7 @@ struct winShm {
/*
** Constants used for locking
*/
#define WIN_SHM_BASE 32 /* Byte offset of the first lock byte */
#define WIN_SHM_BASE 80 /* Byte offset of the first lock byte */
#define WIN_SHM_DMS 0x01 /* Mask for Dead-Man-Switch lock */
#define WIN_SHM_A 0x10 /* Mask for region locks... */
#define WIN_SHM_B 0x20

View File

@ -34,7 +34,7 @@
** The WAL header is 24 bytes in size and consists of the following six
** big-endian 32-bit unsigned integer values:
**
** 0: Magic number. 0x377f0682 (big endian)
** 0: Magic number. 0x377f0682 or 0x377f0683
** 4: File format version. Currently 3007000
** 8: Database page size. Example: 1024
** 12: Checkpoint sequence number
@ -61,9 +61,13 @@
** salt values in the wal-header
**
** (2) The checksum values in the final 8 bytes of the frame-header
** exactly match the checksum computed consecutively on
** (a) the first 16 bytes of the frame-header, and
** (b) the frame data.
** exactly match the checksum computed consecutively on the
** WAL header and the first 8 bytes and the content of all frames
** up to and including the current frame.
**
** The checksum is computed using 32-bit big-endian integers if the
** magic number in the first 4 bytes of the WAL is 0x377f0683 and it
** is computed using little-endian if the magic number is 0x377f0682.
**
** 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.
@ -947,6 +951,18 @@ int sqlite3WalOpen(
assert( zDbName && zDbName[0] );
assert( pDbFd );
/* In the amalgamation, the os_unix.c and os_win.c source files come before
** this source file. Verify that the #defines of the locking byte offsets
** in os_unix.c and os_win.c agree with the WALINDEX_LOCK_OFFSET value.
*/
#ifdef WIN_SHM_BASE
assert( WIN_SHM_BASE==WALINDEX_LOCK_OFFSET );
#endif
#ifdef UNIX_SHM_BASE
assert( UNIX_SHM_BASE==WALINDEX_LOCK_OFFSET );
#endif
/* Allocate an instance of struct Wal to return. */
*ppWal = 0;
nWal = sqlite3Strlen30(zDbName) + 5;