sl@0
|
1 |
#
|
sl@0
|
2 |
# 2001 September 15
|
sl@0
|
3 |
#
|
sl@0
|
4 |
# The author disclaims copyright to this source code. In place of
|
sl@0
|
5 |
# a legal notice, here is a blessing:
|
sl@0
|
6 |
#
|
sl@0
|
7 |
# May you do good and not evil.
|
sl@0
|
8 |
# May you find forgiveness for yourself and forgive others.
|
sl@0
|
9 |
# May you share freely, never taking more than you give.
|
sl@0
|
10 |
#
|
sl@0
|
11 |
#***********************************************************************
|
sl@0
|
12 |
# This file implements regression tests for SQLite library. The
|
sl@0
|
13 |
# focus of this script is page cache subsystem.
|
sl@0
|
14 |
#
|
sl@0
|
15 |
# $Id: collate2.test,v 1.6 2008/08/20 16:35:10 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 |
#
|
sl@0
|
21 |
# Tests are organised as follows:
|
sl@0
|
22 |
#
|
sl@0
|
23 |
# collate2-1.* WHERE <expr> expressions (sqliteExprIfTrue).
|
sl@0
|
24 |
# collate2-2.* WHERE NOT <expr> expressions (sqliteExprIfFalse).
|
sl@0
|
25 |
# collate2-3.* SELECT <expr> expressions (sqliteExprCode).
|
sl@0
|
26 |
# collate2-4.* Precedence of collation/data types in binary comparisons
|
sl@0
|
27 |
# collate2-5.* JOIN syntax.
|
sl@0
|
28 |
#
|
sl@0
|
29 |
|
sl@0
|
30 |
# Create a collation type BACKWARDS for use in testing. This collation type
|
sl@0
|
31 |
# is similar to the built-in TEXT collation type except the order of
|
sl@0
|
32 |
# characters in each string is reversed before the comparison is performed.
|
sl@0
|
33 |
db collate BACKWARDS backwards_collate
|
sl@0
|
34 |
proc backwards_collate {a b} {
|
sl@0
|
35 |
set ra {};
|
sl@0
|
36 |
set rb {}
|
sl@0
|
37 |
foreach c [split $a {}] { set ra $c$ra }
|
sl@0
|
38 |
foreach c [split $b {}] { set rb $c$rb }
|
sl@0
|
39 |
return [string compare $ra $rb]
|
sl@0
|
40 |
}
|
sl@0
|
41 |
|
sl@0
|
42 |
# The following values are used in these tests:
|
sl@0
|
43 |
# NULL aa ab ba bb aA aB bA bB Aa Ab Ba Bb AA AB BA BB
|
sl@0
|
44 |
#
|
sl@0
|
45 |
# The collation orders for each of the tested collation types are:
|
sl@0
|
46 |
#
|
sl@0
|
47 |
# BINARY: NULL AA AB Aa Ab BA BB Ba Bb aA aB aa ab bA bB ba bb
|
sl@0
|
48 |
# NOCASE: NULL aa aA Aa AA ab aB Ab AB ba bA Ba BA bb bB Bb BB
|
sl@0
|
49 |
# BACKWARDS: NULL AA BA aA bA AB BB aB bB Aa Ba aa ba Ab Bb ab bb
|
sl@0
|
50 |
#
|
sl@0
|
51 |
# These tests verify that the default collation type for a column is used
|
sl@0
|
52 |
# for comparison operators (<, >, <=, >=, =) involving that column and
|
sl@0
|
53 |
# an expression that is not a column with a default collation type.
|
sl@0
|
54 |
#
|
sl@0
|
55 |
# The collation sequences BINARY and NOCASE are built-in, the BACKWARDS
|
sl@0
|
56 |
# collation sequence is implemented by the TCL proc backwards_collate
|
sl@0
|
57 |
# above.
|
sl@0
|
58 |
#
|
sl@0
|
59 |
do_test collate2-1.0 {
|
sl@0
|
60 |
execsql {
|
sl@0
|
61 |
CREATE TABLE collate2t1(
|
sl@0
|
62 |
a COLLATE BINARY,
|
sl@0
|
63 |
b COLLATE NOCASE,
|
sl@0
|
64 |
c COLLATE BACKWARDS
|
sl@0
|
65 |
);
|
sl@0
|
66 |
INSERT INTO collate2t1 VALUES( NULL, NULL, NULL );
|
sl@0
|
67 |
|
sl@0
|
68 |
INSERT INTO collate2t1 VALUES( 'aa', 'aa', 'aa' );
|
sl@0
|
69 |
INSERT INTO collate2t1 VALUES( 'ab', 'ab', 'ab' );
|
sl@0
|
70 |
INSERT INTO collate2t1 VALUES( 'ba', 'ba', 'ba' );
|
sl@0
|
71 |
INSERT INTO collate2t1 VALUES( 'bb', 'bb', 'bb' );
|
sl@0
|
72 |
|
sl@0
|
73 |
INSERT INTO collate2t1 VALUES( 'aA', 'aA', 'aA' );
|
sl@0
|
74 |
INSERT INTO collate2t1 VALUES( 'aB', 'aB', 'aB' );
|
sl@0
|
75 |
INSERT INTO collate2t1 VALUES( 'bA', 'bA', 'bA' );
|
sl@0
|
76 |
INSERT INTO collate2t1 VALUES( 'bB', 'bB', 'bB' );
|
sl@0
|
77 |
|
sl@0
|
78 |
INSERT INTO collate2t1 VALUES( 'Aa', 'Aa', 'Aa' );
|
sl@0
|
79 |
INSERT INTO collate2t1 VALUES( 'Ab', 'Ab', 'Ab' );
|
sl@0
|
80 |
INSERT INTO collate2t1 VALUES( 'Ba', 'Ba', 'Ba' );
|
sl@0
|
81 |
INSERT INTO collate2t1 VALUES( 'Bb', 'Bb', 'Bb' );
|
sl@0
|
82 |
|
sl@0
|
83 |
INSERT INTO collate2t1 VALUES( 'AA', 'AA', 'AA' );
|
sl@0
|
84 |
INSERT INTO collate2t1 VALUES( 'AB', 'AB', 'AB' );
|
sl@0
|
85 |
INSERT INTO collate2t1 VALUES( 'BA', 'BA', 'BA' );
|
sl@0
|
86 |
INSERT INTO collate2t1 VALUES( 'BB', 'BB', 'BB' );
|
sl@0
|
87 |
}
|
sl@0
|
88 |
if {[info exists collate_test_use_index]} {
|
sl@0
|
89 |
execsql {
|
sl@0
|
90 |
CREATE INDEX collate2t1_i1 ON collate2t1(a);
|
sl@0
|
91 |
CREATE INDEX collate2t1_i2 ON collate2t1(b);
|
sl@0
|
92 |
CREATE INDEX collate2t1_i3 ON collate2t1(c);
|
sl@0
|
93 |
}
|
sl@0
|
94 |
}
|
sl@0
|
95 |
} {}
|
sl@0
|
96 |
do_test collate2-1.1 {
|
sl@0
|
97 |
execsql {
|
sl@0
|
98 |
SELECT a FROM collate2t1 WHERE a > 'aa' ORDER BY 1;
|
sl@0
|
99 |
}
|
sl@0
|
100 |
} {ab bA bB ba bb}
|
sl@0
|
101 |
do_test collate2-1.1.1 {
|
sl@0
|
102 |
execsql {
|
sl@0
|
103 |
SELECT a FROM collate2t1 WHERE a COLLATE binary > 'aa' ORDER BY 1;
|
sl@0
|
104 |
}
|
sl@0
|
105 |
} {ab bA bB ba bb}
|
sl@0
|
106 |
do_test collate2-1.1.2 {
|
sl@0
|
107 |
execsql {
|
sl@0
|
108 |
SELECT a FROM collate2t1 WHERE b COLLATE binary > 'aa' ORDER BY 1;
|
sl@0
|
109 |
}
|
sl@0
|
110 |
} {ab bA bB ba bb}
|
sl@0
|
111 |
do_test collate2-1.1.3 {
|
sl@0
|
112 |
execsql {
|
sl@0
|
113 |
SELECT a FROM collate2t1 WHERE c COLLATE binary > 'aa' ORDER BY 1;
|
sl@0
|
114 |
}
|
sl@0
|
115 |
} {ab bA bB ba bb}
|
sl@0
|
116 |
do_test collate2-1.2 {
|
sl@0
|
117 |
execsql {
|
sl@0
|
118 |
SELECT b FROM collate2t1 WHERE b > 'aa' ORDER BY 1, oid;
|
sl@0
|
119 |
}
|
sl@0
|
120 |
} {ab aB Ab AB ba bA Ba BA bb bB Bb BB}
|
sl@0
|
121 |
do_test collate2-1.2.1 {
|
sl@0
|
122 |
execsql {
|
sl@0
|
123 |
SELECT b FROM collate2t1 WHERE a COLLATE nocase > 'aa'
|
sl@0
|
124 |
ORDER BY 1, oid;
|
sl@0
|
125 |
}
|
sl@0
|
126 |
} {ab aB Ab AB ba bA Ba BA bb bB Bb BB}
|
sl@0
|
127 |
do_test collate2-1.2.2 {
|
sl@0
|
128 |
execsql {
|
sl@0
|
129 |
SELECT b FROM collate2t1 WHERE b COLLATE nocase > 'aa'
|
sl@0
|
130 |
ORDER BY 1, oid;
|
sl@0
|
131 |
}
|
sl@0
|
132 |
} {ab aB Ab AB ba bA Ba BA bb bB Bb BB}
|
sl@0
|
133 |
do_test collate2-1.2.3 {
|
sl@0
|
134 |
execsql {
|
sl@0
|
135 |
SELECT b FROM collate2t1 WHERE c COLLATE nocase > 'aa'
|
sl@0
|
136 |
ORDER BY 1, oid;
|
sl@0
|
137 |
}
|
sl@0
|
138 |
} {ab aB Ab AB ba bA Ba BA bb bB Bb BB}
|
sl@0
|
139 |
do_test collate2-1.2.4 {
|
sl@0
|
140 |
execsql {
|
sl@0
|
141 |
SELECT b FROM collate2t1 WHERE b > 'aa' ORDER BY +b;
|
sl@0
|
142 |
}
|
sl@0
|
143 |
} {ab aB Ab AB ba bA Ba BA bb bB Bb BB}
|
sl@0
|
144 |
do_test collate2-1.2.5 {
|
sl@0
|
145 |
execsql {
|
sl@0
|
146 |
SELECT b FROM collate2t1 WHERE a COLLATE nocase > 'aa' ORDER BY +b;
|
sl@0
|
147 |
}
|
sl@0
|
148 |
} {ab aB Ab AB ba bA Ba BA bb bB Bb BB}
|
sl@0
|
149 |
do_test collate2-1.2.6 {
|
sl@0
|
150 |
execsql {
|
sl@0
|
151 |
SELECT b FROM collate2t1 WHERE b COLLATE nocase > 'aa' ORDER BY +b;
|
sl@0
|
152 |
}
|
sl@0
|
153 |
} {ab aB Ab AB ba bA Ba BA bb bB Bb BB}
|
sl@0
|
154 |
do_test collate2-1.2.7 {
|
sl@0
|
155 |
execsql {
|
sl@0
|
156 |
SELECT b FROM collate2t1 WHERE c COLLATE nocase > 'aa' ORDER BY +b;
|
sl@0
|
157 |
}
|
sl@0
|
158 |
} {ab aB Ab AB ba bA Ba BA bb bB Bb BB}
|
sl@0
|
159 |
do_test collate2-1.3 {
|
sl@0
|
160 |
execsql {
|
sl@0
|
161 |
SELECT c FROM collate2t1 WHERE c > 'aa' ORDER BY 1;
|
sl@0
|
162 |
}
|
sl@0
|
163 |
} {ba Ab Bb ab bb}
|
sl@0
|
164 |
do_test collate2-1.3.1 {
|
sl@0
|
165 |
execsql {
|
sl@0
|
166 |
SELECT c FROM collate2t1 WHERE a COLLATE backwards > 'aa'
|
sl@0
|
167 |
ORDER BY 1;
|
sl@0
|
168 |
}
|
sl@0
|
169 |
} {ba Ab Bb ab bb}
|
sl@0
|
170 |
do_test collate2-1.3.2 {
|
sl@0
|
171 |
execsql {
|
sl@0
|
172 |
SELECT c FROM collate2t1 WHERE b COLLATE backwards > 'aa'
|
sl@0
|
173 |
ORDER BY 1;
|
sl@0
|
174 |
}
|
sl@0
|
175 |
} {ba Ab Bb ab bb}
|
sl@0
|
176 |
do_test collate2-1.3.3 {
|
sl@0
|
177 |
execsql {
|
sl@0
|
178 |
SELECT c FROM collate2t1 WHERE c COLLATE backwards > 'aa'
|
sl@0
|
179 |
ORDER BY 1;
|
sl@0
|
180 |
}
|
sl@0
|
181 |
} {ba Ab Bb ab bb}
|
sl@0
|
182 |
do_test collate2-1.4 {
|
sl@0
|
183 |
execsql {
|
sl@0
|
184 |
SELECT a FROM collate2t1 WHERE a < 'aa' ORDER BY 1;
|
sl@0
|
185 |
}
|
sl@0
|
186 |
} {AA AB Aa Ab BA BB Ba Bb aA aB}
|
sl@0
|
187 |
do_test collate2-1.5 {
|
sl@0
|
188 |
execsql {
|
sl@0
|
189 |
SELECT b FROM collate2t1 WHERE b < 'aa' ORDER BY 1, oid;
|
sl@0
|
190 |
}
|
sl@0
|
191 |
} {}
|
sl@0
|
192 |
do_test collate2-1.5.1 {
|
sl@0
|
193 |
execsql {
|
sl@0
|
194 |
SELECT b FROM collate2t1 WHERE b < 'aa' ORDER BY +b;
|
sl@0
|
195 |
}
|
sl@0
|
196 |
} {}
|
sl@0
|
197 |
do_test collate2-1.6 {
|
sl@0
|
198 |
execsql {
|
sl@0
|
199 |
SELECT c FROM collate2t1 WHERE c < 'aa' ORDER BY 1;
|
sl@0
|
200 |
}
|
sl@0
|
201 |
} {AA BA aA bA AB BB aB bB Aa Ba}
|
sl@0
|
202 |
do_test collate2-1.7 {
|
sl@0
|
203 |
execsql {
|
sl@0
|
204 |
SELECT a FROM collate2t1 WHERE a = 'aa';
|
sl@0
|
205 |
}
|
sl@0
|
206 |
} {aa}
|
sl@0
|
207 |
do_test collate2-1.8 {
|
sl@0
|
208 |
execsql {
|
sl@0
|
209 |
SELECT b FROM collate2t1 WHERE b = 'aa' ORDER BY oid;
|
sl@0
|
210 |
}
|
sl@0
|
211 |
} {aa aA Aa AA}
|
sl@0
|
212 |
do_test collate2-1.9 {
|
sl@0
|
213 |
execsql {
|
sl@0
|
214 |
SELECT c FROM collate2t1 WHERE c = 'aa';
|
sl@0
|
215 |
}
|
sl@0
|
216 |
} {aa}
|
sl@0
|
217 |
do_test collate2-1.10 {
|
sl@0
|
218 |
execsql {
|
sl@0
|
219 |
SELECT a FROM collate2t1 WHERE a >= 'aa' ORDER BY 1;
|
sl@0
|
220 |
}
|
sl@0
|
221 |
} {aa ab bA bB ba bb}
|
sl@0
|
222 |
do_test collate2-1.11 {
|
sl@0
|
223 |
execsql {
|
sl@0
|
224 |
SELECT b FROM collate2t1 WHERE b >= 'aa' ORDER BY 1, oid;
|
sl@0
|
225 |
}
|
sl@0
|
226 |
} {aa aA Aa AA ab aB Ab AB ba bA Ba BA bb bB Bb BB}
|
sl@0
|
227 |
do_test collate2-1.12 {
|
sl@0
|
228 |
execsql {
|
sl@0
|
229 |
SELECT c FROM collate2t1 WHERE c >= 'aa' ORDER BY 1;
|
sl@0
|
230 |
}
|
sl@0
|
231 |
} {aa ba Ab Bb ab bb}
|
sl@0
|
232 |
do_test collate2-1.13 {
|
sl@0
|
233 |
execsql {
|
sl@0
|
234 |
SELECT a FROM collate2t1 WHERE a <= 'aa' ORDER BY 1;
|
sl@0
|
235 |
}
|
sl@0
|
236 |
} {AA AB Aa Ab BA BB Ba Bb aA aB aa}
|
sl@0
|
237 |
do_test collate2-1.14 {
|
sl@0
|
238 |
execsql {
|
sl@0
|
239 |
SELECT b FROM collate2t1 WHERE b <= 'aa' ORDER BY 1, oid;
|
sl@0
|
240 |
}
|
sl@0
|
241 |
} {aa aA Aa AA}
|
sl@0
|
242 |
do_test collate2-1.15 {
|
sl@0
|
243 |
execsql {
|
sl@0
|
244 |
SELECT c FROM collate2t1 WHERE c <= 'aa' ORDER BY 1;
|
sl@0
|
245 |
}
|
sl@0
|
246 |
} {AA BA aA bA AB BB aB bB Aa Ba aa}
|
sl@0
|
247 |
do_test collate2-1.16 {
|
sl@0
|
248 |
execsql {
|
sl@0
|
249 |
SELECT a FROM collate2t1 WHERE a BETWEEN 'Aa' AND 'Bb' ORDER BY 1;
|
sl@0
|
250 |
}
|
sl@0
|
251 |
} {Aa Ab BA BB Ba Bb}
|
sl@0
|
252 |
do_test collate2-1.17 {
|
sl@0
|
253 |
execsql {
|
sl@0
|
254 |
SELECT b FROM collate2t1 WHERE b BETWEEN 'Aa' AND 'Bb' ORDER BY 1, oid;
|
sl@0
|
255 |
}
|
sl@0
|
256 |
} {aa aA Aa AA ab aB Ab AB ba bA Ba BA bb bB Bb BB}
|
sl@0
|
257 |
do_test collate2-1.17.1 {
|
sl@0
|
258 |
execsql {
|
sl@0
|
259 |
SELECT b FROM collate2t1 WHERE b BETWEEN 'Aa' AND 'Bb' ORDER BY +b;
|
sl@0
|
260 |
}
|
sl@0
|
261 |
} {aa aA Aa AA ab aB Ab AB ba bA Ba BA bb bB Bb BB}
|
sl@0
|
262 |
do_test collate2-1.18 {
|
sl@0
|
263 |
execsql {
|
sl@0
|
264 |
SELECT c FROM collate2t1 WHERE c BETWEEN 'Aa' AND 'Bb' ORDER BY 1;
|
sl@0
|
265 |
}
|
sl@0
|
266 |
} {Aa Ba aa ba Ab Bb}
|
sl@0
|
267 |
do_test collate2-1.19 {
|
sl@0
|
268 |
execsql {
|
sl@0
|
269 |
SELECT a FROM collate2t1 WHERE
|
sl@0
|
270 |
CASE a WHEN 'aa' THEN 1 ELSE 0 END
|
sl@0
|
271 |
ORDER BY 1, oid;
|
sl@0
|
272 |
}
|
sl@0
|
273 |
} {aa}
|
sl@0
|
274 |
do_test collate2-1.20 {
|
sl@0
|
275 |
execsql {
|
sl@0
|
276 |
SELECT b FROM collate2t1 WHERE
|
sl@0
|
277 |
CASE b WHEN 'aa' THEN 1 ELSE 0 END
|
sl@0
|
278 |
ORDER BY 1, oid;
|
sl@0
|
279 |
}
|
sl@0
|
280 |
} {aa aA Aa AA}
|
sl@0
|
281 |
do_test collate2-1.21 {
|
sl@0
|
282 |
execsql {
|
sl@0
|
283 |
SELECT c FROM collate2t1 WHERE
|
sl@0
|
284 |
CASE c WHEN 'aa' THEN 1 ELSE 0 END
|
sl@0
|
285 |
ORDER BY 1, oid;
|
sl@0
|
286 |
}
|
sl@0
|
287 |
} {aa}
|
sl@0
|
288 |
|
sl@0
|
289 |
ifcapable subquery {
|
sl@0
|
290 |
do_test collate2-1.22 {
|
sl@0
|
291 |
execsql {
|
sl@0
|
292 |
SELECT a FROM collate2t1 WHERE a IN ('aa', 'bb') ORDER BY 1, oid;
|
sl@0
|
293 |
}
|
sl@0
|
294 |
} {aa bb}
|
sl@0
|
295 |
do_test collate2-1.23 {
|
sl@0
|
296 |
execsql {
|
sl@0
|
297 |
SELECT b FROM collate2t1 WHERE b IN ('aa', 'bb') ORDER BY 1, oid;
|
sl@0
|
298 |
}
|
sl@0
|
299 |
} {aa aA Aa AA bb bB Bb BB}
|
sl@0
|
300 |
do_test collate2-1.24 {
|
sl@0
|
301 |
execsql {
|
sl@0
|
302 |
SELECT c FROM collate2t1 WHERE c IN ('aa', 'bb') ORDER BY 1, oid;
|
sl@0
|
303 |
}
|
sl@0
|
304 |
} {aa bb}
|
sl@0
|
305 |
do_test collate2-1.25 {
|
sl@0
|
306 |
execsql {
|
sl@0
|
307 |
SELECT a FROM collate2t1
|
sl@0
|
308 |
WHERE a IN (SELECT a FROM collate2t1 WHERE a IN ('aa', 'bb'));
|
sl@0
|
309 |
}
|
sl@0
|
310 |
} {aa bb}
|
sl@0
|
311 |
do_test collate2-1.26 {
|
sl@0
|
312 |
execsql {
|
sl@0
|
313 |
SELECT b FROM collate2t1
|
sl@0
|
314 |
WHERE b IN (SELECT a FROM collate2t1 WHERE a IN ('aa', 'bb'));
|
sl@0
|
315 |
}
|
sl@0
|
316 |
} {aa bb aA bB Aa Bb AA BB}
|
sl@0
|
317 |
do_test collate2-1.27 {
|
sl@0
|
318 |
execsql {
|
sl@0
|
319 |
SELECT c FROM collate2t1
|
sl@0
|
320 |
WHERE c IN (SELECT a FROM collate2t1 WHERE a IN ('aa', 'bb'));
|
sl@0
|
321 |
}
|
sl@0
|
322 |
} {aa bb}
|
sl@0
|
323 |
} ;# ifcapable subquery
|
sl@0
|
324 |
|
sl@0
|
325 |
do_test collate2-2.1 {
|
sl@0
|
326 |
execsql {
|
sl@0
|
327 |
SELECT a FROM collate2t1 WHERE NOT a > 'aa' ORDER BY 1;
|
sl@0
|
328 |
}
|
sl@0
|
329 |
} {AA AB Aa Ab BA BB Ba Bb aA aB aa}
|
sl@0
|
330 |
do_test collate2-2.2 {
|
sl@0
|
331 |
execsql {
|
sl@0
|
332 |
SELECT b FROM collate2t1 WHERE NOT b > 'aa' ORDER BY 1, oid;
|
sl@0
|
333 |
}
|
sl@0
|
334 |
} {aa aA Aa AA}
|
sl@0
|
335 |
do_test collate2-2.3 {
|
sl@0
|
336 |
execsql {
|
sl@0
|
337 |
SELECT c FROM collate2t1 WHERE NOT c > 'aa' ORDER BY 1;
|
sl@0
|
338 |
}
|
sl@0
|
339 |
} {AA BA aA bA AB BB aB bB Aa Ba aa}
|
sl@0
|
340 |
do_test collate2-2.4 {
|
sl@0
|
341 |
execsql {
|
sl@0
|
342 |
SELECT a FROM collate2t1 WHERE NOT a < 'aa' ORDER BY 1;
|
sl@0
|
343 |
}
|
sl@0
|
344 |
} {aa ab bA bB ba bb}
|
sl@0
|
345 |
do_test collate2-2.5 {
|
sl@0
|
346 |
execsql {
|
sl@0
|
347 |
SELECT b FROM collate2t1 WHERE NOT b < 'aa' ORDER BY 1, oid;
|
sl@0
|
348 |
}
|
sl@0
|
349 |
} {aa aA Aa AA ab aB Ab AB ba bA Ba BA bb bB Bb BB}
|
sl@0
|
350 |
do_test collate2-2.6 {
|
sl@0
|
351 |
execsql {
|
sl@0
|
352 |
SELECT c FROM collate2t1 WHERE NOT c < 'aa' ORDER BY 1;
|
sl@0
|
353 |
}
|
sl@0
|
354 |
} {aa ba Ab Bb ab bb}
|
sl@0
|
355 |
do_test collate2-2.7 {
|
sl@0
|
356 |
execsql {
|
sl@0
|
357 |
SELECT a FROM collate2t1 WHERE NOT a = 'aa';
|
sl@0
|
358 |
}
|
sl@0
|
359 |
} {ab ba bb aA aB bA bB Aa Ab Ba Bb AA AB BA BB}
|
sl@0
|
360 |
do_test collate2-2.8 {
|
sl@0
|
361 |
execsql {
|
sl@0
|
362 |
SELECT b FROM collate2t1 WHERE NOT b = 'aa';
|
sl@0
|
363 |
}
|
sl@0
|
364 |
} {ab ba bb aB bA bB Ab Ba Bb AB BA BB}
|
sl@0
|
365 |
do_test collate2-2.9 {
|
sl@0
|
366 |
execsql {
|
sl@0
|
367 |
SELECT c FROM collate2t1 WHERE NOT c = 'aa';
|
sl@0
|
368 |
}
|
sl@0
|
369 |
} {ab ba bb aA aB bA bB Aa Ab Ba Bb AA AB BA BB}
|
sl@0
|
370 |
do_test collate2-2.10 {
|
sl@0
|
371 |
execsql {
|
sl@0
|
372 |
SELECT a FROM collate2t1 WHERE NOT a >= 'aa' ORDER BY 1;
|
sl@0
|
373 |
}
|
sl@0
|
374 |
} {AA AB Aa Ab BA BB Ba Bb aA aB}
|
sl@0
|
375 |
do_test collate2-2.11 {
|
sl@0
|
376 |
execsql {
|
sl@0
|
377 |
SELECT b FROM collate2t1 WHERE NOT b >= 'aa' ORDER BY 1, oid;
|
sl@0
|
378 |
}
|
sl@0
|
379 |
} {}
|
sl@0
|
380 |
do_test collate2-2.12 {
|
sl@0
|
381 |
execsql {
|
sl@0
|
382 |
SELECT c FROM collate2t1 WHERE NOT c >= 'aa' ORDER BY 1;
|
sl@0
|
383 |
}
|
sl@0
|
384 |
} {AA BA aA bA AB BB aB bB Aa Ba}
|
sl@0
|
385 |
do_test collate2-2.13 {
|
sl@0
|
386 |
execsql {
|
sl@0
|
387 |
SELECT a FROM collate2t1 WHERE NOT a <= 'aa' ORDER BY 1;
|
sl@0
|
388 |
}
|
sl@0
|
389 |
} {ab bA bB ba bb}
|
sl@0
|
390 |
do_test collate2-2.14 {
|
sl@0
|
391 |
execsql {
|
sl@0
|
392 |
SELECT b FROM collate2t1 WHERE NOT b <= 'aa' ORDER BY 1, oid;
|
sl@0
|
393 |
}
|
sl@0
|
394 |
} {ab aB Ab AB ba bA Ba BA bb bB Bb BB}
|
sl@0
|
395 |
do_test collate2-2.15 {
|
sl@0
|
396 |
execsql {
|
sl@0
|
397 |
SELECT c FROM collate2t1 WHERE NOT c <= 'aa' ORDER BY 1;
|
sl@0
|
398 |
}
|
sl@0
|
399 |
} {ba Ab Bb ab bb}
|
sl@0
|
400 |
do_test collate2-2.16 {
|
sl@0
|
401 |
execsql {
|
sl@0
|
402 |
SELECT a FROM collate2t1 WHERE a NOT BETWEEN 'Aa' AND 'Bb' ORDER BY 1;
|
sl@0
|
403 |
}
|
sl@0
|
404 |
} {AA AB aA aB aa ab bA bB ba bb}
|
sl@0
|
405 |
do_test collate2-2.17 {
|
sl@0
|
406 |
execsql {
|
sl@0
|
407 |
SELECT b FROM collate2t1 WHERE b NOT BETWEEN 'Aa' AND 'Bb' ORDER BY 1, oid;
|
sl@0
|
408 |
}
|
sl@0
|
409 |
} {}
|
sl@0
|
410 |
do_test collate2-2.18 {
|
sl@0
|
411 |
execsql {
|
sl@0
|
412 |
SELECT c FROM collate2t1 WHERE c NOT BETWEEN 'Aa' AND 'Bb' ORDER BY 1;
|
sl@0
|
413 |
}
|
sl@0
|
414 |
} {AA BA aA bA AB BB aB bB ab bb}
|
sl@0
|
415 |
do_test collate2-2.19 {
|
sl@0
|
416 |
execsql {
|
sl@0
|
417 |
SELECT a FROM collate2t1 WHERE NOT CASE a WHEN 'aa' THEN 1 ELSE 0 END;
|
sl@0
|
418 |
}
|
sl@0
|
419 |
} {{} ab ba bb aA aB bA bB Aa Ab Ba Bb AA AB BA BB}
|
sl@0
|
420 |
do_test collate2-2.20 {
|
sl@0
|
421 |
execsql {
|
sl@0
|
422 |
SELECT b FROM collate2t1 WHERE NOT CASE b WHEN 'aa' THEN 1 ELSE 0 END;
|
sl@0
|
423 |
}
|
sl@0
|
424 |
} {{} ab ba bb aB bA bB Ab Ba Bb AB BA BB}
|
sl@0
|
425 |
do_test collate2-2.21 {
|
sl@0
|
426 |
execsql {
|
sl@0
|
427 |
SELECT c FROM collate2t1 WHERE NOT CASE c WHEN 'aa' THEN 1 ELSE 0 END;
|
sl@0
|
428 |
}
|
sl@0
|
429 |
} {{} ab ba bb aA aB bA bB Aa Ab Ba Bb AA AB BA BB}
|
sl@0
|
430 |
|
sl@0
|
431 |
ifcapable subquery {
|
sl@0
|
432 |
do_test collate2-2.22 {
|
sl@0
|
433 |
execsql {
|
sl@0
|
434 |
SELECT a FROM collate2t1 WHERE NOT a IN ('aa', 'bb');
|
sl@0
|
435 |
}
|
sl@0
|
436 |
} {ab ba aA aB bA bB Aa Ab Ba Bb AA AB BA BB}
|
sl@0
|
437 |
do_test collate2-2.23 {
|
sl@0
|
438 |
execsql {
|
sl@0
|
439 |
SELECT b FROM collate2t1 WHERE NOT b IN ('aa', 'bb');
|
sl@0
|
440 |
}
|
sl@0
|
441 |
} {ab ba aB bA Ab Ba AB BA}
|
sl@0
|
442 |
do_test collate2-2.24 {
|
sl@0
|
443 |
execsql {
|
sl@0
|
444 |
SELECT c FROM collate2t1 WHERE NOT c IN ('aa', 'bb');
|
sl@0
|
445 |
}
|
sl@0
|
446 |
} {ab ba aA aB bA bB Aa Ab Ba Bb AA AB BA BB}
|
sl@0
|
447 |
do_test collate2-2.25 {
|
sl@0
|
448 |
execsql {
|
sl@0
|
449 |
SELECT a FROM collate2t1
|
sl@0
|
450 |
WHERE NOT a IN (SELECT a FROM collate2t1 WHERE a IN ('aa', 'bb'));
|
sl@0
|
451 |
}
|
sl@0
|
452 |
} {ab ba aA aB bA bB Aa Ab Ba Bb AA AB BA BB}
|
sl@0
|
453 |
do_test collate2-2.26 {
|
sl@0
|
454 |
execsql {
|
sl@0
|
455 |
SELECT b FROM collate2t1
|
sl@0
|
456 |
WHERE NOT b IN (SELECT a FROM collate2t1 WHERE a IN ('aa', 'bb'));
|
sl@0
|
457 |
}
|
sl@0
|
458 |
} {ab ba aB bA Ab Ba AB BA}
|
sl@0
|
459 |
do_test collate2-2.27 {
|
sl@0
|
460 |
execsql {
|
sl@0
|
461 |
SELECT c FROM collate2t1
|
sl@0
|
462 |
WHERE NOT c IN (SELECT a FROM collate2t1 WHERE a IN ('aa', 'bb'));
|
sl@0
|
463 |
}
|
sl@0
|
464 |
} {ab ba aA aB bA bB Aa Ab Ba Bb AA AB BA BB}
|
sl@0
|
465 |
}
|
sl@0
|
466 |
|
sl@0
|
467 |
do_test collate2-3.1 {
|
sl@0
|
468 |
execsql {
|
sl@0
|
469 |
SELECT a > 'aa' FROM collate2t1;
|
sl@0
|
470 |
}
|
sl@0
|
471 |
} {{} 0 1 1 1 0 0 1 1 0 0 0 0 0 0 0 0}
|
sl@0
|
472 |
do_test collate2-3.2 {
|
sl@0
|
473 |
execsql {
|
sl@0
|
474 |
SELECT b > 'aa' FROM collate2t1;
|
sl@0
|
475 |
}
|
sl@0
|
476 |
} {{} 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1}
|
sl@0
|
477 |
do_test collate2-3.3 {
|
sl@0
|
478 |
execsql {
|
sl@0
|
479 |
SELECT c > 'aa' FROM collate2t1;
|
sl@0
|
480 |
}
|
sl@0
|
481 |
} {{} 0 1 1 1 0 0 0 0 0 1 0 1 0 0 0 0}
|
sl@0
|
482 |
do_test collate2-3.4 {
|
sl@0
|
483 |
execsql {
|
sl@0
|
484 |
SELECT a < 'aa' FROM collate2t1;
|
sl@0
|
485 |
}
|
sl@0
|
486 |
} {{} 0 0 0 0 1 1 0 0 1 1 1 1 1 1 1 1}
|
sl@0
|
487 |
do_test collate2-3.5 {
|
sl@0
|
488 |
execsql {
|
sl@0
|
489 |
SELECT b < 'aa' FROM collate2t1;
|
sl@0
|
490 |
}
|
sl@0
|
491 |
} {{} 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0}
|
sl@0
|
492 |
do_test collate2-3.6 {
|
sl@0
|
493 |
execsql {
|
sl@0
|
494 |
SELECT c < 'aa' FROM collate2t1;
|
sl@0
|
495 |
}
|
sl@0
|
496 |
} {{} 0 0 0 0 1 1 1 1 1 0 1 0 1 1 1 1}
|
sl@0
|
497 |
do_test collate2-3.7 {
|
sl@0
|
498 |
execsql {
|
sl@0
|
499 |
SELECT a = 'aa' FROM collate2t1;
|
sl@0
|
500 |
}
|
sl@0
|
501 |
} {{} 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0}
|
sl@0
|
502 |
do_test collate2-3.8 {
|
sl@0
|
503 |
execsql {
|
sl@0
|
504 |
SELECT b = 'aa' FROM collate2t1;
|
sl@0
|
505 |
}
|
sl@0
|
506 |
} {{} 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0}
|
sl@0
|
507 |
do_test collate2-3.9 {
|
sl@0
|
508 |
execsql {
|
sl@0
|
509 |
SELECT c = 'aa' FROM collate2t1;
|
sl@0
|
510 |
}
|
sl@0
|
511 |
} {{} 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0}
|
sl@0
|
512 |
do_test collate2-3.10 {
|
sl@0
|
513 |
execsql {
|
sl@0
|
514 |
SELECT a <= 'aa' FROM collate2t1;
|
sl@0
|
515 |
}
|
sl@0
|
516 |
} {{} 1 0 0 0 1 1 0 0 1 1 1 1 1 1 1 1}
|
sl@0
|
517 |
do_test collate2-3.11 {
|
sl@0
|
518 |
execsql {
|
sl@0
|
519 |
SELECT b <= 'aa' FROM collate2t1;
|
sl@0
|
520 |
}
|
sl@0
|
521 |
} {{} 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0}
|
sl@0
|
522 |
do_test collate2-3.12 {
|
sl@0
|
523 |
execsql {
|
sl@0
|
524 |
SELECT c <= 'aa' FROM collate2t1;
|
sl@0
|
525 |
}
|
sl@0
|
526 |
} {{} 1 0 0 0 1 1 1 1 1 0 1 0 1 1 1 1}
|
sl@0
|
527 |
do_test collate2-3.13 {
|
sl@0
|
528 |
execsql {
|
sl@0
|
529 |
SELECT a >= 'aa' FROM collate2t1;
|
sl@0
|
530 |
}
|
sl@0
|
531 |
} {{} 1 1 1 1 0 0 1 1 0 0 0 0 0 0 0 0}
|
sl@0
|
532 |
do_test collate2-3.14 {
|
sl@0
|
533 |
execsql {
|
sl@0
|
534 |
SELECT b >= 'aa' FROM collate2t1;
|
sl@0
|
535 |
}
|
sl@0
|
536 |
} {{} 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1}
|
sl@0
|
537 |
do_test collate2-3.15 {
|
sl@0
|
538 |
execsql {
|
sl@0
|
539 |
SELECT c >= 'aa' FROM collate2t1;
|
sl@0
|
540 |
}
|
sl@0
|
541 |
} {{} 1 1 1 1 0 0 0 0 0 1 0 1 0 0 0 0}
|
sl@0
|
542 |
do_test collate2-3.16 {
|
sl@0
|
543 |
execsql {
|
sl@0
|
544 |
SELECT a BETWEEN 'Aa' AND 'Bb' FROM collate2t1;
|
sl@0
|
545 |
}
|
sl@0
|
546 |
} {{} 0 0 0 0 0 0 0 0 1 1 1 1 0 0 1 1}
|
sl@0
|
547 |
do_test collate2-3.17 {
|
sl@0
|
548 |
execsql {
|
sl@0
|
549 |
SELECT b BETWEEN 'Aa' AND 'Bb' FROM collate2t1;
|
sl@0
|
550 |
}
|
sl@0
|
551 |
} {{} 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1}
|
sl@0
|
552 |
do_test collate2-3.18 {
|
sl@0
|
553 |
execsql {
|
sl@0
|
554 |
SELECT c BETWEEN 'Aa' AND 'Bb' FROM collate2t1;
|
sl@0
|
555 |
}
|
sl@0
|
556 |
} {{} 1 0 1 0 0 0 0 0 1 1 1 1 0 0 0 0}
|
sl@0
|
557 |
do_test collate2-3.19 {
|
sl@0
|
558 |
execsql {
|
sl@0
|
559 |
SELECT CASE a WHEN 'aa' THEN 1 ELSE 0 END FROM collate2t1;
|
sl@0
|
560 |
}
|
sl@0
|
561 |
} {0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0}
|
sl@0
|
562 |
do_test collate2-3.20 {
|
sl@0
|
563 |
execsql {
|
sl@0
|
564 |
SELECT CASE b WHEN 'aa' THEN 1 ELSE 0 END FROM collate2t1;
|
sl@0
|
565 |
}
|
sl@0
|
566 |
} {0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0}
|
sl@0
|
567 |
do_test collate2-3.21 {
|
sl@0
|
568 |
execsql {
|
sl@0
|
569 |
SELECT CASE c WHEN 'aa' THEN 1 ELSE 0 END FROM collate2t1;
|
sl@0
|
570 |
}
|
sl@0
|
571 |
} {0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0}
|
sl@0
|
572 |
|
sl@0
|
573 |
ifcapable subquery {
|
sl@0
|
574 |
do_test collate2-3.22 {
|
sl@0
|
575 |
execsql {
|
sl@0
|
576 |
SELECT a IN ('aa', 'bb') FROM collate2t1;
|
sl@0
|
577 |
}
|
sl@0
|
578 |
} {{} 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0}
|
sl@0
|
579 |
do_test collate2-3.23 {
|
sl@0
|
580 |
execsql {
|
sl@0
|
581 |
SELECT b IN ('aa', 'bb') FROM collate2t1;
|
sl@0
|
582 |
}
|
sl@0
|
583 |
} {{} 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1}
|
sl@0
|
584 |
do_test collate2-3.24 {
|
sl@0
|
585 |
execsql {
|
sl@0
|
586 |
SELECT c IN ('aa', 'bb') FROM collate2t1;
|
sl@0
|
587 |
}
|
sl@0
|
588 |
} {{} 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0}
|
sl@0
|
589 |
do_test collate2-3.25 {
|
sl@0
|
590 |
execsql {
|
sl@0
|
591 |
SELECT a IN (SELECT a FROM collate2t1 WHERE a IN ('aa', 'bb'))
|
sl@0
|
592 |
FROM collate2t1;
|
sl@0
|
593 |
}
|
sl@0
|
594 |
} {{} 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0}
|
sl@0
|
595 |
do_test collate2-3.26 {
|
sl@0
|
596 |
execsql {
|
sl@0
|
597 |
SELECT b IN (SELECT a FROM collate2t1 WHERE a IN ('aa', 'bb'))
|
sl@0
|
598 |
FROM collate2t1;
|
sl@0
|
599 |
}
|
sl@0
|
600 |
} {{} 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1}
|
sl@0
|
601 |
do_test collate2-3.27 {
|
sl@0
|
602 |
execsql {
|
sl@0
|
603 |
SELECT c IN (SELECT a FROM collate2t1 WHERE a IN ('aa', 'bb'))
|
sl@0
|
604 |
FROM collate2t1;
|
sl@0
|
605 |
}
|
sl@0
|
606 |
} {{} 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0}
|
sl@0
|
607 |
}
|
sl@0
|
608 |
|
sl@0
|
609 |
do_test collate2-4.0 {
|
sl@0
|
610 |
execsql {
|
sl@0
|
611 |
CREATE TABLE collate2t2(b COLLATE binary);
|
sl@0
|
612 |
CREATE TABLE collate2t3(b text);
|
sl@0
|
613 |
INSERT INTO collate2t2 VALUES('aa');
|
sl@0
|
614 |
INSERT INTO collate2t3 VALUES('aa');
|
sl@0
|
615 |
}
|
sl@0
|
616 |
} {}
|
sl@0
|
617 |
|
sl@0
|
618 |
# Test that when both sides of a binary comparison operator have
|
sl@0
|
619 |
# default collation types, the collate type for the leftmost term
|
sl@0
|
620 |
# is used.
|
sl@0
|
621 |
do_test collate2-4.1 {
|
sl@0
|
622 |
execsql {
|
sl@0
|
623 |
SELECT collate2t1.a FROM collate2t1, collate2t2
|
sl@0
|
624 |
WHERE collate2t1.b = collate2t2.b;
|
sl@0
|
625 |
}
|
sl@0
|
626 |
} {aa aA Aa AA}
|
sl@0
|
627 |
do_test collate2-4.2 {
|
sl@0
|
628 |
execsql {
|
sl@0
|
629 |
SELECT collate2t1.a FROM collate2t1, collate2t2
|
sl@0
|
630 |
WHERE collate2t2.b = collate2t1.b;
|
sl@0
|
631 |
}
|
sl@0
|
632 |
} {aa}
|
sl@0
|
633 |
|
sl@0
|
634 |
# Test that when one side has a default collation type and the other
|
sl@0
|
635 |
# does not, the collation type is used.
|
sl@0
|
636 |
do_test collate2-4.3 {
|
sl@0
|
637 |
execsql {
|
sl@0
|
638 |
SELECT collate2t1.a FROM collate2t1, collate2t3
|
sl@0
|
639 |
WHERE collate2t1.b = collate2t3.b||'';
|
sl@0
|
640 |
}
|
sl@0
|
641 |
} {aa aA Aa AA}
|
sl@0
|
642 |
do_test collate2-4.4 {
|
sl@0
|
643 |
execsql {
|
sl@0
|
644 |
SELECT collate2t1.a FROM collate2t1, collate2t3
|
sl@0
|
645 |
WHERE collate2t3.b||'' = collate2t1.b;
|
sl@0
|
646 |
}
|
sl@0
|
647 |
} {aa aA Aa AA}
|
sl@0
|
648 |
|
sl@0
|
649 |
do_test collate2-4.5 {
|
sl@0
|
650 |
execsql {
|
sl@0
|
651 |
DROP TABLE collate2t3;
|
sl@0
|
652 |
}
|
sl@0
|
653 |
} {}
|
sl@0
|
654 |
|
sl@0
|
655 |
#
|
sl@0
|
656 |
# Test that the default collation types are used when the JOIN syntax
|
sl@0
|
657 |
# is used in place of a WHERE clause.
|
sl@0
|
658 |
#
|
sl@0
|
659 |
# SQLite transforms the JOIN syntax into a WHERE clause internally, so
|
sl@0
|
660 |
# the focus of these tests is to ensure that the table on the left-hand-side
|
sl@0
|
661 |
# of the join determines the collation type used.
|
sl@0
|
662 |
#
|
sl@0
|
663 |
do_test collate2-5.0 {
|
sl@0
|
664 |
execsql {
|
sl@0
|
665 |
SELECT collate2t1.b FROM collate2t1 JOIN collate2t2 USING (b);
|
sl@0
|
666 |
}
|
sl@0
|
667 |
} {aa aA Aa AA}
|
sl@0
|
668 |
do_test collate2-5.1 {
|
sl@0
|
669 |
execsql {
|
sl@0
|
670 |
SELECT collate2t1.b FROM collate2t2 JOIN collate2t1 USING (b);
|
sl@0
|
671 |
}
|
sl@0
|
672 |
} {aa}
|
sl@0
|
673 |
do_test collate2-5.2 {
|
sl@0
|
674 |
execsql {
|
sl@0
|
675 |
SELECT collate2t1.b FROM collate2t1 NATURAL JOIN collate2t2;
|
sl@0
|
676 |
}
|
sl@0
|
677 |
} {aa aA Aa AA}
|
sl@0
|
678 |
do_test collate2-5.3 {
|
sl@0
|
679 |
execsql {
|
sl@0
|
680 |
SELECT collate2t1.b FROM collate2t2 NATURAL JOIN collate2t1;
|
sl@0
|
681 |
}
|
sl@0
|
682 |
} {aa}
|
sl@0
|
683 |
do_test collate2-5.4 {
|
sl@0
|
684 |
execsql {
|
sl@0
|
685 |
SELECT collate2t2.b FROM collate2t1 LEFT OUTER JOIN collate2t2 USING (b) order by collate2t1.oid;
|
sl@0
|
686 |
}
|
sl@0
|
687 |
} {{} aa {} {} {} aa {} {} {} aa {} {} {} aa {} {} {}}
|
sl@0
|
688 |
do_test collate2-5.5 {
|
sl@0
|
689 |
execsql {
|
sl@0
|
690 |
SELECT collate2t1.b, collate2t2.b FROM collate2t2 LEFT OUTER JOIN collate2t1 USING (b);
|
sl@0
|
691 |
}
|
sl@0
|
692 |
} {aa aa}
|
sl@0
|
693 |
|
sl@0
|
694 |
finish_test
|