check-partition-key-datatype-wip.patch

text/x-diff

Filename: check-partition-key-datatype-wip.patch
Type: text/x-diff
Part: 0
Message: Re: unsupportable composite type partition keys

Patch

Format: unified
File+
src/backend/commands/tablecmds.c 10 0
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index e8e004e..29efc9c 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -15102,6 +15102,16 @@ ComputePartitionAttrs(ParseState *pstate, Relation rel, List *partParams, AttrNu
 			attcollation = exprCollation(expr);
 
 			/*
+			 * The expression must be of a storable type (e.g., not RECORD).
+			 * The test is the same as for whether a table column is of a safe
+			 * type (which is why we needn't check for the non-expression
+			 * case).
+			 */
+			CheckAttributeType("partition key",
+							   atttype, attcollation,
+							   NIL, 0);
+
+			/*
 			 * Strip any top-level COLLATE clause.  This ensures that we treat
 			 * "x COLLATE y" and "(x COLLATE y)" alike.
 			 */