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

Commit087abe7

Browse files
committed
resolve fixme regarding flushing all caches
1 parentee8ef93 commit087abe7

File tree

3 files changed

+64
-17
lines changed

3 files changed

+64
-17
lines changed

‎src/hooks.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -834,9 +834,9 @@ pathman_relcache_hook(Datum arg, Oid relid)
834834
/* Invalidation event for whole cache */
835835
if (relid==InvalidOid)
836836
{
837-
invalidate_pathman_status_info_cache();
838-
839-
/* FIXME: reset other caches as well */
837+
invalidate_bounds_cache();
838+
invalidate_parents_cache();
839+
invalidate_status_cache();
840840
}
841841

842842
/* Invalidation event for PATHMAN_CONFIG table (probably DROP) */
@@ -855,7 +855,7 @@ pathman_relcache_hook(Datum arg, Oid relid)
855855
forget_parent_of_partition(relid);
856856

857857
/* Invalidate PartStatusInfo entry if needed */
858-
invalidate_pathman_status_info(relid);
858+
forget_status_of_relation(relid);
859859
}
860860
}
861861

‎src/include/relation_info.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,16 @@ typedef struct PartBoundInfo
184184
uint32part_idx;
185185
}PartBoundInfo;
186186

187+
staticinlinevoid
188+
FreePartBoundInfo(PartBoundInfo*pbin)
189+
{
190+
if (pbin->parttype==PT_RANGE)
191+
{
192+
FreeBound(&pbin->range_min,pbin->byval);
193+
FreeBound(&pbin->range_max,pbin->byval);
194+
}
195+
}
196+
187197
/*
188198
* PartRelationInfo
189199
*Per-relation partitioning information.
@@ -341,8 +351,8 @@ PartTypeToCString(PartType parttype)
341351

342352

343353
/* Status chache */
344-
voidinvalidate_pathman_status_info(Oidrelid);
345-
voidinvalidate_pathman_status_info_cache(void);
354+
voidforget_status_of_relation(Oidrelid);
355+
voidinvalidate_status_cache(void);
346356

347357
/* Dispatch cache */
348358
boolhas_pathman_relation_info(Oidrelid);
@@ -359,11 +369,13 @@ void shout_if_prel_is_invalid(const Oid parent_oid,
359369
/* Bounds cache */
360370
voidforget_bounds_of_partition(Oidpartition);
361371
PartBoundInfo*get_bounds_of_partition(Oidpartition,constPartRelationInfo*prel);
372+
voidinvalidate_bounds_cache(void);
362373

363374
/* Parents cache */
364375
voidcache_parent_of_partition(Oidpartition,Oidparent);
365376
voidforget_parent_of_partition(Oidpartition);
366377
Oidget_parent_of_partition(Oidpartition);
378+
voidinvalidate_parents_cache(void);
367379

368380
/* Partitioning expression routines */
369381
Node*parse_partitioning_expression(constOidrelid,

‎src/relation_info.c

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ init_relation_info_static_data(void)
187187

188188
/* Invalidate PartStatusInfo for 'relid' */
189189
void
190-
invalidate_pathman_status_info(Oidrelid)
190+
forget_status_of_relation(Oidrelid)
191191
{
192192
PartStatusInfo*psin;
193193
PartParentInfo*ppar;
@@ -225,7 +225,7 @@ invalidate_pathman_status_info(Oid relid)
225225

226226
/* Invalidate all PartStatusInfo entries */
227227
void
228-
invalidate_pathman_status_info_cache(void)
228+
invalidate_status_cache(void)
229229
{
230230
invalidate_psin_entries_using_relid(InvalidOid);
231231
}
@@ -241,14 +241,14 @@ invalidate_psin_entries_using_relid(Oid relid)
241241

242242
while ((psin= (PartStatusInfo*)hash_seq_search(&status))!=NULL)
243243
{
244-
if (relid==InvalidOid||
244+
if (!OidIsValid(relid)||
245245
psin->relid==relid||
246246
(psin->prel&&PrelHasPartition(psin->prel,relid)))
247247
{
248248
/* Perform invalidation */
249249
invalidate_psin_entry(psin);
250250

251-
/* Exit iffound */
251+
/* Exit ifexact match */
252252
if (OidIsValid(relid))
253253
{
254254
hash_seq_term(&status);
@@ -952,15 +952,10 @@ forget_bounds_of_partition(Oid partition)
952952
NULL) :
953953
NULL;/* don't even bother */
954954

955-
/* Free this entry */
956955
if (pbin)
957956
{
958-
/* Call pfree() if it's RANGE bounds */
959-
if (pbin->parttype==PT_RANGE)
960-
{
961-
FreeBound(&pbin->range_min,pbin->byval);
962-
FreeBound(&pbin->range_max,pbin->byval);
963-
}
957+
/* Free this entry */
958+
FreePartBoundInfo(pbin);
964959

965960
/* Finally remove this entry from cache */
966961
pathman_cache_search_relid(bounds_cache,
@@ -1027,6 +1022,26 @@ get_bounds_of_partition(Oid partition, const PartRelationInfo *prel)
10271022
returnpbin;
10281023
}
10291024

1025+
void
1026+
invalidate_bounds_cache(void)
1027+
{
1028+
HASH_SEQ_STATUSstatus;
1029+
PartBoundInfo*pbin;
1030+
1031+
Assert(offsetof(PartBoundInfo,child_relid)==0);
1032+
1033+
hash_seq_init(&status,bounds_cache);
1034+
1035+
while ((pbin=hash_seq_search(&status))!=NULL)
1036+
{
1037+
FreePartBoundInfo(pbin);
1038+
1039+
pathman_cache_search_relid(bounds_cache,
1040+
pbin->child_relid,
1041+
HASH_REMOVE,NULL);
1042+
}
1043+
}
1044+
10301045
/*
10311046
* Get constraint expression tree of a partition.
10321047
*
@@ -1258,6 +1273,26 @@ get_parent_of_partition(Oid partition)
12581273
}
12591274
}
12601275

1276+
void
1277+
invalidate_parents_cache(void)
1278+
{
1279+
HASH_SEQ_STATUSstatus;
1280+
PartParentInfo*ppar;
1281+
1282+
Assert(offsetof(PartParentInfo,child_relid)==0);
1283+
1284+
hash_seq_init(&status,parents_cache);
1285+
1286+
while ((ppar=hash_seq_search(&status))!=NULL)
1287+
{
1288+
/* This is a plain structure, no need to pfree() */
1289+
1290+
pathman_cache_search_relid(parents_cache,
1291+
ppar->child_relid,
1292+
HASH_REMOVE,NULL);
1293+
}
1294+
}
1295+
12611296

12621297
/*
12631298
* Partitioning expression routines.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp