1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-11 01:42:22 +03:00

Try to factor constant subcomponents of the WHERE clause out of the loop.

FossilOrigin-Name: 9d05777fe24e1a5ce71762de38db840931ef0bc8
This commit is contained in:
drh
2014-01-02 21:05:10 +00:00
parent 762c1c4071
commit 759e858811
3 changed files with 13 additions and 10 deletions

View File

@@ -5430,9 +5430,12 @@ WhereInfo *sqlite3WhereBegin(
/* Special case: a WHERE clause that is constant. Evaluate the
** expression and either jump over all of the code or fall thru.
*/
if( pWhere && (nTabList==0 || sqlite3ExprIsConstantNotJoin(pWhere)) ){
sqlite3ExprIfFalse(pParse, pWhere, pWInfo->iBreak, SQLITE_JUMPIFNULL);
pWhere = 0;
for(ii=0; ii<sWLB.pWC->nTerm; ii++){
if( nTabList==0 || sqlite3ExprIsConstantNotJoin(sWLB.pWC->a[ii].pExpr) ){
sqlite3ExprIfFalse(pParse, sWLB.pWC->a[ii].pExpr, pWInfo->iBreak,
SQLITE_JUMPIFNULL);
sWLB.pWC->a[ii].wtFlags |= TERM_CODED;
}
}
/* Special case: No FROM clause