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