@@ -605,9 +605,10 @@ static void RangeVarCallbackForDropRelation(const RangeVar *rel, Oid relOid,
605
605
Oid oldRelOid, void *arg);
606
606
static void RangeVarCallbackForAlterRelation(const RangeVar *rv, Oid relid,
607
607
Oid oldrelid, void *arg);
608
- static PartitionSpec *transformPartitionSpec(Relation rel, PartitionSpec *partspec, char *strategy );
608
+ static PartitionSpec *transformPartitionSpec(Relation rel, PartitionSpec *partspec);
609
609
static void ComputePartitionAttrs(ParseState *pstate, Relation rel, List *partParams, AttrNumber *partattrs,
610
- List **partexprs, Oid *partopclass, Oid *partcollation, char strategy);
610
+ List **partexprs, Oid *partopclass, Oid *partcollation,
611
+ PartitionStrategy strategy);
611
612
static void CreateInheritance(Relation child_rel, Relation parent_rel);
612
613
static void RemoveInheritance(Relation child_rel, Relation parent_rel,
613
614
bool expect_detached);
@@ -1122,7 +1123,6 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
1122
1123
if (partitioned)
1123
1124
{
1124
1125
ParseState *pstate;
1125
- char strategy;
1126
1126
int partnatts;
1127
1127
AttrNumber partattrs[PARTITION_MAX_KEYS];
1128
1128
Oid partopclass[PARTITION_MAX_KEYS];
@@ -1147,14 +1147,14 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
1147
1147
* and CHECK constraints, we could not have done the transformation
1148
1148
* earlier.
1149
1149
*/
1150
- stmt->partspec = transformPartitionSpec(rel, stmt->partspec,
1151
- &strategy);
1150
+ stmt->partspec = transformPartitionSpec(rel, stmt->partspec);
1152
1151
1153
1152
ComputePartitionAttrs(pstate, rel, stmt->partspec->partParams,
1154
1153
partattrs, &partexprs, partopclass,
1155
- partcollation, strategy);
1154
+ partcollation, stmt->partspec-> strategy);
1156
1155
1157
- StorePartitionKey(rel, strategy, partnatts, partattrs, partexprs,
1156
+ StorePartitionKey(rel, stmt->partspec->strategy, partnatts, partattrs,
1157
+ partexprs,
1158
1158
partopclass, partcollation);
1159
1159
1160
1160
/* make it all visible */
@@ -17132,10 +17132,10 @@ RangeVarCallbackForAlterRelation(const RangeVar *rv, Oid relid, Oid oldrelid,
17132
17132
/*
17133
17133
* Transform any expressions present in the partition key
17134
17134
*
17135
- * Returns a transformed PartitionSpec, as well as the strategy code
17135
+ * Returns a transformed PartitionSpec.
17136
17136
*/
17137
17137
static PartitionSpec *
17138
- transformPartitionSpec(Relation rel, PartitionSpec *partspec, char *strategy )
17138
+ transformPartitionSpec(Relation rel, PartitionSpec *partspec)
17139
17139
{
17140
17140
PartitionSpec *newspec;
17141
17141
ParseState *pstate;
@@ -17148,21 +17148,8 @@ transformPartitionSpec(Relation rel, PartitionSpec *partspec, char *strategy)
17148
17148
newspec->partParams = NIL;
17149
17149
newspec->location = partspec->location;
17150
17150
17151
- /* Parse partitioning strategy name */
17152
- if (pg_strcasecmp(partspec->strategy, "hash") == 0)
17153
- *strategy = PARTITION_STRATEGY_HASH;
17154
- else if (pg_strcasecmp(partspec->strategy, "list") == 0)
17155
- *strategy = PARTITION_STRATEGY_LIST;
17156
- else if (pg_strcasecmp(partspec->strategy, "range") == 0)
17157
- *strategy = PARTITION_STRATEGY_RANGE;
17158
- else
17159
- ereport(ERROR,
17160
- (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
17161
- errmsg("unrecognized partitioning strategy \"%s\"",
17162
- partspec->strategy)));
17163
-
17164
17151
/* Check valid number of columns for strategy */
17165
- if (* strategy == PARTITION_STRATEGY_LIST &&
17152
+ if (partspec-> strategy == PARTITION_STRATEGY_LIST &&
17166
17153
list_length(partspec->partParams) != 1)
17167
17154
ereport(ERROR,
17168
17155
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
@@ -17208,7 +17195,7 @@ transformPartitionSpec(Relation rel, PartitionSpec *partspec, char *strategy)
17208
17195
static void
17209
17196
ComputePartitionAttrs(ParseState *pstate, Relation rel, List *partParams, AttrNumber *partattrs,
17210
17197
List **partexprs, Oid *partopclass, Oid *partcollation,
17211
- char strategy)
17198
+ PartitionStrategy strategy)
17212
17199
{
17213
17200
int attn;
17214
17201
ListCell *lc;
0 commit comments