/ Check-in [1b243032]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:When considering partial indexes, do not assume that a "CASE x ..." expression implies "x IS NOT NULL".
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 1b24303220b7b4f59520176a0150fc619c668865450b4fdaa9ce4113a56e9687
User & Date: dan 2019-05-11 16:14:42
Context
2019-05-11
19:36
A new implementation for the sqlite3ExprImpliesExpr() theorem prover that does a better job of answering TRUE to "(NOT A) OR B" when B is a NOT NULL expression. check-in: b3413197 user: drh tags: trunk
16:14
When considering partial indexes, do not assume that a "CASE x ..." expression implies "x IS NOT NULL". check-in: 1b243032 user: dan tags: trunk
13:04
Do not assume that "x IS NOT ?" implies "x NOT NULL" when considering partial indexes. Fix for ticket [8025674847]. check-in: 0ba6d709 user: dan tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/expr.c.

4944
4945
4946
4947
4948
4949
4950

4951
4952
4953
4954
4955
4956
4957
    return 1;
  }
  if( pE2->op==TK_NOTNULL
   && pE1->op!=TK_ISNULL
   && pE1->op!=TK_IS
   && pE1->op!=TK_ISNOT
   && pE1->op!=TK_OR

  ){
    Expr *pX = sqlite3ExprSkipCollate(pE1->pLeft);
    testcase( pX!=pE1->pLeft );
    if( sqlite3ExprCompare(pParse, pX, pE2->pLeft, iTab)==0 ) return 1;
  }
  return 0;
}







>







4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
    return 1;
  }
  if( pE2->op==TK_NOTNULL
   && pE1->op!=TK_ISNULL
   && pE1->op!=TK_IS
   && pE1->op!=TK_ISNOT
   && pE1->op!=TK_OR
   && pE1->op!=TK_CASE
  ){
    Expr *pX = sqlite3ExprSkipCollate(pE1->pLeft);
    testcase( pX!=pE1->pLeft );
    if( sqlite3ExprCompare(pParse, pX, pE2->pLeft, iTab)==0 ) return 1;
  }
  return 0;
}

Changes to test/index6.test.

428
429
430
431
432
433
434




435
436
437
reset_db
do_execsql_test index6-14.1 {
  CREATE TABLE IF NOT EXISTS t0 (c0, c1);
  CREATE INDEX IF NOT EXISTS i0 ON t0(c0, c1) WHERE c0 NOT NULL;
  INSERT INTO t0(c0, c1) VALUES(NULL, 'row');
  SELECT * FROM t0 WHERE t0.c0 IS NOT 1;
} {{} row}





finish_test








>
>
>
>



428
429
430
431
432
433
434
435
436
437
438
439
440
441
reset_db
do_execsql_test index6-14.1 {
  CREATE TABLE IF NOT EXISTS t0 (c0, c1);
  CREATE INDEX IF NOT EXISTS i0 ON t0(c0, c1) WHERE c0 NOT NULL;
  INSERT INTO t0(c0, c1) VALUES(NULL, 'row');
  SELECT * FROM t0 WHERE t0.c0 IS NOT 1;
} {{} row}

do_execsql_test index6-14.2 {
  SELECT * FROM t0 WHERE CASE c0 WHEN 0 THEN 0 ELSE 1 END;
} {{} row}

finish_test