44 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
			
		
		
	
	
			44 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
| Subject: [PATCH] Fix a problem with handling expressions like '(col IS NULL
 | |
|  AND <expr1>) OR col == NULL' in WHERE clauses.
 | |
| 
 | |
| ---
 | |
|  src/whereexpr.c    |  1 +
 | |
|  test/notnull2.test | 10 ++++++++++
 | |
|  2 files changed, 11 insertions(+)
 | |
| 
 | |
| diff --git a/src/whereexpr.c b/src/whereexpr.c
 | |
| index b3f48fe..1807fbb 100644
 | |
| --- a/src/whereexpr.c
 | |
| +++ b/src/whereexpr.c
 | |
| @@ -511,6 +511,7 @@ static void whereCombineDisjuncts(
 | |
|    int op;                /* Operator for the combined expression */
 | |
|    int idxNew;            /* Index in pWC of the next virtual term */
 | |
|  
 | |
| +  if( (pOne->wtFlags | pTwo->wtFlags) & TERM_VNULL ) return;
 | |
|    if( (pOne->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE))==0 ) return;
 | |
|    if( (pTwo->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE))==0 ) return;
 | |
|    if( (eOp & (WO_EQ|WO_LT|WO_LE))!=eOp
 | |
| diff --git a/test/notnull2.test b/test/notnull2.test
 | |
| index 9ae190f..0a7a492 100644
 | |
| --- a/test/notnull2.test
 | |
| +++ b/test/notnull2.test
 | |
| @@ -97,5 +97,15 @@ do_execsql_test 2.1 {
 | |
|    SELECT * FROM (SELECT a, b FROM t1) LEFT JOIN t3 ON a IS NULL;
 | |
|  }
 | |
|  
 | |
| +#-------------------------------------------------------------------------
 | |
| +reset_db
 | |
| +do_execsql_test 3.0 {
 | |
| +  CREATE TABLE t0(c0 PRIMARY KEY);
 | |
| +  INSERT INTO t0(c0) VALUES (0);
 | |
| +}
 | |
| +do_execsql_test 3.1 {
 | |
| +  SELECT * FROM t0 WHERE ((c0 NOT NULL) AND 1) OR (c0 == NULL);
 | |
| +} {0}
 | |
| +
 | |
|  finish_test
 | |
|  
 | |
| -- 
 | |
| 2.30.2
 | |
| 
 |