@@ -605,9 +605,10 @@ static void RangeVarCallbackForDropRelation(const RangeVar *rel, Oid relOid,
605605 Oid oldRelOid, void *arg);
606606static void RangeVarCallbackForAlterRelation(const RangeVar *rv, Oid relid,
607607 Oid oldrelid, void *arg);
608- static PartitionSpec *transformPartitionSpec(Relation rel, PartitionSpec *partspec, char *strategy );
608+ static PartitionSpec *transformPartitionSpec(Relation rel, PartitionSpec *partspec);
609609static 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);
611612static void CreateInheritance(Relation child_rel, Relation parent_rel);
612613static void RemoveInheritance(Relation child_rel, Relation parent_rel,
613614 bool expect_detached);
@@ -1122,7 +1123,6 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
11221123 if (partitioned)
11231124 {
11241125 ParseState *pstate;
1125- char strategy;
11261126 int partnatts;
11271127 AttrNumber partattrs[PARTITION_MAX_KEYS];
11281128 Oid partopclass[PARTITION_MAX_KEYS];
@@ -1147,14 +1147,14 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
11471147 * and CHECK constraints, we could not have done the transformation
11481148 * earlier.
11491149 */
1150- stmt->partspec = transformPartitionSpec(rel, stmt->partspec,
1151- &strategy);
1150+ stmt->partspec = transformPartitionSpec(rel, stmt->partspec);
11521151
11531152 ComputePartitionAttrs(pstate, rel, stmt->partspec->partParams,
11541153 partattrs, &partexprs, partopclass,
1155- partcollation, strategy);
1154+ partcollation, stmt->partspec-> strategy);
11561155
1157- StorePartitionKey(rel, strategy, partnatts, partattrs, partexprs,
1156+ StorePartitionKey(rel, stmt->partspec->strategy, partnatts, partattrs,
1157+ partexprs,
11581158 partopclass, partcollation);
11591159
11601160 /* make it all visible */
@@ -17132,10 +17132,10 @@ RangeVarCallbackForAlterRelation(const RangeVar *rv, Oid relid, Oid oldrelid,
1713217132/*
1713317133 * Transform any expressions present in the partition key
1713417134 *
17135- * Returns a transformed PartitionSpec, as well as the strategy code
17135+ * Returns a transformed PartitionSpec.
1713617136 */
1713717137static PartitionSpec *
17138- transformPartitionSpec(Relation rel, PartitionSpec *partspec, char *strategy )
17138+ transformPartitionSpec(Relation rel, PartitionSpec *partspec)
1713917139{
1714017140 PartitionSpec *newspec;
1714117141 ParseState *pstate;
@@ -17148,21 +17148,8 @@ transformPartitionSpec(Relation rel, PartitionSpec *partspec, char *strategy)
1714817148 newspec->partParams = NIL;
1714917149 newspec->location = partspec->location;
1715017150
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-
1716417151 /* Check valid number of columns for strategy */
17165- if (* strategy == PARTITION_STRATEGY_LIST &&
17152+ if (partspec-> strategy == PARTITION_STRATEGY_LIST &&
1716617153 list_length(partspec->partParams) != 1)
1716717154 ereport(ERROR,
1716817155 (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
@@ -17208,7 +17195,7 @@ transformPartitionSpec(Relation rel, PartitionSpec *partspec, char *strategy)
1720817195static void
1720917196ComputePartitionAttrs(ParseState *pstate, Relation rel, List *partParams, AttrNumber *partattrs,
1721017197 List **partexprs, Oid *partopclass, Oid *partcollation,
17211- char strategy)
17198+ PartitionStrategy strategy)
1721217199{
1721317200 int attn;
1721417201 ListCell *lc;
0 commit comments