Index: src/test8.c ================================================================== --- src/test8.c +++ src/test8.c @@ -11,11 +11,11 @@ ************************************************************************* ** Code for testing the virtual table interfaces. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** -** $Id: test8.c,v 1.77 2009/04/21 09:02:47 danielk1977 Exp $ +** $Id: test8.c,v 1.78 2009/04/29 11:50:54 danielk1977 Exp $ */ #include "sqliteInt.h" #include "tcl.h" #include #include @@ -693,11 +693,11 @@ ** runtime parameters passed to this function to it. */ rc = sqlite3_prepare(db, idxStr, -1, &pCur->pStmt, 0); assert( pCur->pStmt || rc!=SQLITE_OK ); for(i=0; rc==SQLITE_OK && ipStmt, i+1, argv[i]); + rc = sqlite3_bind_value(pCur->pStmt, i+1, argv[i]); } /* If everything was successful, advance to the first row of the scan */ if( rc==SQLITE_OK ){ rc = echoNext(pVtabCursor); 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.390 2009/04/24 15:46:22 drh Exp $ +** $Id: where.c,v 1.391 2009/04/29 11:50:54 danielk1977 Exp $ */ #include "sqliteInt.h" /* ** Trace output macros @@ -1744,10 +1744,16 @@ struct sqlite3_index_constraint *pIdxCons; struct sqlite3_index_constraint_usage *pUsage; WhereTerm *pTerm; int i, j; int nOrderBy; + + /* Make sure wsFlags is initialized to some sane value. Otherwise, if the + ** malloc in allocateIndexInfo() fails and this function returns leaving + ** wsFlags in an uninitialized state, the caller may behave unpredictably. + */ + pCost->plan.wsFlags = WHERE_VIRTUALTABLE; /* If the sqlite3_index_info structure has not been previously ** allocated and initialized, then allocate and initialize it now. */ pIdxInfo = *ppIdxInfo; @@ -1828,11 +1834,10 @@ if( (SQLITE_BIG_DBL/((double)2))estimatedCost ){ pCost->rCost = (SQLITE_BIG_DBL/((double)2)); }else{ pCost->rCost = pIdxInfo->estimatedCost; } - pCost->plan.wsFlags = WHERE_VIRTUALTABLE; pCost->plan.u.pVtabIdx = pIdxInfo; if( pIdxInfo && pIdxInfo->orderByConsumed ){ pCost->plan.wsFlags |= WHERE_ORDERBY; } pCost->plan.nEq = 0;