3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give.
10 #***********************************************************************
11 # This file implements regression tests for SQLite library.
13 # This file implements tests to verify that ticket [31338dca7e] has been
14 # fixed. Ticket [31338dca7e] demonstrates problems with the OR-clause
15 # optimization in joins where the WHERE clause is of the form
19 # And the x and y subterms from from different tables of the join.
22 set testdir [file dirname $argv0]
23 source $testdir/tester.tcl
25 do_test tkt-31338-1.1 {
29 INSERT INTO t1 VALUES(111);
30 INSERT INTO t1 VALUES(222);
31 INSERT INTO t2 VALUES(333);
32 INSERT INTO t2 VALUES(444);
34 WHERE (x=111 AND y!=444) OR x=222
37 } {111 333 222 333 222 444}
39 do_test tkt-31338-1.2 {
41 CREATE INDEX t1x ON t1(x);
43 WHERE (x=111 AND y!=444) OR x=222
46 } {111 333 222 333 222 444}
48 do_test tkt-31338-2.1 {
53 INSERT INTO t3 VALUES(111,222);
54 INSERT INTO t3 VALUES(333,444);
55 INSERT INTO t4 VALUES(222,333);
56 INSERT INTO t4 VALUES(444,555);
57 INSERT INTO t5 VALUES(888);
58 INSERT INTO t5 VALUES(999);
60 SELECT * FROM t3, t4, t5
61 WHERE (v=111 AND x=w AND z!=999) OR (v=333 AND x=444)
62 ORDER BY v, w, x, y, z;
64 } {111 222 222 333 888 333 444 444 555 888 333 444 444 555 999}
66 do_test tkt-31338-2.2 {
68 CREATE INDEX t3v ON t3(v);
69 CREATE INDEX t4x ON t4(x);
70 SELECT * FROM t3, t4, t5
71 WHERE (v=111 AND x=w AND z!=999) OR (v=333 AND x=444)
72 ORDER BY v, w, x, y, z;
74 } {111 222 222 333 888 333 444 444 555 888 333 444 444 555 999}