/ Check-in [84ae41fd]
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:Avoid assuming that for "~ (? AND FALSE)" to be true, "?" must not be NULL, just as we do for "NOT (? AND FALSE)". Fix for ticket [c0390363].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 84ae41fd2f50cb7c0c3f6522d0f94817e1bbf96eae5316279e3e32cee4e46e91
User & Date: dan 2019-08-29 15:06:35
Original Comment: Avoid assuming that for "~ (? OR TRUE)" to be true, "?" must not be NULL, just as we do for "NOT (? OR TRUE)". Fix for ticket [c0390363].
References
2019-08-29
15:07 Closed ticket [c0390363]: Indexes causes row to not be fetched plus 6 other changes artifact: f038f6f7 user: dan
Context
2019-08-29
15:50
Fix another case where SQLite assumes that if "~(? AND FALSE)" is true, "?" must be non-null. check-in: 616f5663 user: dan tags: trunk
15:06
Avoid assuming that for "~ (? AND FALSE)" to be true, "?" must not be NULL, just as we do for "NOT (? AND FALSE)". Fix for ticket [c0390363]. check-in: 84ae41fd user: dan tags: trunk
14:25
Fix a potential buffer overrun in fts5 caused by corrupted database records. check-in: c465d0eb user: dan tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/expr.c.

5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039

5040
5041
5042
5043
5044
5045
5046
    case TK_RSHIFT: 
    case TK_CONCAT: {
      if( exprImpliesNotNull(pParse, p->pRight, pNN, iTab, seenNot) ) return 1;
      /* Fall thru into the next case */
    }
    case TK_SPAN:
    case TK_COLLATE:
    case TK_BITNOT:
    case TK_UPLUS:
    case TK_UMINUS: {
      return exprImpliesNotNull(pParse, p->pLeft, pNN, iTab, seenNot);
    }
    case TK_TRUTH: {
      if( seenNot ) return 0;
      if( p->op2!=TK_IS ) return 0;
      return exprImpliesNotNull(pParse, p->pLeft, pNN, iTab, seenNot);
    }

    case TK_NOT: {
      return exprImpliesNotNull(pParse, p->pLeft, pNN, iTab, 1);
    }
  }
  return 0;
}








<









>







5023
5024
5025
5026
5027
5028
5029

5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
    case TK_RSHIFT: 
    case TK_CONCAT: {
      if( exprImpliesNotNull(pParse, p->pRight, pNN, iTab, seenNot) ) return 1;
      /* Fall thru into the next case */
    }
    case TK_SPAN:
    case TK_COLLATE:

    case TK_UPLUS:
    case TK_UMINUS: {
      return exprImpliesNotNull(pParse, p->pLeft, pNN, iTab, seenNot);
    }
    case TK_TRUTH: {
      if( seenNot ) return 0;
      if( p->op2!=TK_IS ) return 0;
      return exprImpliesNotNull(pParse, p->pLeft, pNN, iTab, seenNot);
    }
    case TK_BITNOT:
    case TK_NOT: {
      return exprImpliesNotNull(pParse, p->pLeft, pNN, iTab, 1);
    }
  }
  return 0;
}

Changes to test/indexexpr2.test.

290
291
292
293
294
295
296

















297
298
299
300
  COMMIT;
  SELECT sql FROM sqlite_master WHERE tbl_name = 't0';
  CREATE INDEX i0 ON t0(c0);
} {{CREATE TABLE t0(c0)}}
do_execsql_test 7.3 {
  REINDEX;
} {}




















finish_test







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>




290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
  COMMIT;
  SELECT sql FROM sqlite_master WHERE tbl_name = 't0';
  CREATE INDEX i0 ON t0(c0);
} {{CREATE TABLE t0(c0)}}
do_execsql_test 7.3 {
  REINDEX;
} {}

#-------------------------------------------------------------------------
reset_db
do_execsql_test 8.0 {
  CREATE TABLE t0(c0);
  CREATE INDEX i0 ON t0(c0) WHERE c0 NOT NULL;
  INSERT INTO t0(c0) VALUES (NULL);
}

breakpoint
do_execsql_test 8.1 {
  SELECT * FROM t0 WHERE ~('' BETWEEN t0.c0 AND TRUE);
} {{}}

do_execsql_test 8.2 {
  SELECT ~('' BETWEEN t0.c0 AND TRUE) FROM t0;
} {-1}



finish_test