1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-16 23:02:26 +03:00

Disable the OR-clause optimization if it does not result in an index being

used that would not have been used otherwise.  In other words, do not
convert OR clauses into an IN statement if it does not help the optimizer. (CVS 2789)

FossilOrigin-Name: 7e7cfce0f8ed2a6e04747736a2c68484f447cdfb
This commit is contained in:
drh
2005-11-26 14:24:40 +00:00
parent 54a167d1fe
commit 9a5f7474e3
3 changed files with 14 additions and 12 deletions

View File

@@ -16,7 +16,7 @@
** 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.184 2005/11/26 14:08:08 drh Exp $
** $Id: where.c,v 1.185 2005/11/26 14:24:41 drh Exp $
*/
#include "sqliteInt.h"
@@ -700,15 +700,17 @@ static void exprAnalyze(
}
pNew = sqlite3Expr(TK_IN, pDup, 0, 0);
if( pNew ){
int idxNew;
transferJoinMarkings(pNew, pExpr);
pNew->pList = pList;
idxNew = whereClauseInsert(pWC, pNew, TERM_VIRTUAL|TERM_DYNAMIC);
exprAnalyze(pSrc, pMaskSet, pWC, idxNew);
pTerm = &pWC->a[idxTerm];
pWC->a[idxNew].iParent = idxTerm;
pTerm->nChild = 1;
}else{
sqlite3ExprListDelete(pList);
}
pTerm->pExpr = pNew;
pTerm->flags |= TERM_DYNAMIC;
exprAnalyze(pSrc, pMaskSet, pWC, idxTerm);
pTerm = &pWC->a[idxTerm];
}
or_not_possible:
whereClauseClear(&sOr);