sl@0
|
1 |
# 2007 June 8
|
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. The
|
sl@0
|
12 |
# focus of this file is testing that terms in the ON clause of
|
sl@0
|
13 |
# a LEFT OUTER JOIN are not used with indices. See ticket #3015.
|
sl@0
|
14 |
#
|
sl@0
|
15 |
# $Id: where6.test,v 1.2 2008/04/17 19:14:02 drh Exp $
|
sl@0
|
16 |
|
sl@0
|
17 |
set testdir [file dirname $argv0]
|
sl@0
|
18 |
source $testdir/tester.tcl
|
sl@0
|
19 |
|
sl@0
|
20 |
# Build some test data
|
sl@0
|
21 |
#
|
sl@0
|
22 |
do_test where6-1.1 {
|
sl@0
|
23 |
execsql {
|
sl@0
|
24 |
CREATE TABLE t1(a INTEGER PRIMARY KEY,b,c);
|
sl@0
|
25 |
INSERT INTO t1 VALUES(1,3,1);
|
sl@0
|
26 |
INSERT INTO t1 VALUES(2,4,2);
|
sl@0
|
27 |
CREATE TABLE t2(x INTEGER PRIMARY KEY);
|
sl@0
|
28 |
INSERT INTO t2 VALUES(3);
|
sl@0
|
29 |
|
sl@0
|
30 |
SELECT * FROM t1 LEFT JOIN t2 ON b=x AND c=1;
|
sl@0
|
31 |
}
|
sl@0
|
32 |
} {1 3 1 3 2 4 2 {}}
|
sl@0
|
33 |
do_test where6-1.2 {
|
sl@0
|
34 |
execsql {
|
sl@0
|
35 |
SELECT * FROM t1 LEFT JOIN t2 ON x=b AND c=1;
|
sl@0
|
36 |
}
|
sl@0
|
37 |
} {1 3 1 3 2 4 2 {}}
|
sl@0
|
38 |
do_test where6-1.3 {
|
sl@0
|
39 |
execsql {
|
sl@0
|
40 |
SELECT * FROM t1 LEFT JOIN t2 ON x=b AND 1=c;
|
sl@0
|
41 |
}
|
sl@0
|
42 |
} {1 3 1 3 2 4 2 {}}
|
sl@0
|
43 |
do_test where6-1.4 {
|
sl@0
|
44 |
execsql {
|
sl@0
|
45 |
SELECT * FROM t1 LEFT JOIN t2 ON b=x AND 1=c;
|
sl@0
|
46 |
}
|
sl@0
|
47 |
} {1 3 1 3 2 4 2 {}}
|
sl@0
|
48 |
|
sl@0
|
49 |
ifcapable explain {
|
sl@0
|
50 |
do_test where6-1.5 {
|
sl@0
|
51 |
explain_no_trace {SELECT * FROM t1 LEFT JOIN t2 ON x=b AND 1=c}
|
sl@0
|
52 |
} [explain_no_trace {SELECT * FROM t1 LEFT JOIN t2 ON b=x AND c=1}]
|
sl@0
|
53 |
do_test where6-1.6 {
|
sl@0
|
54 |
explain_no_trace {SELECT * FROM t1 LEFT JOIN t2 ON x=b WHERE 1=c}
|
sl@0
|
55 |
} [explain_no_trace {SELECT * FROM t1 LEFT JOIN t2 ON b=x WHERE c=1}]
|
sl@0
|
56 |
}
|
sl@0
|
57 |
|
sl@0
|
58 |
do_test where6-1.11 {
|
sl@0
|
59 |
execsql {
|
sl@0
|
60 |
SELECT * FROM t1 LEFT JOIN t2 ON b=x WHERE c=1;
|
sl@0
|
61 |
}
|
sl@0
|
62 |
} {1 3 1 3}
|
sl@0
|
63 |
do_test where6-1.12 {
|
sl@0
|
64 |
execsql {
|
sl@0
|
65 |
SELECT * FROM t1 LEFT JOIN t2 ON x=b WHERE c=1;
|
sl@0
|
66 |
}
|
sl@0
|
67 |
} {1 3 1 3}
|
sl@0
|
68 |
do_test where6-1.13 {
|
sl@0
|
69 |
execsql {
|
sl@0
|
70 |
SELECT * FROM t1 LEFT JOIN t2 ON b=x WHERE 1=c;
|
sl@0
|
71 |
}
|
sl@0
|
72 |
} {1 3 1 3}
|
sl@0
|
73 |
|
sl@0
|
74 |
|
sl@0
|
75 |
|
sl@0
|
76 |
do_test where6-2.1 {
|
sl@0
|
77 |
execsql {
|
sl@0
|
78 |
CREATE INDEX i1 ON t1(c);
|
sl@0
|
79 |
|
sl@0
|
80 |
SELECT * FROM t1 LEFT JOIN t2 ON b=x AND c=1;
|
sl@0
|
81 |
}
|
sl@0
|
82 |
} {1 3 1 3 2 4 2 {}}
|
sl@0
|
83 |
do_test where6-2.2 {
|
sl@0
|
84 |
execsql {
|
sl@0
|
85 |
SELECT * FROM t1 LEFT JOIN t2 ON x=b AND c=1;
|
sl@0
|
86 |
}
|
sl@0
|
87 |
} {1 3 1 3 2 4 2 {}}
|
sl@0
|
88 |
do_test where6-2.3 {
|
sl@0
|
89 |
execsql {
|
sl@0
|
90 |
SELECT * FROM t1 LEFT JOIN t2 ON x=b AND 1=c;
|
sl@0
|
91 |
}
|
sl@0
|
92 |
} {1 3 1 3 2 4 2 {}}
|
sl@0
|
93 |
do_test where6-2.4 {
|
sl@0
|
94 |
execsql {
|
sl@0
|
95 |
SELECT * FROM t1 LEFT JOIN t2 ON b=x AND 1=c;
|
sl@0
|
96 |
}
|
sl@0
|
97 |
} {1 3 1 3 2 4 2 {}}
|
sl@0
|
98 |
|
sl@0
|
99 |
ifcapable explain {
|
sl@0
|
100 |
do_test where6-2.5 {
|
sl@0
|
101 |
explain_no_trace {SELECT * FROM t1 LEFT JOIN t2 ON x=b AND 1=c}
|
sl@0
|
102 |
} [explain_no_trace {SELECT * FROM t1 LEFT JOIN t2 ON b=x AND c=1}]
|
sl@0
|
103 |
do_test where6-2.6 {
|
sl@0
|
104 |
explain_no_trace {SELECT * FROM t1 LEFT JOIN t2 ON x=b WHERE 1=c}
|
sl@0
|
105 |
} [explain_no_trace {SELECT * FROM t1 LEFT JOIN t2 ON b=x WHERE c=1}]
|
sl@0
|
106 |
}
|
sl@0
|
107 |
|
sl@0
|
108 |
|
sl@0
|
109 |
do_test where6-2.11 {
|
sl@0
|
110 |
execsql {
|
sl@0
|
111 |
SELECT * FROM t1 LEFT JOIN t2 ON b=x WHERE c=1;
|
sl@0
|
112 |
}
|
sl@0
|
113 |
} {1 3 1 3}
|
sl@0
|
114 |
do_test where6-2.12 {
|
sl@0
|
115 |
execsql {
|
sl@0
|
116 |
SELECT * FROM t1 LEFT JOIN t2 ON x=b WHERE c=1;
|
sl@0
|
117 |
}
|
sl@0
|
118 |
} {1 3 1 3}
|
sl@0
|
119 |
do_test where6-2.13 {
|
sl@0
|
120 |
execsql {
|
sl@0
|
121 |
SELECT * FROM t1 LEFT JOIN t2 ON x=b WHERE 1=c;
|
sl@0
|
122 |
}
|
sl@0
|
123 |
} {1 3 1 3}
|
sl@0
|
124 |
do_test where6-2.14 {
|
sl@0
|
125 |
execsql {
|
sl@0
|
126 |
SELECT * FROM t1 LEFT JOIN t2 ON b=x WHERE 1=c;
|
sl@0
|
127 |
}
|
sl@0
|
128 |
} {1 3 1 3}
|
sl@0
|
129 |
|
sl@0
|
130 |
finish_test
|