1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-18 10:21:03 +03:00

Enhance the query planner so that it detects when the xBestIndex method

of a virtual table gives out-of-sequence argvIndex values and reports an
error.  Secondary fix for ticket [2b8aed9f7c9e6].

FossilOrigin-Name: 9506ec14fb9e58986c1b79a3ca78430ad94b10966944c864e0429a7688dd1454
This commit is contained in:
drh
2018-04-09 15:57:54 +00:00
parent 67ecf1f5c2
commit 337679be4e
3 changed files with 19 additions and 10 deletions

View File

@@ -3099,9 +3099,9 @@ static int whereLoopAddVirtualOne(
|| pNew->aLTerm[iTerm]!=0
|| pIdxCons->usable==0
){
rc = SQLITE_ERROR;
sqlite3ErrorMsg(pParse,"%s.xBestIndex malfunction",pSrc->pTab->zName);
return rc;
testcase( pIdxInfo->needToFreeIdxStr );
return SQLITE_ERROR;
}
testcase( iTerm==nConstraint-1 );
testcase( j==0 );
@@ -3129,6 +3129,15 @@ static int whereLoopAddVirtualOne(
pNew->u.vtab.omitMask &= ~mNoOmit;
pNew->nLTerm = mxTerm+1;
for(i=0; i<=mxTerm; i++){
if( pNew->aLTerm[i]==0 ){
/* The non-zero argvIdx values must be contiguous. Raise an
** error if they are not */
sqlite3ErrorMsg(pParse,"%s.xBestIndex malfunction",pSrc->pTab->zName);
testcase( pIdxInfo->needToFreeIdxStr );
return SQLITE_ERROR;
}
}
assert( pNew->nLTerm<=pNew->nLSlot );
pNew->u.vtab.idxNum = pIdxInfo->idxNum;
pNew->u.vtab.needFree = pIdxInfo->needToFreeIdxStr;