Adjustments to column cache handling in order to restore 100% branch

test coverage.

FossilOrigin-Name: cc6b959bc1f968e08eea1afd387201d70a0c1e80
This commit is contained in:
drh 2009-12-30 14:12:38 +00:00
parent 27ee406e2c
commit f49f352320
7 changed files with 34 additions and 36 deletions

View File

@ -1,8 +1,8 @@
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
C Remove\ssome\scode\sin\sthe\scolumn\scache\sthat\sis\sno\slonger\sused.\s\sReplace\sit\swith\nan\sassert().
D 2009-12-30T01:13:12
C Adjustments\sto\scolumn\scache\shandling\sin\sorder\sto\srestore\s100%\sbranch\ntest\scoverage.
D 2009-12-30T14:12:38
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in c5827ead754ab32b9585487177c93bb00b9497b3
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -118,8 +118,8 @@ F src/build.c 6ab7f8d8fa5b0ac6bfdce359e85f580b7a9b2e86
F src/callback.c 908f3e0172c3d4058f4ca0acd42c637c52e9669f
F src/complete.c 4c8a742c4a4a6d9c835912648f5c8f032ea36c7b
F src/date.c a79c0a8f219370b972e320741f995a3bef9df33f
F src/delete.c 1425b44a1a8127ada4c909e8b71439354e523c24
F src/expr.c bdbf8714374e1bba4587e3b098b793f2de967f6f
F src/delete.c 610dc008e88a9599f905f5cbe9577ac9c36e0581
F src/expr.c d695300ba8b7a42d6b27a52d0288b974c89bf698
F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb
F src/fkey.c e2116672a6bd610dc888e27df292ebc7999c9bb0
F src/func.c 69906340991919b4933dd8630774ad069e4d582e
@ -165,11 +165,11 @@ F src/printf.c 644bc7d59df3dc56d6d8b9a510914bfc6b51bc69
F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50
F src/resolve.c e8e0866009405b24b81791b8cabc4463fd1d7ebb
F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697
F src/select.c 71511cdee4393c4dbaaa6feeff6c860b3f7e4f5f
F src/select.c 0109b993c360d649857523abb72919e1794f9b45
F src/shell.c b9fae60b0f2ce306c20fa99e83c75023bf35f15b
F src/sqlite.h.in 60cbf318765de59bb454e229bd2d5ec065dd686a
F src/sqlite3ext.h 69dfb8116af51b84a029cddb3b35062354270c89
F src/sqliteInt.h 3b9eba31a66b2bcc7c0f51cbcf92ae273c883d73
F src/sqliteInt.h d6c48b1a5cd6485151e1d1b071dbe0a85ceb70fe
F src/sqliteLimit.h 3afab2291762b5d09ae20c18feb8e9fa935a60a6
F src/status.c e651be6b30d397d86384c6867bc016e4913bcac7
F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e
@ -222,7 +222,7 @@ F src/vdbemem.c 1e16e3a16e55f4c3452834f0e041726021aa66e0
F src/vdbetrace.c 864cef96919323482ebd9986f2132435115e9cc2
F src/vtab.c 7c7713d66cda699f16bf1cc601d8d4f5070ab935
F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f
F src/where.c 5bf4b84dbd7b0129203562906340dded3de46543
F src/where.c 62553021aee64332af4acd9be23e6cec4727f9a0
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87
F test/all.test 14165b3e32715b700b5f0cbf8f6e3833dda0be45
@ -786,14 +786,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
P 84058be0beb799bc989d73a8d4cd8791ab709395
R 17c216161af4761c513c00696c4bffa1
P 1f890efb7863bd743b9f6ef841e0c0c4e67d76e1
R cdb4eff082e43b2502e0bb3de476ad7f
U drh
Z 14cceaab32fe4018f07c09ae0e5ddbe8
Z a33bada4bbf44d61d4561f0cf02acbc5
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFLOqkroxKgR168RlERAvW8AJ9iX9De4j6U8UxioIbM3TFZMWN3aACcDJ37
8lIlAKD+ufFWpQY2itcCNuc=
=T4JX
iD8DBQFLO1/ZoxKgR168RlERAk4fAJwPLG/kRFtfgWr1o/aNBgKjJ0KvRACfa+A1
+7mV62NdL7HnyG9DHas6RfI=
=YzHo
-----END PGP SIGNATURE-----

View File

@ -1 +1 @@
1f890efb7863bd743b9f6ef841e0c0c4e67d76e1
cc6b959bc1f968e08eea1afd387201d70a0c1e80

View File

@ -630,7 +630,6 @@ int sqlite3GenerateIndexKey(
if( doMakeRec ){
sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol+1, regOut);
sqlite3VdbeChangeP4(v, -1, sqlite3IndexAffinityStr(v, pIdx), 0);
sqlite3ExprCacheAffinityChange(pParse, regBase, nCol+1);
}
sqlite3ReleaseTempRange(pParse, regBase, nCol+1);
return regBase;

View File

@ -2019,14 +2019,16 @@ void sqlite3ExprCacheStore(Parse *pParse, int iTab, int iCol, int iReg){
}
/*
** Indicate that a register is being overwritten. Purge the register
** from the column cache.
** Indicate that registers between iReg..iReg+nReg-1 are being overwritten.
** Purge the range of registers from the column cache.
*/
void sqlite3ExprCacheRemove(Parse *pParse, int iReg){
void sqlite3ExprCacheRemove(Parse *pParse, int iReg, int nReg){
int i;
int iLast = iReg + nReg - 1;
struct yColCache *p;
for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){
if( p->iReg==iReg ){
int r = p->iReg;
if( r>=iReg && r<=iLast ){
cacheEntryClear(pParse, p);
p->iReg = 0;
}
@ -2136,16 +2138,7 @@ void sqlite3ExprCacheClear(Parse *pParse){
** registers starting with iStart.
*/
void sqlite3ExprCacheAffinityChange(Parse *pParse, int iStart, int iCount){
int iEnd = iStart + iCount - 1;
int i;
struct yColCache *p;
for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){
int r = p->iReg;
if( r>=iStart && r<=iEnd ){
cacheEntryClear(pParse, p);
p->iReg = 0;
}
}
sqlite3ExprCacheRemove(pParse, iStart, iCount);
}
/*
@ -2177,19 +2170,24 @@ void sqlite3ExprCodeCopy(Parse *pParse, int iFrom, int iTo, int nReg){
}
}
#if defined(SQLITE_DEBUG) || defined(SQLITE_COVERAGE_TEST)
/*
** Return true if any register in the range iFrom..iTo (inclusive)
** is used as part of the column cache.
**
** This routine is used within assert() and testcase() macros only
** and does not appear in a normal build.
*/
static int usedAsColumnCache(Parse *pParse, int iFrom, int iTo){
int i;
struct yColCache *p;
for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){
int r = p->iReg;
if( r>=iFrom && r<=iTo ) return 1;
if( r>=iFrom && r<=iTo ) return 1; /*NO_TEST*/
}
return 0;
}
#endif /* SQLITE_DEBUG || SQLITE_COVERAGE_TEST */
/*
** If the last instruction coded is an ephemeral copy of any of
@ -2585,7 +2583,7 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){
sqlite3ExprCode(pParse, pFarg->a[0].pExpr, target);
for(i=1; i<nFarg; i++){
sqlite3VdbeAddOp2(v, OP_NotNull, target, endCoalesce);
sqlite3ExprCacheRemove(pParse, target);
sqlite3ExprCacheRemove(pParse, target, 1);
sqlite3ExprCachePush(pParse);
sqlite3ExprCode(pParse, pFarg->a[i].pExpr, target);
sqlite3ExprCachePop(pParse, 1);
@ -2640,7 +2638,6 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){
if( nFarg ){
sqlite3ReleaseTempRange(pParse, r1, nFarg);
}
sqlite3ExprCacheAffinityChange(pParse, r1, nFarg);
break;
}
#ifndef SQLITE_OMIT_SUBQUERY
@ -3720,7 +3717,8 @@ int sqlite3GetTempRange(Parse *pParse, int nReg){
int i, n;
i = pParse->iRangeReg;
n = pParse->nRangeReg;
if( nReg<=n && !usedAsColumnCache(pParse, i, i+n-1) ){
if( nReg<=n ){
assert( !usedAsColumnCache(pParse, i, i+n-1) );
pParse->iRangeReg += nReg;
pParse->nRangeReg -= nReg;
}else{
@ -3730,6 +3728,7 @@ int sqlite3GetTempRange(Parse *pParse, int nReg){
return i;
}
void sqlite3ReleaseTempRange(Parse *pParse, int iReg, int nReg){
sqlite3ExprCacheRemove(pParse, iReg, nReg);
if( nReg>pParse->nRangeReg ){
pParse->nRangeReg = nReg;
pParse->iRangeReg = iReg;

View File

@ -3490,8 +3490,8 @@ static void updateAccumulator(Parse *pParse, AggInfo *pAggInfo){
sqlite3VdbeAddOp4(v, OP_AggStep, 0, regAgg, pF->iMem,
(void*)pF->pFunc, P4_FUNCDEF);
sqlite3VdbeChangeP5(v, (u8)nArg);
sqlite3ReleaseTempRange(pParse, regAgg, nArg);
sqlite3ExprCacheAffinityChange(pParse, regAgg, nArg);
sqlite3ReleaseTempRange(pParse, regAgg, nArg);
if( addrNext ){
sqlite3VdbeResolveLabel(v, addrNext);
sqlite3ExprCacheClear(pParse);

View File

@ -2656,7 +2656,7 @@ void sqlite3ExprCodeCopy(Parse*, int, int, int);
void sqlite3ExprCacheStore(Parse*, int, int, int);
void sqlite3ExprCachePush(Parse*);
void sqlite3ExprCachePop(Parse*, int);
void sqlite3ExprCacheRemove(Parse*, int);
void sqlite3ExprCacheRemove(Parse*, int, int);
void sqlite3ExprCacheClear(Parse*);
void sqlite3ExprCacheAffinityChange(Parse*, int, int);
void sqlite3ExprHardCopy(Parse*,int,int);

View File

@ -3160,7 +3160,7 @@ static Bitmask codeOneLoopStart(
nConstraint = nEq;
if( pRangeEnd ){
Expr *pRight = pRangeEnd->pExpr->pRight;
sqlite3ExprCacheRemove(pParse, regBase+nEq);
sqlite3ExprCacheRemove(pParse, regBase+nEq, 1);
sqlite3ExprCode(pParse, pRight, regBase+nEq);
sqlite3ExprCodeIsNullJump(v, pRight, regBase+nEq, addrNxt);
if( zAff ){