From: drh Date: Tue, 1 Apr 2014 01:24:34 +0000 (+0000) Subject: Remove an unnecessary conditional, replacing it with an assert(). X-Git-Tag: version-3.8.5~82^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a38c9516e847f90d914dce229b7c601698e94102;p=thirdparty%2Fsqlite.git Remove an unnecessary conditional, replacing it with an assert(). Improvements to comments. FossilOrigin-Name: 834bf1c367e1ccd498c7f9f843be2d2aa11ffb3c --- diff --git a/manifest b/manifest index a1eded678c..dbe10602d3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\scompiler\swarning\swhen\sSQLITE_DIRECT_OVERFLOW_READ\sis\sdefined.\nMinor\sperformance\senhancement\sand\ssize\sreduction. -D 2014-03-31T23:57:41.627 +C Remove\san\sunnecessary\sconditional,\sreplacing\sit\swith\san\sassert().\nImprovements\sto\scomments. +D 2014-04-01T01:24:34.512 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -164,7 +164,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c a729e63cf5cd1829507cb7b8e89f99b95141bb53 F src/bitvec.c 19a4ba637bd85f8f63fc8c9bae5ade9fb05ec1cb F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 -F src/btree.c b1d6309d6623f4ea8d9466aebd1ec84adc40cb9b +F src/btree.c 6c9b51abd404ce5b78b173b6f2248e8cb824758c F src/btree.h d79306df4ed9181b48916737fe8871a4392c4594 F src/btreeInt.h cf180d86b2e9e418f638d65baa425c4c69c0e0e3 F src/build.c 0d50ef95aad63f4c4fc47f3fa2670d4557c45db0 @@ -1159,7 +1159,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P f6211540c9d66a08dc580dd733e4f4a98968ae30 -R a9646e8cad6830bc030ac01ef7720050 +P 96385dc460545807a5c8fcf6280a971700f84866 +R 193f537069a669cf49d79f97b46daa7e U drh -Z be4271c513a3efe06acb17f300ec9933 +Z 9306db9f51cd1c998fccb67bf7fedc94 diff --git a/manifest.uuid b/manifest.uuid index e03a98f749..44d48365ac 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -96385dc460545807a5c8fcf6280a971700f84866 \ No newline at end of file +834bf1c367e1ccd498c7f9f843be2d2aa11ffb3c \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index cbb968ad8b..2bf026b840 100644 --- a/src/btree.c +++ b/src/btree.c @@ -3974,6 +3974,7 @@ static int accessPayload( assert( pCur->eState==CURSOR_VALID ); assert( pCur->aiIdx[pCur->iPage]nCell ); assert( cursorHoldsMutex(pCur) ); + assert( eOp!=2 || offset==0 ); /* Always start from beginning for eOp==2 */ getCellInfo(pCur); aPayload = pCur->info.pCell + pCur->info.nHeader; @@ -4009,12 +4010,13 @@ static int accessPayload( nextPage = get4byte(&aPayload[pCur->info.nLocal]); - /* If the BTCF_Incrblob flag is set and the BtCursor.aOverflow[] - ** has not been allocated, allocate it now. The array is sized at - ** one entry for each overflow page in the overflow chain. The - ** page number of the first overflow page is stored in aOverflow[0], - ** etc. A value of 0 in the aOverflow[] array means "not yet known" - ** (the cache is lazily populated). + /* If the BtCursor.aOverflow[] has not been allocated, allocate it now. + ** Except, do not allocate aOverflow[] for eOp==2. + ** + ** The aOverflow[] array is sized at one entry for each overflow page + ** in the overflow chain. The page number of the first overflow page is + ** stored in aOverflow[0], etc. A value of 0 in the aOverflow[] array + ** means "not yet known" (the cache is lazily populated). */ if( eOp!=2 && (pCur->curFlags & BTCF_ValidOvfl)==0 ){ int nOvfl = (pCur->info.nPayload-pCur->info.nLocal+ovflSize-1)/ovflSize; @@ -4059,11 +4061,17 @@ static int accessPayload( ** data is not required. So first try to lookup the overflow ** page-list cache, if any, then fall back to the getOverflowPage() ** function. + ** + ** Note that the aOverflow[] array must be allocated because eOp!=2 + ** here. If eOp==2, then offset==0 and this branch is never taken. */ - if( (pCur->curFlags & BTCF_ValidOvfl)!=0 && pCur->aOverflow[iIdx+1] ){ + assert( eOp!=2 ); + assert( pCur->curFlags & BTCF_ValidOvfl ); + if( pCur->aOverflow[iIdx+1] ){ nextPage = pCur->aOverflow[iIdx+1]; - } else + }else{ rc = getOverflowPage(pBt, nextPage, 0, &nextPage); + } offset -= ovflSize; }else{ /* Need to read this page properly. It contains some of the