Skip to content

Commit f833863

Browse files
committed
several bugfixes, detect that pathman has been dropped more reliably
1 parent 2d49398 commit f833863

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

src/init.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static int oid_cmp(const void *p1, const void *p2);
8383
void
8484
load_config(void)
8585
{
86-
/* Cache PATHMAN_CONFIG relation Oid */
86+
/* Cache PATHMAN_CONFIG relation's Oid */
8787
pathman_config_relid = get_relname_relid(PATHMAN_CONFIG, get_pathman_schema());
8888

8989
init_local_cache(); /* create 'partitioned_rels' hash table */
@@ -99,7 +99,7 @@ load_config(void)
9999
/* Mark pg_pathman as initialized */
100100
initialization_needed = false;
101101

102-
elog(DEBUG2, "pg_pathman's config has been loaded successfully");
102+
elog(DEBUG2, "pg_pathman's config has been loaded successfully [%u]", MyProcPid);
103103
}
104104

105105
/*
@@ -108,12 +108,15 @@ load_config(void)
108108
void
109109
unload_config(void)
110110
{
111+
/* Don't forget to reset cached PATHMAN_CONFIG relation's Oid */
112+
pathman_config_relid = InvalidOid;
113+
111114
fini_local_cache(); /* destroy 'partitioned_rels' hash table */
112115

113116
/* Mark pg_pathman as uninitialized */
114117
initialization_needed = true;
115118

116-
elog(DEBUG2, "pg_pathman's config has been unloaded successfully");
119+
elog(DEBUG2, "pg_pathman's config has been unloaded successfully [%u]", MyProcPid);
117120
}
118121

119122
/*

src/pg_pathman.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2078,6 +2078,9 @@ generate_mergeappend_paths(PlannerInfo *root, RelOptInfo *rel,
20782078
}
20792079
}
20802080

2081+
/*
2082+
* Get cached PATHMAN_CONFIG relation Oid.
2083+
*/
20812084
Oid
20822085
get_pathman_config_relid(void)
20832086
{

src/relation_info.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,10 @@ refresh_pathman_relation_info(Oid relid,
137137

138138
/* If there's no children at all, remove this entry */
139139
if (prel_children_count == 0)
140+
{
140141
remove_pathman_relation_info(relid);
142+
return NULL;
143+
}
141144

142145
/*
143146
* Fill 'prel' with partition info, raise ERROR if anything is wrong.
@@ -306,10 +309,18 @@ finish_delayed_invalidation(void)
306309
/* Handle the probable 'DROP EXTENSION' case */
307310
if (delayed_shutdown)
308311
{
312+
Oid cur_pathman_config_relid;
313+
314+
/* Unset 'shutdown' flag */
309315
delayed_shutdown = false;
310316

317+
/* Get current PATHMAN_CONFIG relid */
318+
cur_pathman_config_relid = get_relname_relid(PATHMAN_CONFIG,
319+
get_pathman_schema());
320+
311321
/* Check that PATHMAN_CONFIG table has indeed been dropped */
312-
if (InvalidOid == get_relname_relid(PATHMAN_CONFIG, get_pathman_schema()))
322+
if (cur_pathman_config_relid == InvalidOid ||
323+
cur_pathman_config_relid != get_pathman_config_relid())
313324
{
314325
/* Ok, let's unload pg_pathman's config */
315326
unload_config();

0 commit comments

Comments
 (0)