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

Commitdbf8262

Browse files
committed
A couple of sanity checks.
One of them is pretty ugly -- we are checking out pathman_config each timeduring create_single_range_partition_internal.Also invalidate prel cache after manual add_to_pathman_config, just in case.
1 parentdebe43d commitdbf8262

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

‎src/partition_creation.c

Lines 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_paramscallback_params;
113113
List*trigger_columns=NIL;
114114
Node*expr;
115+
Datumvalues[Natts_pathman_config];
116+
boolisnull[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

Lines 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)

[8]ページ先頭

©2009-2025 Movatter.jp