From fec1ad94dfc5ddacfda8d249bf4b3c739da8f7a1 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 26 Dec 2015 13:41:29 -0500 Subject: Include typmod when complaining about inherited column type mismatches. MergeAttributes() rejects cases where columns to be merged have the same type but different typmod, which is correct; but the error message it printed didn't show either typmod, which is unhelpful. Changing this requires using format_type_with_typemod() in place of TypeNameToString(), which will have some minor side effects on the way some type names are printed, but on balance this is an improvement: the old code sometimes printed one type according to one set of rules and the other type according to the other set, which could be confusing in its own way. Oddly, there were no regression test cases covering any of this behavior, so add some. Complaint and fix by Amit Langote --- src/backend/commands/tablecmds.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/backend/commands/tablecmds.c') diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 56fed4d87cd..a217dbcb1ef 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -1613,8 +1613,10 @@ MergeAttributes(List *schema, List *supers, char relpersistence, errmsg("inherited column \"%s\" has a type conflict", attributeName), errdetail("%s versus %s", - TypeNameToString(def->typeName), - format_type_be(attribute->atttypid)))); + format_type_with_typemod(defTypeId, + deftypmod), + format_type_with_typemod(attribute->atttypid, + attribute->atttypmod)))); defCollId = GetColumnDefCollation(NULL, def, defTypeId); if (defCollId != attribute->attcollation) ereport(ERROR, @@ -1832,8 +1834,10 @@ MergeAttributes(List *schema, List *supers, char relpersistence, errmsg("column \"%s\" has a type conflict", attributeName), errdetail("%s versus %s", - TypeNameToString(def->typeName), - TypeNameToString(newdef->typeName)))); + format_type_with_typemod(defTypeId, + deftypmod), + format_type_with_typemod(newTypeId, + newtypmod)))); defcollid = GetColumnDefCollation(NULL, def, defTypeId); newcollid = GetColumnDefCollation(NULL, newdef, newTypeId); if (defcollid != newcollid) -- cgit v1.2.3