Skip to content

Commit 01d9ad6

Browse files
committed
move refcount etc into PartRelationInfo
1 parent e5280fb commit 01d9ad6

File tree

4 files changed

+153
-161
lines changed

4 files changed

+153
-161
lines changed

Diff for: src/hooks.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ pathman_relcache_hook(Datum arg, Oid relid)
822822
/* Invalidation event for whole cache */
823823
if (relid == InvalidOid)
824824
{
825-
invalidate_pathman_status_info_cache();
825+
invalidate_pathman_relation_info_cache();
826826
}
827827

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

843843
/* Invalidate PartStatusInfo entry if needed */
844-
invalidate_pathman_status_info(relid);
844+
invalidate_pathman_relation_info(relid);
845845
}
846846
}
847847

Diff for: src/include/relation_info.h

+13-20
Original file line numberDiff line numberDiff line change
@@ -133,16 +133,14 @@ typedef struct
133133
*/
134134
typedef struct PartStatusInfo
135135
{
136-
Oid relid; /* key */
137-
int32 refcount; /* reference counter */
138-
bool is_valid; /* is this entry fresh? */
136+
Oid relid; /* key */
139137
struct PartRelationInfo *prel;
140138
} PartStatusInfo;
141139

142140
/*
143141
* PartParentInfo
144142
* Cached parent of the specified partition.
145-
* Allows us to quickly search for PartRelationInfo.
143+
* Allows us to quickly search for parent PartRelationInfo.
146144
*/
147145
typedef struct PartParentInfo
148146
{
@@ -177,7 +175,9 @@ typedef struct PartBoundInfo
177175
*/
178176
typedef struct PartRelationInfo
179177
{
180-
PartStatusInfo *psin; /* entry holding this prel */
178+
Oid relid; /* key */
179+
int32 refcount; /* reference counter */
180+
bool fresh; /* is this entry fresh? */
181181

182182
bool enable_parent; /* should plan include parent? */
183183

@@ -214,14 +214,18 @@ typedef struct PartRelationInfo
214214
* PartRelationInfo field access macros & functions.
215215
*/
216216

217-
#define PrelParentRelid(prel) ( (prel)->psin->relid )
217+
#define PrelParentRelid(prel) ( (prel)->relid )
218218

219219
#define PrelGetChildrenArray(prel) ( (prel)->children )
220220

221221
#define PrelGetRangesArray(prel) ( (prel)->ranges )
222222

223223
#define PrelChildrenCount(prel) ( (prel)->children_count )
224224

225+
#define PrelReferenceCount(prel) ( (prel)->refcount )
226+
227+
#define PrelIsFresh(prel) ( (prel)->fresh )
228+
225229
static inline uint32
226230
PrelLastChild(const PartRelationInfo *prel)
227231
{
@@ -265,14 +269,6 @@ AttrNumber *PrelExpressionAttributesMap(const PartRelationInfo *prel,
265269
TupleDesc source_tupdesc,
266270
int *map_length);
267271

268-
/*
269-
* PartStatusInfo field access macros & functions.
270-
*/
271-
272-
#define PsinIsValid(psin) ( (psin)->is_valid )
273-
274-
#define PsinReferenceCount(psin) ( (psin)->refcount )
275-
276272

277273
/* PartType wrappers */
278274
static inline void
@@ -312,6 +308,9 @@ PartTypeToCString(PartType parttype)
312308

313309
/* Dispatch cache */
314310
void refresh_pathman_relation_info(Oid relid);
311+
void invalidate_pathman_relation_info(Oid relid);
312+
void invalidate_pathman_relation_info_cache(void);
313+
void close_pathman_relation_info(PartRelationInfo *prel);
315314
const PartRelationInfo *get_pathman_relation_info(Oid relid);
316315
const PartRelationInfo *get_pathman_relation_info_after_lock(Oid relid,
317316
bool unlock_if_not_found,
@@ -321,12 +320,6 @@ void shout_if_prel_is_invalid(const Oid parent_oid,
321320
const PartRelationInfo *prel,
322321
const PartType expected_part_type);
323322

324-
/* Status cache */
325-
PartStatusInfo *open_pathman_status_info(Oid relid);
326-
void close_pathman_status_info(PartStatusInfo *psin);
327-
void invalidate_pathman_status_info(Oid relid);
328-
void invalidate_pathman_status_info_cache(void);
329-
330323
/* Bounds cache */
331324
void forget_bounds_of_partition(Oid partition);
332325
PartBoundInfo *get_bounds_of_partition(Oid partition, const PartRelationInfo *prel);

Diff for: src/init.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ pathman_config_contains_relation(Oid relid, Datum *values, bool *isnull,
692692
UnregisterSnapshot(snapshot);
693693
heap_close(rel, AccessShareLock);
694694

695-
elog(DEBUG2, "PATHMAN_CONFIG table %s relation %u",
695+
elog(DEBUG2, "PATHMAN_CONFIG %s relation %u",
696696
(contains_rel ? "contains" : "doesn't contain"), relid);
697697

698698
return contains_rel;

0 commit comments

Comments
 (0)