SQLite

Check-in [778b1224]
Login

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

Overview
Comment:Fix an assert() failure that could occur in a join query if the RHS of an IN() operator is a list containing correlated expressions. This problem was introduced by checkin [e130319317e7611938] which was part of the fix for ticket [787fa716be3a7f650c] - so this commit is part of that ticket's fix too.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 778b1224a318d0137c7dab8361128f593506d3677267898119b934b4d66dfe38
User & Date: dan 2019-05-18 21:22:25
References
2019-05-19
17:01 Ticket [787fa716] Assertion fault when multi-use subquery implemented by co-routine status still Fixed with 3 other changes (artifact: 929aa109 user: mrigger)
Context
2019-05-20
10:36
Update the sqlite3ExprCompare() routine so that it does not think "? IS NOT TRUE" is the same as "? IS TRUE". Fix for [d3e7f2ba5b3]. (check-in: 99eba69b user: dan tags: trunk)
2019-05-18
21:22
Fix an assert() failure that could occur in a join query if the RHS of an IN() operator is a list containing correlated expressions. This problem was introduced by checkin [e130319317e7611938] which was part of the fix for ticket [787fa716be3a7f650c] - so this commit is part of that ticket's fix too. (check-in: 778b1224 user: dan tags: trunk)
19:49
Avoid including the comment in the output of "PRAGMA table_info" in situations where there is a comment following a DEFAULT value within a CREATE TABLE statement. (check-in: d91095ba user: dan tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/expr.c.

2804
2805
2806
2807
2808
2809
2810

2811
2812
2813
2814
2815
2816
2817
      /* If the expression is not constant then we will need to
      ** disable the test that was generated above that makes sure
      ** this code only executes once.  Because for a non-constant
      ** expression we need to rerun this code each time.
      */
      if( addrOnce && !sqlite3ExprIsConstant(pE2) ){
        sqlite3VdbeChangeToNoop(v, addrOnce);

        addrOnce = 0;
      }

      /* Evaluate the expression and insert it into the temp table */
      r3 = sqlite3ExprCodeTarget(pParse, pE2, r1);
      sqlite3VdbeAddOp4(v, OP_MakeRecord, r3, 1, r2, &affinity, 1);
      sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iTab, r2, r3, 1);







>







2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
      /* If the expression is not constant then we will need to
      ** disable the test that was generated above that makes sure
      ** this code only executes once.  Because for a non-constant
      ** expression we need to rerun this code each time.
      */
      if( addrOnce && !sqlite3ExprIsConstant(pE2) ){
        sqlite3VdbeChangeToNoop(v, addrOnce);
        ExprClearProperty(pExpr, EP_Subrtn);
        addrOnce = 0;
      }

      /* Evaluate the expression and insert it into the temp table */
      r3 = sqlite3ExprCodeTarget(pParse, pE2, r1);
      sqlite3VdbeAddOp4(v, OP_MakeRecord, r3, 1, r2, &affinity, 1);
      sqlite3VdbeAddOp4Int(v, OP_IdxInsert, iTab, r2, r3, 1);

Changes to test/join5.test.

301
302
303
304
305
306
307





















308
309
do_eqp_test 7.4 {
  SELECT * FROM t3 LEFT JOIN t4 ON (t4.x = t3.x) WHERE (t4.y = ? OR t4.z = ?);
} {
  QUERY PLAN
  |--SCAN TABLE t3
  `--SEARCH TABLE t4 USING INDEX t4xz (x=?)
} 






















finish_test







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


301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
do_eqp_test 7.4 {
  SELECT * FROM t3 LEFT JOIN t4 ON (t4.x = t3.x) WHERE (t4.y = ? OR t4.z = ?);
} {
  QUERY PLAN
  |--SCAN TABLE t3
  `--SEARCH TABLE t4 USING INDEX t4xz (x=?)
} 

reset_db
do_execsql_test 8.0 {
  CREATE TABLE t0 (c0, c1, PRIMARY KEY (c0, c1));
  CREATE TABLE t1 (c0);

  INSERT INTO t1 VALUES (2);

  INSERT INTO t0 VALUES(0, 10);
  INSERT INTO t0 VALUES(1, 10);
  INSERT INTO t0 VALUES(2, 10);
  INSERT INTO t0 VALUES(3, 10);
}

do_execsql_test 8.1 {
  SELECT * FROM t0, t1 
  WHERE (t0.c1 >= 1 OR t0.c1 < 1) AND t0.c0 IN (1, t1.c0) ORDER BY 1;
} {
  1 10 2
  2 10 2
}

finish_test