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

Commit476acbe

Browse files
committed
fix incorrect HASH_REMOVE usages, remove useless params in Prel-related macros and functions
1 parent8f87c53 commit476acbe

File tree

9 files changed

+47
-39
lines changed

9 files changed

+47
-39
lines changed

‎src/hooks.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pathman_join_pathlist_hook(PlannerInfo *root,
6161

6262
/* Check that innerrel is a BASEREL with inheritors & PartRelationInfo */
6363
if (innerrel->reloptkind!=RELOPT_BASEREL|| !inner_rte->inh||
64-
!(inner_prel=get_pathman_relation_info(inner_rte->relid,NULL)))
64+
!(inner_prel=get_pathman_relation_info(inner_rte->relid)))
6565
{
6666
return;/* Obviously not our case */
6767
}
@@ -177,7 +177,7 @@ pathman_rel_pathlist_hook(PlannerInfo *root, RelOptInfo *rel, Index rti, RangeTb
177177
return;
178178

179179
/* Proceed iff relation 'rel' is partitioned */
180-
if ((prel=get_pathman_relation_info(rte->relid,NULL))!=NULL)
180+
if ((prel=get_pathman_relation_info(rte->relid))!=NULL)
181181
{
182182
ListCell*lc;
183183
Oid*children;
@@ -225,7 +225,7 @@ pathman_rel_pathlist_hook(PlannerInfo *root, RelOptInfo *rel, Index rti, RangeTb
225225

226226
rte->inh= true;/* we must restore 'inh' flag! */
227227

228-
children=PrelGetChildrenArray(prel, true);
228+
children=PrelGetChildrenArray(prel);
229229
ranges=list_make1_irange(make_irange(0,PrelChildrenCount(prel)-1, false));
230230

231231
/* Make wrappers over restrictions and collect final rangeset */

‎src/init.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,7 @@ init_local_config(void)
125125
PART_RELS_SIZE*CHILD_FACTOR,
126126
&ctl,HASH_ELEM |HASH_BLOBS);
127127

128-
CacheRegisterRelcacheCallback(pathman_relcache_hook,
129-
PointerGetDatum(NULL));
128+
CacheRegisterRelcacheCallback(pathman_relcache_hook,PointerGetDatum(NULL));
130129
}
131130

132131
/*

‎src/nodes_common.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ get_partition_oids(List *ranges, int *n, const PartRelationInfo *prel)
247247
uint32allocated=INITIAL_ALLOC_NUM;
248248
uint32used=0;
249249
Oid*result= (Oid*)palloc(allocated*sizeof(Oid));
250-
Oid*children=PrelGetChildrenArray(prel, true);
250+
Oid*children=PrelGetChildrenArray(prel);
251251

252252
foreach (range_cell,ranges)
253253
{
@@ -349,7 +349,7 @@ create_append_plan_common(PlannerInfo *root, RelOptInfo *rel,
349349
{
350350
RuntimeAppendPath*rpath= (RuntimeAppendPath*)best_path;
351351
CustomScan*cscan;
352-
PartRelationInfo*prel=get_pathman_relation_info(rpath->relid,NULL);
352+
PartRelationInfo*prel=get_pathman_relation_info(rpath->relid);
353353

354354
cscan=makeNode(CustomScan);
355355
cscan->custom_scan_tlist=NIL;/* initial value (empty list) */
@@ -496,7 +496,7 @@ rescan_append_common(CustomScanState *node)
496496
Oid*parts;
497497
intnparts;
498498

499-
prel=get_pathman_relation_info(scan_state->relid,NULL);
499+
prel=get_pathman_relation_info(scan_state->relid);
500500
Assert(prel);
501501

502502
ranges=list_make1_irange(make_irange(0,PrelChildrenCount(prel)-1, false));

‎src/partition_filter.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ partition_filter_exec(CustomScanState *node)
167167
Datumvalue;
168168

169169
/* Fetch PartRelationInfo for this partitioned relation */
170-
prel=get_pathman_relation_info(state->partitioned_table,NULL);
170+
prel=get_pathman_relation_info(state->partitioned_table);
171171
if (!prel)
172172
{
173173
if (!state->warning_triggered)
@@ -389,7 +389,7 @@ partition_filter_visitor(Plan *plan, void *context)
389389
{
390390
Indexrindex=lfirst_int(lc2);
391391
Oidrelid=getrelid(rindex,rtable);
392-
PartRelationInfo*prel=get_pathman_relation_info(relid,NULL);
392+
PartRelationInfo*prel=get_pathman_relation_info(relid);
393393

394394
/* Check that table is partitioned */
395395
if (prel)

‎src/pg_pathman.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ disable_inheritance(Query *parse)
190190
if (rte->inh)
191191
{
192192
/* Look up this relation in pathman local cache */
193-
prel=get_pathman_relation_info(rte->relid,NULL);
193+
prel=get_pathman_relation_info(rte->relid);
194194
if (prel)
195195
{
196196
/* We'll set this flag later */
@@ -300,17 +300,16 @@ handle_modification_query(Query *parse)
300300
RangeTblEntry*rte;
301301
WrapperNode*wrap;
302302
Expr*expr;
303-
boolfound;
304303
WalkerContextcontext;
305304

306305
Assert(parse->commandType==CMD_UPDATE||
307306
parse->commandType==CMD_DELETE);
308307
Assert(parse->resultRelation>0);
309308

310309
rte=rt_fetch(parse->resultRelation,parse->rtable);
311-
prel=get_pathman_relation_info(rte->relid,&found);
310+
prel=get_pathman_relation_info(rte->relid);
312311

313-
if (!found)
312+
if (!prel)
314313
return;
315314

316315
/* Parse syntax tree and extract partition ranges */
@@ -331,7 +330,7 @@ handle_modification_query(Query *parse)
331330
IndexRangeirange=linitial_irange(ranges);
332331
if (irange.ir_lower==irange.ir_upper)
333332
{
334-
Oid*children=PrelGetChildrenArray(prel, true);
333+
Oid*children=PrelGetChildrenArray(prel);
335334
rte->relid=children[irange.ir_lower];
336335
rte->inh= false;
337336
}
@@ -803,7 +802,7 @@ create_partitions_internal(Oid relid, Datum value, Oid value_type)
803802
boolisnull[Natts_pathman_config];
804803

805804
/* Get both PartRelationInfo & PATHMAN_CONFIG contents for this relation */
806-
if ((prel=get_pathman_relation_info(relid,NULL))!=NULL&&
805+
if ((prel=get_pathman_relation_info(relid))!=NULL&&
807806
pathman_config_contains_relation(relid,values,isnull,NULL))
808807
{
809808
Datummin_rvalue,
@@ -1229,7 +1228,7 @@ search_range_partition_eq(const Datum value,
12291228
intnranges;
12301229
WrapperNoderesult;
12311230

1232-
ranges=PrelGetRangesArray(prel, true);
1231+
ranges=PrelGetRangesArray(prel);
12331232
nranges=PrelChildrenCount(prel);
12341233

12351234
select_range_partitions(value,

‎src/pl_funcs.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ find_or_create_range_partition(PG_FUNCTION_ARGS)
119119
RangeEntryfound_rentry;
120120
search_rangerel_resultsearch_state;
121121

122-
prel=get_pathman_relation_info(parent_oid,NULL);
122+
prel=get_pathman_relation_info(parent_oid);
123123

124124
if (!prel)
125125
PG_RETURN_NULL();
@@ -190,13 +190,13 @@ get_partition_range(PG_FUNCTION_ARGS)
190190
TypeCacheEntry*tce;
191191
ArrayType*arr;
192192

193-
prel=get_pathman_relation_info(parent_oid,NULL);
193+
prel=get_pathman_relation_info(parent_oid);
194194

195195
if (!prel)
196196
PG_RETURN_NULL();
197197

198-
ranges=PrelGetRangesArray(prel, true);
199-
parts=PrelGetChildrenArray(prel, true);
198+
ranges=PrelGetRangesArray(prel);
199+
parts=PrelGetChildrenArray(prel);
200200
tce=lookup_type_cache(prel->atttype,0);
201201

202202
/* Looking for specified partition */
@@ -279,15 +279,15 @@ get_range_by_idx(PG_FUNCTION_ARGS)
279279
RangeEntryre;
280280
Datum*elems;
281281

282-
prel=get_pathman_relation_info(parent_oid,NULL);
282+
prel=get_pathman_relation_info(parent_oid);
283283
if (!prel)
284284
elog(ERROR,"Cannot get partitioning cache entry for relation %u",parent_oid);
285285

286286
if (((uint32)abs(idx)) >=PrelChildrenCount(prel))
287287
elog(ERROR,"Partition #%d does not exist (max is #%u)",
288288
idx,PrelChildrenCount(prel)-1);
289289

290-
ranges=PrelGetRangesArray(prel, true);
290+
ranges=PrelGetRangesArray(prel);
291291
if (idx >=0)
292292
re=ranges[idx];
293293
elseif(idx==-1)
@@ -316,12 +316,12 @@ get_min_range_value(PG_FUNCTION_ARGS)
316316
PartRelationInfo*prel;
317317
RangeEntry*ranges;
318318

319-
prel=get_pathman_relation_info(parent_oid,NULL);
319+
prel=get_pathman_relation_info(parent_oid);
320320

321321
if (!prel||prel->parttype!=PT_RANGE||PrelChildrenCount(prel)==0)
322322
PG_RETURN_NULL();
323323

324-
ranges=PrelGetRangesArray(prel, true);
324+
ranges=PrelGetRangesArray(prel);
325325

326326
PG_RETURN_DATUM(ranges[0].min);
327327
}
@@ -336,12 +336,12 @@ get_max_range_value(PG_FUNCTION_ARGS)
336336
PartRelationInfo*prel;
337337
RangeEntry*ranges;
338338

339-
prel=get_pathman_relation_info(parent_oid,NULL);
339+
prel=get_pathman_relation_info(parent_oid);
340340

341341
if (!prel||prel->parttype!=PT_RANGE||PrelChildrenCount(prel)==0)
342342
PG_RETURN_NULL();
343343

344-
ranges=PrelGetRangesArray(prel, true);
344+
ranges=PrelGetRangesArray(prel);
345345

346346
PG_RETURN_DATUM(ranges[PrelChildrenCount(prel)-1].max);
347347
}
@@ -368,7 +368,7 @@ check_overlap(PG_FUNCTION_ARGS)
368368
RangeEntry*ranges;
369369
uint32i;
370370

371-
prel=get_pathman_relation_info(parent_oid,NULL);
371+
prel=get_pathman_relation_info(parent_oid);
372372

373373
if (!prel||prel->parttype!=PT_RANGE)
374374
PG_RETURN_NULL();
@@ -377,7 +377,7 @@ check_overlap(PG_FUNCTION_ARGS)
377377
fill_type_cmp_fmgr_info(&cmp_func_1,p1_type,prel->atttype);
378378
fill_type_cmp_fmgr_info(&cmp_func_2,p2_type,prel->atttype);
379379

380-
ranges=PrelGetRangesArray(prel, true);
380+
ranges=PrelGetRangesArray(prel);
381381
for (i=0;i<PrelChildrenCount(prel);i++)
382382
{
383383
intc1=FunctionCall2(&cmp_func_1,p1,ranges[i].max);

‎src/relation_info.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ refresh_pathman_relation_info(Oid relid,
124124
/* Initialize PartRelationInfo using syscache & typcache */
125125
prel->attnum=get_attnum(relid,part_column_name);
126126
prel->atttype=get_atttype(relid,prel->attnum);
127-
prel->atttypmod=get_atttypmod(relid,prel->attnum);
127+
prel->atttypmod=get_atttypmod(relid,prel->attnum);
128128

129129
/* Fetch HASH & CMP fuctions for atttype */
130130
typcache=lookup_type_cache(prel->atttype,
@@ -196,11 +196,11 @@ invalidate_pathman_relation_info(Oid relid, bool *found)
196196

197197
/* Get PartRelationInfo from local cache. */
198198
PartRelationInfo*
199-
get_pathman_relation_info(Oidrelid,bool*found)
199+
get_pathman_relation_info(Oidrelid)
200200
{
201201
PartRelationInfo*prel=hash_search(partitioned_rels,
202202
(constvoid*)&relid,
203-
HASH_FIND,found);
203+
HASH_FIND,NULL);
204204

205205
/* Refresh PartRelationInfo if needed */
206206
if (prel&& !PrelIsValid(prel))
@@ -238,15 +238,19 @@ remove_pathman_relation_info(Oid relid)
238238
{
239239
PartRelationInfo*prel=hash_search(partitioned_rels,
240240
(constvoid*)&relid,
241-
HASH_REMOVE,NULL);
242-
241+
HASH_FIND,NULL);
243242
if (prel)
244243
{
245244
/* Free these arrays iff they're not NULL */
246245
FreeChildrenArray(prel);
247246
FreeRangesArray(prel);
248247
}
249248

249+
/* Now let's remove the entry completely */
250+
hash_search(partitioned_rels,
251+
(constvoid*)&relid,
252+
HASH_REMOVE,NULL);
253+
250254
elog(DEBUG2,
251255
"Removing record for relation %u in pg_pathman's cache [%u]",
252256
relid,MyProcPid);
@@ -393,7 +397,7 @@ get_parent_of_partition_internal(Oid partition,
393397
Oidparent;
394398
PartParentInfo*ppar=hash_search(parent_cache,
395399
(constvoid*)&partition,
396-
action,NULL);
400+
HASH_FIND,NULL);
397401

398402
/* Set 'action_str' */
399403
switch (action)
@@ -418,6 +422,12 @@ get_parent_of_partition_internal(Oid partition,
418422
{
419423
if (status)*status=PPS_ENTRY_PART_PARENT;
420424
parent=ppar->parent_rel;
425+
426+
/* Remove entry if necessary */
427+
if (action==HASH_REMOVE)
428+
hash_search(parent_cache,
429+
(constvoid*)&partition,
430+
HASH_REMOVE,NULL);
421431
}
422432
/* Try fetching parent from syscache if 'status' is provided */
423433
elseif (status)

‎src/relation_info.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ typedef enum
101101
}PartParentSearch;
102102

103103

104-
#definePrelGetChildrenArray(prel,copy) ( (prel)->children )
104+
#definePrelGetChildrenArray(prel) ( (prel)->children )
105105

106-
#definePrelGetRangesArray(prel,copy) ( (prel)->ranges )
106+
#definePrelGetRangesArray(prel) ( (prel)->ranges )
107107

108108
#definePrelChildrenCount(prel) ( (prel)->children_count )
109109

@@ -115,7 +115,7 @@ PartRelationInfo *refresh_pathman_relation_info(Oid relid,
115115
constchar*part_column_name);
116116
voidinvalidate_pathman_relation_info(Oidrelid,bool*found);
117117
voidremove_pathman_relation_info(Oidrelid);
118-
PartRelationInfo*get_pathman_relation_info(Oidrelid,bool*found);
118+
PartRelationInfo*get_pathman_relation_info(Oidrelid);
119119

120120
voiddelay_invalidation_parent_rel(Oidparent);
121121
voiddelay_invalidation_vague_rel(Oidvague_rel);

‎src/utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ rowmark_add_tableoids(Query *parse)
613613
charresname[64];
614614

615615
/* Check that table is partitioned */
616-
if (!get_pathman_relation_info(parent,NULL))
616+
if (!get_pathman_relation_info(parent))
617617
continue;
618618

619619
var=makeVar(rc->rti,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp