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

Do not move WHERE clause terms inside OR expressions that are contained

within an ON clause of a LEFT JOIN.  Fix for ticket [f2369304e47167e3e].

FossilOrigin-Name: 1128575d0ab24f7023a0f6e6ce4828b9a09a7c6c
This commit is contained in:
drh
2013-05-09 14:20:11 +00:00
parent 0bf3bc6c64
commit b3129fa560
4 changed files with 35 additions and 10 deletions

View File

@@ -4726,6 +4726,10 @@ static Bitmask codeOneLoopStart(
** the "interesting" terms of z - terms that did not originate in the
** ON or USING clause of a LEFT JOIN, and terms that are usable as
** indices.
**
** This optimization also only applies if the (x1 OR x2 OR ...) term
** is not contained in the ON clause of a LEFT JOIN.
** See ticket http://www.sqlite.org/src/info/f2369304e4
*/
if( pWC->nTerm>1 ){
int iTerm;
@@ -4747,7 +4751,7 @@ static Bitmask codeOneLoopStart(
if( pOrTerm->leftCursor==iCur || (pOrTerm->eOperator & WO_AND)!=0 ){
WhereInfo *pSubWInfo; /* Info for single OR-term scan */
Expr *pOrExpr = pOrTerm->pExpr;
if( pAndExpr ){
if( pAndExpr && !ExprHasProperty(pOrExpr, EP_FromJoin) ){
pAndExpr->pLeft = pOrExpr;
pOrExpr = pAndExpr;
}