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

Commit89d5351

Browse files
committed
In planner.c, avoid assuming that all PathTargets have sortgrouprefs.
The struct definition for PathTarget specifies that a NULL sortgrouprefspointer means no sortgroupref labels. While it's likely that thereshould always be at least one labeled column in the places that wereunconditionally fetching through the pointer, it seems wiser to adhere tothe data structure specification and test first. Add a macro to make thisconvenient. Per experimentation with running the regression tests with avery small parallelization threshold --- the crash I observed may wellrepresent a bug elsewhere, but still this coding was not very robust.Report: <20756.1465834072@sss.pgh.pa.us>
1 parentcd9b4f2 commit89d5351

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4222,7 +4222,7 @@ make_group_input_target(PlannerInfo *root, PathTarget *final_target)
42224222
foreach(lc,final_target->exprs)
42234223
{
42244224
Expr*expr= (Expr*)lfirst(lc);
4225-
Indexsgref=final_target->sortgrouprefs[i];
4225+
Indexsgref=get_pathtarget_sortgroupref(final_target,i);
42264226

42274227
if (sgref&&parse->groupClause&&
42284228
get_sortgroupref_clause_noerr(sgref,parse->groupClause)!=NULL)
@@ -4304,7 +4304,7 @@ make_partialgroup_input_target(PlannerInfo *root, PathTarget *final_target)
43044304
foreach(lc,final_target->exprs)
43054305
{
43064306
Expr*expr= (Expr*)lfirst(lc);
4307-
Indexsgref=final_target->sortgrouprefs[i];
4307+
Indexsgref=get_pathtarget_sortgroupref(final_target,i);
43084308

43094309
if (sgref&&parse->groupClause&&
43104310
get_sortgroupref_clause_noerr(sgref,parse->groupClause)!=NULL)
@@ -4556,7 +4556,7 @@ make_window_input_target(PlannerInfo *root,
45564556
foreach(lc,final_target->exprs)
45574557
{
45584558
Expr*expr= (Expr*)lfirst(lc);
4559-
Indexsgref=final_target->sortgrouprefs[i];
4559+
Indexsgref=get_pathtarget_sortgroupref(final_target,i);
45604560

45614561
/*
45624562
* Don't want to deconstruct window clauses or GROUP BY items. (Note
@@ -4757,7 +4757,7 @@ make_sort_input_target(PlannerInfo *root,
47574757
* only be Vars anyway. There don't seem to be any cases where it
47584758
* would be worth the trouble to double-check.
47594759
*/
4760-
if (final_target->sortgrouprefs[i]==0)
4760+
if (get_pathtarget_sortgroupref(final_target,i)==0)
47614761
{
47624762
/*
47634763
* Check for SRF or volatile functions. Check the SRF case first
@@ -4847,7 +4847,7 @@ make_sort_input_target(PlannerInfo *root,
48474847
postponable_cols=lappend(postponable_cols,expr);
48484848
else
48494849
add_column_to_pathtarget(input_target,expr,
4850-
final_target->sortgrouprefs[i]);
4850+
get_pathtarget_sortgroupref(final_target,i));
48514851

48524852
i++;
48534853
}

‎src/include/nodes/relation.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,10 @@ typedef struct PathTarget
783783
intwidth;/* estimated avg width of result tuples */
784784
}PathTarget;
785785

786+
/* Convenience macro to get a sort/group refno from a PathTarget */
787+
#defineget_pathtarget_sortgroupref(target,colno) \
788+
((target)->sortgrouprefs ? (target)->sortgrouprefs[colno] : (Index) 0)
789+
786790

787791
/*
788792
* ParamPathInfo

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp