Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit57eebca

Browse files
committed
Fix create_lateral_join_info to handle dead relations properly.
Commit0a48050 broke it.Report by Andreas Seltenreich. Fix by Ashutosh Bapat.Discussion:http://postgr.es/m/874ls2vrnx.fsf@ansel.ydns.eu
1 parent7f3a331 commit57eebca

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

‎src/backend/optimizer/plan/initsplan.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,11 @@ create_lateral_join_info(PlannerInfo *root)
632632
RelOptInfo*brel=root->simple_rel_array[rti];
633633
RangeTblEntry*brte=root->simple_rte_array[rti];
634634

635-
if (brel==NULL)
635+
/*
636+
* Skip empty slots. Also skip non-simple relations i.e. dead
637+
* relations.
638+
*/
639+
if (brel==NULL|| !IS_SIMPLE_REL(brel))
636640
continue;
637641

638642
/*
@@ -644,7 +648,6 @@ create_lateral_join_info(PlannerInfo *root)
644648
* therefore be marked with the appropriate lateral info so that those
645649
* children eventually get marked also.
646650
*/
647-
Assert(IS_SIMPLE_REL(brel));
648651
Assert(brte);
649652
if (brel->reloptkind==RELOPT_OTHER_MEMBER_REL&&
650653
(brte->rtekind!=RTE_RELATION||

‎src/test/regress/expected/join.out

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4060,6 +4060,18 @@ select i8.* from int8_tbl i8 left join (select f1 from int4_tbl group by f1) i4
40604060
Seq Scan on int8_tbl i8
40614061
(1 row)
40624062

4063+
-- check join removal with lateral references
4064+
explain (costs off)
4065+
select 1 from (select a.id FROM a left join b on a.b_id = b.id) q,
4066+
lateral generate_series(1, q.id) gs(i) where q.id = gs.i;
4067+
QUERY PLAN
4068+
-------------------------------------------
4069+
Nested Loop
4070+
-> Seq Scan on a
4071+
-> Function Scan on generate_series gs
4072+
Filter: (a.id = i)
4073+
(4 rows)
4074+
40634075
rollback;
40644076
create temp table parent (k int primary key, pd int);
40654077
create temp table child (k int unique, cd int);

‎src/test/regress/sql/join.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,6 +1336,11 @@ explain (costs off)
13361336
select i8.*from int8_tbl i8left join (select f1from int4_tblgroup by f1) i4
13371337
oni8.q1=i4.f1;
13381338

1339+
-- check join removal with lateral references
1340+
explain (costs off)
1341+
select1from (selecta.idFROM aleft join bona.b_id=b.id) q,
1342+
lateral generate_series(1,q.id) gs(i)whereq.id=gs.i;
1343+
13391344
rollback;
13401345

13411346
create temp table parent (kintprimary key, pdint);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp