From d738e4ca815d89eaa5897028335e319a5024a901 Mon Sep 17 00:00:00 2001 From: ryanfmurphy Date: Sat, 7 Jan 2017 09:39:49 -0600 Subject: [PATCH] child table is missing attribute: show type just a preliminary patch for discussion would like to show type name and constraints for convenience in making inherited structures consistent --- src/backend/commands/tablecmds.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 1c219b0..9f6ca2d 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -10893,12 +10893,17 @@ MergeAttributesIntoExisting(Relation child_rel, Relation parent_rel) CatalogUpdateIndexes(attrrel, tuple); heap_freetuple(tuple); } - else + else // child table is missing column - print error msg { + // get the type to display to the user + HeapTuple typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(attribute->atttypid)); + // #todo #fixme - factor into function? lots of logic copied from getTypeOutputInfo in src/backend/utils/cache/lsyscache.c + Form_pg_type attributeType = (Form_pg_type) GETSTRUCT(typeTuple); + ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("child table is missing column \"%s\"", - attributeName))); + errmsg("child table is missing column \"%s\" %s", + attributeName, NameStr(attributeType->typname)))); } } -- 2.5.4 (Apple Git-61)