mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-12 13:01:09 +03:00
Prevent SQLite from assuming that if ((? IS NOT NULL) IS NOT NULL) is true, ? may not be NULL. Fix for [d51a8696].
FossilOrigin-Name: 7833feecfe745e237f239ee4c38a9e4bf7ad66a32919150208da87c00a826473
This commit is contained in:
20
src/expr.c
20
src/expr.c
@@ -5168,10 +5168,11 @@ static int impliesNotNullRow(Walker *pWalker, Expr *pExpr){
|
||||
return WRC_Prune;
|
||||
|
||||
case TK_AND:
|
||||
if( sqlite3ExprImpliesNonNullRow(pExpr->pLeft, pWalker->u.iCur)
|
||||
&& sqlite3ExprImpliesNonNullRow(pExpr->pRight, pWalker->u.iCur)
|
||||
){
|
||||
pWalker->eCode = 1;
|
||||
assert( pWalker->eCode==0 );
|
||||
sqlite3WalkExpr(pWalker, pExpr->pLeft);
|
||||
if( pWalker->eCode ){
|
||||
pWalker->eCode = 0;
|
||||
sqlite3WalkExpr(pWalker, pExpr->pRight);
|
||||
}
|
||||
return WRC_Prune;
|
||||
|
||||
@@ -5230,15 +5231,8 @@ static int impliesNotNullRow(Walker *pWalker, Expr *pExpr){
|
||||
int sqlite3ExprImpliesNonNullRow(Expr *p, int iTab){
|
||||
Walker w;
|
||||
p = sqlite3ExprSkipCollateAndLikely(p);
|
||||
while( p ){
|
||||
if( p->op==TK_NOTNULL ){
|
||||
p = p->pLeft;
|
||||
}else if( p->op==TK_AND ){
|
||||
if( sqlite3ExprImpliesNonNullRow(p->pLeft, iTab) ) return 1;
|
||||
p = p->pRight;
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
if( p && p->op==TK_NOTNULL ){
|
||||
p = p->pLeft;
|
||||
}
|
||||
w.xExprCallback = impliesNotNullRow;
|
||||
w.xSelectCallback = 0;
|
||||
|
||||
Reference in New Issue
Block a user