xref: /sqlite-3.40.0/test/sorterref.test (revision 37f3ac8f)
124e25d32Sdan# 2018 April 14.
224e25d32Sdan#
324e25d32Sdan# The author disclaims copyright to this source code.  In place of
424e25d32Sdan# a legal notice, here is a blessing:
524e25d32Sdan#
624e25d32Sdan#    May you do good and not evil.
724e25d32Sdan#    May you find forgiveness for yourself and forgive others.
824e25d32Sdan#    May you share freely, never taking more than you give.
924e25d32Sdan#
1024e25d32Sdan#***********************************************************************
1124e25d32Sdan#
1224e25d32Sdan
1324e25d32Sdanset testdir [file dirname $argv0]
1424e25d32Sdansource $testdir/tester.tcl
1524e25d32Sdanset testprefix sorterref
1624e25d32Sdan
17*37f3ac8fSdan# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
18*37f3ac8fSdanifcapable !altertable {
19*37f3ac8fSdan  finish_test
20*37f3ac8fSdan  return
21*37f3ac8fSdan}
22*37f3ac8fSdan
2324e25d32Sdando_execsql_test 1.0 {
2424e25d32Sdan  CREATE TABLE t1(a, b, c);
2524e25d32Sdan  INSERT INTO t1 VALUES(1, 2, 3);
2624e25d32Sdan  INSERT INTO t1 VALUES(4, 5, 6);
2724e25d32Sdan  ALTER TABLE t1 ADD COLUMN d DEFAULT 'string';
2824e25d32Sdan  INSERT INTO t1 VALUES(7, 8, 9, 'text');
2924e25d32Sdan}
3024e25d32Sdan
3124e25d32Sdando_execsql_test 1.1 {
3224e25d32Sdan  SELECT * FROM t1 ORDER BY b;
3324e25d32Sdan} {
3424e25d32Sdan  1 2 3 string 4 5 6 string 7 8 9 text
3524e25d32Sdan}
3624e25d32Sdan
3724e25d32Sdando_execsql_test 2.0 {
3824e25d32Sdan  DROP TABLE IF EXISTS t1;
3924e25d32Sdan  CREATE TABLE t1(a, b);
4024e25d32Sdan  CREATE TABLE t2(c, d, PRIMARY KEY(c)) WITHOUT ROWID;
4124e25d32Sdan
4224e25d32Sdan  INSERT INTO t1 VALUES(1, 2);
4324e25d32Sdan  INSERT INTO t1 VALUES(2, 3);
4424e25d32Sdan  INSERT INTO t1 VALUES(3, 4);
4524e25d32Sdan
4624e25d32Sdan  INSERT INTO t2 VALUES(1, 'one');
4724e25d32Sdan  INSERT INTO t2 VALUES(3, 'three');
4824e25d32Sdan}
4924e25d32Sdan
5024e25d32Sdando_execsql_test 2.1 {
5124e25d32Sdan  SELECT * FROM t1 LEFT JOIN t2 ON (a=c) ORDER BY b;
5224e25d32Sdan} {1 2 1 one 2 3 {} {} 3 4 3 three}
5324e25d32Sdan
5424e25d32Sdan
5524e25d32Sdan
5624e25d32Sdanfinish_test
57