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

Commitf3ee021

Browse files
committed
refactoring (static inline), introduce function WrongPartType()
1 parent879dc1d commitf3ee021

File tree

6 files changed

+49
-54
lines changed

6 files changed

+49
-54
lines changed

‎src/include/relation_info.h

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,47 @@ void forget_bounds_of_partition(Oid partition);
308308
PartBoundInfo*get_bounds_of_partition(Oidpartition,
309309
constPartRelationInfo*prel);
310310

311-
/* Safe casts for PartType */
312-
PartTypeDatumGetPartType(Datumdatum);
313-
char*PartTypeToCString(PartTypeparttype);
311+
/* PartType wrappers */
312+
313+
staticinlinevoid
314+
WrongPartType(PartTypeparttype)
315+
{
316+
elog(ERROR,"Unknown partitioning type %u",parttype);
317+
}
318+
319+
staticinlinePartType
320+
DatumGetPartType(Datumdatum)
321+
{
322+
uint32parttype=DatumGetUInt32(datum);
323+
324+
if (parttype<1||parttype>2)
325+
WrongPartType(parttype);
326+
327+
return (PartType)parttype;
328+
}
329+
330+
staticinlinechar*
331+
PartTypeToCString(PartTypeparttype)
332+
{
333+
staticchar*hash_str="1",
334+
*range_str="2";
335+
336+
switch (parttype)
337+
{
338+
casePT_HASH:
339+
returnhash_str;
340+
341+
casePT_RANGE:
342+
returnrange_str;
343+
344+
default:
345+
WrongPartType(parttype);
346+
returnNULL;/* keep compiler happy */
347+
}
348+
}
349+
350+
351+
314352

315353
/* PartRelationInfo checker */
316354
voidshout_if_prel_is_invalid(constOidparent_oid,

‎src/partition_creation.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,8 +1588,7 @@ invoke_init_callback_internal(init_callback_params *cb_params)
15881588
break;
15891589

15901590
default:
1591-
elog(ERROR,"Unknown partitioning type %u",cb_params->parttype);
1592-
break;
1591+
WrongPartType(cb_params->parttype);
15931592
}
15941593

15951594
/* Fetch function call data */

‎src/pg_pathman.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -781,8 +781,7 @@ handle_const(const Const *c, WalkerContext *context)
781781
break;
782782

783783
default:
784-
elog(ERROR,"Unknown partitioning type %u",prel->parttype);
785-
break;
784+
WrongPartType(prel->parttype);
786785
}
787786

788787
returnresult;
@@ -966,7 +965,7 @@ handle_arrexpr(const ScalarArrayOpExpr *expr, WalkerContext *context)
966965
break;
967966

968967
default:
969-
elog(ERROR,"Unknown partitioning type %u",prel->parttype);
968+
WrongPartType(prel->parttype);
970969
}
971970

972971
/* Free resources */
@@ -1100,7 +1099,7 @@ handle_binary_opexpr(const Const *c,
11001099
}
11011100

11021101
default:
1103-
elog(ERROR,"Unknown partitioning type %u",prel->parttype);
1102+
WrongPartType(prel->parttype);
11041103
}
11051104

11061105
binary_opexpr_return:

‎src/pl_funcs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ show_partition_list_internal(PG_FUNCTION_ARGS)
506506
break;
507507

508508
default:
509-
elog(ERROR,"Unknown partitioning type %u",prel->parttype);
509+
WrongPartType(prel->parttype);
510510
}
511511

512512
/* Fill tuptable */

‎src/rangeset.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ irange_union_internal(IndexRange first,
162162
/* IndexRanges intersect */
163163
if (iranges_intersect(first,second))
164164
{
165-
/* Calculate theintersection of 'first' and 'second' */
165+
/* Calculate theunion of 'first' and 'second' */
166166
IndexRangeir_union=irange_union_simple(first,second);
167167

168168
/* if lossiness is the same, unite them and skip */

‎src/relation_info.c

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -509,10 +509,7 @@ fill_prel_with_partitions(PartRelationInfo *prel,
509509
default:
510510
{
511511
DisablePathman();/* disable pg_pathman since config is broken */
512-
ereport(ERROR,
513-
(errmsg("Unknown partitioning type for relation \"%s\"",
514-
get_rel_name_or_relid(PrelParentRelid(prel))),
515-
errhint(INIT_ERROR_HINT)));
512+
WrongPartType(prel->parttype);
516513
}
517514
break;
518515
}
@@ -1243,10 +1240,7 @@ fill_pbin_with_bounds(PartBoundInfo *pbin,
12431240
default:
12441241
{
12451242
DisablePathman();/* disable pg_pathman since config is broken */
1246-
ereport(ERROR,
1247-
(errmsg("Unknown partitioning type for relation \"%s\"",
1248-
get_rel_name_or_relid(PrelParentRelid(prel))),
1249-
errhint(INIT_ERROR_HINT)));
1243+
WrongPartType(prel->parttype);
12501244
}
12511245
break;
12521246
}
@@ -1264,41 +1258,6 @@ cmp_range_entries(const void *p1, const void *p2, void *arg)
12641258
}
12651259

12661260

1267-
/*
1268-
* Safe PartType wrapper.
1269-
*/
1270-
PartType
1271-
DatumGetPartType(Datumdatum)
1272-
{
1273-
uint32val=DatumGetUInt32(datum);
1274-
1275-
if (val<1||val>2)
1276-
elog(ERROR,"Unknown partitioning type %u",val);
1277-
1278-
return (PartType)val;
1279-
}
1280-
1281-
char*
1282-
PartTypeToCString(PartTypeparttype)
1283-
{
1284-
staticchar*hash_str="1",
1285-
*range_str="2";
1286-
1287-
switch (parttype)
1288-
{
1289-
casePT_HASH:
1290-
returnhash_str;
1291-
1292-
casePT_RANGE:
1293-
returnrange_str;
1294-
1295-
default:
1296-
elog(ERROR,"Unknown partitioning type %u",parttype);
1297-
returnNULL;/* keep compiler happy */
1298-
}
1299-
}
1300-
1301-
13021261
/*
13031262
* Common PartRelationInfo checks. Emit ERROR if anything is wrong.
13041263
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp