]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Change the interface to internal function walGetHash() to make it easier to follow.
authordan <dan@noemail.net>
Mon, 14 Jun 2010 11:18:50 +0000 (11:18 +0000)
committerdan <dan@noemail.net>
Mon, 14 Jun 2010 11:18:50 +0000 (11:18 +0000)
FossilOrigin-Name: 5e8e2e978ea48ce4ad93a936c838934f33d665df

manifest
manifest.uuid
src/wal.c

index 1842e90493b90436fff9c61a107b33163ca100ba..6f09fdd48daec7c51cc02854d94d45c25a135066 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\sthe\sxShmPage\smethod\sto\sthe\s"crash"\svfs\sin\stest6.c.
-D 2010-06-14T10:30:12
+C Change\sthe\sinterface\sto\sinternal\sfunction\swalGetHash()\sto\smake\sit\seasier\sto\sfollow.
+D 2010-06-14T11:18:51
 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 7cf566b5c1cb9e1094bbbd9b188605ed83330e40
+F src/wal.c eb0a433af578bccd8c3742806d8f2748976aa894
 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 37b26d125f4b1d8e75bb38800fefd145611f94aa
-R dea40a6fff442af044dc9e87dfed9d5b
+P 1008f536440840da7d56c01ec147a25295fd1fd4
+R 912042aef26c7174a859c811eae607e9
 U dan
-Z 06678e8838f3de5fe68cbedec2758b53
+Z 1a6bfab282147a6b78cbcbccc32bce51
index 13d1c158aa62b1331436d74fbed8bd417f97d388..4411035668f5263771aa1ff1f7a67a8674d559fe 100644 (file)
@@ -1 +1 @@
-1008f536440840da7d56c01ec147a25295fd1fd4
\ No newline at end of file
+5e8e2e978ea48ce4ad93a936c838934f33d665df
\ No newline at end of file
index e4be0abf626565c064cc5021fc3d515aefa93146..4a3ed99ff6a9cb8d5572c223da3faef44a9bcb1f 100644 (file)
--- a/src/wal.c
+++ b/src/wal.c
@@ -749,9 +749,8 @@ static int walNextHash(int iPriorHash){
 ** slot in the hash table is set to N, it refers to frame number 
 ** (*piZero+N) in the log.
 **
-** Finally, set *paPgno such that for all frames F between (*piZero+1) and 
-** (*piZero+HASHTABLE_NPAGE), (*paPgno)[F] is the database page number 
-** associated with frame F.
+** Finally, set *paPgno so that *paPgno[1] is the page number of the
+** first frame indexed by the hash table, frame (*piZero+1).
 */
 static int walHashGet(
   Wal *pWal,                      /* WAL handle */
@@ -772,14 +771,13 @@ static int walHashGet(
 
     aHash = (volatile ht_slot *)&aPgno[HASHTABLE_NPAGE];
     if( iHash==0 ){
-      aPgno = &aPgno[WALINDEX_HDR_SIZE/sizeof(u32)-1];
+      aPgno = &aPgno[WALINDEX_HDR_SIZE/sizeof(u32)];
       iZero = 0;
     }else{
       iZero = HASHTABLE_NPAGE_ONE + (iHash-1)*HASHTABLE_NPAGE;
-      aPgno = &aPgno[-1*iZero-1];
     }
   
-    *paPgno = aPgno;
+    *paPgno = &aPgno[-1];
     *paHash = aHash;
     *piZero = iZero;
   }
@@ -863,8 +861,8 @@ static void walCleanupHash(Wal *pWal){
   /* Zero the entries in the aPgno array that correspond to frames with
   ** frame numbers greater than pWal->hdr.mxFrame. 
   */
-  nByte = ((char *)aHash - (char *)&aPgno[pWal->hdr.mxFrame+1]);
-  memset((void *)&aPgno[pWal->hdr.mxFrame+1], 0, nByte);
+  nByte = ((char *)aHash - (char *)&aPgno[iLimit+1]);
+  memset((void *)&aPgno[iLimit+1], 0, nByte);
 
 #ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT
   /* Verify that the every entry in the mapping region is still reachable
@@ -874,7 +872,7 @@ static void walCleanupHash(Wal *pWal){
     int i;           /* Loop counter */
     int iKey;        /* Hash key */
     for(i=1; i<=iLimit; i++){
-      for(iKey=walHash(aPgno[i+iZero]); aHash[iKey]; iKey=walNextHash(iKey)){
+      for(iKey=walHash(aPgno[i]); aHash[iKey]; iKey=walNextHash(iKey)){
         if( aHash[iKey]==i ) break;
       }
       assert( aHash[iKey]==i );
@@ -911,8 +909,8 @@ static int walIndexAppend(Wal *pWal, u32 iFrame, u32 iPage){
     ** entire hash table and aPgno[] array before proceding. 
     */
     if( idx==1 ){
-      int nByte = (u8 *)&aHash[HASHTABLE_NSLOT] - (u8 *)&aPgno[1+iZero];
-      memset((void*)&aPgno[1+iZero], 0, nByte);
+      int nByte = (u8 *)&aHash[HASHTABLE_NSLOT] - (u8 *)&aPgno[1];
+      memset((void*)&aPgno[1], 0, nByte);
     }
 
     /* If the entry in aPgno[] is already set, then the previous writer
@@ -921,16 +919,16 @@ static int walIndexAppend(Wal *pWal, u32 iFrame, u32 iPage){
     ** Remove the remnants of that writers uncommitted transaction from 
     ** the hash-table before writing any new entries.
     */
-    if( aPgno[iFrame] ){
+    if( aPgno[idx] ){
       walCleanupHash(pWal);
-      assert( !aPgno[iFrame] );
+      assert( !aPgno[idx] );
     }
 
     /* Write the aPgno[] array entry and the hash-table slot. */
     for(iKey=walHash(iPage); aHash[iKey]; iKey=walNextHash(iKey)){
       assert( nCollide++ < idx );
     }
-    aPgno[iFrame] = iPage;
+    aPgno[idx] = iPage;
     aHash[iKey] = idx;
 
 #ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT
@@ -952,7 +950,7 @@ static int walIndexAppend(Wal *pWal, u32 iFrame, u32 iPage){
     if( (idx&0x3ff)==0 ){
       int i;           /* Loop counter */
       for(i=1; i<=idx; i++){
-        for(iKey=walHash(aPgno[i+iZero]); aHash[iKey]; iKey=walNextHash(iKey)){
+        for(iKey=walHash(aPgno[i]); aHash[iKey]; iKey=walNextHash(iKey)){
           if( aHash[iKey]==i ) break;
         }
         assert( aHash[iKey]==i );
@@ -1353,10 +1351,9 @@ static int walIteratorInit(Wal *pWal, WalIterator **pp){
       walIteratorFree(p);
       return rc;
     }
-    nEntry = ((i+1)==nSegment)?iLast-iZero:(u32 *)aHash-(u32 *)&aPgno[iZero+1];
-
+    aPgno++;
+    nEntry = ((i+1)==nSegment)?iLast-iZero:(u32 *)aHash-(u32 *)aPgno;
     iZero++;
-    aPgno += iZero;
 
     for(j=0; j<nEntry; j++){
       aSpace[j] = j;
@@ -1965,7 +1962,7 @@ int sqlite3WalRead(
     }
     for(iKey=walHash(pgno); aHash[iKey]; iKey=walNextHash(iKey)){
       u32 iFrame = aHash[iKey] + iZero;
-      if( iFrame<=iLast && aPgno[iFrame]==pgno ){
+      if( iFrame<=iLast && aPgno[aHash[iKey]]==pgno ){
         assert( iFrame>iRead );
         iRead = iFrame;
       }