Tweaks to comments in btree.c. Minor code changes to enhance testability.

FossilOrigin-Name: c7d9aa3a1ce63e27ec94295601bc89fecf1e4977
This commit is contained in:
drh 2014-10-30 20:48:44 +00:00
parent af8f513f9d
commit ba0f999418
3 changed files with 17 additions and 17 deletions

View File

@ -1,5 +1,5 @@
C Fix\sthe\s%c\sformat\scharacter\sin\ssqlite3VXPrintf()\sso\sthat\sit\scorrectly\nhandles\sprecisions\slarger\sthan\s70. C Tweaks\sto\scomments\sin\sbtree.c.\s\sMinor\scode\schanges\sto\senhance\stestability.
D 2014-10-29T18:20:18.932 D 2014-10-30T20:48:44.305
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in cf57f673d77606ab0f2d9627ca52a9ba1464146a F Makefile.in cf57f673d77606ab0f2d9627ca52a9ba1464146a
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -172,7 +172,7 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240
F src/backup.c 7f841396adfd47507ff670a471162d2bfcda3136 F src/backup.c 7f841396adfd47507ff670a471162d2bfcda3136
F src/bitvec.c 19a4ba637bd85f8f63fc8c9bae5ade9fb05ec1cb F src/bitvec.c 19a4ba637bd85f8f63fc8c9bae5ade9fb05ec1cb
F src/btmutex.c 49ca66250c7dfa844a4d4cb8272b87420d27d3a5 F src/btmutex.c 49ca66250c7dfa844a4d4cb8272b87420d27d3a5
F src/btree.c 5189881ca403938c5ceddde496b984fef9f40c5a F src/btree.c 8d955d8ef15dd724ea5ef1cb65c17151beaff1e0
F src/btree.h a79aa6a71e7f1055f01052b7f821bd1c2dce95c8 F src/btree.h a79aa6a71e7f1055f01052b7f821bd1c2dce95c8
F src/btreeInt.h 026d0129724e8f265fdc60d44ec240cf5a4e6179 F src/btreeInt.h 026d0129724e8f265fdc60d44ec240cf5a4e6179
F src/build.c 67bb05b1077e0cdaccb2e36bfcbe7a5df9ed31e8 F src/build.c 67bb05b1077e0cdaccb2e36bfcbe7a5df9ed31e8
@ -1209,7 +1209,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P 24780f8ddc1683fc62180e6961dc6bfe1168f4df P 08a27440f19b7fc884464832e6105af1bf008172
R c12283d048765bdbe52bad70443f70c1 R 984c5e022c7b2ce03eb5bed97ff43b89
U drh U drh
Z 8aeb3112f50d033e0580c4400e41dd66 Z 333c45d7dfd79a88b32c00dfbc4028a5

View File

@ -1 +1 @@
08a27440f19b7fc884464832e6105af1bf008172 c7d9aa3a1ce63e27ec94295601bc89fecf1e4977

View File

@ -1231,10 +1231,8 @@ static int defragmentPage(MemPage *pPage){
** **
** If no suitable space can be found on the free-list, return NULL. ** If no suitable space can be found on the free-list, return NULL.
** **
** This function may detect corruption within pPg. If it does and argument ** This function may detect corruption within pPg. If corruption is
** pRc is non-NULL, then *pRc is set to SQLITE_CORRUPT and NULL is returned. ** detected then *pRc is set to SQLITE_CORRUPT and NULL is returned.
** Or, if corruption is detected and pRc is NULL, NULL is returned and the
** corruption goes unreported.
** **
** If a slot of at least nByte bytes is found but cannot be used because ** If a slot of at least nByte bytes is found but cannot be used because
** there are already at least 60 fragmented bytes on the page, return NULL. ** there are already at least 60 fragmented bytes on the page, return NULL.
@ -1250,7 +1248,7 @@ static u8 *pageFindSlot(MemPage *pPg, int nByte, int *pRc, int *pbDefrag){
for(iAddr=hdr+1; (pc = get2byte(&aData[iAddr]))>0; iAddr=pc){ for(iAddr=hdr+1; (pc = get2byte(&aData[iAddr]))>0; iAddr=pc){
int size; /* Size of the free slot */ int size; /* Size of the free slot */
if( pc>usableSize-4 || pc<iAddr+4 ){ if( pc>usableSize-4 || pc<iAddr+4 ){
if( pRc ) *pRc = SQLITE_CORRUPT_BKPT; *pRc = SQLITE_CORRUPT_BKPT;
return 0; return 0;
} }
size = get2byte(&aData[pc+2]); size = get2byte(&aData[pc+2]);
@ -1268,7 +1266,7 @@ static u8 *pageFindSlot(MemPage *pPg, int nByte, int *pRc, int *pbDefrag){
memcpy(&aData[iAddr], &aData[pc], 2); memcpy(&aData[iAddr], &aData[pc], 2);
aData[hdr+7] += (u8)x; aData[hdr+7] += (u8)x;
}else if( size+pc > usableSize ){ }else if( size+pc > usableSize ){
if( pRc ) *pRc = SQLITE_CORRUPT_BKPT; *pRc = SQLITE_CORRUPT_BKPT;
return 0; return 0;
}else{ }else{
/* The slot remains on the free-list. Reduce its size to account /* The slot remains on the free-list. Reduce its size to account
@ -6076,8 +6074,9 @@ static int pageInsertArray(
assert( CORRUPT_DB || pPg->hdrOffset==0 ); /* Never called on page 1 */ assert( CORRUPT_DB || pPg->hdrOffset==0 ); /* Never called on page 1 */
for(i=0; i<nCell; i++){ for(i=0; i<nCell; i++){
int sz = szCell[i]; int sz = szCell[i];
int rc;
u8 *pSlot; u8 *pSlot;
if( bFreelist==0 || (pSlot = pageFindSlot(pPg, sz, 0, 0))==0 ){ if( bFreelist==0 || (pSlot = pageFindSlot(pPg, sz, &rc, 0))==0 ){
pData -= sz; pData -= sz;
if( pData<pBegin ) return 1; if( pData<pBegin ) return 1;
pSlot = pData; pSlot = pData;
@ -6870,8 +6869,9 @@ static int balance_nonroot(
/* This branch is taken if the set of sibling pages somehow contains /* This branch is taken if the set of sibling pages somehow contains
** duplicate entries. This can happen if the database is corrupt. ** duplicate entries. This can happen if the database is corrupt.
** It would be simpler to detect this as part of the loop below, but ** It would be simpler to detect this as part of the loop below, but
** in order to avoid populating the pager cache with two separate ** we do the detection here in order to avoid populating the pager
** objects associated with the same page number. */ ** cache with two separate objects associated with the same
** page number. */
assert( CORRUPT_DB ); assert( CORRUPT_DB );
rc = SQLITE_CORRUPT_BKPT; rc = SQLITE_CORRUPT_BKPT;
goto balance_cleanup; goto balance_cleanup;
@ -6956,7 +6956,7 @@ static int balance_nonroot(
} }
/* Cell pCell is destined for new sibling page pNew. Originally, it /* Cell pCell is destined for new sibling page pNew. Originally, it
** was either part of sibling page iOld (possibly an overflow page), ** was either part of sibling page iOld (possibly an overflow cell),
** or else the divider cell to the left of sibling page iOld. So, ** or else the divider cell to the left of sibling page iOld. So,
** if sibling page iOld had the same page number as pNew, and if ** if sibling page iOld had the same page number as pNew, and if
** pCell really was a part of sibling page iOld (not a divider or ** pCell really was a part of sibling page iOld (not a divider or