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

Do not apply the WHERE-clause pushdown optimization to terms that originate

in the ON or USING clause of a LEFT JOIN.  Fix for ticket
[6df18e949d3676290].

FossilOrigin-Name: 351bc22fa9b5a2e50da3583a882c5aa390bda19f
This commit is contained in:
drh
2015-08-22 01:32:29 +00:00
parent 1fa97b3ec8
commit 38978dd4ed
4 changed files with 35 additions and 9 deletions

View File

@@ -3757,6 +3757,9 @@ static int flattenSubquery(
** enforces this restriction since this routine does not have enough
** information to know.)
**
** (5) The WHERE clause expression originates in the ON or USING clause
** of a LEFT JOIN.
**
** Return 0 if no changes are made and non-zero if one or more WHERE clause
** terms are duplicated into the subquery.
*/
@@ -3779,6 +3782,7 @@ static int pushDownWhereTerms(
nChng += pushDownWhereTerms(db, pSubq, pWhere->pRight, iCursor);
pWhere = pWhere->pLeft;
}
if( ExprHasProperty(pWhere,EP_FromJoin) ) return 0; /* restriction 5 */
if( sqlite3ExprIsTableConstant(pWhere, iCursor) ){
nChng++;
while( pSubq ){