aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2011-04-17 16:22:13 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2011-04-17 16:22:13 -0400
commit49a642ab1802ea4cd80f9c184e7699219688197f (patch)
tree8f14abc74b73bf34646c6fe3d5d11f7c453e6605
parentc94732585647437291ec3f4a9902eeffc65a6945 (diff)
downloadpostgresql-49a642ab1802ea4cd80f9c184e7699219688197f.tar.gz
postgresql-49a642ab1802ea4cd80f9c184e7699219688197f.zip
Add check for matching column collations in ALTER TABLE ... INHERIT.
The other DDL operations that create an inheritance relationship were checking for collation match already, but this one got missed. Also fix comments that failed to mention collation checks.
-rw-r--r--src/backend/commands/tablecmds.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 35929b20d53..1f709a49773 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -1434,7 +1434,7 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
/*
* 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\"",
@@ -1620,7 +1620,7 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
/*
* 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",
@@ -4121,7 +4121,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
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)
@@ -8178,7 +8178,7 @@ MergeAttributesIntoExisting(Relation child_rel, Relation parent_rel)
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 ||
@@ -8189,6 +8189,17 @@ MergeAttributesIntoExisting(Relation child_rel, Relation parent_rel)
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),