1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/where6.test Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,130 @@
1.4 +# 2007 June 8
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. The
1.15 +# focus of this file is testing that terms in the ON clause of
1.16 +# a LEFT OUTER JOIN are not used with indices. See ticket #3015.
1.17 +#
1.18 +# $Id: where6.test,v 1.2 2008/04/17 19:14:02 drh Exp $
1.19 +
1.20 +set testdir [file dirname $argv0]
1.21 +source $testdir/tester.tcl
1.22 +
1.23 +# Build some test data
1.24 +#
1.25 +do_test where6-1.1 {
1.26 + execsql {
1.27 + CREATE TABLE t1(a INTEGER PRIMARY KEY,b,c);
1.28 + INSERT INTO t1 VALUES(1,3,1);
1.29 + INSERT INTO t1 VALUES(2,4,2);
1.30 + CREATE TABLE t2(x INTEGER PRIMARY KEY);
1.31 + INSERT INTO t2 VALUES(3);
1.32 +
1.33 + SELECT * FROM t1 LEFT JOIN t2 ON b=x AND c=1;
1.34 + }
1.35 +} {1 3 1 3 2 4 2 {}}
1.36 +do_test where6-1.2 {
1.37 + execsql {
1.38 + SELECT * FROM t1 LEFT JOIN t2 ON x=b AND c=1;
1.39 + }
1.40 +} {1 3 1 3 2 4 2 {}}
1.41 +do_test where6-1.3 {
1.42 + execsql {
1.43 + SELECT * FROM t1 LEFT JOIN t2 ON x=b AND 1=c;
1.44 + }
1.45 +} {1 3 1 3 2 4 2 {}}
1.46 +do_test where6-1.4 {
1.47 + execsql {
1.48 + SELECT * FROM t1 LEFT JOIN t2 ON b=x AND 1=c;
1.49 + }
1.50 +} {1 3 1 3 2 4 2 {}}
1.51 +
1.52 +ifcapable explain {
1.53 + do_test where6-1.5 {
1.54 + explain_no_trace {SELECT * FROM t1 LEFT JOIN t2 ON x=b AND 1=c}
1.55 + } [explain_no_trace {SELECT * FROM t1 LEFT JOIN t2 ON b=x AND c=1}]
1.56 + do_test where6-1.6 {
1.57 + explain_no_trace {SELECT * FROM t1 LEFT JOIN t2 ON x=b WHERE 1=c}
1.58 + } [explain_no_trace {SELECT * FROM t1 LEFT JOIN t2 ON b=x WHERE c=1}]
1.59 +}
1.60 +
1.61 +do_test where6-1.11 {
1.62 + execsql {
1.63 + SELECT * FROM t1 LEFT JOIN t2 ON b=x WHERE c=1;
1.64 + }
1.65 +} {1 3 1 3}
1.66 +do_test where6-1.12 {
1.67 + execsql {
1.68 + SELECT * FROM t1 LEFT JOIN t2 ON x=b WHERE c=1;
1.69 + }
1.70 +} {1 3 1 3}
1.71 +do_test where6-1.13 {
1.72 + execsql {
1.73 + SELECT * FROM t1 LEFT JOIN t2 ON b=x WHERE 1=c;
1.74 + }
1.75 +} {1 3 1 3}
1.76 +
1.77 +
1.78 +
1.79 +do_test where6-2.1 {
1.80 + execsql {
1.81 + CREATE INDEX i1 ON t1(c);
1.82 +
1.83 + SELECT * FROM t1 LEFT JOIN t2 ON b=x AND c=1;
1.84 + }
1.85 +} {1 3 1 3 2 4 2 {}}
1.86 +do_test where6-2.2 {
1.87 + execsql {
1.88 + SELECT * FROM t1 LEFT JOIN t2 ON x=b AND c=1;
1.89 + }
1.90 +} {1 3 1 3 2 4 2 {}}
1.91 +do_test where6-2.3 {
1.92 + execsql {
1.93 + SELECT * FROM t1 LEFT JOIN t2 ON x=b AND 1=c;
1.94 + }
1.95 +} {1 3 1 3 2 4 2 {}}
1.96 +do_test where6-2.4 {
1.97 + execsql {
1.98 + SELECT * FROM t1 LEFT JOIN t2 ON b=x AND 1=c;
1.99 + }
1.100 +} {1 3 1 3 2 4 2 {}}
1.101 +
1.102 +ifcapable explain {
1.103 + do_test where6-2.5 {
1.104 + explain_no_trace {SELECT * FROM t1 LEFT JOIN t2 ON x=b AND 1=c}
1.105 + } [explain_no_trace {SELECT * FROM t1 LEFT JOIN t2 ON b=x AND c=1}]
1.106 + do_test where6-2.6 {
1.107 + explain_no_trace {SELECT * FROM t1 LEFT JOIN t2 ON x=b WHERE 1=c}
1.108 + } [explain_no_trace {SELECT * FROM t1 LEFT JOIN t2 ON b=x WHERE c=1}]
1.109 +}
1.110 +
1.111 +
1.112 +do_test where6-2.11 {
1.113 + execsql {
1.114 + SELECT * FROM t1 LEFT JOIN t2 ON b=x WHERE c=1;
1.115 + }
1.116 +} {1 3 1 3}
1.117 +do_test where6-2.12 {
1.118 + execsql {
1.119 + SELECT * FROM t1 LEFT JOIN t2 ON x=b WHERE c=1;
1.120 + }
1.121 +} {1 3 1 3}
1.122 +do_test where6-2.13 {
1.123 + execsql {
1.124 + SELECT * FROM t1 LEFT JOIN t2 ON x=b WHERE 1=c;
1.125 + }
1.126 +} {1 3 1 3}
1.127 +do_test where6-2.14 {
1.128 + execsql {
1.129 + SELECT * FROM t1 LEFT JOIN t2 ON b=x WHERE 1=c;
1.130 + }
1.131 +} {1 3 1 3}
1.132 +
1.133 +finish_test