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 #1537 is
17 set testdir [file dirname $argv0]
18 source $testdir/tester.tcl
22 CREATE TABLE t1(id, a1, a2);
23 INSERT INTO t1 VALUES(1, NULL, NULL);
24 INSERT INTO t1 VALUES(2, 1, 3);
25 CREATE TABLE t2(id, b);
26 INSERT INTO t2 VALUES(3, 1);
27 INSERT INTO t2 VALUES(4, NULL);
28 SELECT * FROM t1 LEFT JOIN t2 ON a1=b OR a2=+b;
30 } {1 {} {} {} {} 2 1 3 3 1}
33 SELECT * FROM t1 LEFT JOIN t2 ON a1=b OR a2=b;
35 } {1 {} {} {} {} 2 1 3 3 1}
38 SELECT * FROM t2 LEFT JOIN t1 ON a1=b OR a2=b;
40 } {3 1 2 1 3 4 {} {} {} {}}
44 SELECT * FROM t1 LEFT JOIN t2 ON b IN (a1,a2);
46 } {1 {} {} {} {} 2 1 3 3 1}
49 SELECT * FROM t2 LEFT JOIN t1 ON b IN (a2,a1);
51 } {3 1 2 1 3 4 {} {} {} {}}
55 CREATE INDEX t1a1 ON t1(a1);
56 CREATE INDEX t1a2 ON t1(a2);
57 CREATE INDEX t2b ON t2(b);
58 SELECT * FROM t1 LEFT JOIN t2 ON a1=b OR a2=b;
60 } {1 {} {} {} {} 2 1 3 3 1}
63 SELECT * FROM t2 LEFT JOIN t1 ON a1=b OR a2=b;
65 } {3 1 2 1 3 4 {} {} {} {}}
70 SELECT * FROM t1 LEFT JOIN t2 ON b IN (a1,a2);
72 } {1 {} {} {} {} 2 1 3 3 1}
75 SELECT * FROM t2 LEFT JOIN t1 ON b IN (a2,a1);
77 } {3 1 2 1 3 4 {} {} {} {}}
88 SELECT * FROM t1 LEFT JOIN t2 ON b BETWEEN a1 AND a2;
90 } {1 {} {} {} {} 2 1 3 3 1}
93 CREATE INDEX t2b ON t2(b);
94 SELECT * FROM t1 LEFT JOIN t2 ON b BETWEEN a1 AND a2;
96 } {1 {} {} {} {} 2 1 3 3 1}
99 SELECT * FROM t2 LEFT JOIN t1 ON b BETWEEN a1 AND a2;
101 } {3 1 2 1 3 4 {} {} {} {}}
102 do_test tkt1537-2.4 {
104 CREATE INDEX t1a1 ON t1(a1);
105 CREATE INDEX t1a2 ON t1(a2);
106 SELECT * FROM t2 LEFT JOIN t1 ON b BETWEEN a1 AND a2;
108 } {3 1 2 1 3 4 {} {} {} {}}
110 do_test tkt1537-3.1 {
112 SELECT * FROM t1 LEFT JOIN t2 ON b GLOB 'abc*' WHERE t1.id=1;
115 do_test tkt1537-3.2 {
117 SELECT * FROM t2 LEFT JOIN t1 ON a1 GLOB 'abc*' WHERE t2.id=3;