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

Commitfc4089f

Browse files
committed
Fix possible crash in add_paths_to_append_rel()
While working ona8a968a, I failed to consider thatcheapest_startup_path can be NULL when there is no non-parameterizedpath in the pathlist. This is well documented in set_cheapest(), I justfailed to notice.Here we adjust the code to just check if the RelOptInfo has acheapest_startup_path set before adding it to the startup_subpaths list.Reported-by: Richard GuoAuthor: Richard GuoDiscussion:https://postgr.es/m/CAMbWs49w3t03V69XhdCuw+GDwivny4uQUxrkVp6Gejaspt0wMQ@mail.gmail.com
1 parent4f3b56e commitfc4089f

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,14 +1350,17 @@ add_paths_to_append_rel(PlannerInfo *root, RelOptInfo *rel,
13501350

13511351
/*
13521352
* When the planner is considering cheap startup plans, we'll also
1353-
* collect all the cheapest_startup_paths and build an AppendPath
1354-
* containing those as subpaths.
1353+
* collect all the cheapest_startup_paths(if set)and build an
1354+
*AppendPathcontaining those as subpaths.
13551355
*/
1356-
if (rel->consider_startup&&childrel->pathlist!=NIL&&
1357-
childrel->cheapest_startup_path->param_info==NULL)
1356+
if (rel->consider_startup&&childrel->cheapest_startup_path!=NULL)
1357+
{
1358+
/* cheapest_startup_path must not be a parameterized path. */
1359+
Assert(childrel->cheapest_startup_path->param_info==NULL);
13581360
accumulate_append_subpath(childrel->cheapest_startup_path,
13591361
&startup_subpaths,
13601362
NULL);
1363+
}
13611364
else
13621365
startup_subpaths_valid= false;
13631366

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,3 +1453,19 @@ inner join tenk2 t2 on t1.tenthous = t2.tenthous
14531453
-> Result
14541454
(8 rows)
14551455

1456+
-- Ensure there is no problem if cheapest_startup_path is NULL
1457+
explain (costs off)
1458+
select * from tenk1 t1
1459+
left join lateral
1460+
(select t1.tenthous from tenk2 t2 union all (values(1)))
1461+
on true limit 1;
1462+
QUERY PLAN
1463+
-------------------------------------------------------------------
1464+
Limit
1465+
-> Nested Loop Left Join
1466+
-> Seq Scan on tenk1 t1
1467+
-> Append
1468+
-> Index Only Scan using tenk2_hundred on tenk2 t2
1469+
-> Result
1470+
(6 rows)
1471+

‎src/test/regress/sql/union.sql

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,4 +550,11 @@ explain (costs off)
550550
selectt1.unique1from tenk1 t1
551551
inner join tenk2 t2ont1.tenthous=t2.tenthous
552552
union all
553-
(values(1))limit1;
553+
(values(1))limit1;
554+
555+
-- Ensure there is no problem if cheapest_startup_path is NULL
556+
explain (costs off)
557+
select*from tenk1 t1
558+
left join lateral
559+
(selectt1.tenthousfrom tenk2 t2union all (values(1)))
560+
on truelimit1;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp