@@ -1434,7 +1434,7 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
1434
1434
1435
1435
/*
1436
1436
* Yes, try to merge the two column definitions. They must
1437
- * have the same type and typmod .
1437
+ * have the same type, typmod, and collation .
1438
1438
*/
1439
1439
ereport (NOTICE ,
1440
1440
(errmsg ("merging multiple inherited definitions of column \"%s\"" ,
@@ -1620,7 +1620,7 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
1620
1620
1621
1621
/*
1622
1622
* Yes, try to merge the two column definitions. They must
1623
- * have the same type and typmod .
1623
+ * have the same type, typmod, and collation .
1624
1624
*/
1625
1625
ereport (NOTICE ,
1626
1626
(errmsg ("merging column \"%s\" with inherited definition" ,
@@ -4121,7 +4121,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
4121
4121
int32 ctypmod ;
4122
4122
Oid ccollid ;
4123
4123
4124
- /* Child column must match by type */
4124
+ /* Child column must match on type, typmod, and collation */
4125
4125
typenameTypeIdAndMod (NULL , colDef -> typeName , & ctypeId , & ctypmod );
4126
4126
if (ctypeId != childatt -> atttypid ||
4127
4127
ctypmod != childatt -> atttypmod )
@@ -8178,7 +8178,7 @@ MergeAttributesIntoExisting(Relation child_rel, Relation parent_rel)
8178
8178
attributeName );
8179
8179
if (HeapTupleIsValid (tuple ))
8180
8180
{
8181
- /* Check they are same type and typmod */
8181
+ /* Check they are same type, typmod, and collation */
8182
8182
Form_pg_attribute childatt = (Form_pg_attribute ) GETSTRUCT (tuple );
8183
8183
8184
8184
if (attribute -> atttypid != childatt -> atttypid ||
@@ -8189,6 +8189,17 @@ MergeAttributesIntoExisting(Relation child_rel, Relation parent_rel)
8189
8189
RelationGetRelationName (child_rel ),
8190
8190
attributeName )));
8191
8191
8192
+ if (attribute -> attcollation != childatt -> attcollation )
8193
+ ereport (ERROR ,
8194
+ (errcode (ERRCODE_COLLATION_MISMATCH ),
8195
+ errmsg ("child table \"%s\" has different collation for column \"%s\"" ,
8196
+ RelationGetRelationName (child_rel ),
8197
+ attributeName )));
8198
+
8199
+ /*
8200
+ * Check child doesn't discard NOT NULL property. (Other
8201
+ * constraints are checked elsewhere.)
8202
+ */
8192
8203
if (attribute -> attnotnull && !childatt -> attnotnull )
8193
8204
ereport (ERROR ,
8194
8205
(errcode (ERRCODE_DATATYPE_MISMATCH ),
0 commit comments