aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/cache/partcache.c
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2022-11-03 16:25:54 +0100
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2022-11-03 16:25:54 +0100
commit5fca91025e05f803140831953c09a36f08efcef5 (patch)
tree0c399e1a56dff2a58dc4e37503a03e97b4d5458a /src/backend/utils/cache/partcache.c
parentcf8b7d374ae10c8de389229ff924addc69e6f7df (diff)
downloadpostgresql-5fca91025e05f803140831953c09a36f08efcef5.tar.gz
postgresql-5fca91025e05f803140831953c09a36f08efcef5.zip
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
Diffstat (limited to 'src/backend/utils/cache/partcache.c')
-rw-r--r--src/backend/utils/cache/partcache.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/backend/utils/cache/partcache.c b/src/backend/utils/cache/partcache.c
index afa99c5d036..e32f4b96119 100644
--- a/src/backend/utils/cache/partcache.c
+++ b/src/backend/utils/cache/partcache.c
@@ -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