Skip to content

Commit f1dd03d

Browse files
committed
Fix a segfault that could occur when optimizing a NOT NULL constraint against an IPK column of a sub-query.
1 parent 91106fe commit f1dd03d

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/whereexpr.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,6 +1409,7 @@ static void exprAnalyze(
14091409
pNew->eOperator = (operatorMask(pDup->op) + eExtraOp) & opMask;
14101410
}else if( op==TK_ISNULL && 0==sqlite3ExprCanBeNull(pLeft) ){
14111411
pExpr->op = TK_TRUEFALSE;
1412+
pExpr->u.zToken = "false";
14121413
ExprSetProperty(pExpr, EP_IsFalse);
14131414
pTerm->prereqAll = 0;
14141415
pTerm->eOperator = 0;

test/notnull2.test

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,16 @@ do_vmstep_test 1.5.2 {
8686
)
8787
} +100000 {1000}
8888

89+
#-------------------------------------------------------------------------
90+
reset_db
91+
do_execsql_test 2.0 {
92+
CREATE TABLE T1(a INTEGER PRIMARY KEY, b);
93+
CREATE TABLE T3(k, v);
94+
}
95+
96+
do_execsql_test 2.1 {
97+
SELECT * FROM (SELECT a, b FROM t1) LEFT JOIN t3 ON a IS NULL;
98+
}
8999

90100
finish_test
91101

0 commit comments

Comments
 (0)