]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
More JOIN test cases inspired by the problem fixed in [3869fd9a2b9483cb].
authordrh <>
Tue, 31 May 2022 17:24:56 +0000 (17:24 +0000)
committerdrh <>
Tue, 31 May 2022 17:24:56 +0000 (17:24 +0000)
FossilOrigin-Name: f2d224c5fa06de70f6f22e159a3b7065d4c6b004f9accc13004b9ac1f2fd5549

manifest
manifest.uuid
test/joinF.test [new file with mode: 0644]

index 56f93f7911b3049cf3a60cfadf1b52ab58d4ba7c..eedb0e4028ece89bb66696e2aa05fde6a4ec400c 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\san\sassert\sthat\sis\sincorrect\sfor\sa\scorrupt\sdatabase.
-D 2022-05-31T15:18:55.576
+C More\sJOIN\stest\scases\sinspired\sby\sthe\sproblem\sfixed\sin\s[3869fd9a2b9483cb].
+D 2022-05-31T17:24:56.173
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -1170,6 +1170,7 @@ F test/joinB.test 1b2ba3fc8568b49411787fccbf540570c148e9b6a53a30f80691cb6268098d
 F test/joinC.test 1f1a602c2127f55f136e2cbd3bf2d26546614bf8cffe5902ec1ac9c07f87f207
 F test/joinD.test 1a430af8dac5b68663f13df534ffe98775e582bac2305b80f1e8eb4ab778672a
 F test/joinE.test d5d182f3812771e2c0d97c9dcf5dbe4c41c8e21c82560e59358731c4a3981d6b
+F test/joinF.test 53dd66158806823ea680dd7543b5406af151b5aafa5cd06a7f3231cd94938127
 F test/journal1.test c7b768041b7f494471531e17abc2f4f5ebf9e5096984f43ed17c4eb80ba34497
 F test/journal2.test 9dac6b4ba0ca79c3b21446bbae993a462c2397c4
 F test/journal3.test 7c3cf23ffc77db06601c1fcfc9743de8441cb77db9d1aa931863d94f5ffa140e
@@ -1970,8 +1971,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 481e89c764ad8906cd21c8fbe58df57ae40bb3f261fa4892ea7ce7762786ad26
-R 8f91b5bbe0e66ec193c1dce7167d1ead
+P fe0a840805b435efd38a953a8aae60e29a35289f9d9955472a8bab2bce7051c8
+R c0ffeba5ccdcebb082740c0b41152760
 U drh
-Z ac5b54ebdc12e737823c0b3b4f423c63
+Z 0a8eec1e043d479748a93aebd2bf5bf2
 # Remove this line to create a well-formed Fossil manifest.
index 90d509d6850341c58f560f87e16c8e5016b60a4d..e3bc3713f722009ceda43c3bb9cc53dd363f9c5b 100644 (file)
@@ -1 +1 @@
-fe0a840805b435efd38a953a8aae60e29a35289f9d9955472a8bab2bce7051c8
\ No newline at end of file
+f2d224c5fa06de70f6f22e159a3b7065d4c6b004f9accc13004b9ac1f2fd5549
\ No newline at end of file
diff --git a/test/joinF.test b/test/joinF.test
new file mode 100644 (file)
index 0000000..0848e37
--- /dev/null
@@ -0,0 +1,613 @@
+# 2022-05-31
+#
+# The author disclaims copyright to this source code.  In place of
+# a legal notice, here is a blessing:
+#
+#    May you do good and not evil.
+#    May you find forgiveness for yourself and forgive others.
+#    May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# This file implements tests for JOINs
+#
+# The test case output is (mostly) all generated by PostgreSQL 14.  This
+# test module was created as follows:
+#
+#   1.   Run a TCL script (included at the bottom of this file) that
+#        generates an input script for "psql" that will run man
+#        diverse tests on joins.
+#
+#   2.   Run the script from step (1) through psql and collect the
+#        output.
+#
+#   3.   Make a few minor global search-and-replace operations to convert
+#        the psql output into a form suitable for this test module.
+#
+#   4.   Add this header, and the script content at the footer.
+#
+# A few extra tests that were not generated from postgresql output are
+# added at the end.
+#
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+db nullvalue -
+db eval {
+  CREATE TABLE t1(x INT);
+  CREATE TABLE t2(y INT);
+  CREATE TABLE t3(z INT);
+  CREATE TABLE t4(w INT);
+  INSERT INTO t1 VALUES(10);
+  INSERT INTO t3 VALUES(20),(30);
+  INSERT INTO t4 VALUES(50);
+}
+do_execsql_test joinF-1 {
+  SELECT *
+  FROM t1 INNER JOIN t2 ON true
+  INNER JOIN t3 ON t2.y IS NOT NULL
+  INNER JOIN t4 ON true
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-2 {
+  SELECT *
+  FROM t1 INNER JOIN t2 ON true
+  INNER JOIN t3 ON t2.y IS NOT NULL
+  INNER JOIN t4 ON true
+  WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-3 {
+  SELECT *
+  FROM t1 INNER JOIN t2 ON true
+  INNER JOIN t3 ON t2.y IS NOT NULL
+  LEFT JOIN t4 ON true
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-4 {
+  SELECT *
+  FROM t1 INNER JOIN t2 ON true
+  INNER JOIN t3 ON t2.y IS NOT NULL
+  LEFT JOIN t4 ON true
+  WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-5 {
+  SELECT *
+  FROM t1 INNER JOIN t2 ON true
+  INNER JOIN t3 ON t2.y IS NOT NULL
+  RIGHT JOIN t4 ON true
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+  - - - 50
+}
+do_execsql_test joinF-6 {
+  SELECT *
+  FROM t1 INNER JOIN t2 ON true
+  INNER JOIN t3 ON t2.y IS NOT NULL
+  RIGHT JOIN t4 ON true
+  WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-7 {
+  SELECT *
+  FROM t1 INNER JOIN t2 ON true
+  LEFT JOIN t3 ON t2.y IS NOT NULL
+  INNER JOIN t4 ON true
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-8 {
+  SELECT *
+  FROM t1 INNER JOIN t2 ON true
+  LEFT JOIN t3 ON t2.y IS NOT NULL
+  INNER JOIN t4 ON true
+  WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-9 {
+  SELECT *
+  FROM t1 INNER JOIN t2 ON true
+  LEFT JOIN t3 ON t2.y IS NOT NULL
+  LEFT JOIN t4 ON true
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-10 {
+  SELECT *
+  FROM t1 INNER JOIN t2 ON true
+  LEFT JOIN t3 ON t2.y IS NOT NULL
+  LEFT JOIN t4 ON true
+  WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-11 {
+  SELECT *
+  FROM t1 INNER JOIN t2 ON true
+  LEFT JOIN t3 ON t2.y IS NOT NULL
+  RIGHT JOIN t4 ON true
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+  - - - 50
+}
+do_execsql_test joinF-12 {
+  SELECT *
+  FROM t1 INNER JOIN t2 ON true
+  LEFT JOIN t3 ON t2.y IS NOT NULL
+  RIGHT JOIN t4 ON true
+  WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-13 {
+  SELECT *
+  FROM t1 INNER JOIN t2 ON true
+  RIGHT JOIN t3 ON t2.y IS NOT NULL
+  INNER JOIN t4 ON true
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+  - - 20 50
+  - - 30 50
+}
+do_execsql_test joinF-14 {
+  SELECT *
+  FROM t1 INNER JOIN t2 ON true
+  RIGHT JOIN t3 ON t2.y IS NOT NULL
+  INNER JOIN t4 ON true
+  WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+  - - 20 50
+  - - 30 50
+}
+do_execsql_test joinF-15 {
+  SELECT *
+  FROM t1 INNER JOIN t2 ON true
+  RIGHT JOIN t3 ON t2.y IS NOT NULL
+  LEFT JOIN t4 ON true
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+  - - 20 50
+  - - 30 50
+}
+do_execsql_test joinF-16 {
+  SELECT *
+  FROM t1 INNER JOIN t2 ON true
+  RIGHT JOIN t3 ON t2.y IS NOT NULL
+  LEFT JOIN t4 ON true
+  WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+  - - 20 50
+  - - 30 50
+}
+do_execsql_test joinF-17 {
+  SELECT *
+  FROM t1 INNER JOIN t2 ON true
+  RIGHT JOIN t3 ON t2.y IS NOT NULL
+  RIGHT JOIN t4 ON true
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+  - - 20 50
+  - - 30 50
+}
+do_execsql_test joinF-18 {
+  SELECT *
+  FROM t1 INNER JOIN t2 ON true
+  RIGHT JOIN t3 ON t2.y IS NOT NULL
+  RIGHT JOIN t4 ON true
+  WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+  - - 20 50
+  - - 30 50
+}
+do_execsql_test joinF-19 {
+  SELECT *
+  FROM t1 LEFT JOIN t2 ON true
+  INNER JOIN t3 ON t2.y IS NOT NULL
+  INNER JOIN t4 ON true
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-20 {
+  SELECT *
+  FROM t1 LEFT JOIN t2 ON true
+  INNER JOIN t3 ON t2.y IS NOT NULL
+  INNER JOIN t4 ON true
+  WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-21 {
+  SELECT *
+  FROM t1 LEFT JOIN t2 ON true
+  INNER JOIN t3 ON t2.y IS NOT NULL
+  LEFT JOIN t4 ON true
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-22 {
+  SELECT *
+  FROM t1 LEFT JOIN t2 ON true
+  INNER JOIN t3 ON t2.y IS NOT NULL
+  LEFT JOIN t4 ON true
+  WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-23 {
+  SELECT *
+  FROM t1 LEFT JOIN t2 ON true
+  INNER JOIN t3 ON t2.y IS NOT NULL
+  RIGHT JOIN t4 ON true
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+  - - - 50
+}
+do_execsql_test joinF-24 {
+  SELECT *
+  FROM t1 LEFT JOIN t2 ON true
+  INNER JOIN t3 ON t2.y IS NOT NULL
+  RIGHT JOIN t4 ON true
+  WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-25 {
+  SELECT *
+  FROM t1 LEFT JOIN t2 ON true
+  LEFT JOIN t3 ON t2.y IS NOT NULL
+  INNER JOIN t4 ON true
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+  10 - - 50
+}
+do_execsql_test joinF-26 {
+  SELECT *
+  FROM t1 LEFT JOIN t2 ON true
+  LEFT JOIN t3 ON t2.y IS NOT NULL
+  INNER JOIN t4 ON true
+  WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-27 {
+  SELECT *
+  FROM t1 LEFT JOIN t2 ON true
+  LEFT JOIN t3 ON t2.y IS NOT NULL
+  LEFT JOIN t4 ON true
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+  10 - - 50
+}
+do_execsql_test joinF-28 {
+  SELECT *
+  FROM t1 LEFT JOIN t2 ON true
+  LEFT JOIN t3 ON t2.y IS NOT NULL
+  LEFT JOIN t4 ON true
+  WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-29 {
+  SELECT *
+  FROM t1 LEFT JOIN t2 ON true
+  LEFT JOIN t3 ON t2.y IS NOT NULL
+  RIGHT JOIN t4 ON true
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+  10 - - 50
+}
+do_execsql_test joinF-30 {
+  SELECT *
+  FROM t1 LEFT JOIN t2 ON true
+  LEFT JOIN t3 ON t2.y IS NOT NULL
+  RIGHT JOIN t4 ON true
+  WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-31 {
+  SELECT *
+  FROM t1 LEFT JOIN t2 ON true
+  RIGHT JOIN t3 ON t2.y IS NOT NULL
+  INNER JOIN t4 ON true
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+  - - 20 50
+  - - 30 50
+}
+do_execsql_test joinF-32 {
+  SELECT *
+  FROM t1 LEFT JOIN t2 ON true
+  RIGHT JOIN t3 ON t2.y IS NOT NULL
+  INNER JOIN t4 ON true
+  WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+  - - 20 50
+  - - 30 50
+}
+do_execsql_test joinF-33 {
+  SELECT *
+  FROM t1 LEFT JOIN t2 ON true
+  RIGHT JOIN t3 ON t2.y IS NOT NULL
+  LEFT JOIN t4 ON true
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+  - - 20 50
+  - - 30 50
+}
+do_execsql_test joinF-34 {
+  SELECT *
+  FROM t1 LEFT JOIN t2 ON true
+  RIGHT JOIN t3 ON t2.y IS NOT NULL
+  LEFT JOIN t4 ON true
+  WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+  - - 20 50
+  - - 30 50
+}
+do_execsql_test joinF-35 {
+  SELECT *
+  FROM t1 LEFT JOIN t2 ON true
+  RIGHT JOIN t3 ON t2.y IS NOT NULL
+  RIGHT JOIN t4 ON true
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+  - - 20 50
+  - - 30 50
+}
+do_execsql_test joinF-36 {
+  SELECT *
+  FROM t1 LEFT JOIN t2 ON true
+  RIGHT JOIN t3 ON t2.y IS NOT NULL
+  RIGHT JOIN t4 ON true
+  WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+  - - 20 50
+  - - 30 50
+}
+do_execsql_test joinF-37 {
+  SELECT *
+  FROM t1 RIGHT JOIN t2 ON true
+  INNER JOIN t3 ON t2.y IS NOT NULL
+  INNER JOIN t4 ON true
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-38 {
+  SELECT *
+  FROM t1 RIGHT JOIN t2 ON true
+  INNER JOIN t3 ON t2.y IS NOT NULL
+  INNER JOIN t4 ON true
+  WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-39 {
+  SELECT *
+  FROM t1 RIGHT JOIN t2 ON true
+  INNER JOIN t3 ON t2.y IS NOT NULL
+  LEFT JOIN t4 ON true
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-40 {
+  SELECT *
+  FROM t1 RIGHT JOIN t2 ON true
+  INNER JOIN t3 ON t2.y IS NOT NULL
+  LEFT JOIN t4 ON true
+  WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-41 {
+  SELECT *
+  FROM t1 RIGHT JOIN t2 ON true
+  INNER JOIN t3 ON t2.y IS NOT NULL
+  RIGHT JOIN t4 ON true
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+  - - - 50
+}
+do_execsql_test joinF-42 {
+  SELECT *
+  FROM t1 RIGHT JOIN t2 ON true
+  INNER JOIN t3 ON t2.y IS NOT NULL
+  RIGHT JOIN t4 ON true
+  WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-43 {
+  SELECT *
+  FROM t1 RIGHT JOIN t2 ON true
+  LEFT JOIN t3 ON t2.y IS NOT NULL
+  INNER JOIN t4 ON true
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-44 {
+  SELECT *
+  FROM t1 RIGHT JOIN t2 ON true
+  LEFT JOIN t3 ON t2.y IS NOT NULL
+  INNER JOIN t4 ON true
+  WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-45 {
+  SELECT *
+  FROM t1 RIGHT JOIN t2 ON true
+  LEFT JOIN t3 ON t2.y IS NOT NULL
+  LEFT JOIN t4 ON true
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-46 {
+  SELECT *
+  FROM t1 RIGHT JOIN t2 ON true
+  LEFT JOIN t3 ON t2.y IS NOT NULL
+  LEFT JOIN t4 ON true
+  WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-47 {
+  SELECT *
+  FROM t1 RIGHT JOIN t2 ON true
+  LEFT JOIN t3 ON t2.y IS NOT NULL
+  RIGHT JOIN t4 ON true
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+  - - - 50
+}
+do_execsql_test joinF-48 {
+  SELECT *
+  FROM t1 RIGHT JOIN t2 ON true
+  LEFT JOIN t3 ON t2.y IS NOT NULL
+  RIGHT JOIN t4 ON true
+  WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+}
+do_execsql_test joinF-49 {
+  SELECT *
+  FROM t1 RIGHT JOIN t2 ON true
+  RIGHT JOIN t3 ON t2.y IS NOT NULL
+  INNER JOIN t4 ON true
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+  - - 20 50
+  - - 30 50
+}
+do_execsql_test joinF-50 {
+  SELECT *
+  FROM t1 RIGHT JOIN t2 ON true
+  RIGHT JOIN t3 ON t2.y IS NOT NULL
+  INNER JOIN t4 ON true
+  WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+  - - 20 50
+  - - 30 50
+}
+do_execsql_test joinF-51 {
+  SELECT *
+  FROM t1 RIGHT JOIN t2 ON true
+  RIGHT JOIN t3 ON t2.y IS NOT NULL
+  LEFT JOIN t4 ON true
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+  - - 20 50
+  - - 30 50
+}
+do_execsql_test joinF-52 {
+  SELECT *
+  FROM t1 RIGHT JOIN t2 ON true
+  RIGHT JOIN t3 ON t2.y IS NOT NULL
+  LEFT JOIN t4 ON true
+  WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+  - - 20 50
+  - - 30 50
+}
+do_execsql_test joinF-53 {
+  SELECT *
+  FROM t1 RIGHT JOIN t2 ON true
+  RIGHT JOIN t3 ON t2.y IS NOT NULL
+  RIGHT JOIN t4 ON true
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+  - - 20 50
+  - - 30 50
+}
+do_execsql_test joinF-54 {
+  SELECT *
+  FROM t1 RIGHT JOIN t2 ON true
+  RIGHT JOIN t3 ON t2.y IS NOT NULL
+  RIGHT JOIN t4 ON true
+  WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)
+  ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);
+} {
+  - - 20 50
+  - - 30 50
+}
+finish_test
+
+############################################################################
+# This is the TCL script used to generate the psql script that generated
+# the data above.
+#
+# puts "
+# \\pset border off
+# \\pset tuples_only on
+# \\pset null -
+# 
+# DROP TABLE IF EXISTS t1;
+# DROP TABLE IF EXISTS t2;
+# DROP TABLE IF EXISTS t3;
+# DROP TABLE IF EXISTS t4;
+# CREATE TABLE t1(x INT);
+# CREATE TABLE t2(y INT);
+# CREATE TABLE t3(z INT);
+# CREATE TABLE t4(w INT);
+# INSERT INTO t1 VALUES(10);
+# INSERT INTO t3 VALUES(20),(30);
+# INSERT INTO t4 VALUES(50);
+# "
+# 
+# proc echo {prefix txt} {
+#   regsub -all {\n} $txt \n$prefix txt
+#   puts "$prefix$txt"
+# }
+# 
+# set n 0
+# foreach j1 {INNER LEFT RIGHT} {
+#   foreach j2 {INNER LEFT RIGHT} {
+#     foreach j3 {INNER LEFT RIGHT} {
+# 
+# incr n
+# set q1 ""
+# append q1 "SELECT *\n"
+# append q1 "  FROM t1 $j1 JOIN t2 ON true\n"
+# append q1 "          $j2 JOIN t3 ON t2.y IS NOT NULL\n"
+# append q1 "          $j3 JOIN t4 ON true\n"
+# append q1 " ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);"
+# 
+# echo "\\qecho " "do_execsql_test joinF-$n \{"
+# echo "\\qecho X  " $q1
+# echo "\\qecho " "\} \{"
+# puts $q1
+# echo "\\qecho " "\}"
+# 
+# incr n
+# set q1 ""
+# append q1 "SELECT *\n"
+# append q1 "  FROM t1 $j1 JOIN t2 ON true\n"
+# append q1 "          $j2 JOIN t3 ON t2.y IS NOT NULL\n"
+# append q1 "          $j3 JOIN t4 ON true\n"
+# append q1 " WHERE (t3.z!=400 AND t3.z!=500 AND t3.z!=600)\n"
+# append q1 " ORDER BY coalesce(t1.x,t2.y,t3.z,t4.w,0);"
+# 
+# echo "\\qecho " "do_execsql_test joinF-$n \{"
+# echo "\\qecho X  " $q1
+# echo "\\qecho " "\} \{"
+# puts $q1
+# echo "\\qecho " "\}"
+# 
+#     }
+#   }
+# }
+#