xref: /titanic_52/usr/src/lib/libsqlite/test/join4_28.test (revision c5c4113dfcabb1eed3d4bdf7609de5170027a794)
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 left outer joins containing WHERE
17*c5c4113dSnw141292# clauses that restrict the scope of the left term of the join.
18*c5c4113dSnw141292#
19*c5c4113dSnw141292# $Id: join4_28.test,v 1.1.2.1 2004/07/22 16:08:39 drh Exp $
20*c5c4113dSnw141292
21*c5c4113dSnw141292set testdir [file dirname $argv0]
22*c5c4113dSnw141292source $testdir/tester.tcl
23*c5c4113dSnw141292
24*c5c4113dSnw141292do_test join4-1.1 {
25*c5c4113dSnw141292  execsql {
26*c5c4113dSnw141292    create temp table t1(a integer, b varchar(10));
27*c5c4113dSnw141292    insert into t1 values(1,'one');
28*c5c4113dSnw141292    insert into t1 values(2,'two');
29*c5c4113dSnw141292    insert into t1 values(3,'three');
30*c5c4113dSnw141292    insert into t1 values(4,'four');
31*c5c4113dSnw141292
32*c5c4113dSnw141292    create temp table t2(x integer, y varchar(10), z varchar(10));
33*c5c4113dSnw141292    insert into t2 values(2,'niban','ok');
34*c5c4113dSnw141292    insert into t2 values(4,'yonban','err');
35*c5c4113dSnw141292  }
36*c5c4113dSnw141292  execsql {
37*c5c4113dSnw141292    select * from t1 left outer join t2 on t1.a=t2.x where t2.z='ok'
38*c5c4113dSnw141292  }
39*c5c4113dSnw141292} {2 two 2 niban ok}
40*c5c4113dSnw141292do_test join4-1.2 {
41*c5c4113dSnw141292  execsql {
42*c5c4113dSnw141292    select * from t1 left outer join t2 on t1.a=t2.x and t2.z='ok'
43*c5c4113dSnw141292  }
44*c5c4113dSnw141292} {1 one {} {} {} 2 two 2 niban ok 3 three {} {} {} 4 four {} {} {}}
45*c5c4113dSnw141292do_test join4-1.3 {
46*c5c4113dSnw141292  execsql {
47*c5c4113dSnw141292    create index i2 on t2(z);
48*c5c4113dSnw141292  }
49*c5c4113dSnw141292  execsql {
50*c5c4113dSnw141292    select * from t1 left outer join t2 on t1.a=t2.x where t2.z='ok'
51*c5c4113dSnw141292  }
52*c5c4113dSnw141292} {2 two 2 niban ok}
53*c5c4113dSnw141292do_test join4-1.4 {
54*c5c4113dSnw141292  execsql {
55*c5c4113dSnw141292    select * from t1 left outer join t2 on t1.a=t2.x and t2.z='ok'
56*c5c4113dSnw141292  }
57*c5c4113dSnw141292} {1 one {} {} {} 2 two 2 niban ok 3 three {} {} {} 4 four {} {} {}}
58*c5c4113dSnw141292do_test join4-1.5 {
59*c5c4113dSnw141292  execsql {
60*c5c4113dSnw141292    select * from t1 left outer join t2 on t1.a=t2.x where t2.z>='ok'
61*c5c4113dSnw141292  }
62*c5c4113dSnw141292} {2 two 2 niban ok}
63*c5c4113dSnw141292do_test join4-1.4 {
64*c5c4113dSnw141292  execsql {
65*c5c4113dSnw141292    select * from t1 left outer join t2 on t1.a=t2.x and t2.z>='ok'
66*c5c4113dSnw141292  }
67*c5c4113dSnw141292} {1 one {} {} {} 2 two 2 niban ok 3 three {} {} {} 4 four {} {} {}}
68*c5c4113dSnw141292do_test join4-1.6 {
69*c5c4113dSnw141292  execsql {
70*c5c4113dSnw141292    select * from t1 left outer join t2 on t1.a=t2.x where t2.z IN ('ok')
71*c5c4113dSnw141292  }
72*c5c4113dSnw141292} {2 two 2 niban ok}
73*c5c4113dSnw141292do_test join4-1.7 {
74*c5c4113dSnw141292  execsql {
75*c5c4113dSnw141292    select * from t1 left outer join t2 on t1.a=t2.x and t2.z IN ('ok')
76*c5c4113dSnw141292  }
77*c5c4113dSnw141292} {1 one {} {} {} 2 two 2 niban ok 3 three {} {} {} 4 four {} {} {}}
78*c5c4113dSnw141292
79*c5c4113dSnw141292
80*c5c4113dSnw141292finish_test
81