mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-12 13:01:09 +03:00
Take care when checking the table of a TK_COLUMN expression node to see if the
table is a virtual table to first ensure that the Expr.y.pTab pointer is not null due to generated column optimizations. Ticket [4374860b29383380]. FossilOrigin-Name: 9d0d4ab95dc0c56e053c2924ed322a9ea7b25439e6f74599f706905a1994e454
This commit is contained in:
13
src/expr.c
13
src/expr.c
@@ -2244,6 +2244,15 @@ int sqlite3ExprIsInteger(Expr *p, int *pValue){
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
** Return true if p is a Column node that references a virtual table.
|
||||
*/
|
||||
int sqlite3ExprIsVtabRef(Expr *p){
|
||||
if( p->op!=TK_COLUMN ) return 0;
|
||||
if( p->y.pTab==0 ) return 0;
|
||||
return IsVirtual(p->y.pTab);
|
||||
}
|
||||
|
||||
/*
|
||||
** Return FALSE if there is no chance that the expression can be NULL.
|
||||
**
|
||||
@@ -5479,8 +5488,8 @@ static int impliesNotNullRow(Walker *pWalker, Expr *pExpr){
|
||||
testcase( pExpr->op==TK_LE );
|
||||
testcase( pExpr->op==TK_GT );
|
||||
testcase( pExpr->op==TK_GE );
|
||||
if( (pExpr->pLeft->op==TK_COLUMN && IsVirtual(pExpr->pLeft->y.pTab))
|
||||
|| (pExpr->pRight->op==TK_COLUMN && IsVirtual(pExpr->pRight->y.pTab))
|
||||
if( sqlite3ExprIsVtabRef(pExpr->pLeft)
|
||||
|| sqlite3ExprIsVtabRef(pExpr->pRight)
|
||||
){
|
||||
return WRC_Prune;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user