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 #***********************************************************************
12 # This file implements tests for JOINs that use Bloom filters.
14 # The test case output is (mostly) all generated by PostgreSQL 14. This
15 # test module was created as follows:
17 # 1. Run a TCL script (included at the bottom of this file) that
18 # generates an input script for "psql" that will run man
19 # diverse tests on joins.
21 # 2. Run the script from step (1) through psql and collect the
24 # 3. Make a few minor global search-and-replace operations to convert
25 # the psql output into a form suitable for this test module.
27 # 4. Add this header, and the script content at the footer.
29 set testdir [file dirname $argv0]
30 source $testdir/tester.tcl
33 CREATE TABLE t1(a INT);
34 INSERT INTO t1 VALUES(1),(NULL);
35 CREATE TABLE t2(b INT);
36 INSERT INTO t2 VALUES(2),(NULL);
38 do_execsql_test joinE-1 {
40 FROM t1 INNER JOIN t2 ON true
41 ORDER BY coalesce(a,b,3);
48 do_execsql_test joinE-2 {
50 FROM t1 INNER JOIN t2 ON true WHERE a IS NULL
51 ORDER BY coalesce(a,b,3);
56 do_execsql_test joinE-3 {
58 FROM t1 INNER JOIN t2 ON a IS NULL
59 ORDER BY coalesce(a,b,3);
64 do_execsql_test joinE-4 {
66 FROM t1 INNER JOIN t2 ON true WHERE b IS NULL
67 ORDER BY coalesce(a,b,3);
72 do_execsql_test joinE-5 {
74 FROM t1 INNER JOIN t2 ON b IS NULL
75 ORDER BY coalesce(a,b,3);
80 do_execsql_test joinE-6 {
82 FROM t1 LEFT JOIN t2 ON true
83 ORDER BY coalesce(a,b,3);
90 do_execsql_test joinE-7 {
92 FROM t1 LEFT JOIN t2 ON true WHERE a IS NULL
93 ORDER BY coalesce(a,b,3);
98 do_execsql_test joinE-8 {
100 FROM t1 LEFT JOIN t2 ON a IS NULL
101 ORDER BY coalesce(a,b,3);
107 do_execsql_test joinE-9 {
109 FROM t1 LEFT JOIN t2 ON true WHERE b IS NULL
110 ORDER BY coalesce(a,b,3);
115 do_execsql_test joinE-10 {
117 FROM t1 LEFT JOIN t2 ON b IS NULL
118 ORDER BY coalesce(a,b,3);
123 do_execsql_test joinE-11 {
125 FROM t1 RIGHT JOIN t2 ON true
126 ORDER BY coalesce(a,b,3);
133 do_execsql_test joinE-12 {
135 FROM t1 RIGHT JOIN t2 ON true WHERE a IS NULL
136 ORDER BY coalesce(a,b,3);
141 do_execsql_test joinE-13 {
143 FROM t1 RIGHT JOIN t2 ON a IS NULL
144 ORDER BY coalesce(a,b,3);
149 do_execsql_test joinE-14 {
151 FROM t1 RIGHT JOIN t2 ON true WHERE b IS NULL
152 ORDER BY coalesce(a,b,3);
157 do_execsql_test joinE-15 {
159 FROM t1 RIGHT JOIN t2 ON b IS NULL
160 ORDER BY coalesce(a,b,3);
166 do_execsql_test joinE-16 {
168 FROM t1 FULL JOIN t2 ON true
169 ORDER BY coalesce(a,b,3);
176 do_execsql_test joinE-17 {
178 FROM t1 FULL JOIN t2 ON true WHERE a IS NULL
179 ORDER BY coalesce(a,b,3);
185 # PG-14 is unable to perform this join. It says: FULL JOIN is only
186 # supported with merge-joinable or hash-joinable join conditions
188 # do_execsql_test joinE-18 {
190 # FROM t1 FULL JOIN t2 ON a IS NULL
191 # ORDER BY coalesce(a,b,3);
195 do_execsql_test joinE-19 {
197 FROM t1 FULL JOIN t2 ON true WHERE b IS NULL
198 ORDER BY coalesce(a,b,3);
204 # PG-14 is unable to perform this join. It says: FULL JOIN is only
205 # supported with merge-joinable or hash-joinable join conditions
207 # do_execsql_test joinE-20 {
209 # FROM t1 FULL JOIN t2 ON b IS NULL
210 # ORDER BY coalesce(a,b,3);
216 INSERT INTO t1 VALUES(1);
218 INSERT INTO t2 VALUES(NULL);
221 do_execsql_test joinE-21 {
223 FROM t1 INNER JOIN t2 ON true
224 ORDER BY coalesce(a,b,3);
228 do_execsql_test joinE-22 {
230 FROM t1 INNER JOIN t2 ON true WHERE a IS NULL
231 ORDER BY coalesce(a,b,3);
234 do_execsql_test joinE-23 {
236 FROM t1 INNER JOIN t2 ON a IS NULL
237 ORDER BY coalesce(a,b,3);
240 do_execsql_test joinE-24 {
242 FROM t1 INNER JOIN t2 ON true WHERE b IS NULL
243 ORDER BY coalesce(a,b,3);
247 do_execsql_test joinE-25 {
249 FROM t1 INNER JOIN t2 ON b IS NULL
250 ORDER BY coalesce(a,b,3);
254 do_execsql_test joinE-26 {
256 FROM t1 LEFT JOIN t2 ON true
257 ORDER BY coalesce(a,b,3);
261 do_execsql_test joinE-27 {
263 FROM t1 LEFT JOIN t2 ON true WHERE a IS NULL
264 ORDER BY coalesce(a,b,3);
267 do_execsql_test joinE-28 {
269 FROM t1 LEFT JOIN t2 ON a IS NULL
270 ORDER BY coalesce(a,b,3);
274 do_execsql_test joinE-29 {
276 FROM t1 LEFT JOIN t2 ON true WHERE b IS NULL
277 ORDER BY coalesce(a,b,3);
281 do_execsql_test joinE-30 {
283 FROM t1 LEFT JOIN t2 ON b IS NULL
284 ORDER BY coalesce(a,b,3);
288 do_execsql_test joinE-31 {
290 FROM t1 RIGHT JOIN t2 ON true
291 ORDER BY coalesce(a,b,3);
296 do_execsql_test joinE-32 {
298 FROM t1 RIGHT JOIN t2 ON true WHERE a IS NULL
299 ORDER BY coalesce(a,b,3);
303 do_execsql_test joinE-33 {
305 FROM t1 RIGHT JOIN t2 ON a IS NULL
306 ORDER BY coalesce(a,b,3);
310 do_execsql_test joinE-34 {
312 FROM t1 RIGHT JOIN t2 ON true WHERE b IS NULL
313 ORDER BY coalesce(a,b,3);
317 do_execsql_test joinE-35 {
319 FROM t1 RIGHT JOIN t2 ON b IS NULL
320 ORDER BY coalesce(a,b,3);
324 do_execsql_test joinE-36 {
326 FROM t1 FULL JOIN t2 ON true
327 ORDER BY coalesce(a,b,3);
331 do_execsql_test joinE-37 {
333 FROM t1 FULL JOIN t2 ON true WHERE a IS NULL
334 ORDER BY coalesce(a,b,3);
340 # do_execsql_test joinE-38 {
342 # FROM t1 FULL JOIN t2 ON a IS NULL
343 # ORDER BY coalesce(a,b,3);
347 do_execsql_test joinE-39 {
349 FROM t1 FULL JOIN t2 ON true WHERE b IS NULL
350 ORDER BY coalesce(a,b,3);
356 # do_execsql_test joinE-40 {
358 # FROM t1 FULL JOIN t2 ON b IS NULL
359 # ORDER BY coalesce(a,b,3);
365 ##############################################################################
366 # This is the PG-14 test script generator
370 # \\pset tuples_only on
373 # DROP TABLE IF EXISTS t1;
374 # DROP TABLE IF EXISTS t2;
375 # CREATE TABLE t1(a INT);
376 # INSERT INTO t1 VALUES(1),(NULL);
377 # CREATE TABLE t2(b INT);
378 # INSERT INTO t2 VALUES(2),(NULL);
381 # proc echo {prefix txt} {
382 # regsub -all {\n} $txt \n$prefix txt
388 # foreach j1 {INNER LEFT RIGHT FULL} {
391 # {true WHERE a IS NULL}
393 # {true WHERE b IS NULL}
400 # append q1 "SELECT a, b\n"
401 # append q1 " FROM t1 $j1 JOIN t2 ON $on1\n"
402 # append q1 " ORDER BY coalesce(a,b,3);"
404 # echo "\\qecho " "do_execsql_test joinE-$n \{"
405 # echo "\\qecho X " $q1
406 # echo "\\qecho " "\} \{"
408 # echo "\\qecho " "\}"
415 # INSERT INTO t1 VALUES(1);
417 # INSERT INTO t2 VALUES(NULL);
420 # foreach j1 {INNER LEFT RIGHT FULL} {
423 # {true WHERE a IS NULL}
425 # {true WHERE b IS NULL}
432 # append q1 "SELECT a, b\n"
433 # append q1 " FROM t1 $j1 JOIN t2 ON $on1\n"
434 # append q1 " ORDER BY coalesce(a,b,3);"
436 # echo "\\qecho " "do_execsql_test joinE-$n \{"
437 # echo "\\qecho X " $q1
438 # echo "\\qecho " "\} \{"
440 # echo "\\qecho " "\}"