Index: src/test_tclvar.c ================================================================== --- src/test_tclvar.c +++ src/test_tclvar.c @@ -14,11 +14,11 @@ ** testing of the SQLite library. ** ** The emphasis of this file is a virtual table that provides ** access to TCL variables. ** -** $Id: test_tclvar.c,v 1.14 2007/08/21 10:44:16 drh Exp $ +** $Id: test_tclvar.c,v 1.15 2008/05/29 05:23:42 drh Exp $ */ #include "sqliteInt.h" #include "tcl.h" #include #include @@ -220,11 +220,12 @@ static int tclvarBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ int ii; for(ii=0; iinConstraint; ii++){ struct sqlite3_index_constraint const *pCons = &pIdxInfo->aConstraint[ii]; - if( pCons->iColumn==0 && pCons->op==SQLITE_INDEX_CONSTRAINT_EQ ){ + if( pCons->iColumn==0 && pCons->usable + && pCons->op==SQLITE_INDEX_CONSTRAINT_EQ ){ struct sqlite3_index_constraint_usage *pUsage; pUsage = &pIdxInfo->aConstraintUsage[ii]; pUsage->omit = 0; pUsage->argvIndex = 1; return SQLITE_OK; @@ -231,11 +232,12 @@ } } for(ii=0; iinConstraint; ii++){ struct sqlite3_index_constraint const *pCons = &pIdxInfo->aConstraint[ii]; - if( pCons->iColumn==0 && pCons->op==SQLITE_INDEX_CONSTRAINT_MATCH ){ + if( pCons->iColumn==0 && pCons->usable + && pCons->op==SQLITE_INDEX_CONSTRAINT_MATCH ){ struct sqlite3_index_constraint_usage *pUsage; pUsage = &pIdxInfo->aConstraintUsage[ii]; pUsage->omit = 1; pUsage->argvIndex = 1; return SQLITE_OK; Index: src/vdbe.c ================================================================== --- src/vdbe.c +++ src/vdbe.c @@ -41,11 +41,11 @@ ** documentation, headers files, or other derived files. The formatting ** of the code in this file is, therefore, important. See other comments ** in this file for details. If in doubt, do not deviate from existing ** commenting and indentation practices when changing or adding code. ** -** $Id: vdbe.c,v 1.742 2008/05/29 03:12:55 drh Exp $ +** $Id: vdbe.c,v 1.743 2008/05/29 05:23:42 drh Exp $ */ #include "sqliteInt.h" #include #include "vdbeInt.h" @@ -4549,12 +4549,12 @@ ** to the module implementation. ** ** This opcode invokes the xFilter method on the virtual table specified ** by P1. The integer query plan parameter to xFilter is stored in register ** P3. Register P3+1 stores the argc parameter to be passed to the -** xFilter method. Registers P3+2..P3+1+argc are the argc additional -** parametersneath additional parameters which are passed to +** xFilter method. Registers P3+2..P3+1+argc are the argc +** additional parameters which are passed to ** xFilter as argv. Register P3+2 becomes argv[0] when passed to xFilter. ** ** A jump is made to P2 if the result set after filtering would be empty. */ case OP_VFilter: { /* jump */ Index: src/where.c ================================================================== --- src/where.c +++ src/where.c @@ -14,11 +14,11 @@ ** generating the code that loops through a table looking for applicable ** rows. Indices are selected and used to speed the search when doing ** so is applicable. Because this module is responsible for selecting ** indices, you might also think of this module as the "query optimizer". ** -** $Id: where.c,v 1.305 2008/05/28 18:01:45 shane Exp $ +** $Id: where.c,v 1.306 2008/05/29 05:23:42 drh Exp $ */ #include "sqliteInt.h" /* ** The number of bits in a Bitmask. "BMS" means "BitMask Size". @@ -2361,24 +2361,26 @@ for(j=1; j<=nConstraint; j++){ int k; for(k=0; kdisableColCache ); sqlite3ExprCode(pParse, wc.a[iTerm].pExpr->pRight, iReg+j+1); break; } } if( k==nConstraint ) break; } + assert( pParse->disableColCache ); pParse->disableColCache--; sqlite3VdbeAddOp2(v, OP_Integer, pBestIdx->idxNum, iReg); sqlite3VdbeAddOp2(v, OP_Integer, j-1, iReg+1); sqlite3VdbeAddOp4(v, OP_VFilter, iCur, brk, iReg, pBestIdx->idxStr, pBestIdx->needToFreeIdxStr ? P4_MPRINTF : P4_STATIC); sqlite3ReleaseTempRange(pParse, iReg, nConstraint+2); pBestIdx->needToFreeIdxStr = 0; - for(j=0; jnConstraint; j++){ + for(j=0; jdisableColCache; if( pRangeEnd ){ - pParse->disableColCache = 1; + pParse->disableColCache++; } sqlite3ExprCode(pParse, pRangeStart->pExpr->pRight, regBase+nEq); pParse->disableColCache = dcc; sqlite3VdbeAddOp2(v, OP_IsNull, regBase+nEq, nxt); nConstraint++;