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.
13 # This file implements tests for joins, including outer joins.
16 set testdir [file dirname $argv0]
17 source $testdir/tester.tcl
23 INSERT INTO t1 VALUES(1,11);
24 INSERT INTO t1 VALUES(2,22);
25 INSERT INTO t1 VALUES(3,33);
32 INSERT INTO t2 VALUES(11,111);
33 INSERT INTO t2 VALUES(33,333);
34 INSERT INTO t2 VALUES(44,444);
37 } {11 111 33 333 44 444};
41 INSERT INTO t3 VALUES(111,1111);
42 INSERT INTO t3 VALUES(444,4444);
43 INSERT INTO t3 VALUES(555,5555);
46 } {111 1111 444 4444 555 5555}
51 t1 NATURAL JOIN t2 NATURAL JOIN t3
57 t1 NATURAL JOIN t2 NATURAL LEFT OUTER JOIN t3
59 } {1 11 111 1111 3 33 333 {}}
63 t1 NATURAL LEFT OUTER JOIN t2 NATURAL JOIN t3
70 t1 NATURAL LEFT OUTER JOIN (t2 NATURAL JOIN t3)
72 } {1 11 111 1111 2 22 {} {} 3 33 {} {}}
75 #-------------------------------------------------------------------------
76 # Check that ticket [25e335f802ddc] has been resolved. It should be an
77 # error for the ON clause of a LEFT JOIN to refer to a table to its right.
83 INSERT INTO aa VALUES('one');
84 INSERT INTO bb VALUES('one');
85 INSERT INTO cc VALUES('one');
88 do_catchsql_test 2.1 {
89 SELECT * FROM aa LEFT JOIN cc ON (a=b) JOIN bb ON (b=c);
90 } {1 {ON clause references tables to its right}}
91 do_catchsql_test 2.2 {
92 SELECT * FROM aa JOIN cc ON (a=b) JOIN bb ON (b=c);