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

Ensure that the query planner knows that any column of a flattened LEFT JOIN

can be NULL even if that column is labeled with "NOT NULL".
Fix for ticket [892fc34f173e99d8].

FossilOrigin-Name: 483462682d3a57fb9dd85b4772596e9738f1694a454b8ebbc480b9452733e88d
This commit is contained in:
dan
2017-06-20 17:43:26 +00:00
parent 40db2fd7a3
commit bd11a2acbb
4 changed files with 32 additions and 12 deletions

View File

@@ -3205,9 +3205,12 @@ static Expr *substExpr(
pCopy = &ifNullRow;
}
pNew = sqlite3ExprDup(db, pCopy, 0);
if( pNew && (pExpr->flags & EP_FromJoin) ){
if( pNew && pSubst->isLeftJoin ){
ExprSetProperty(pNew, EP_CanBeNull);
}
if( pNew && ExprHasProperty(pExpr,EP_FromJoin) ){
pNew->iRightJoinTable = pExpr->iRightJoinTable;
pNew->flags |= EP_FromJoin;
ExprSetProperty(pNew, EP_FromJoin);
}
sqlite3ExprDelete(db, pExpr);
pExpr = pNew;
@@ -3500,7 +3503,7 @@ static int flattenSubquery(
**
** If the subquery is the right operand of a LEFT JOIN, then the outer
** query cannot be an aggregate. This is an artifact of the way aggregates
** are processed - there is not mechanism to determine if the LEFT JOIN
** are processed - there is no mechanism to determine if the LEFT JOIN
** table should be all-NULL.
**
** See also tickets #306, #350, and #3300.