diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2011-03-29 17:54:27 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2011-04-09 17:59:03 -0400 |
commit | 9a8b73147c07e02e10e0d0a34aa99d72e3336fb2 (patch) | |
tree | fe2844659754aedffa351ffd6ebd988d7d36fc77 /src | |
parent | 11745364d074f3a7ee54c98fad55cfb5c5149326 (diff) | |
download | postgresql-9a8b73147c07e02e10e0d0a34aa99d72e3336fb2.tar.gz postgresql-9a8b73147c07e02e10e0d0a34aa99d72e3336fb2.zip |
Clean up overly complex code for issuing some related error messages.
The original version was unreadable, and not mechanically checkable
either.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/commands/tablecmds.c | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index bd18db3b831..886b656b437 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -3944,23 +3944,34 @@ find_composite_type_dependencies(Oid typeOid, Relation origRelation, if (rel->rd_rel->relkind == RELKIND_RELATION) { - const char *msg; - - if (origTypeName - || origRelation->rd_rel->relkind == RELKIND_COMPOSITE_TYPE) - msg = gettext_noop("cannot alter type \"%s\" because column \"%s\".\"%s\" uses it"); + if (origTypeName) + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("cannot alter type \"%s\" because column \"%s\".\"%s\" uses it", + origTypeName, + RelationGetRelationName(rel), + NameStr(att->attname)))); + else if (origRelation->rd_rel->relkind == RELKIND_COMPOSITE_TYPE) + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("cannot alter type \"%s\" because column \"%s\".\"%s\" uses it", + RelationGetRelationName(origRelation), + RelationGetRelationName(rel), + NameStr(att->attname)))); else if (origRelation->rd_rel->relkind == RELKIND_FOREIGN_TABLE) - msg = gettext_noop("cannot alter foreign table \"%s\" because column \"%s\".\"%s\" uses its rowtype"); + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("cannot alter foreign table \"%s\" because column \"%s\".\"%s\" uses its rowtype", + RelationGetRelationName(origRelation), + RelationGetRelationName(rel), + NameStr(att->attname)))); else - msg = gettext_noop("cannot alter table \"%s\" because column \"%s\".\"%s\" uses its rowtype"); - - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg(msg, - origTypeName ? origTypeName - : RelationGetRelationName(origRelation), - RelationGetRelationName(rel), - NameStr(att->attname)))); + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("cannot alter table \"%s\" because column \"%s\".\"%s\" uses its rowtype", + RelationGetRelationName(origRelation), + RelationGetRelationName(rel), + NameStr(att->attname)))); } else if (OidIsValid(rel->rd_rel->reltype)) { |