Enhance the command-line completion extension to return the names of
[sqlite.git] / test / orderby4.test
blobec6eb041f63042ed966d2373f5916d4bea9c8a4e
1 # 2013 March 26
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 multi-value primary keys and
14 # unique indices when only some prefix of the terms in the key are
15 # used.  See ticket http://www.sqlite.org/src/info/a179fe74659
19 set testdir [file dirname $argv0]
20 source $testdir/tester.tcl
21 set ::testprefix orderby4
23 # Generate test data for a join.  Verify that the join gets the
24 # correct answer.
26 do_execsql_test 1.1 {
27   CREATE TABLE t1(a, b, PRIMARY KEY(a,b));
28   INSERT INTO t1 VALUES(1,1),(1,2);
29   CREATE TABLE t2(x, y, PRIMARY KEY(x,y));
30   INSERT INTO t2 VALUES(3,3),(4,4);
31   SELECT a, x FROM t1, t2 ORDER BY 1, 2;
32 } {1 3 1 3 1 4 1 4}
33 do_execsql_test 1.2 {
34   SELECT a, x FROM t1 CROSS JOIN t2 ORDER BY 1, 2;
35 } {1 3 1 3 1 4 1 4}
36 do_execsql_test 1.3 {
37   SELECT a, x FROM t2 CROSS JOIN t1 ORDER BY 1, 2;
38 } {1 3 1 3 1 4 1 4}
40 do_execsql_test 2.1 {
41   CREATE TABLE t3(a);
42   INSERT INTO t3 VALUES(1),(1);
43   CREATE INDEX t3a ON t3(a);
44   CREATE TABLE t4(x);
45   INSERT INTO t4 VALUES(3),(4);
46   CREATE INDEX t4x ON t4(x);
47   SELECT a, x FROM t3, t4 ORDER BY 1, 2;
48 } {1 3 1 3 1 4 1 4}
49 do_execsql_test 2.2 {
50   SELECT a, x FROM t3 CROSS JOIN t4 ORDER BY 1, 2;
51 } {1 3 1 3 1 4 1 4}
52 do_execsql_test 2.3 {
53   SELECT a, x FROM t4 CROSS JOIN t3 ORDER BY 1, 2;
54 } {1 3 1 3 1 4 1 4}
56 finish_test