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

Commitd671416

Browse files
committed
[PGPRO-10286] Added error processing for some cases
Tags: pg_pathman
1 parent4b25894 commitd671416

File tree

5 files changed

+38
-6
lines changed

5 files changed

+38
-6
lines changed

‎src/declarative.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ handle_attach_partition(Oid parent_relid, AlterTableCmd *cmd)
237237

238238
/* Fetch pg_pathman's schema */
239239
pathman_schema=get_namespace_name(get_pathman_schema());
240+
if (pathman_schema==NULL)
241+
elog(ERROR,"pg_pathman schema not initialized");
240242

241243
/* Build function's name */
242244
proc_name=list_make2(makeString(pathman_schema),
@@ -296,6 +298,8 @@ handle_detach_partition(AlterTableCmd *cmd)
296298

297299
/* Fetch pg_pathman's schema */
298300
pathman_schema=get_namespace_name(get_pathman_schema());
301+
if (pathman_schema==NULL)
302+
elog(ERROR,"pg_pathman schema not initialized");
299303

300304
/* Build function's name */
301305
proc_name=list_make2(makeString(pathman_schema),

‎src/init.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,8 @@ static bool
273273
init_pathman_relation_oids(void)
274274
{
275275
Oidschema=get_pathman_schema();
276-
Assert(schema!=InvalidOid);
276+
if (schema==InvalidOid)
277+
return false;/* extension can be dropped by another backend */
277278

278279
/* Cache PATHMAN_CONFIG relation's Oid */
279280
pathman_config_relid=get_relname_relid(PATHMAN_CONFIG,schema);

‎src/partition_creation.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,7 @@ spawn_partitions_val(Oid parent_relid,/* parent's Oid */
585585
Oidparent_nsp=get_rel_namespace(parent_relid);
586586
char*parent_nsp_name=get_namespace_name(parent_nsp);
587587
char*partition_name=choose_range_partition_name(parent_relid,parent_nsp);
588+
char*pathman_schema;
588589

589590
/* Assign the 'following' boundary to current 'leading' value */
590591
cur_following_bound=cur_leading_bound;
@@ -611,10 +612,14 @@ spawn_partitions_val(Oid parent_relid,/* parent's Oid */
611612
typname=pstrdup(NameStr(((Form_pg_type)GETSTRUCT(typeTuple))->typname));
612613
ReleaseSysCache(typeTuple);
613614

615+
pathman_schema=get_namespace_name(get_pathman_schema());
616+
if (pathman_schema==NULL)
617+
elog(ERROR,"pg_pathman schema not initialized");
618+
614619
/* Construct call to create_single_range_partition() */
615620
create_sql=psprintf(
616621
"select %s.create_single_range_partition('%s.%s'::regclass, '%s'::%s, '%s'::%s, '%s.%s', NULL::text)",
617-
quote_identifier(get_namespace_name(get_pathman_schema())),
622+
quote_identifier(pathman_schema),
618623
quote_identifier(parent_nsp_name),
619624
quote_identifier(get_rel_name(parent_relid)),
620625
IsInfinite(&bounds[0]) ?"NULL" :datum_to_cstring(bounds[0].value,range_bound_type),
@@ -1195,6 +1200,8 @@ copy_foreign_keys(Oid parent_relid, Oid partition_oid)
11951200

11961201
/* Fetch pg_pathman's schema */
11971202
pathman_schema=get_namespace_name(get_pathman_schema());
1203+
if (pathman_schema==NULL)
1204+
elog(ERROR,"pg_pathman schema not initialized");
11981205

11991206
/* Build function's name */
12001207
copy_fkeys_proc_name=list_make2(makeString(pathman_schema),
@@ -1564,6 +1571,7 @@ build_raw_hash_check_tree(Node *raw_expression,
15641571

15651572
Oidhash_proc;
15661573
TypeCacheEntry*tce;
1574+
char*pathman_schema;
15671575

15681576
tce=lookup_type_cache(value_type,TYPECACHE_HASH_PROC);
15691577
hash_proc=tce->hash_proc;
@@ -1596,9 +1604,13 @@ build_raw_hash_check_tree(Node *raw_expression,
15961604
hash_call->over=NULL;
15971605
hash_call->location=-1;
15981606

1607+
pathman_schema=get_namespace_name(get_pathman_schema());
1608+
if (pathman_schema==NULL)
1609+
elog(ERROR,"pg_pathman schema not initialized");
1610+
15991611
/* Build schema-qualified name of function get_hash_part_idx() */
16001612
get_hash_part_idx_proc=
1601-
list_make2(makeString(get_namespace_name(get_pathman_schema())),
1613+
list_make2(makeString(pathman_schema),
16021614
makeString("get_hash_part_idx"));
16031615

16041616
/* Call get_hash_part_idx() */

‎src/pathman_workers.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,14 +520,19 @@ bgw_main_concurrent_part(Datum main_arg)
520520
if (sql==NULL)
521521
{
522522
MemoryContextcurrent_mcxt;
523+
char*pathman_schema;
524+
525+
pathman_schema=get_namespace_name(get_pathman_schema());
526+
if (pathman_schema==NULL)
527+
elog(ERROR,"pg_pathman schema not initialized");
523528

524529
/*
525530
* Allocate SQL query in TopPathmanContext because current
526531
* context will be destroyed after transaction finishes
527532
*/
528533
current_mcxt=MemoryContextSwitchTo(TopPathmanContext);
529534
sql=psprintf("SELECT %s._partition_data_concurrent($1::regclass, NULL::text, NULL::text, p_limit:=$2)",
530-
get_namespace_name(get_pathman_schema()));
535+
pathman_schema);
531536
MemoryContextSwitchTo(current_mcxt);
532537
}
533538

@@ -700,6 +705,7 @@ partition_table_concurrently(PG_FUNCTION_ARGS)
700705
i;
701706
TransactionIdrel_xmin;
702707
LOCKMODElockmode=ShareUpdateExclusiveLock;
708+
char*pathman_schema;
703709

704710
/* Check batch_size */
705711
if (batch_size<1||batch_size>10000)
@@ -800,11 +806,15 @@ partition_table_concurrently(PG_FUNCTION_ARGS)
800806
start_bgworker_errmsg(concurrent_part_bgw);
801807
}
802808

809+
pathman_schema=get_namespace_name(get_pathman_schema());
810+
if (pathman_schema==NULL)
811+
elog(ERROR,"pg_pathman schema not initialized");
812+
803813
/* Tell user everything's fine */
804814
elog(NOTICE,
805815
"worker started, you can stop it "
806816
"with the following command: select %s.%s('%s');",
807-
get_namespace_name(get_pathman_schema()),
817+
pathman_schema,
808818
CppAsString(stop_concurrent_part_task),
809819
get_rel_name(relid));
810820

‎src/pl_hash_funcs.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ build_hash_condition(PG_FUNCTION_ARGS)
122122
char*expr_cstr=TextDatumGetCString(PG_GETARG_DATUM(1));
123123
uint32part_count=PG_GETARG_UINT32(2),
124124
part_idx=PG_GETARG_UINT32(3);
125+
char*pathman_schema;
125126

126127
TypeCacheEntry*tce;
127128

@@ -141,9 +142,13 @@ build_hash_condition(PG_FUNCTION_ARGS)
141142
errmsg("no hash function for type %s",
142143
format_type_be(expr_type))));
143144

145+
pathman_schema=get_namespace_name(get_pathman_schema());
146+
if (pathman_schema==NULL)
147+
elog(ERROR,"pg_pathman schema not initialized");
148+
144149
/* Create hash condition CSTRING */
145150
result=psprintf("%s.get_hash_part_idx(%s(%s), %u) = %u",
146-
get_namespace_name(get_pathman_schema()),
151+
pathman_schema,
147152
get_func_name(tce->hash_proc),
148153
expr_cstr,
149154
part_count,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp