xref: /illumos-gate/usr/src/lib/libsqlite/test/join2.test (revision 09fbbb7d1b5a956a9b81304070dcff318a4a158e)
1#
2# 2002 May 24
3#
4# The author disclaims copyright to this source code.  In place of
5# a legal notice, here is a blessing:
6#
7#    May you do good and not evil.
8#    May you find forgiveness for yourself and forgive others.
9#    May you share freely, never taking more than you give.
10#
11#***********************************************************************
12# This file implements regression tests for SQLite library.
13#
14# This file implements tests for joins, including outer joins.
15#
16# $Id: join2.test,v 1.1 2004/01/24 20:18:13 drh Exp $
17
18set testdir [file dirname $argv0]
19source $testdir/tester.tcl
20
21do_test join2-1.1 {
22  execsql {
23    CREATE TABLE t1(a,b);
24    INSERT INTO t1 VALUES(1,11);
25    INSERT INTO t1 VALUES(2,22);
26    INSERT INTO t1 VALUES(3,33);
27    SELECT * FROM t1;
28  }
29} {1 11 2 22 3 33}
30do_test join2-1.2 {
31  execsql {
32    CREATE TABLE t2(b,c);
33    INSERT INTO t2 VALUES(11,111);
34    INSERT INTO t2 VALUES(33,333);
35    INSERT INTO t2 VALUES(44,444);
36    SELECT * FROM t2;
37  }
38} {11 111 33 333 44 444};
39do_test join2-1.3 {
40  execsql {
41    CREATE TABLE t3(c,d);
42    INSERT INTO t3 VALUES(111,1111);
43    INSERT INTO t3 VALUES(444,4444);
44    INSERT INTO t3 VALUES(555,5555);
45    SELECT * FROM t3;
46  }
47} {111 1111 444 4444 555 5555}
48
49do_test join2-1.4 {
50  execsql {
51    SELECT * FROM
52      t1 NATURAL JOIN t2 NATURAL JOIN t3
53  }
54} {1 11 111 1111}
55do_test join2-1.5 {
56  execsql {
57    SELECT * FROM
58      t1 NATURAL JOIN t2 NATURAL LEFT OUTER JOIN t3
59  }
60} {1 11 111 1111 3 33 333 {}}
61do_test join2-1.6 {
62  execsql {
63    SELECT * FROM
64      t1 NATURAL LEFT OUTER JOIN t2 NATURAL JOIN t3
65  }
66} {1 11 111 1111}
67do_test join2-1.6 {
68  execsql {
69    SELECT * FROM
70      t1 NATURAL LEFT OUTER JOIN (t2 NATURAL JOIN t3)
71  }
72} {1 11 111 1111 2 22 {} {} 3 33 {} {}}
73
74finish_test
75