1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-03 20:02:46 +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:
Alvaro Herrera
2022-11-03 16:25:54 +01:00
parent cf8b7d374a
commit 5fca91025e
7 changed files with 54 additions and 56 deletions

View File

@ -115,6 +115,12 @@ RelationBuildPartitionKey(Relation relation)
key->strategy = form->partstrat;
key->partnatts = form->partnatts;
/* Validate partition strategy code */
if (key->strategy != PARTITION_STRATEGY_LIST &&
key->strategy != PARTITION_STRATEGY_RANGE &&
key->strategy != PARTITION_STRATEGY_HASH)
elog(ERROR, "invalid partition strategy \"%c\"", key->strategy);
/*
* We can rely on the first variable-length attribute being mapped to the
* relevant field of the catalog's C struct, because all previous