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