/*
* Yes, try to merge the two column definitions. They must
- * have the same type and typmod.
+ * have the same type, typmod, and collation.
*/
ereport(NOTICE,
(errmsg("merging multiple inherited definitions of column \"%s\"",
/*
* Yes, try to merge the two column definitions. They must
- * have the same type and typmod.
+ * have the same type, typmod, and collation.
*/
ereport(NOTICE,
(errmsg("merging column \"%s\" with inherited definition",
int32 ctypmod;
Oid ccollid;
- /* Child column must match by type */
+ /* Child column must match on type, typmod, and collation */
typenameTypeIdAndMod(NULL, colDef->typeName, &ctypeId, &ctypmod);
if (ctypeId != childatt->atttypid ||
ctypmod != childatt->atttypmod)
attributeName);
if (HeapTupleIsValid(tuple))
{
- /* Check they are same type and typmod */
+ /* Check they are same type, typmod, and collation */
Form_pg_attribute childatt = (Form_pg_attribute) GETSTRUCT(tuple);
if (attribute->atttypid != childatt->atttypid ||
RelationGetRelationName(child_rel),
attributeName)));
+ if (attribute->attcollation != childatt->attcollation)
+ ereport(ERROR,
+ (errcode(ERRCODE_COLLATION_MISMATCH),
+ errmsg("child table \"%s\" has different collation for column \"%s\"",
+ RelationGetRelationName(child_rel),
+ attributeName)));
+
+ /*
+ * Check child doesn't discard NOT NULL property. (Other
+ * constraints are checked elsewhere.)
+ */
if (attribute->attnotnull && !childatt->attnotnull)
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),