1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-05 15:55:57 +03:00

Change the interface to internal function walGetHash() to make it easier to follow.

FossilOrigin-Name: 5e8e2e978ea48ce4ad93a936c838934f33d665df
This commit is contained in:
dan
2010-06-14 11:18:50 +00:00
parent 067f3165d8
commit d60bf11036
3 changed files with 23 additions and 26 deletions

View File

@@ -1,5 +1,5 @@
C Add\sthe\sxShmPage\smethod\sto\sthe\s"crash"\svfs\sin\stest6.c. C Change\sthe\sinterface\sto\sinternal\sfunction\swalGetHash()\sto\smake\sit\seasier\sto\sfollow.
D 2010-06-14T10:30:12 D 2010-06-14T11:18:51
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in a5cad1f8f3e021356bfcc6c77dc16f6f1952bbc3 F Makefile.in a5cad1f8f3e021356bfcc6c77dc16f6f1952bbc3
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -226,7 +226,7 @@ F src/vdbeblob.c 5327132a42a91e8b7acfb60b9d2c3b1c5c863e0e
F src/vdbemem.c 2a82f455f6ca6f78b59fb312f96054c04ae0ead1 F src/vdbemem.c 2a82f455f6ca6f78b59fb312f96054c04ae0ead1
F src/vdbetrace.c 864cef96919323482ebd9986f2132435115e9cc2 F src/vdbetrace.c 864cef96919323482ebd9986f2132435115e9cc2
F src/vtab.c a0f8a40274e4261696ef57aa806de2776ab72cda F src/vtab.c a0f8a40274e4261696ef57aa806de2776ab72cda
F src/wal.c 7cf566b5c1cb9e1094bbbd9b188605ed83330e40 F src/wal.c eb0a433af578bccd8c3742806d8f2748976aa894
F src/wal.h 4ace25262452d17e7d3ec970c89ee17794004008 F src/wal.h 4ace25262452d17e7d3ec970c89ee17794004008
F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f
F src/where.c 1c895bef33d0dfc7ed90fb1f74120435d210ea56 F src/where.c 1c895bef33d0dfc7ed90fb1f74120435d210ea56
@@ -820,7 +820,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
P 37b26d125f4b1d8e75bb38800fefd145611f94aa P 1008f536440840da7d56c01ec147a25295fd1fd4
R dea40a6fff442af044dc9e87dfed9d5b R 912042aef26c7174a859c811eae607e9
U dan U dan
Z 06678e8838f3de5fe68cbedec2758b53 Z 1a6bfab282147a6b78cbcbccc32bce51

View File

@@ -1 +1 @@
1008f536440840da7d56c01ec147a25295fd1fd4 5e8e2e978ea48ce4ad93a936c838934f33d665df

View File

@@ -749,9 +749,8 @@ static int walNextHash(int iPriorHash){
** slot in the hash table is set to N, it refers to frame number ** slot in the hash table is set to N, it refers to frame number
** (*piZero+N) in the log. ** (*piZero+N) in the log.
** **
** Finally, set *paPgno such that for all frames F between (*piZero+1) and ** Finally, set *paPgno so that *paPgno[1] is the page number of the
** (*piZero+HASHTABLE_NPAGE), (*paPgno)[F] is the database page number ** first frame indexed by the hash table, frame (*piZero+1).
** associated with frame F.
*/ */
static int walHashGet( static int walHashGet(
Wal *pWal, /* WAL handle */ Wal *pWal, /* WAL handle */
@@ -772,14 +771,13 @@ static int walHashGet(
aHash = (volatile ht_slot *)&aPgno[HASHTABLE_NPAGE]; aHash = (volatile ht_slot *)&aPgno[HASHTABLE_NPAGE];
if( iHash==0 ){ if( iHash==0 ){
aPgno = &aPgno[WALINDEX_HDR_SIZE/sizeof(u32)-1]; aPgno = &aPgno[WALINDEX_HDR_SIZE/sizeof(u32)];
iZero = 0; iZero = 0;
}else{ }else{
iZero = HASHTABLE_NPAGE_ONE + (iHash-1)*HASHTABLE_NPAGE; iZero = HASHTABLE_NPAGE_ONE + (iHash-1)*HASHTABLE_NPAGE;
aPgno = &aPgno[-1*iZero-1];
} }
*paPgno = aPgno; *paPgno = &aPgno[-1];
*paHash = aHash; *paHash = aHash;
*piZero = iZero; *piZero = iZero;
} }
@@ -863,8 +861,8 @@ static void walCleanupHash(Wal *pWal){
/* Zero the entries in the aPgno array that correspond to frames with /* Zero the entries in the aPgno array that correspond to frames with
** frame numbers greater than pWal->hdr.mxFrame. ** frame numbers greater than pWal->hdr.mxFrame.
*/ */
nByte = ((char *)aHash - (char *)&aPgno[pWal->hdr.mxFrame+1]); nByte = ((char *)aHash - (char *)&aPgno[iLimit+1]);
memset((void *)&aPgno[pWal->hdr.mxFrame+1], 0, nByte); memset((void *)&aPgno[iLimit+1], 0, nByte);
#ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT #ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT
/* Verify that the every entry in the mapping region is still reachable /* 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 i; /* Loop counter */
int iKey; /* Hash key */ int iKey; /* Hash key */
for(i=1; i<=iLimit; i++){ 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; if( aHash[iKey]==i ) break;
} }
assert( aHash[iKey]==i ); 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. ** entire hash table and aPgno[] array before proceding.
*/ */
if( idx==1 ){ if( idx==1 ){
int nByte = (u8 *)&aHash[HASHTABLE_NSLOT] - (u8 *)&aPgno[1+iZero]; int nByte = (u8 *)&aHash[HASHTABLE_NSLOT] - (u8 *)&aPgno[1];
memset((void*)&aPgno[1+iZero], 0, nByte); memset((void*)&aPgno[1], 0, nByte);
} }
/* If the entry in aPgno[] is already set, then the previous writer /* 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 ** Remove the remnants of that writers uncommitted transaction from
** the hash-table before writing any new entries. ** the hash-table before writing any new entries.
*/ */
if( aPgno[iFrame] ){ if( aPgno[idx] ){
walCleanupHash(pWal); walCleanupHash(pWal);
assert( !aPgno[iFrame] ); assert( !aPgno[idx] );
} }
/* Write the aPgno[] array entry and the hash-table slot. */ /* Write the aPgno[] array entry and the hash-table slot. */
for(iKey=walHash(iPage); aHash[iKey]; iKey=walNextHash(iKey)){ for(iKey=walHash(iPage); aHash[iKey]; iKey=walNextHash(iKey)){
assert( nCollide++ < idx ); assert( nCollide++ < idx );
} }
aPgno[iFrame] = iPage; aPgno[idx] = iPage;
aHash[iKey] = idx; aHash[iKey] = idx;
#ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT #ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT
@@ -952,7 +950,7 @@ static int walIndexAppend(Wal *pWal, u32 iFrame, u32 iPage){
if( (idx&0x3ff)==0 ){ if( (idx&0x3ff)==0 ){
int i; /* Loop counter */ int i; /* Loop counter */
for(i=1; i<=idx; i++){ 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; if( aHash[iKey]==i ) break;
} }
assert( aHash[iKey]==i ); assert( aHash[iKey]==i );
@@ -1353,10 +1351,9 @@ static int walIteratorInit(Wal *pWal, WalIterator **pp){
walIteratorFree(p); walIteratorFree(p);
return rc; 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++; iZero++;
aPgno += iZero;
for(j=0; j<nEntry; j++){ for(j=0; j<nEntry; j++){
aSpace[j] = j; aSpace[j] = j;
@@ -1965,7 +1962,7 @@ int sqlite3WalRead(
} }
for(iKey=walHash(pgno); aHash[iKey]; iKey=walNextHash(iKey)){ for(iKey=walHash(pgno); aHash[iKey]; iKey=walNextHash(iKey)){
u32 iFrame = aHash[iKey] + iZero; u32 iFrame = aHash[iKey] + iZero;
if( iFrame<=iLast && aPgno[iFrame]==pgno ){ if( iFrame<=iLast && aPgno[aHash[iKey]]==pgno ){
assert( iFrame>iRead ); assert( iFrame>iRead );
iRead = iFrame; iRead = iFrame;
} }