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

Change the LEFT JOIN strength reduction optimization so that assumes that

virtual table constraints can be true even if terms within the constraint
are NULL.  This works around dodgy virtual table implementations.

FossilOrigin-Name: cbb977fe1908431f3aad8e67668588b119e7d491724f2042af436f509a4f6623
This commit is contained in:
drh
2018-04-03 14:04:48 +00:00
parent 18e2b8af1c
commit 9881155d54
3 changed files with 28 additions and 10 deletions

View File

@@ -5037,6 +5037,27 @@ static int impliesNotNullRow(Walker *pWalker, Expr *pExpr){
return WRC_Abort;
}
return WRC_Prune;
/* Virtual tables are allowed to use constraints like x=NULL. So
** a term of the form x=y does not prove that y is not null if x
** is the column of a virtual table */
case TK_EQ:
case TK_NE:
case TK_LT:
case TK_LE:
case TK_GT:
case TK_GE:
testcase( pExpr->op==TK_EQ );
testcase( pExpr->op==TK_NE );
testcase( pExpr->op==TK_LT );
testcase( pExpr->op==TK_LE );
testcase( pExpr->op==TK_GT );
testcase( pExpr->op==TK_GE );
if( (pExpr->pLeft->op==TK_COLUMN && IsVirtual(pExpr->pLeft->pTab))
|| (pExpr->pRight->op==TK_COLUMN && IsVirtual(pExpr->pRight->pTab))
){
return WRC_Prune;
}
default:
return WRC_Continue;
}