sl@0
|
1 |
# 2005 November 26
|
sl@0
|
2 |
#
|
sl@0
|
3 |
# The author disclaims copyright to this source code. In place of
|
sl@0
|
4 |
# a legal notice, here is a blessing:
|
sl@0
|
5 |
#
|
sl@0
|
6 |
# May you do good and not evil.
|
sl@0
|
7 |
# May you find forgiveness for yourself and forgive others.
|
sl@0
|
8 |
# May you share freely, never taking more than you give.
|
sl@0
|
9 |
#
|
sl@0
|
10 |
#***********************************************************************
|
sl@0
|
11 |
# This file implements regression tests for SQLite library.
|
sl@0
|
12 |
#
|
sl@0
|
13 |
# This file implements tests to verify that ticket #1537 is
|
sl@0
|
14 |
# fixed.
|
sl@0
|
15 |
#
|
sl@0
|
16 |
|
sl@0
|
17 |
set testdir [file dirname $argv0]
|
sl@0
|
18 |
source $testdir/tester.tcl
|
sl@0
|
19 |
|
sl@0
|
20 |
do_test tkt1537-1.1 {
|
sl@0
|
21 |
execsql {
|
sl@0
|
22 |
CREATE TABLE t1(id, a1, a2);
|
sl@0
|
23 |
INSERT INTO t1 VALUES(1, NULL, NULL);
|
sl@0
|
24 |
INSERT INTO t1 VALUES(2, 1, 3);
|
sl@0
|
25 |
CREATE TABLE t2(id, b);
|
sl@0
|
26 |
INSERT INTO t2 VALUES(3, 1);
|
sl@0
|
27 |
INSERT INTO t2 VALUES(4, NULL);
|
sl@0
|
28 |
SELECT * FROM t1 LEFT JOIN t2 ON a1=b OR a2=+b;
|
sl@0
|
29 |
}
|
sl@0
|
30 |
} {1 {} {} {} {} 2 1 3 3 1}
|
sl@0
|
31 |
do_test tkt1537-1.2 {
|
sl@0
|
32 |
execsql {
|
sl@0
|
33 |
SELECT * FROM t1 LEFT JOIN t2 ON a1=b OR a2=b;
|
sl@0
|
34 |
}
|
sl@0
|
35 |
} {1 {} {} {} {} 2 1 3 3 1}
|
sl@0
|
36 |
do_test tkt1537-1.3 {
|
sl@0
|
37 |
execsql {
|
sl@0
|
38 |
SELECT * FROM t2 LEFT JOIN t1 ON a1=b OR a2=b;
|
sl@0
|
39 |
}
|
sl@0
|
40 |
} {3 1 2 1 3 4 {} {} {} {}}
|
sl@0
|
41 |
ifcapable subquery {
|
sl@0
|
42 |
do_test tkt1537-1.4 {
|
sl@0
|
43 |
execsql {
|
sl@0
|
44 |
SELECT * FROM t1 LEFT JOIN t2 ON b IN (a1,a2);
|
sl@0
|
45 |
}
|
sl@0
|
46 |
} {1 {} {} {} {} 2 1 3 3 1}
|
sl@0
|
47 |
do_test tkt1537-1.5 {
|
sl@0
|
48 |
execsql {
|
sl@0
|
49 |
SELECT * FROM t2 LEFT JOIN t1 ON b IN (a2,a1);
|
sl@0
|
50 |
}
|
sl@0
|
51 |
} {3 1 2 1 3 4 {} {} {} {}}
|
sl@0
|
52 |
}
|
sl@0
|
53 |
do_test tkt1537-1.6 {
|
sl@0
|
54 |
execsql {
|
sl@0
|
55 |
CREATE INDEX t1a1 ON t1(a1);
|
sl@0
|
56 |
CREATE INDEX t1a2 ON t1(a2);
|
sl@0
|
57 |
CREATE INDEX t2b ON t2(b);
|
sl@0
|
58 |
SELECT * FROM t1 LEFT JOIN t2 ON a1=b OR a2=b;
|
sl@0
|
59 |
}
|
sl@0
|
60 |
} {1 {} {} {} {} 2 1 3 3 1}
|
sl@0
|
61 |
do_test tkt1537-1.7 {
|
sl@0
|
62 |
execsql {
|
sl@0
|
63 |
SELECT * FROM t2 LEFT JOIN t1 ON a1=b OR a2=b;
|
sl@0
|
64 |
}
|
sl@0
|
65 |
} {3 1 2 1 3 4 {} {} {} {}}
|
sl@0
|
66 |
|
sl@0
|
67 |
ifcapable subquery {
|
sl@0
|
68 |
do_test tkt1537-1.8 {
|
sl@0
|
69 |
execsql {
|
sl@0
|
70 |
SELECT * FROM t1 LEFT JOIN t2 ON b IN (a1,a2);
|
sl@0
|
71 |
}
|
sl@0
|
72 |
} {1 {} {} {} {} 2 1 3 3 1}
|
sl@0
|
73 |
do_test tkt1537-1.9 {
|
sl@0
|
74 |
execsql {
|
sl@0
|
75 |
SELECT * FROM t2 LEFT JOIN t1 ON b IN (a2,a1);
|
sl@0
|
76 |
}
|
sl@0
|
77 |
} {3 1 2 1 3 4 {} {} {} {}}
|
sl@0
|
78 |
}
|
sl@0
|
79 |
|
sl@0
|
80 |
execsql {
|
sl@0
|
81 |
DROP INDEX t1a1;
|
sl@0
|
82 |
DROP INDEX t1a2;
|
sl@0
|
83 |
DROP INDEX t2b;
|
sl@0
|
84 |
}
|
sl@0
|
85 |
|
sl@0
|
86 |
do_test tkt1537-2.1 {
|
sl@0
|
87 |
execsql {
|
sl@0
|
88 |
SELECT * FROM t1 LEFT JOIN t2 ON b BETWEEN a1 AND a2;
|
sl@0
|
89 |
}
|
sl@0
|
90 |
} {1 {} {} {} {} 2 1 3 3 1}
|
sl@0
|
91 |
do_test tkt1537-2.2 {
|
sl@0
|
92 |
execsql {
|
sl@0
|
93 |
CREATE INDEX t2b ON t2(b);
|
sl@0
|
94 |
SELECT * FROM t1 LEFT JOIN t2 ON b BETWEEN a1 AND a2;
|
sl@0
|
95 |
}
|
sl@0
|
96 |
} {1 {} {} {} {} 2 1 3 3 1}
|
sl@0
|
97 |
do_test tkt1537-2.3 {
|
sl@0
|
98 |
execsql {
|
sl@0
|
99 |
SELECT * FROM t2 LEFT JOIN t1 ON b BETWEEN a1 AND a2;
|
sl@0
|
100 |
}
|
sl@0
|
101 |
} {3 1 2 1 3 4 {} {} {} {}}
|
sl@0
|
102 |
do_test tkt1537-2.4 {
|
sl@0
|
103 |
execsql {
|
sl@0
|
104 |
CREATE INDEX t1a1 ON t1(a1);
|
sl@0
|
105 |
CREATE INDEX t1a2 ON t1(a2);
|
sl@0
|
106 |
SELECT * FROM t2 LEFT JOIN t1 ON b BETWEEN a1 AND a2;
|
sl@0
|
107 |
}
|
sl@0
|
108 |
} {3 1 2 1 3 4 {} {} {} {}}
|
sl@0
|
109 |
|
sl@0
|
110 |
do_test tkt1537-3.1 {
|
sl@0
|
111 |
execsql {
|
sl@0
|
112 |
SELECT * FROM t1 LEFT JOIN t2 ON b GLOB 'abc*' WHERE t1.id=1;
|
sl@0
|
113 |
}
|
sl@0
|
114 |
} {1 {} {} {} {}}
|
sl@0
|
115 |
do_test tkt1537-3.2 {
|
sl@0
|
116 |
execsql {
|
sl@0
|
117 |
SELECT * FROM t2 LEFT JOIN t1 ON a1 GLOB 'abc*' WHERE t2.id=3;
|
sl@0
|
118 |
}
|
sl@0
|
119 |
} {3 1 {} {} {}}
|
sl@0
|
120 |
|
sl@0
|
121 |
|
sl@0
|
122 |
finish_test
|