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