xref: /titanic_50/usr/src/lib/libsqlite/test/join4_28.test (revision 1100f00d5652de2808b73c61bcfdb3fc87ef1fc8)
1
2#pragma ident	"%Z%%M%	%I%	%E% SMI"
3
4# 2002 May 24
5#
6# The author disclaims copyright to this source code.  In place of
7# a legal notice, here is a blessing:
8#
9#    May you do good and not evil.
10#    May you find forgiveness for yourself and forgive others.
11#    May you share freely, never taking more than you give.
12#
13#***********************************************************************
14# This file implements regression tests for SQLite library.
15#
16# This file implements tests for left outer joins containing WHERE
17# clauses that restrict the scope of the left term of the join.
18#
19# $Id: join4_28.test,v 1.1.2.1 2004/07/22 16:08:39 drh Exp $
20
21set testdir [file dirname $argv0]
22source $testdir/tester.tcl
23
24do_test join4-1.1 {
25  execsql {
26    create temp table t1(a integer, b varchar(10));
27    insert into t1 values(1,'one');
28    insert into t1 values(2,'two');
29    insert into t1 values(3,'three');
30    insert into t1 values(4,'four');
31
32    create temp table t2(x integer, y varchar(10), z varchar(10));
33    insert into t2 values(2,'niban','ok');
34    insert into t2 values(4,'yonban','err');
35  }
36  execsql {
37    select * from t1 left outer join t2 on t1.a=t2.x where t2.z='ok'
38  }
39} {2 two 2 niban ok}
40do_test join4-1.2 {
41  execsql {
42    select * from t1 left outer join t2 on t1.a=t2.x and t2.z='ok'
43  }
44} {1 one {} {} {} 2 two 2 niban ok 3 three {} {} {} 4 four {} {} {}}
45do_test join4-1.3 {
46  execsql {
47    create index i2 on t2(z);
48  }
49  execsql {
50    select * from t1 left outer join t2 on t1.a=t2.x where t2.z='ok'
51  }
52} {2 two 2 niban ok}
53do_test join4-1.4 {
54  execsql {
55    select * from t1 left outer join t2 on t1.a=t2.x and t2.z='ok'
56  }
57} {1 one {} {} {} 2 two 2 niban ok 3 three {} {} {} 4 four {} {} {}}
58do_test join4-1.5 {
59  execsql {
60    select * from t1 left outer join t2 on t1.a=t2.x where t2.z>='ok'
61  }
62} {2 two 2 niban ok}
63do_test join4-1.4 {
64  execsql {
65    select * from t1 left outer join t2 on t1.a=t2.x and t2.z>='ok'
66  }
67} {1 one {} {} {} 2 two 2 niban ok 3 three {} {} {} 4 four {} {} {}}
68do_test join4-1.6 {
69  execsql {
70    select * from t1 left outer join t2 on t1.a=t2.x where t2.z IN ('ok')
71  }
72} {2 two 2 niban ok}
73do_test join4-1.7 {
74  execsql {
75    select * from t1 left outer join t2 on t1.a=t2.x and t2.z IN ('ok')
76  }
77} {1 one {} {} {} 2 two 2 niban ok 3 three {} {} {} 4 four {} {} {}}
78
79
80finish_test
81