/ Check-in [1b243032]
Login

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 Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/expr.c.

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

Changes to test/index6.test.

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