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

Appearance settings

Commit dbf8262

Browse filesBrowse files
committed
A couple of sanity checks.
One of them is pretty ugly -- we are checking out pathman_config each time during create_single_range_partition_internal. Also invalidate prel cache after manual add_to_pathman_config, just in case.
1 parent debe43d commit dbf8262
Copy full SHA for dbf8262

File tree

2 files changed

+24
-0
lines changed
Filter options

2 files changed

+24
-0
lines changed

‎src/partition_creation.c

Copy file name to clipboardExpand all lines: src/partition_creation.c
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,23 @@ create_single_range_partition_internal(Oid parent_relid,
112112
init_callback_params callback_params;
113113
List *trigger_columns = NIL;
114114
Node *expr;
115+
Datum values[Natts_pathman_config];
116+
bool isnull[Natts_pathman_config];
117+
118+
119+
/*
120+
* Sanity check. Probably needed only if some absurd init_callback
121+
* decides to drop the table while we are creating partitions.
122+
* It seems much better to use prel cache here, but this doesn't work
123+
* because it regards tables with no partitions as not partitioned at all
124+
* (build_pathman_relation_info returns NULL), and if I comment out that,
125+
* tests fail for not immediately obvious reasons. Don't want to dig
126+
* into this now.
127+
*/
128+
if (!pathman_config_contains_relation(parent_relid, values, isnull, NULL, NULL))
129+
{
130+
elog(ERROR, "Can't create range partition: relid %u doesn't exist or not partitioned", parent_relid);
131+
}
115132

116133
/* Generate a name if asked to */
117134
if (!partition_rv)

‎src/pl_funcs.c

Copy file name to clipboardExpand all lines: src/pl_funcs.c
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,11 @@ show_cache_stats_internal(PG_FUNCTION_ARGS)
252252

253253
funccxt = SRF_FIRSTCALL_INIT();
254254

255+
if (!TopPathmanContext)
256+
{
257+
elog(ERROR, "pg_pathman's memory contexts are not initialized yet");
258+
}
259+
255260
old_mcxt = MemoryContextSwitchTo(funccxt->multi_call_memory_ctx);
256261

257262
usercxt = (show_cache_stats_cxt *) palloc(sizeof(show_cache_stats_cxt));
@@ -893,6 +898,8 @@ add_to_pathman_config(PG_FUNCTION_ARGS)
893898
}
894899
}
895900

901+
CacheInvalidateRelcacheByRelid(relid);
902+
896903
PG_RETURN_BOOL(true);
897904
}
898905

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.