mirror of
https://github.com/postgres/postgres.git
synced 2025-07-17 06:41:09 +03:00
Resolve partition strategy during early parsing
This has little practical value, but there's no reason to let the partition strategy names travel through DDL as strings. Reviewed-by: Japin Li <japinli@hotmail.com> Discussion: https://postgr.es/m/20221021093216.ffupd7epy2mytkux@alvherre.pgsql
This commit is contained in:
@ -213,6 +213,7 @@ static void SplitColQualList(List *qualList,
|
||||
static void processCASbits(int cas_bits, int location, const char *constrType,
|
||||
bool *deferrable, bool *initdeferred, bool *not_valid,
|
||||
bool *no_inherit, core_yyscan_t yyscanner);
|
||||
static PartitionStrategy parsePartitionStrategy(char *strategy);
|
||||
static void preprocess_pubobj_list(List *pubobjspec_list,
|
||||
core_yyscan_t yyscanner);
|
||||
static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
|
||||
@ -4357,7 +4358,7 @@ PartitionSpec: PARTITION BY ColId '(' part_params ')'
|
||||
{
|
||||
PartitionSpec *n = makeNode(PartitionSpec);
|
||||
|
||||
n->strategy = $3;
|
||||
n->strategy = parsePartitionStrategy($3);
|
||||
n->partParams = $5;
|
||||
n->location = @1;
|
||||
|
||||
@ -18414,6 +18415,25 @@ processCASbits(int cas_bits, int location, const char *constrType,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse a user-supplied partition strategy string into parse node
|
||||
* PartitionStrategy representation, or die trying.
|
||||
*/
|
||||
static PartitionStrategy
|
||||
parsePartitionStrategy(char *strategy)
|
||||
{
|
||||
if (pg_strcasecmp(strategy, "list") == 0)
|
||||
return PARTITION_STRATEGY_LIST;
|
||||
else if (pg_strcasecmp(strategy, "range") == 0)
|
||||
return PARTITION_STRATEGY_RANGE;
|
||||
else if (pg_strcasecmp(strategy, "hash") == 0)
|
||||
return PARTITION_STRATEGY_HASH;
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("unrecognized partitioning strategy \"%s\"",
|
||||
strategy)));
|
||||
}
|
||||
|
||||
/*
|
||||
* Process pubobjspec_list to check for errors in any of the objects and
|
||||
* convert PUBLICATIONOBJ_CONTINUATION into appropriate PublicationObjSpecType.
|
||||
|
Reference in New Issue
Block a user