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

Commite373da0

Browse files
committed
fix 'spawned' in spawn_partitions(), small fixes in pl_funcs.c, get_pathman_relation_info() returns pointer to const PartRelationInfo
1 parent18167f8 commite373da0

File tree

7 files changed

+146
-138
lines changed

7 files changed

+146
-138
lines changed

‎src/hooks.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@ pathman_join_pathlist_hook(PlannerInfo *root,
3636
JoinTypejointype,
3737
JoinPathExtraData*extra)
3838
{
39-
JoinCostWorkspaceworkspace;
40-
RangeTblEntry*inner_rte=root->simple_rte_array[innerrel->relid];
41-
PartRelationInfo*inner_prel;
42-
List*pathkeys=NIL,
43-
*joinclauses,
44-
*otherclauses;
45-
ListCell*lc;
46-
WalkerContextcontext;
47-
doubleparamsel;
48-
boolinnerrel_rinfo_contains_part_attr;
39+
JoinCostWorkspaceworkspace;
40+
RangeTblEntry*inner_rte=root->simple_rte_array[innerrel->relid];
41+
constPartRelationInfo*inner_prel;
42+
List*pathkeys=NIL,
43+
*joinclauses,
44+
*otherclauses;
45+
ListCell*lc;
46+
WalkerContextcontext;
47+
doubleparamsel;
48+
boolinnerrel_rinfo_contains_part_attr;
4949

5050
/* Call hooks set by other extensions */
5151
if (set_join_pathlist_next)
@@ -159,10 +159,10 @@ pathman_join_pathlist_hook(PlannerInfo *root,
159159
void
160160
pathman_rel_pathlist_hook(PlannerInfo*root,RelOptInfo*rel,Indexrti,RangeTblEntry*rte)
161161
{
162-
PartRelationInfo*prel=NULL;
163-
RangeTblEntry**new_rte_array;
164-
RelOptInfo**new_rel_array;
165-
intlen;
162+
constPartRelationInfo*prel;
163+
RangeTblEntry**new_rte_array;
164+
RelOptInfo**new_rel_array;
165+
intlen;
166166

167167
/* Invoke original hook if needed */
168168
if (set_rel_pathlist_hook_next!=NULL)

‎src/nodes_common.c

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ replace_tlist_varnos(List *child_tlist, RelOptInfo *parent)
139139

140140
/* Append partition attribute in case it's not present in target list */
141141
staticList*
142-
append_part_attr_to_tlist(List*tlist,Indexrelno,PartRelationInfo*prel)
142+
append_part_attr_to_tlist(List*tlist,Indexrelno,constPartRelationInfo*prel)
143143
{
144144
ListCell*lc;
145145
boolpart_attr_found= false;
@@ -346,9 +346,12 @@ create_append_plan_common(PlannerInfo *root, RelOptInfo *rel,
346346
List*clauses,List*custom_plans,
347347
CustomScanMethods*scan_methods)
348348
{
349-
RuntimeAppendPath*rpath= (RuntimeAppendPath*)best_path;
350-
CustomScan*cscan;
351-
PartRelationInfo*prel=get_pathman_relation_info(rpath->relid);
349+
RuntimeAppendPath*rpath= (RuntimeAppendPath*)best_path;
350+
constPartRelationInfo*prel;
351+
CustomScan*cscan;
352+
353+
prel=get_pathman_relation_info(rpath->relid);
354+
Assert(prel);
352355

353356
cscan=makeNode(CustomScan);
354357
cscan->custom_scan_tlist=NIL;/* initial value (empty list) */
@@ -487,27 +490,27 @@ end_append_common(CustomScanState *node)
487490
void
488491
rescan_append_common(CustomScanState*node)
489492
{
490-
RuntimeAppendState*scan_state= (RuntimeAppendState*)node;
491-
ExprContext*econtext=node->ss.ps.ps_ExprContext;
492-
PartRelationInfo*prel;
493-
List*ranges;
494-
ListCell*lc;
495-
Oid*parts;
496-
intnparts;
493+
RuntimeAppendState*scan_state= (RuntimeAppendState*)node;
494+
ExprContext*econtext=node->ss.ps.ps_ExprContext;
495+
constPartRelationInfo*prel;
496+
List*ranges;
497+
ListCell*lc;
498+
Oid*parts;
499+
intnparts;
497500

498501
prel=get_pathman_relation_info(scan_state->relid);
499502
Assert(prel);
500503

504+
/* First we select all available partitions... */
501505
ranges=list_make1_irange(make_irange(0,PrelChildrenCount(prel)-1, false));
502506

503507
InitWalkerContext(&scan_state->wcxt,prel,econtext, false);
504-
505508
foreach (lc,scan_state->custom_exprs)
506509
{
507510
WrapperNode*wn;
508511

512+
/* ... then we cut off irrelevant ones using the provided clauses */
509513
wn=walk_expr_tree((Expr*)lfirst(lc),&scan_state->wcxt);
510-
511514
ranges=irange_list_intersect(ranges,wn->rangeset);
512515
}
513516

‎src/partition_filter.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -153,18 +153,18 @@ partition_filter_exec(CustomScanState *node)
153153

154154
if (!TupIsNull(slot))
155155
{
156-
PartRelationInfo*prel;
156+
constPartRelationInfo*prel;
157157

158-
MemoryContextold_cxt;
158+
MemoryContextold_cxt;
159159

160-
List*ranges;
161-
intnparts;
162-
Oid*parts;
163-
Oidselected_partid;
160+
List*ranges;
161+
intnparts;
162+
Oid*parts;
163+
Oidselected_partid;
164164

165-
WalkerContextwcxt;
166-
boolisnull;
167-
Datumvalue;
165+
WalkerContextwcxt;
166+
boolisnull;
167+
Datumvalue;
168168

169169
/* Fetch PartRelationInfo for this partitioned relation */
170170
prel=get_pathman_relation_info(state->partitioned_table);
@@ -390,9 +390,9 @@ partition_filter_visitor(Plan *plan, void *context)
390390

391391
forboth (lc1,modify_table->plans,lc2,modify_table->resultRelations)
392392
{
393-
Indexrindex=lfirst_int(lc2);
394-
Oidrelid=getrelid(rindex,rtable);
395-
PartRelationInfo*prel=get_pathman_relation_info(relid);
393+
Indexrindex=lfirst_int(lc2);
394+
Oidrelid=getrelid(rindex,rtable);
395+
constPartRelationInfo*prel=get_pathman_relation_info(relid);
396396

397397
/* Check that table is partitioned */
398398
if (prel)

‎src/pg_pathman.c

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,10 @@ _PG_init(void)
175175
void
176176
disable_inheritance(Query*parse)
177177
{
178-
ListCell*lc;
179-
RangeTblEntry*rte;
180-
PartRelationInfo*prel;
181-
MemoryContextoldcontext;
178+
constPartRelationInfo*prel;
179+
RangeTblEntry*rte;
180+
MemoryContextoldcontext;
181+
ListCell*lc;
182182

183183
/* If query contains CTE (WITH statement) then handle subqueries too */
184184
disable_inheritance_cte(parse);
@@ -301,12 +301,12 @@ disable_inheritance_subselect_walker(Node *node, void *context)
301301
void
302302
handle_modification_query(Query*parse)
303303
{
304-
PartRelationInfo*prel;
305-
List*ranges;
306-
RangeTblEntry*rte;
307-
WrapperNode*wrap;
308-
Expr*expr;
309-
WalkerContextcontext;
304+
constPartRelationInfo*prel;
305+
List*ranges;
306+
RangeTblEntry*rte;
307+
WrapperNode*wrap;
308+
Expr*expr;
309+
WalkerContextcontext;
310310

311311
Assert(parse->commandType==CMD_UPDATE||
312312
parse->commandType==CMD_DELETE);
@@ -725,7 +725,7 @@ spawn_partitions(Oid partitioned_rel,/* parent's Oid */
725725

726726
FmgrInfointerval_move_bound;/* function to move upper\lower boundary */
727727
boolinterval_move_bound_cached= false;/* is it cached already? */
728-
booldone= false;
728+
boolspawned= false;
729729

730730
Datumcur_part_leading=leading_bound;
731731

@@ -737,7 +737,7 @@ spawn_partitions(Oid partitioned_rel,/* parent's Oid */
737737
get_namespace_name(get_pathman_schema()));
738738

739739
/* Execute comparison function cmp(value, cur_part_leading) */
740-
while ((done=do_compare(cmp_proc,value,cur_part_leading,forward)))
740+
while (do_compare(cmp_proc,value,cur_part_leading,forward))
741741
{
742742
char*nulls=NULL;/* no params are NULL */
743743
Oidtypes[3]= {REGCLASSOID,leading_bound_type,leading_bound_type };
@@ -786,11 +786,14 @@ spawn_partitions(Oid partitioned_rel,/* parent's Oid */
786786
DebugPrintDatum(cur_part_leading,leading_bound_type),
787787
MyProcPid);
788788
#endif
789+
790+
/* We have spawned at least 1 partition */
791+
spawned= true;
789792
}
790793

791794
pfree(query);
792795

793-
returndone;
796+
returnspawned;
794797
}
795798

796799
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp