3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give.
10 #***********************************************************************
11 # This file implements regression tests for SQLite library.
14 set testdir [file dirname $argv0]
15 source $testdir/tester.tcl
19 CREATE TABLE t1(a INT);
20 CREATE TABLE t2(b INT);
21 INSERT INTO t2(b) VALUES(NULL);
27 SELECT DISTINCT a FROM t1 FULL JOIN t2 ON true WHERE (b ISNULL);
30 SELECT a FROM t1 FULL JOIN t2 ON true;
33 SELECT a FROM t1 FULL JOIN t2 ON true WHERE (b ISNULL);
36 SELECT DISTINCT a FROM t1 FULL JOIN t2 ON true;
39 #-----------------------------------------------------------
44 CREATE TABLE r4(y INTEGER PRIMARY KEY);
45 INSERT INTO r4 VALUES(55);
49 SELECT 'value!' FROM r3 FULL JOIN r4 ON (y=x);
53 SELECT 'value!' FROM r3 FULL JOIN r4 ON (y=x) WHERE +y=55;
56 #-----------------------------------------------------------
61 CREATE TABLE t2 (c0 , c1 , c2 , UNIQUE (c0), UNIQUE (c2 DESC));
62 INSERT INTO t2 VALUES ('x', 'y', 'z');
64 CREATE VIEW v0(c0) AS SELECT FALSE;
67 do_catchsql_test 3.2 {
68 SELECT * FROM t0 LEFT OUTER JOIN t1 ON v0.c0 INNER JOIN v0 INNER JOIN t2 ON (t2.c2 NOT NULL);
69 } {1 {ON clause references tables to its right}}
71 #-------------------------------------------------------------
75 CREATE TABLE t1(a,b,c,d,e,f,g,h,PRIMARY KEY(a,b,c)) WITHOUT ROWID;
76 CREATE TABLE t2(i, j);
77 INSERT INTO t2 VALUES(10, 20);
81 SELECT (d IS NULL) FROM t1 RIGHT JOIN t2 ON (j=33);
85 CREATE INDEX i1 ON t1( (d IS NULL), d );
89 SELECT (d IS NULL) FROM t1 RIGHT JOIN t2 ON (j=33);
92 #-------------------------------------------------------------------------
100 INSERT INTO t3 VALUES('t3val');
103 do_execsql_test 5.1 {
104 SELECT * FROM t1 INNER JOIN t2 ON (0) RIGHT OUTER JOIN t3;
107 do_execsql_test 5.2 {
108 SELECT * FROM t1 INNER JOIN t2 ON (0) FULL OUTER JOIN t3;
111 do_execsql_test 5.3 {
112 SELECT * FROM t3 LEFT JOIN t2 ON (0);
115 do_execsql_test 5.4 {
116 SELECT * FROM t0 RIGHT JOIN t1 INNER JOIN t2 ON (0) RIGHT JOIN t3
119 do_execsql_test 5.5 {
120 SELECT * FROM t0 RIGHT JOIN t1 INNER JOIN t2 ON (0)
126 do_execsql_test 6.0 {
127 CREATE TABLE t1(a INT);
128 CREATE TABLE t2(b INT);
129 INSERT INTO t1 VALUES(3);
130 SELECT CASE WHEN t2.b THEN 0 ELSE 1 END FROM t1 LEFT JOIN t2 ON true;
132 do_execsql_test 6.1 {
133 SELECT * FROM t1 LEFT JOIN t2 ON true WHERE CASE WHEN t2.b THEN 0 ELSE 1 END;