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

Commitd4b754c

Browse files
committed
Ensure dummy paths have correct required_outer if rel is parameterized.
The assertions added by commits34ea1ab et al found another problem:set_dummy_rel_pathlist and mark_dummy_rel were failing to labelthe dummy paths they create with the correct outer_relids, in casethe relation is necessarily parameterized due to having lateralreferences in its tlist. It's likely that this has no user-visibleconsequences in production builds, at the moment; but still an assertionfailure is a bad thing, so back-patch the fix.Per bug #15694 from Roman Zharkov (via Alexander Lakhin)and an independent report by Tushar Ahuja.Discussion:https://postgr.es/m/15694-74f2ca97e7044f7f@postgresql.orgDiscussion:https://postgr.es/m/7d72ab20-c725-3ce2-f99d-4e64dd8a0de6@enterprisedb.com
1 parent0ca982a commitd4b754c

File tree

4 files changed

+43
-2
lines changed

4 files changed

+43
-2
lines changed

‎src/backend/optimizer/path/allpaths.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1768,7 +1768,9 @@ set_dummy_rel_pathlist(RelOptInfo *rel)
17681768
rel->partial_pathlist=NIL;
17691769

17701770
/* Set up the dummy path */
1771-
add_path(rel, (Path*)create_append_path(rel,NIL,NULL,0,NIL));
1771+
add_path(rel, (Path*)create_append_path(rel,NIL,
1772+
rel->lateral_relids,
1773+
0,NIL));
17721774

17731775
/*
17741776
* We set the cheapest-path fields immediately, just in case they were

‎src/backend/optimizer/path/joinrels.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,9 @@ mark_dummy_rel(RelOptInfo *rel)
12451245
rel->partial_pathlist=NIL;
12461246

12471247
/* Set up the dummy path */
1248-
add_path(rel, (Path*)create_append_path(rel,NIL,NULL,0,NIL));
1248+
add_path(rel, (Path*)create_append_path(rel,NIL,
1249+
rel->lateral_relids,
1250+
0,NIL));
12491251

12501252
/* Set or update cheapest_total_path and related fields */
12511253
set_cheapest(rel);

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5291,6 +5291,35 @@ select * from
52915291
Output: 3
52925292
(11 rows)
52935293

5294+
-- check dummy rels with lateral references (bug #15694)
5295+
explain (verbose, costs off)
5296+
select * from int8_tbl i8 left join lateral
5297+
(select *, i8.q2 from int4_tbl where false) ss on true;
5298+
QUERY PLAN
5299+
--------------------------------------
5300+
Nested Loop Left Join
5301+
Output: i8.q1, i8.q2, f1, (i8.q2)
5302+
-> Seq Scan on public.int8_tbl i8
5303+
Output: i8.q1, i8.q2
5304+
-> Result
5305+
Output: f1, i8.q2
5306+
One-Time Filter: false
5307+
(7 rows)
5308+
5309+
explain (verbose, costs off)
5310+
select * from int8_tbl i8 left join lateral
5311+
(select *, i8.q2 from int4_tbl i1, int4_tbl i2 where false) ss on true;
5312+
QUERY PLAN
5313+
-----------------------------------------
5314+
Nested Loop Left Join
5315+
Output: i8.q1, i8.q2, f1, f1, (i8.q2)
5316+
-> Seq Scan on public.int8_tbl i8
5317+
Output: i8.q1, i8.q2
5318+
-> Result
5319+
Output: f1, f1, i8.q2
5320+
One-Time Filter: false
5321+
(7 rows)
5322+
52945323
-- check handling of nested appendrels inside LATERAL
52955324
select * from
52965325
((select 2 as v) union all (select 3 as v)) as q1

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,6 +1730,14 @@ select * from
17301730
select*from (select3as z offset0) zwherez.z=x.x
17311731
) zzonzz.z=y.y;
17321732

1733+
-- check dummy rels with lateral references (bug #15694)
1734+
explain (verbose, costs off)
1735+
select*from int8_tbl i8left join lateral
1736+
(select*,i8.q2from int4_tblwhere false) sson true;
1737+
explain (verbose, costs off)
1738+
select*from int8_tbl i8left join lateral
1739+
(select*,i8.q2from int4_tbl i1, int4_tbl i2where false) sson true;
1740+
17331741
-- check handling of nested appendrels inside LATERAL
17341742
select*from
17351743
((select2as v)union all (select3as v))as q1

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp