@@ -1434,7 +1434,7 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
14341434
14351435/*
14361436 * Yes, try to merge the two column definitions. They must
1437- * have the same type andtypmod .
1437+ * have the same type, typmod, andcollation .
14381438 */
14391439ereport (NOTICE ,
14401440(errmsg ("merging multiple inherited definitions of column \"%s\"" ,
@@ -1620,7 +1620,7 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
16201620
16211621/*
16221622 * Yes, try to merge the two column definitions. They must
1623- * have the same type andtypmod .
1623+ * have the same type, typmod, andcollation .
16241624 */
16251625ereport (NOTICE ,
16261626 (errmsg ("merging column \"%s\" with inherited definition" ,
@@ -4121,7 +4121,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
41214121int32 ctypmod ;
41224122Oid ccollid ;
41234123
4124- /* Child column must matchby type */
4124+ /* Child column must matchon type, typmod, and collation */
41254125typenameTypeIdAndMod (NULL ,colDef -> typeName ,& ctypeId ,& ctypmod );
41264126if (ctypeId != childatt -> atttypid ||
41274127ctypmod != childatt -> atttypmod )
@@ -8178,7 +8178,7 @@ MergeAttributesIntoExisting(Relation child_rel, Relation parent_rel)
81788178attributeName );
81798179if (HeapTupleIsValid (tuple ))
81808180{
8181- /* Check they are same type andtypmod */
8181+ /* Check they are same type, typmod, andcollation */
81828182Form_pg_attribute childatt = (Form_pg_attribute )GETSTRUCT (tuple );
81838183
81848184if (attribute -> atttypid != childatt -> atttypid ||
@@ -8189,6 +8189,17 @@ MergeAttributesIntoExisting(Relation child_rel, Relation parent_rel)
81898189RelationGetRelationName (child_rel ),
81908190attributeName )));
81918191
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+ */
81928203if (attribute -> attnotnull && !childatt -> attnotnull )
81938204ereport (ERROR ,
81948205(errcode (ERRCODE_DATATYPE_MISMATCH ),