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. The
12 # focus of this file is testing that the optimizations that disable
13 # ORDER BY clauses work correctly on a 3-way join. See ticket
14 # http://www.sqlite.org/src/956e4d7f89
18 set testdir [file dirname $argv0]
19 source $testdir/tester.tcl
20 set ::testprefix orderby3
22 # Generate test data for a join. Verify that the join gets the
26 CREATE TABLE t1(a INTEGER PRIMARY KEY);
27 CREATE TABLE t2(b INTEGER PRIMARY KEY, c INTEGER);
28 CREATE TABLE t3(d INTEGER);
30 INSERT INTO t1 VALUES(1),(2),(3);
32 INSERT INTO t2 VALUES(3, 1);
33 INSERT INTO t2 VALUES(4, 2);
34 INSERT INTO t2 VALUES(5, 3);
36 INSERT INTO t3 VALUES(4),(3),(5);
38 do_execsql_test 1.1.asc {
41 WHERE t1.a=t2.c AND t2.b=t3.d
44 do_execsql_test 1.1.desc {
47 WHERE t1.a=t2.c AND t2.b=t3.d
50 do_execsql_test 1.123.asc {
52 FROM t1 CROSS JOIN t2 CROSS JOIN t3
53 WHERE t1.a=t2.c AND t2.b=t3.d
56 do_execsql_test 1.123.desc {
58 FROM t1 CROSS JOIN t2 CROSS JOIN t3
59 WHERE t1.a=t2.c AND t2.b=t3.d
62 do_execsql_test 1.132.asc {
64 FROM t1 CROSS JOIN t3 CROSS JOIN t2
65 WHERE t1.a=t2.c AND t2.b=t3.d
68 do_execsql_test 1.132.desc {
70 FROM t1 CROSS JOIN t3 CROSS JOIN t2
71 WHERE t1.a=t2.c AND t2.b=t3.d
74 do_execsql_test 1.213.asc {
76 FROM t2 CROSS JOIN t1 CROSS JOIN t3
77 WHERE t1.a=t2.c AND t2.b=t3.d
80 do_execsql_test 1.213.desc {
82 FROM t2 CROSS JOIN t1 CROSS JOIN t3
83 WHERE t1.a=t2.c AND t2.b=t3.d
86 do_execsql_test 1.231.asc {
88 FROM t2 CROSS JOIN t3 CROSS JOIN t1
89 WHERE t1.a=t2.c AND t2.b=t3.d
92 do_execsql_test 1.231.desc {
94 FROM t2 CROSS JOIN t3 CROSS JOIN t1
95 WHERE t1.a=t2.c AND t2.b=t3.d
98 do_execsql_test 1.312.asc {
100 FROM t3 CROSS JOIN t1 CROSS JOIN t2
101 WHERE t1.a=t2.c AND t2.b=t3.d
104 do_execsql_test 1.312.desc {
106 FROM t3 CROSS JOIN t1 CROSS JOIN t2
107 WHERE t1.a=t2.c AND t2.b=t3.d
110 do_execsql_test 1.321.asc {
112 FROM t3 CROSS JOIN t2 CROSS JOIN t1
113 WHERE t1.a=t2.c AND t2.b=t3.d
116 do_execsql_test 1.321.desc {
118 FROM t3 CROSS JOIN t2 CROSS JOIN t1
119 WHERE t1.a=t2.c AND t2.b=t3.d