1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/join4.test Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,98 @@
1.4 +# 2002 May 24
1.5 +#
1.6 +# The author disclaims copyright to this source code. In place of
1.7 +# a legal notice, here is a blessing:
1.8 +#
1.9 +# May you do good and not evil.
1.10 +# May you find forgiveness for yourself and forgive others.
1.11 +# May you share freely, never taking more than you give.
1.12 +#
1.13 +#***********************************************************************
1.14 +# This file implements regression tests for SQLite library.
1.15 +#
1.16 +# This file implements tests for left outer joins containing WHERE
1.17 +# clauses that restrict the scope of the left term of the join.
1.18 +#
1.19 +# $Id: join4.test,v 1.4 2005/03/29 03:11:00 danielk1977 Exp $
1.20 +
1.21 +set testdir [file dirname $argv0]
1.22 +source $testdir/tester.tcl
1.23 +
1.24 +ifcapable tempdb {
1.25 + do_test join4-1.1 {
1.26 + execsql {
1.27 + create temp table t1(a integer, b varchar(10));
1.28 + insert into t1 values(1,'one');
1.29 + insert into t1 values(2,'two');
1.30 + insert into t1 values(3,'three');
1.31 + insert into t1 values(4,'four');
1.32 +
1.33 + create temp table t2(x integer, y varchar(10), z varchar(10));
1.34 + insert into t2 values(2,'niban','ok');
1.35 + insert into t2 values(4,'yonban','err');
1.36 + }
1.37 + execsql {
1.38 + select * from t1 left outer join t2 on t1.a=t2.x where t2.z='ok'
1.39 + }
1.40 + } {2 two 2 niban ok}
1.41 +} else {
1.42 + do_test join4-1.1 {
1.43 + execsql {
1.44 + create table t1(a integer, b varchar(10));
1.45 + insert into t1 values(1,'one');
1.46 + insert into t1 values(2,'two');
1.47 + insert into t1 values(3,'three');
1.48 + insert into t1 values(4,'four');
1.49 +
1.50 + create table t2(x integer, y varchar(10), z varchar(10));
1.51 + insert into t2 values(2,'niban','ok');
1.52 + insert into t2 values(4,'yonban','err');
1.53 + }
1.54 + execsql {
1.55 + select * from t1 left outer join t2 on t1.a=t2.x where t2.z='ok'
1.56 + }
1.57 + } {2 two 2 niban ok}
1.58 +}
1.59 +do_test join4-1.2 {
1.60 + execsql {
1.61 + select * from t1 left outer join t2 on t1.a=t2.x and t2.z='ok'
1.62 + }
1.63 +} {1 one {} {} {} 2 two 2 niban ok 3 three {} {} {} 4 four {} {} {}}
1.64 +do_test join4-1.3 {
1.65 + execsql {
1.66 + create index i2 on t2(z);
1.67 + }
1.68 + execsql {
1.69 + select * from t1 left outer join t2 on t1.a=t2.x where t2.z='ok'
1.70 + }
1.71 +} {2 two 2 niban ok}
1.72 +do_test join4-1.4 {
1.73 + execsql {
1.74 + select * from t1 left outer join t2 on t1.a=t2.x and t2.z='ok'
1.75 + }
1.76 +} {1 one {} {} {} 2 two 2 niban ok 3 three {} {} {} 4 four {} {} {}}
1.77 +do_test join4-1.5 {
1.78 + execsql {
1.79 + select * from t1 left outer join t2 on t1.a=t2.x where t2.z>='ok'
1.80 + }
1.81 +} {2 two 2 niban ok}
1.82 +do_test join4-1.4 {
1.83 + execsql {
1.84 + select * from t1 left outer join t2 on t1.a=t2.x and t2.z>='ok'
1.85 + }
1.86 +} {1 one {} {} {} 2 two 2 niban ok 3 three {} {} {} 4 four {} {} {}}
1.87 +ifcapable subquery {
1.88 + do_test join4-1.6 {
1.89 + execsql {
1.90 + select * from t1 left outer join t2 on t1.a=t2.x where t2.z IN ('ok')
1.91 + }
1.92 + } {2 two 2 niban ok}
1.93 + do_test join4-1.7 {
1.94 + execsql {
1.95 + select * from t1 left outer join t2 on t1.a=t2.x and t2.z IN ('ok')
1.96 + }
1.97 + } {1 one {} {} {} 2 two 2 niban ok 3 three {} {} {} 4 four {} {} {}}
1.98 +}
1.99 +
1.100 +
1.101 +finish_test