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