diff options
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r-- | src/backend/commands/tablecmds.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 3ce9aa974e7..ea978ce6999 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -4899,8 +4899,8 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode) /* * Set all columns in the new slot to NULL initially, to ensure - * columns added as part of the rewrite are initialized to - * NULL. That is necessary as tab->newvals will not contain an + * columns added as part of the rewrite are initialized to NULL. + * That is necessary as tab->newvals will not contain an * expression for columns with a NULL default, e.g. when adding a * column without a default together with a column with a default * requiring an actual rewrite. @@ -15139,12 +15139,24 @@ ComputePartitionAttrs(ParseState *pstate, Relation rel, List *partParams, AttrNu { /* Expression */ Node *expr = pelem->expr; + char partattname[16]; Assert(expr != NULL); atttype = exprType(expr); 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). + */ + snprintf(partattname, sizeof(partattname), "%d", attn + 1); + CheckAttributeType(partattname, + atttype, attcollation, + NIL, CHKATYPE_IS_PARTKEY); + + /* * Strip any top-level COLLATE clause. This ensures that we treat * "x COLLATE y" and "(x COLLATE y)" alike. */ |