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 #1473 has been
17 set testdir [file dirname $argv0]
18 source $testdir/tester.tcl
28 INSERT INTO t1 VALUES(1,2);
29 INSERT INTO t1 VALUES(3,4);
36 SELECT 1 FROM t1 WHERE a=1 UNION ALL SELECT 2 FROM t1 WHERE b=0
41 SELECT 1 FROM t1 WHERE a=1 UNION SELECT 2 FROM t1 WHERE b=0
46 SELECT 1 FROM t1 WHERE a=1 UNION ALL SELECT 2 FROM t1 WHERE b=4
51 SELECT 1 FROM t1 WHERE a=1 UNION SELECT 2 FROM t1 WHERE b=4
56 SELECT 1 FROM t1 WHERE a=0 UNION ALL SELECT 2 FROM t1 WHERE b=4
61 SELECT 1 FROM t1 WHERE a=0 UNION SELECT 2 FROM t1 WHERE b=4
66 SELECT 1 FROM t1 WHERE a=0 UNION ALL SELECT 2 FROM t1 WHERE b=0
71 SELECT 1 FROM t1 WHERE a=0 UNION SELECT 2 FROM t1 WHERE b=0
75 # Everything from this point on depends on sub-queries. So skip it
76 # if sub-queries are not available.
84 SELECT (SELECT 1 FROM t1 WHERE a=1 UNION ALL SELECT 2 FROM t1 WHERE b=0)
89 SELECT (SELECT 1 FROM t1 WHERE a=1 UNION SELECT 2 FROM t1 WHERE b=0)
94 SELECT (SELECT 1 FROM t1 WHERE a=1 UNION ALL SELECT 2 FROM t1 WHERE b=4)
99 SELECT (SELECT 1 FROM t1 WHERE a=1 UNION SELECT 2 FROM t1 WHERE b=4)
102 do_test tkt1473-2.6 {
104 SELECT (SELECT 1 FROM t1 WHERE a=0 UNION ALL SELECT 2 FROM t1 WHERE b=4)
107 do_test tkt1473-2.7 {
109 SELECT (SELECT 1 FROM t1 WHERE a=0 UNION SELECT 2 FROM t1 WHERE b=4)
112 do_test tkt1473-2.8 {
114 SELECT (SELECT 1 FROM t1 WHERE a=0 UNION ALL SELECT 2 FROM t1 WHERE b=0)
117 do_test tkt1473-2.9 {
119 SELECT (SELECT 1 FROM t1 WHERE a=0 UNION SELECT 2 FROM t1 WHERE b=0)
123 do_test tkt1473-3.2 {
126 (SELECT 1 FROM t1 WHERE a=1 UNION ALL SELECT 2 FROM t1 WHERE b=0)
129 do_test tkt1473-3.3 {
132 (SELECT 1 FROM t1 WHERE a=1 UNION SELECT 2 FROM t1 WHERE b=0)
135 do_test tkt1473-3.4 {
138 (SELECT 1 FROM t1 WHERE a=1 UNION ALL SELECT 2 FROM t1 WHERE b=4)
141 do_test tkt1473-3.5 {
144 (SELECT 1 FROM t1 WHERE a=1 UNION SELECT 2 FROM t1 WHERE b=4)
147 do_test tkt1473-3.6 {
150 (SELECT 1 FROM t1 WHERE a=0 UNION ALL SELECT 2 FROM t1 WHERE b=4)
153 do_test tkt1473-3.7 {
156 (SELECT 1 FROM t1 WHERE a=0 UNION SELECT 2 FROM t1 WHERE b=4)
159 do_test tkt1473-3.8 {
162 (SELECT 1 FROM t1 WHERE a=0 UNION ALL SELECT 2 FROM t1 WHERE b=0)
165 do_test tkt1473-3.9 {
168 (SELECT 1 FROM t1 WHERE a=0 UNION SELECT 2 FROM t1 WHERE b=0)
172 do_test tkt1473-4.1 {
174 CREATE TABLE t2(x,y);
175 INSERT INTO t2 VALUES(1,2);
176 INSERT INTO t2 SELECT x+2, y+2 FROM t2;
177 INSERT INTO t2 SELECT x+4, y+4 FROM t2;
178 INSERT INTO t2 SELECT x+8, y+8 FROM t2;
179 INSERT INTO t2 SELECT x+16, y+16 FROM t2;
180 INSERT INTO t2 SELECT x+32, y+32 FROM t2;
181 INSERT INTO t2 SELECT x+64, y+64 FROM t2;
182 SELECT count(*), sum(x), sum(y) FROM t2;
185 do_test tkt1473-4.2 {
187 SELECT 1 FROM t2 WHERE x=0
189 SELECT 2 FROM t2 WHERE x=1
191 SELECT 3 FROM t2 WHERE x=2
193 SELECT 4 FROM t2 WHERE x=3
195 SELECT 5 FROM t2 WHERE x=4
197 SELECT 6 FROM t2 WHERE y=0
199 SELECT 7 FROM t2 WHERE y=1
201 SELECT 8 FROM t2 WHERE y=2
203 SELECT 9 FROM t2 WHERE y=3
205 SELECT 10 FROM t2 WHERE y=4
208 do_test tkt1473-4.3 {
211 SELECT 1 FROM t2 WHERE x=0
213 SELECT 2 FROM t2 WHERE x=1
215 SELECT 3 FROM t2 WHERE x=2
217 SELECT 4 FROM t2 WHERE x=3
219 SELECT 5 FROM t2 WHERE x=4
221 SELECT 6 FROM t2 WHERE y=0
223 SELECT 7 FROM t2 WHERE y=1
225 SELECT 8 FROM t2 WHERE y=2
227 SELECT 9 FROM t2 WHERE y=3
229 SELECT 10 FROM t2 WHERE y=4
233 do_test tkt1473-4.4 {
236 SELECT 1 FROM t2 WHERE x=0
238 SELECT 2 FROM t2 WHERE x=-1
240 SELECT 3 FROM t2 WHERE x=2
242 SELECT 4 FROM t2 WHERE x=3
244 SELECT 5 FROM t2 WHERE x=4
246 SELECT 6 FROM t2 WHERE y=0
248 SELECT 7 FROM t2 WHERE y=1
250 SELECT 8 FROM t2 WHERE y=2
252 SELECT 9 FROM t2 WHERE y=3
254 SELECT 10 FROM t2 WHERE y=4
258 do_test tkt1473-4.5 {
261 SELECT 1 FROM t2 WHERE x=0
263 SELECT 2 FROM t2 WHERE x=-1
265 SELECT 3 FROM t2 WHERE x=2
267 SELECT 4 FROM t2 WHERE x=-1
269 SELECT 5 FROM t2 WHERE x=4
271 SELECT 6 FROM t2 WHERE y=0
273 SELECT 7 FROM t2 WHERE y=1
275 SELECT 8 FROM t2 WHERE y=2
277 SELECT 9 FROM t2 WHERE y=3
279 SELECT 10 FROM t2 WHERE y=-4
283 do_test tkt1473-4.6 {
286 SELECT 1 FROM t2 WHERE x=0
288 SELECT 2 FROM t2 WHERE x=-1
290 SELECT 3 FROM t2 WHERE x=2
292 SELECT 4 FROM t2 WHERE x=-2
294 SELECT 5 FROM t2 WHERE x=4
296 SELECT 6 FROM t2 WHERE y=0
298 SELECT 7 FROM t2 WHERE y=1
300 SELECT 8 FROM t2 WHERE y=-3
302 SELECT 9 FROM t2 WHERE y=3
304 SELECT 10 FROM t2 WHERE y=4
308 do_test tkt1473-4.7 {
311 SELECT 1 FROM t2 WHERE x=0
313 SELECT 2 FROM t2 WHERE x=-1
315 SELECT 3 FROM t2 WHERE x=2
317 SELECT 4 FROM t2 WHERE x=-2
319 SELECT 5 FROM t2 WHERE x=4
321 SELECT 6 FROM t2 WHERE y=0
323 SELECT 7 FROM t2 WHERE y=1
325 SELECT 8 FROM t2 WHERE y=-3
327 SELECT 9 FROM t2 WHERE y=3
329 SELECT 10 FROM t2 WHERE y=-4
334 do_test tkt1473-5.3 {
337 SELECT 1 FROM t2 WHERE x=0
339 SELECT 2 FROM t2 WHERE x=1
341 SELECT 3 FROM t2 WHERE x=2
343 SELECT 4 FROM t2 WHERE x=3
345 SELECT 5 FROM t2 WHERE x=4
347 SELECT 6 FROM t2 WHERE y=0
349 SELECT 7 FROM t2 WHERE y=1
351 SELECT 8 FROM t2 WHERE y=2
353 SELECT 9 FROM t2 WHERE y=3
355 SELECT 10 FROM t2 WHERE y=4
359 do_test tkt1473-5.4 {
362 SELECT 1 FROM t2 WHERE x=0
364 SELECT 2 FROM t2 WHERE x=-1
366 SELECT 3 FROM t2 WHERE x=2
368 SELECT 4 FROM t2 WHERE x=3
370 SELECT 5 FROM t2 WHERE x=4
372 SELECT 6 FROM t2 WHERE y=0
374 SELECT 7 FROM t2 WHERE y=1
376 SELECT 8 FROM t2 WHERE y=2
378 SELECT 9 FROM t2 WHERE y=3
380 SELECT 10 FROM t2 WHERE y=4
385 do_test tkt1473-5.5 {
388 SELECT 1 FROM t2 WHERE x=0
390 SELECT 2 FROM t2 WHERE x=-1
392 SELECT 3 FROM t2 WHERE x=2
394 SELECT 4 FROM t2 WHERE x=-1
396 SELECT 5 FROM t2 WHERE x=4
398 SELECT 6 FROM t2 WHERE y=0
400 SELECT 7 FROM t2 WHERE y=1
402 SELECT 8 FROM t2 WHERE y=2
404 SELECT 9 FROM t2 WHERE y=3
406 SELECT 10 FROM t2 WHERE y=-4
410 do_test tkt1473-5.6 {
413 SELECT 1 FROM t2 WHERE x=0
415 SELECT 2 FROM t2 WHERE x=-1
417 SELECT 3 FROM t2 WHERE x=2
419 SELECT 4 FROM t2 WHERE x=-2
421 SELECT 5 FROM t2 WHERE x=4
423 SELECT 6 FROM t2 WHERE y=0
425 SELECT 7 FROM t2 WHERE y=1
427 SELECT 8 FROM t2 WHERE y=-3
429 SELECT 9 FROM t2 WHERE y=3
431 SELECT 10 FROM t2 WHERE y=4
435 do_test tkt1473-5.7 {
438 SELECT 1 FROM t2 WHERE x=0
440 SELECT 2 FROM t2 WHERE x=-1
442 SELECT 3 FROM t2 WHERE x=2
444 SELECT 4 FROM t2 WHERE x=-2
446 SELECT 5 FROM t2 WHERE x=4
448 SELECT 6 FROM t2 WHERE y=0
450 SELECT 7 FROM t2 WHERE y=1
452 SELECT 8 FROM t2 WHERE y=-3
454 SELECT 9 FROM t2 WHERE y=3
456 SELECT 10 FROM t2 WHERE y=-4
461 do_test tkt1473-6.3 {
464 SELECT 1 FROM t2 WHERE x=0
466 SELECT 2 FROM t2 WHERE x=1
468 SELECT 3 FROM t2 WHERE x=2
470 SELECT 4 FROM t2 WHERE x=3
472 SELECT 5 FROM t2 WHERE x=4
474 SELECT 6 FROM t2 WHERE y=0
476 SELECT 7 FROM t2 WHERE y=1
478 SELECT 8 FROM t2 WHERE y=2
480 SELECT 9 FROM t2 WHERE y=3
482 SELECT 10 FROM t2 WHERE y=4
486 do_test tkt1473-6.4 {
489 SELECT 1 FROM t2 WHERE x=0
491 SELECT 2 FROM t2 WHERE x=-1
493 SELECT 3 FROM t2 WHERE x=2
495 SELECT 4 FROM t2 WHERE x=3
497 SELECT 5 FROM t2 WHERE x=4
499 SELECT 6 FROM t2 WHERE y=0
501 SELECT 7 FROM t2 WHERE y=1
503 SELECT 8 FROM t2 WHERE y=2
505 SELECT 9 FROM t2 WHERE y=3
507 SELECT 10 FROM t2 WHERE y=4
512 do_test tkt1473-6.5 {
515 SELECT 1 FROM t2 WHERE x=0
517 SELECT 2 FROM t2 WHERE x=-1
519 SELECT 3 FROM t2 WHERE x=2
521 SELECT 4 FROM t2 WHERE x=-1
523 SELECT 5 FROM t2 WHERE x=4
525 SELECT 6 FROM t2 WHERE y=0
527 SELECT 7 FROM t2 WHERE y=1
529 SELECT 8 FROM t2 WHERE y=2
531 SELECT 9 FROM t2 WHERE y=3
533 SELECT 10 FROM t2 WHERE y=-4
537 do_test tkt1473-6.6 {
540 SELECT 1 FROM t2 WHERE x=0
542 SELECT 2 FROM t2 WHERE x=-1
544 SELECT 3 FROM t2 WHERE x=2
546 SELECT 4 FROM t2 WHERE x=-2
548 SELECT 5 FROM t2 WHERE x=4
550 SELECT 6 FROM t2 WHERE y=0
552 SELECT 7 FROM t2 WHERE y=1
554 SELECT 8 FROM t2 WHERE y=-3
556 SELECT 9 FROM t2 WHERE y=3
558 SELECT 10 FROM t2 WHERE y=4
562 do_test tkt1473-6.7 {
565 SELECT 1 FROM t2 WHERE x=0
567 SELECT 2 FROM t2 WHERE x=-1
569 SELECT 3 FROM t2 WHERE x=2
571 SELECT 4 FROM t2 WHERE x=-2
573 SELECT 5 FROM t2 WHERE x=4
575 SELECT 6 FROM t2 WHERE y=0
577 SELECT 7 FROM t2 WHERE y=1
579 SELECT 8 FROM t2 WHERE y=-3
581 SELECT 9 FROM t2 WHERE y=3
583 SELECT 10 FROM t2 WHERE y=-4
587 do_test tkt1473-6.8 {
590 SELECT 1 FROM t2 WHERE x=0
592 SELECT 2 FROM t2 WHERE x=-1
594 SELECT 3 FROM t2 WHERE x=2
596 SELECT 4 FROM t2 WHERE x=-2
598 SELECT 5 FROM t2 WHERE x=4
600 SELECT 6 FROM t2 WHERE y=0
602 SELECT 7 FROM t2 WHERE y=1
604 SELECT 8 FROM t2 WHERE y=-3
606 SELECT 9 FROM t2 WHERE y=3
608 SELECT 10 FROM t2 WHERE y=4
612 do_test tkt1473-6.9 {
615 SELECT 1 FROM t2 WHERE x=0
617 SELECT 2 FROM t2 WHERE x=-1
619 SELECT 3 FROM t2 WHERE x=2
621 SELECT 4 FROM t2 WHERE x=-2
623 SELECT 5 FROM t2 WHERE x=4
625 SELECT 6 FROM t2 WHERE y=0
627 SELECT 7 FROM t2 WHERE y=1
629 SELECT 8 FROM t2 WHERE y=-3
631 SELECT 9 FROM t2 WHERE y=3
633 SELECT 10 FROM t2 WHERE y=-4
638 do_test tkt1473-7.1 {
640 SELECT 1 FROM t2 WHERE x=1 EXCEPT SELECT 2 FROM t2 WHERE y=2
643 do_test tkt1473-7.2 {
646 SELECT 1 FROM t2 WHERE x=1 EXCEPT SELECT 2 FROM t2 WHERE y=2
650 do_test tkt1473-7.3 {
653 SELECT 1 FROM t2 WHERE x=1 EXCEPT SELECT 2 FROM t2 WHERE y=2
657 do_test tkt1473-7.4 {
660 SELECT 1 FROM t2 WHERE x=0 EXCEPT SELECT 2 FROM t2 WHERE y=2
664 do_test tkt1473-7.5 {
667 SELECT 1 FROM t2 WHERE x=0 EXCEPT SELECT 2 FROM t2 WHERE y=2
672 do_test tkt1473-8.1 {
674 SELECT 1 FROM t2 WHERE x=1 INTERSECT SELECT 2 FROM t2 WHERE y=2
677 do_test tkt1473-8.1 {
679 SELECT 1 FROM t2 WHERE x=1 INTERSECT SELECT 1 FROM t2 WHERE y=2
682 do_test tkt1473-8.3 {
685 SELECT 1 FROM t2 WHERE x=1 INTERSECT SELECT 2 FROM t2 WHERE y=2
689 do_test tkt1473-8.4 {
692 SELECT 1 FROM t2 WHERE x=1 INTERSECT SELECT 1 FROM t2 WHERE y=2
696 do_test tkt1473-8.5 {
699 SELECT 1 FROM t2 WHERE x=1 INTERSECT SELECT 2 FROM t2 WHERE y=2
703 do_test tkt1473-8.6 {
706 SELECT 1 FROM t2 WHERE x=1 INTERSECT SELECT 1 FROM t2 WHERE y=2
710 do_test tkt1473-8.7 {
713 SELECT 1 FROM t2 WHERE x=0 INTERSECT SELECT 1 FROM t2 WHERE y=2
717 do_test tkt1473-8.8 {
720 SELECT 1 FROM t2 WHERE x=1 INTERSECT SELECT 1 FROM t2 WHERE y=0