Fix create_lateral_join_info to handle dead relations properly.
Commit 0a480502b092195a9b25a2f0f199a21d592a9c57 broke it. Report by Andreas Seltenreich. Fix by Ashutosh Bapat. Discussion: http://postgr.es/m/874ls2vrnx.fsf@ansel.ydns.eu
This commit is contained in:
parent
7f3a3312ab
commit
57eebca03a
@ -632,7 +632,11 @@ create_lateral_join_info(PlannerInfo *root)
|
|||||||
RelOptInfo *brel = root->simple_rel_array[rti];
|
RelOptInfo *brel = root->simple_rel_array[rti];
|
||||||
RangeTblEntry *brte = root->simple_rte_array[rti];
|
RangeTblEntry *brte = root->simple_rte_array[rti];
|
||||||
|
|
||||||
if (brel == NULL)
|
/*
|
||||||
|
* Skip empty slots. Also skip non-simple relations i.e. dead
|
||||||
|
* relations.
|
||||||
|
*/
|
||||||
|
if (brel == NULL || !IS_SIMPLE_REL(brel))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -644,7 +648,6 @@ create_lateral_join_info(PlannerInfo *root)
|
|||||||
* therefore be marked with the appropriate lateral info so that those
|
* therefore be marked with the appropriate lateral info so that those
|
||||||
* children eventually get marked also.
|
* children eventually get marked also.
|
||||||
*/
|
*/
|
||||||
Assert(IS_SIMPLE_REL(brel));
|
|
||||||
Assert(brte);
|
Assert(brte);
|
||||||
if (brel->reloptkind == RELOPT_OTHER_MEMBER_REL &&
|
if (brel->reloptkind == RELOPT_OTHER_MEMBER_REL &&
|
||||||
(brte->rtekind != RTE_RELATION ||
|
(brte->rtekind != RTE_RELATION ||
|
||||||
|
@ -4060,6 +4060,18 @@ select i8.* from int8_tbl i8 left join (select f1 from int4_tbl group by f1) i4
|
|||||||
Seq Scan on int8_tbl i8
|
Seq Scan on int8_tbl i8
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
|
-- check join removal with lateral references
|
||||||
|
explain (costs off)
|
||||||
|
select 1 from (select a.id FROM a left join b on a.b_id = b.id) q,
|
||||||
|
lateral generate_series(1, q.id) gs(i) where q.id = gs.i;
|
||||||
|
QUERY PLAN
|
||||||
|
-------------------------------------------
|
||||||
|
Nested Loop
|
||||||
|
-> Seq Scan on a
|
||||||
|
-> Function Scan on generate_series gs
|
||||||
|
Filter: (a.id = i)
|
||||||
|
(4 rows)
|
||||||
|
|
||||||
rollback;
|
rollback;
|
||||||
create temp table parent (k int primary key, pd int);
|
create temp table parent (k int primary key, pd int);
|
||||||
create temp table child (k int unique, cd int);
|
create temp table child (k int unique, cd int);
|
||||||
|
@ -1336,6 +1336,11 @@ explain (costs off)
|
|||||||
select i8.* from int8_tbl i8 left join (select f1 from int4_tbl group by f1) i4
|
select i8.* from int8_tbl i8 left join (select f1 from int4_tbl group by f1) i4
|
||||||
on i8.q1 = i4.f1;
|
on i8.q1 = i4.f1;
|
||||||
|
|
||||||
|
-- check join removal with lateral references
|
||||||
|
explain (costs off)
|
||||||
|
select 1 from (select a.id FROM a left join b on a.b_id = b.id) q,
|
||||||
|
lateral generate_series(1, q.id) gs(i) where q.id = gs.i;
|
||||||
|
|
||||||
rollback;
|
rollback;
|
||||||
|
|
||||||
create temp table parent (k int primary key, pd int);
|
create temp table parent (k int primary key, pd int);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user