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 left outer joins containing WHERE
14 # clauses that restrict the scope of the left term of the join.
16 # $Id: join4.test,v 1.4 2005/03/29 03:11:00 danielk1977 Exp $
18 set testdir [file dirname $argv0]
19 source $testdir/tester.tcl
24 create temp table t1(a integer, b varchar(10));
25 insert into t1 values(1,'one');
26 insert into t1 values(2,'two');
27 insert into t1 values(3,'three');
28 insert into t1 values(4,'four');
30 create temp table t2(x integer, y varchar(10), z varchar(10));
31 insert into t2 values(2,'niban','ok');
32 insert into t2 values(4,'yonban','err');
35 select * from t1 left outer join t2 on t1.a=t2.x where t2.z='ok'
41 create table t1(a integer, b varchar(10));
42 insert into t1 values(1,'one');
43 insert into t1 values(2,'two');
44 insert into t1 values(3,'three');
45 insert into t1 values(4,'four');
47 create table t2(x integer, y varchar(10), z varchar(10));
48 insert into t2 values(2,'niban','ok');
49 insert into t2 values(4,'yonban','err');
52 select * from t1 left outer join t2 on t1.a=t2.x where t2.z='ok'
58 select * from t1 left outer join t2 on t1.a=t2.x and t2.z='ok'
60 } {1 one {} {} {} 2 two 2 niban ok 3 three {} {} {} 4 four {} {} {}}
63 create index i2 on t2(z);
66 select * from t1 left outer join t2 on t1.a=t2.x where t2.z='ok'
71 select * from t1 left outer join t2 on t1.a=t2.x and t2.z='ok'
73 } {1 one {} {} {} 2 two 2 niban ok 3 three {} {} {} 4 four {} {} {}}
76 select * from t1 left outer join t2 on t1.a=t2.x where t2.z>='ok'
81 select * from t1 left outer join t2 on t1.a=t2.x and t2.z>='ok'
83 } {1 one {} {} {} 2 two 2 niban ok 3 three {} {} {} 4 four {} {} {}}
87 select * from t1 left outer join t2 on t1.a=t2.x where t2.z IN ('ok')
92 select * from t1 left outer join t2 on t1.a=t2.x and t2.z IN ('ok')
94 } {1 one {} {} {} 2 two 2 niban ok 3 three {} {} {} 4 four {} {} {}}