From d60bf110363bc0805ba25cd581c01c60110c3f3c Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 14 Jun 2010 11:18:50 +0000 Subject: [PATCH] Change the interface to internal function walGetHash() to make it easier to follow. FossilOrigin-Name: 5e8e2e978ea48ce4ad93a936c838934f33d665df --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/wal.c | 35 ++++++++++++++++------------------- 3 files changed, 23 insertions(+), 26 deletions(-) diff --git a/manifest b/manifest index 1842e90493..6f09fdd48d 100644 --- 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 diff --git a/manifest.uuid b/manifest.uuid index 13d1c158aa..4411035668 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1008f536440840da7d56c01ec147a25295fd1fd4 \ No newline at end of file +5e8e2e978ea48ce4ad93a936c838934f33d665df \ No newline at end of file diff --git a/src/wal.c b/src/wal.c index e4be0abf62..4a3ed99ff6 100644 --- 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; jiRead ); iRead = iFrame; }