]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Update some comments in wal.c. No code changes.
authordan <dan@noemail.net>
Mon, 14 Jun 2010 11:49:26 +0000 (11:49 +0000)
committerdan <dan@noemail.net>
Mon, 14 Jun 2010 11:49:26 +0000 (11:49 +0000)
FossilOrigin-Name: 1ce9c92bffa5d7f8431c005b29d698b0f5b95875

manifest
manifest.uuid
src/wal.c

index 6f09fdd48daec7c51cc02854d94d45c25a135066..ecd7aedf0c181e63e06a80f46d3def5bcf064a36 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Change\sthe\sinterface\sto\sinternal\sfunction\swalGetHash()\sto\smake\sit\seasier\sto\sfollow.
-D 2010-06-14T11:18:51
+C Update\ssome\scomments\sin\swal.c.\sNo\scode\schanges.
+D 2010-06-14T11:49:26
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in a5cad1f8f3e021356bfcc6c77dc16f6f1952bbc3
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -226,7 +226,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 eb0a433af578bccd8c3742806d8f2748976aa894
+F src/wal.c f8ba403da99ed5f2260f03cd01c3f10fe8155e67
 F src/wal.h 4ace25262452d17e7d3ec970c89ee17794004008
 F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f
 F src/where.c 1c895bef33d0dfc7ed90fb1f74120435d210ea56
@@ -820,7 +820,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P 1008f536440840da7d56c01ec147a25295fd1fd4
-R 912042aef26c7174a859c811eae607e9
+P 5e8e2e978ea48ce4ad93a936c838934f33d665df
+R 4612706a9d4bf144a165ca75ff4d4a89
 U dan
-Z 1a6bfab282147a6b78cbcbccc32bce51
+Z d61a90eb1d7a0bbf02b4e4817b07d279
index 4411035668f5263771aa1ff1f7a67a8674d559fe..5cb0339b07dd3e9749e46a8f7095bb00ee9ad895 100644 (file)
@@ -1 +1 @@
-5e8e2e978ea48ce4ad93a936c838934f33d665df
\ No newline at end of file
+1ce9c92bffa5d7f8431c005b29d698b0f5b95875
\ No newline at end of file
index 4a3ed99ff6a9cb8d5572c223da3faef44a9bcb1f..cd31bc3f813abcfbaaee115cb88ed56c79ad00f3 100644 (file)
--- a/src/wal.c
+++ b/src/wal.c
 ** more index blocks.  
 **
 ** The wal-index header contains the total number of frames within the WAL
-** in the the mxFrame field.  Each index block contains information on
-** HASHTABLE_NPAGE frames.  Each index block contains two sections, a
-** mapping which is a database page number for each frame, and a hash
-** table used to look up frames by page number.  The mapping section is
-** an array of HASHTABLE_NPAGE 32-bit page numbers.  The first entry on the
-** array is the page number for the first frame; the second entry is the
-** page number for the second frame; and so forth.  The last index block
-** holds a total of (mxFrame%HASHTABLE_NPAGE) page numbers.  All index
-** blocks other than the last are completely full with HASHTABLE_NPAGE
-** page numbers.  All index blocks are the same size; the mapping section
-** of the last index block merely contains unused entries if mxFrame is
-** not an even multiple of HASHTABLE_NPAGE.
+** in the the mxFrame field.  
+**
+** Each index block except for the first contains information on 
+** HASHTABLE_NPAGE frames. The first index block contains information on
+** HASHTABLE_NPAGE_ONE frames. The values of HASHTABLE_NPAGE_ONE and 
+** HASHTABLE_NPAGE are selected so that together the wal-index header and
+** first index block are the same size as all other index blocks in the
+** wal-index.
+**
+** Each index block contains two sections, a page-mapping that contains the
+** database page number associated with each wal frame, and a hash-table 
+** that allows users to query an index block for a specific page number.
+** The page-mapping is an array of HASHTABLE_NPAGE (or HASHTABLE_NPAGE_ONE
+** for the first index block) 32-bit page numbers. The first entry in the 
+** first index-block contains the database page number corresponding to the
+** first frame in the WAL file. The first entry in the second index block
+** in the WAL file corresponds to the (HASHTABLE_NPAGE_ONE+1)th frame in
+** the log, and so on.
+**
+** The last index block in a wal-index usually contains less than the full
+** complement of HASHTABLE_NPAGE (or HASHTABLE_NPAGE_ONE) page-numbers,
+** depending on the contents of the WAL file. This does not change the
+** allocated size of the page-mapping array - the page-mapping array merely
+** contains unused entries.
 **
 ** Even without using the hash table, the last frame for page P
-** can be found by scanning the mapping sections of each index block
+** can be found by scanning the page-mapping sections of each index block
 ** starting with the last index block and moving toward the first, and
 ** within each index block, starting at the end and moving toward the
 ** beginning.  The first entry that equals P corresponds to the frame
@@ -392,6 +404,33 @@ struct Wal {
 */
 typedef u16 ht_slot;
 
+/*
+** This structure is used to implement an iterator that loops through
+** all frames in the WAL in database page order. Where two or more frames
+** correspond to the same database page, the iterator visits only the 
+** frame most recently written to the WAL (in other words, the frame with
+** the largest index).
+**
+** The internals of this structure are only accessed by:
+**
+**   walIteratorInit() - Create a new iterator,
+**   walIteratorNext() - Step an iterator,
+**   walIteratorFree() - Free an iterator.
+**
+** This functionality is used by the checkpoint code (see walCheckpoint()).
+*/
+struct WalIterator {
+  int iPrior;                     /* Last result returned from the iterator */
+  int nSegment;                   /* Size of the aSegment[] array */
+  struct WalSegment {
+    int iNext;                    /* Next slot in aIndex[] not yet returned */
+    ht_slot *aIndex;              /* i0, i1, i2... such that aPgno[iN] ascend */
+    u32 *aPgno;                   /* Array of page numbers. */
+    int nEntry;                   /* Max size of aPgno[] and aIndex[] arrays */
+    int iZero;                    /* Frame number associated with aPgno[0] */
+  } aSegment[1];                  /* One for every 32KB page in the WAL */
+};
+
 /*
 ** Define the parameters of the hash tables in the wal-index file. There
 ** is a hash-table following every HASHTABLE_NPAGE page numbers in the
@@ -404,7 +443,8 @@ typedef u16 ht_slot;
 #define HASHTABLE_HASH_1     383                  /* Should be prime */
 #define HASHTABLE_NSLOT      (HASHTABLE_NPAGE*2)  /* Must be a power of 2 */
 
-/* The block of page numbers associated with the first hash-table in a
+/* 
+** The block of page numbers associated with the first hash-table in a
 ** wal-index is smaller than usual. This is so that there is a complete
 ** hash-table on each aligned 32KB page of the wal-index.
 */
@@ -469,33 +509,6 @@ static volatile WalIndexHdr *walIndexHdr(Wal *pWal){
   return (volatile WalIndexHdr*)pWal->apWiData[0];
 }
 
-/*
-** This structure is used to implement an iterator that loops through
-** all frames in the WAL in database page order. Where two or more frames
-** correspond to the same database page, the iterator visits only the 
-** frame most recently written to the WAL (in other words, the frame with
-** the largest index).
-**
-** The internals of this structure are only accessed by:
-**
-**   walIteratorInit() - Create a new iterator,
-**   walIteratorNext() - Step an iterator,
-**   walIteratorFree() - Free an iterator.
-**
-** This functionality is used by the checkpoint code (see walCheckpoint()).
-*/
-struct WalIterator {
-  int iPrior;                     /* Last result returned from the iterator */
-  int nSegment;                   /* Size of the aSegment[] array */
-  struct WalSegment {
-    int iNext;                    /* Next slot in aIndex[] not yet returned */
-    ht_slot *aIndex;              /* i0, i1, i2... such that aPgno[iN] ascend */
-    u32 *aPgno;                   /* Array of page numbers. */
-    int nEntry;                   /* Max size of aPgno[] and aIndex[] arrays */
-    int iZero;                    /* Frame number associated with aPgno[0] */
-  } aSegment[1];                  /* One for every 32KB page in the WAL */
-};
-
 /*
 ** The argument to this macro must be of type u32. On a little-endian
 ** architecture, it returns the u32 value that results from interpreting