summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorTom Lane2023-02-04 22:40:35 +0000
committerTom Lane2023-02-04 22:40:35 +0000
commit9f452feeeb830534dc2ce743a2a14b109128326d (patch)
tree5df0088c54b7565fddabab435e8028b4228957fd /src/test
parent8538519db107777a6b06b7277185e6605caf8d4c (diff)
Fix thinko in qual distribution.
deconstruct_distribute tweaks the outer join scope (ojscope) it passes to distribute_qual_to_rels when considering an outer join qual that's above potentially-commutable outer joins. However, if the current join is *not* potentially commutable, we shouldn't do that. The argument that distribute_qual_to_rels will not do something wrong with the bogus ojscope falls flat if we don't pass it non-null postponed_oj_qual_list. Moreover, there's no need to play games in this case since we aren't going to commute anything. Per SQLSmith testing by Robins Tharakan. Discussion: https://postgr.es/m/CAEP4nAw74k4b-=93gmfCNX3MOY3y4uPxqbk_MnCVEpdsqHJVsg@mail.gmail.com
Diffstat (limited to 'src/test')
-rw-r--r--src/test/regress/expected/join.out18
-rw-r--r--src/test/regress/sql/join.sql10
2 files changed, 28 insertions, 0 deletions
diff --git a/src/test/regress/expected/join.out b/src/test/regress/expected/join.out
index c520839bf7..9762952efd 100644
--- a/src/test/regress/expected/join.out
+++ b/src/test/regress/expected/join.out
@@ -4451,6 +4451,24 @@ select * from
doh! | 123 | 456 | hi de ho neighbor |
(2 rows)
+-- check handling of a variable-free qual for a non-commutable outer join
+explain (costs off)
+select nspname
+from (select 1 as x) ss1
+left join
+( select n.nspname, c.relname
+ from pg_class c left join pg_namespace n on n.oid = c.relnamespace
+ where c.relkind = 'r'
+) ss2 on false;
+ QUERY PLAN
+--------------------------------
+ Nested Loop Left Join
+ Join Filter: false
+ -> Result
+ -> Result
+ One-Time Filter: false
+(5 rows)
+
--
-- test for appropriate join order in the presence of lateral references
--
diff --git a/src/test/regress/sql/join.sql b/src/test/regress/sql/join.sql
index b0e8d559cd..3ef2996040 100644
--- a/src/test/regress/sql/join.sql
+++ b/src/test/regress/sql/join.sql
@@ -1535,6 +1535,16 @@ select * from
left join int4_tbl i4
on i8.q1 = i4.f1;
+-- check handling of a variable-free qual for a non-commutable outer join
+explain (costs off)
+select nspname
+from (select 1 as x) ss1
+left join
+( select n.nspname, c.relname
+ from pg_class c left join pg_namespace n on n.oid = c.relnamespace
+ where c.relkind = 'r'
+) ss2 on false;
+
--
-- test for appropriate join order in the presence of lateral references
--