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

Commit5bab8f8

Browse files
committed
check rel->baserestrictinfo & ppi->ppi_clauses for partitioned column before creating RuntimeXXX paths
1 parentd514103 commit5bab8f8

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed

‎src/hooks.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ pathman_join_pathlist_hook(PlannerInfo *root,
4444
ListCell*lc;
4545
doubleparamsel;
4646
WalkerContextcontext;
47+
boolinnerrel_rinfo_contains_part_attr;
4748

4849
if (set_join_pathlist_next)
4950
set_join_pathlist_next(root,joinrel,outerrel,
@@ -92,6 +93,11 @@ pathman_join_pathlist_hook(PlannerInfo *root,
9293
paramsel *=wrap->paramsel;
9394
}
9495

96+
innerrel_rinfo_contains_part_attr=
97+
check_rinfo_for_partitioned_attr(innerrel->baserestrictinfo,
98+
innerrel->relid,
99+
inner_prel->attnum);
100+
95101
foreach (lc,innerrel->pathlist)
96102
{
97103
AppendPath*cur_inner_path= (AppendPath*)lfirst(lc);
@@ -107,6 +113,16 @@ pathman_join_pathlist_hook(PlannerInfo *root,
107113

108114
ppi=get_baserel_parampathinfo(root,innerrel,inner_required);
109115

116+
/*
117+
* Skip if neither rel->baserestrictinfo nor
118+
* ppi->ppi_clauses reference partition attribute
119+
*/
120+
if (!(innerrel_rinfo_contains_part_attr||
121+
(ppi&&check_rinfo_for_partitioned_attr(ppi->ppi_clauses,
122+
innerrel->relid,
123+
inner_prel->attnum))))
124+
continue;
125+
110126
inner=create_runtimeappend_path(root,cur_inner_path,
111127
ppi,
112128
paramsel);
@@ -162,6 +178,7 @@ pathman_rel_pathlist_hook(PlannerInfo *root, RelOptInfo *rel, Index rti, RangeTb
162178
doubleparamsel=1.0;
163179
WalkerContextcontext;
164180
inti;
181+
boolrel_rinfo_contains_part_attr= false;
165182

166183
if (prel->parttype==PT_RANGE)
167184
{
@@ -280,6 +297,11 @@ pathman_rel_pathlist_hook(PlannerInfo *root, RelOptInfo *rel, Index rti, RangeTb
280297
if (!clause_contains_params((Node*)get_actual_clauses(rel->baserestrictinfo)))
281298
return;
282299

300+
rel_rinfo_contains_part_attr=
301+
check_rinfo_for_partitioned_attr(rel->baserestrictinfo,
302+
rel->relid,
303+
prel->attnum);
304+
283305
foreach (lc,rel->pathlist)
284306
{
285307
AppendPath*cur_path= (AppendPath*)lfirst(lc);
@@ -295,6 +317,16 @@ pathman_rel_pathlist_hook(PlannerInfo *root, RelOptInfo *rel, Index rti, RangeTb
295317
continue;
296318
}
297319

320+
/*
321+
* Skip if neither rel->baserestrictinfo nor
322+
* ppi->ppi_clauses reference partition attribute
323+
*/
324+
if (!(rel_rinfo_contains_part_attr||
325+
(ppi&&check_rinfo_for_partitioned_attr(ppi->ppi_clauses,
326+
rel->relid,
327+
prel->attnum))))
328+
continue;
329+
298330
if (IsA(cur_path,AppendPath)&&pg_pathman_enable_runtimeappend)
299331
inner_path=create_runtimeappend_path(root,cur_path,
300332
ppi,paramsel);

‎src/utils.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include"utils.h"
1111
#include"nodes/nodeFuncs.h"
1212
#include"nodes/makefuncs.h"
13+
#include"optimizer/var.h"
14+
#include"optimizer/restrictinfo.h"
1315
#include"parser/parse_param.h"
1416
#include"utils/builtins.h"
1517
#include"rewrite/rewriteManip.h"
@@ -109,3 +111,33 @@ build_index_tlist(PlannerInfo *root, IndexOptInfo *index,
109111

110112
returntlist;
111113
}
114+
115+
/*
116+
* We should ensure that 'rel->baserestrictinfo' or 'ppi->ppi_clauses' contain
117+
* Var which corresponds to partition attribute before creating RuntimeXXX
118+
* paths since they are used by create_scan_plan() to form 'scan_clauses'
119+
* that are passed to create_customscan_plan().
120+
*/
121+
bool
122+
check_rinfo_for_partitioned_attr(List*rinfo,Indexvarno,AttrNumbervarattno)
123+
{
124+
List*vars;
125+
List*clauses;
126+
ListCell*lc;
127+
128+
clauses=get_actual_clauses(rinfo);
129+
130+
vars=pull_var_clause((Node*)clauses,
131+
PVC_REJECT_AGGREGATES,
132+
PVC_REJECT_PLACEHOLDERS);
133+
134+
foreach (lc,vars)
135+
{
136+
Var*var= (Var*)lfirst(lc);
137+
138+
if (var->varno==varno&&var->varoattno==varattno)
139+
return true;
140+
}
141+
142+
return false;
143+
}

‎src/utils.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,8 @@ bool clause_contains_params(Node *clause);
2727
List*build_index_tlist(PlannerInfo*root,IndexOptInfo*index,
2828
RelationheapRelation);
2929

30+
boolcheck_rinfo_for_partitioned_attr(List*rinfo,
31+
Indexvarno,
32+
AttrNumbervarattno);
33+
3034
#endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp