summaryrefslogtreecommitdiff
path: root/src/test/regress/expected/join.out
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2023-02-04 12:45:53 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2023-02-04 12:45:53 -0500
commit5840c2027264d5dfad743c50874e0ebf8b840f3f (patch)
tree83a185563f0c66f5e9f8f56a2e2a9e57ae0a3841 /src/test/regress/expected/join.out
parentfaff8f8e47f18c7d589453e2e0d841d2bd96c1ac (diff)
downloadpostgresql-5840c2027264d5dfad743c50874e0ebf8b840f3f.tar.gz
Rethink treatment of "postponed" quals in deconstruct_jointree().
After pulling up LATERAL subqueries, we may have qual clauses that refer to relations outside their syntactic scope. Before doing any such pullup, prepjointree.c checks to make sure that it wouldn't create a semantically-invalid situation; but we leave it to deconstruct_jointree() to actually move these quals up the join tree to a place where they can be evaluated. In commit 2489d76c4, I (tgl) refactored deconstruct_jointree() in a way that caused assertion failures while moving such quals, because the new logic failed to distinguish "this jointree node is a parent of the source one" from "this jointree node is processed after the source one in depth-first order". Fix this, and at the same time reduce the overhead a bit, by getting rid of the common PostponedQual list and instead making each JoinTreeItem contain a list of quals that needed to be postponed to its level. We can help distribute_qual_to_rels find the appropriate JoinTreeItem efficiently by adding parent-item links to the JoinTreeItem data structure. This ends up being the same number of relid subset checks as the original (pre-bug) logic, but less list manipulation is required during multi-level postponements. Richard Guo and Tom Lane, per bug #17768 from Robins Tharakan. Discussion: https://postgr.es/m/17768-5ac8730ece54478f@postgresql.org
Diffstat (limited to 'src/test/regress/expected/join.out')
-rw-r--r--src/test/regress/expected/join.out22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/test/regress/expected/join.out b/src/test/regress/expected/join.out
index e73ba93ca3..8d7bd937a7 100644
--- a/src/test/regress/expected/join.out
+++ b/src/test/regress/expected/join.out
@@ -6203,6 +6203,28 @@ select * from
Output: 3
(11 rows)
+-- a new postponed-quals issue (bug #17768)
+explain (costs off)
+select * from int4_tbl t1,
+ lateral (select * from int4_tbl t2 inner join int4_tbl t3 on t1.f1 = 1
+ inner join (int4_tbl t4 left join int4_tbl t5 on true) on true) ss;
+ QUERY PLAN
+-------------------------------------------------
+ Nested Loop Left Join
+ -> Nested Loop
+ -> Nested Loop
+ -> Nested Loop
+ -> Seq Scan on int4_tbl t1
+ Filter: (f1 = 1)
+ -> Seq Scan on int4_tbl t2
+ -> Materialize
+ -> Seq Scan on int4_tbl t3
+ -> Materialize
+ -> Seq Scan on int4_tbl t4
+ -> Materialize
+ -> Seq Scan on int4_tbl t5
+(13 rows)
+
-- check dummy rels with lateral references (bug #15694)
explain (verbose, costs off)
select * from int8_tbl i8 left join lateral