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

Make sure left joins still work even when the OR clause optimization fires.

Ticket #1537. (CVS 2788)

FossilOrigin-Name: cbbeb9de0019a0b81318158711590078fcb7e98a
This commit is contained in:
drh
2005-11-26 14:08:07 +00:00
parent d86959f588
commit 54a167d1fe
4 changed files with 137 additions and 8 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.183 2005/11/21 12:48:24 drh Exp $
** $Id: where.c,v 1.184 2005/11/26 14:08:08 drh Exp $
*/
#include "sqliteInt.h"
@@ -532,6 +532,16 @@ static int isLikeOrGlob(
}
#endif /* SQLITE_OMIT_LIKE_OPTIMIZATION */
/*
** If the pBase expression originated in the ON or USING clause of
** a join, then transfer the appropriate markings over to derived.
*/
static void transferJoinMarkings(Expr *pDerived, Expr *pBase){
pDerived->flags |= pBase->flags & EP_FromJoin;
pDerived->iRightJoinTable = pBase->iRightJoinTable;
}
/*
** The input to this routine is an WhereTerm structure with only the
** "pExpr" field filled in. The job of this routine is to analyze the
@@ -690,6 +700,7 @@ static void exprAnalyze(
}
pNew = sqlite3Expr(TK_IN, pDup, 0, 0);
if( pNew ){
transferJoinMarkings(pNew, pExpr);
pNew->pList = pList;
}else{
sqlite3ExprListDelete(pList);