/* Discard any pre-existing paths; no further need for them */
rel->pathlist = NIL;
- add_path(rel, (Path *) create_append_path(rel, NIL, NULL));
+ add_path(rel, (Path *) create_append_path(rel, NIL,
+ rel->lateral_relids));
/* Select cheapest path (pretty easy in this case...) */
set_cheapest(rel);
rel->pathlist = NIL;
/* Set up the dummy path */
- add_path(rel, (Path *) create_append_path(rel, NIL, NULL));
+ add_path(rel, (Path *) create_append_path(rel, NIL,
+ rel->lateral_relids));
/* Set or update cheapest_total_path and related fields */
set_cheapest(rel);
Output: 3
(11 rows)
+-- check dummy rels with lateral references (bug #15694)
+explain (verbose, costs off)
+select * from int8_tbl i8 left join lateral
+ (select *, i8.q2 from int4_tbl where false) ss on true;
+ QUERY PLAN
+----------------------------------------------
+ Nested Loop Left Join
+ Output: i8.q1, i8.q2, int4_tbl.f1, (i8.q2)
+ -> Seq Scan on public.int8_tbl i8
+ Output: i8.q1, i8.q2
+ -> Result
+ Output: int4_tbl.f1, (i8.q2)
+ One-Time Filter: false
+ -> Seq Scan on public.int4_tbl
+ Output: int4_tbl.f1, i8.q2
+(9 rows)
+
+explain (verbose, costs off)
+select * from int8_tbl i8 left join lateral
+ (select *, i8.q2 from int4_tbl i1, int4_tbl i2 where false) ss on true;
+ QUERY PLAN
+-----------------------------------------
+ Nested Loop Left Join
+ Output: i8.q1, i8.q2, f1, f1, (i8.q2)
+ -> Seq Scan on public.int8_tbl i8
+ Output: i8.q1, i8.q2
+ -> Result
+ Output: f1, f1, i8.q2
+ One-Time Filter: false
+(7 rows)
+
-- check handling of nested appendrels inside LATERAL
select * from
((select 2 as v) union all (select 3 as v)) as q1
select * from (select 3 as z) z where z.z = x.x
) zz on zz.z = y.y;
+-- check dummy rels with lateral references (bug #15694)
+explain (verbose, costs off)
+select * from int8_tbl i8 left join lateral
+ (select *, i8.q2 from int4_tbl where false) ss on true;
+explain (verbose, costs off)
+select * from int8_tbl i8 left join lateral
+ (select *, i8.q2 from int4_tbl i1, int4_tbl i2 where false) ss on true;
+
-- check handling of nested appendrels inside LATERAL
select * from
((select 2 as v) union all (select 3 as v)) as q1