aboutsummaryrefslogtreecommitdiff
path: root/src/expr.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2018-09-23 02:01:42 +0000
committerdrh <drh@noemail.net>2018-09-23 02:01:42 +0000
commitf8937f9034e4df499734ec7bb330616a49ad6d1f (patch)
treea0d384213bafc511254cf4da656a55bf467e73ee /src/expr.c
parent2c3ba949697f5e4d2fe657c6bc49275a94ee2a25 (diff)
downloadsqlite-f8937f9034e4df499734ec7bb330616a49ad6d1f.tar.gz
sqlite-f8937f9034e4df499734ec7bb330616a49ad6d1f.zip
Fix a faulty assert() in the validation logic for the LEFT JOIN strength
reduction optimization. Problem found by OSSFuzz. FossilOrigin-Name: 2fd62fccd13e326dbd7dd730112542c6faa56e466bf4f7b8e22ced543031280c
Diffstat (limited to 'src/expr.c')
-rw-r--r--src/expr.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/expr.c b/src/expr.c
index 169282284..fa0bcd86a 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -4849,18 +4849,15 @@ int sqlite3ExprImpliesExpr(Parse *pParse, Expr *pE1, Expr *pE2, int iTab){
/*
** This is the Expr node callback for sqlite3ExprImpliesNotNullRow().
** If the expression node requires that the table at pWalker->iCur
-** have a non-NULL column, then set pWalker->eCode to 1 and abort.
+** have one or more non-NULL column, then set pWalker->eCode to 1 and abort.
+**
+** This routine controls an optimization. False positives (setting
+** pWalker->eCode to 1 when it should not be) are deadly, but false-negatives
+** (never setting pWalker->eCode) is a harmless missed optimization.
*/
static int impliesNotNullRow(Walker *pWalker, Expr *pExpr){
- /* This routine is only called for WHERE clause expressions and so it
- ** cannot have any TK_AGG_COLUMN entries because those are only found
- ** in HAVING clauses. We can get a TK_AGG_FUNCTION in a WHERE clause,
- ** but that is an illegal construct and the query will be rejected at
- ** a later stage of processing, so the TK_AGG_FUNCTION case does not
- ** need to be considered here. */
- assert( pExpr->op!=TK_AGG_COLUMN );
+ testcase( pExpr->op==TK_AGG_COLUMN );
testcase( pExpr->op==TK_AGG_FUNCTION );
-
if( ExprHasProperty(pExpr, EP_FromJoin) ) return WRC_Prune;
switch( pExpr->op ){
case TK_ISNOT: