From 042aa582f717ceb695a1ab60517c2e9f7d04704b Mon Sep 17 00:00:00 2001 From: amit Date: Thu, 26 Jul 2018 11:07:51 +0900 Subject: [PATCH v1] Disallow domain type partition key --- src/backend/commands/tablecmds.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index eb2d33dd86..871c831cd2 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -13693,6 +13693,12 @@ ComputePartitionAttrs(Relation rel, List *partParams, AttrNumber *partattrs, atttype = attform->atttypid; attcollation = attform->attcollation; ReleaseSysCache(atttuple); + + /* Prevent using domains as a partition key. */ + if (get_typtype(atttype) == TYPTYPE_DOMAIN) + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("cannot use domain type column as partition key"))); } else { @@ -13703,6 +13709,12 @@ ComputePartitionAttrs(Relation rel, List *partParams, AttrNumber *partattrs, atttype = exprType(expr); attcollation = exprCollation(expr); + /* Prevent using domains as a partition key. */ + if (get_typtype(atttype) == TYPTYPE_DOMAIN) + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("cannot use domain type expression as partition key"))); + /* * Strip any top-level COLLATE clause. This ensures that we treat * "x COLLATE y" and "(x COLLATE y)" alike. -- 2.11.0