Skip to content

Commit 9a8b731

Browse files
committed
Clean up overly complex code for issuing some related error messages.
The original version was unreadable, and not mechanically checkable either.
1 parent 1174536 commit 9a8b731

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

src/backend/commands/tablecmds.c

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3944,23 +3944,34 @@ find_composite_type_dependencies(Oid typeOid, Relation origRelation,
39443944

39453945
if (rel->rd_rel->relkind == RELKIND_RELATION)
39463946
{
3947-
const char *msg;
3948-
3949-
if (origTypeName
3950-
|| origRelation->rd_rel->relkind == RELKIND_COMPOSITE_TYPE)
3951-
msg = gettext_noop("cannot alter type \"%s\" because column \"%s\".\"%s\" uses it");
3947+
if (origTypeName)
3948+
ereport(ERROR,
3949+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3950+
errmsg("cannot alter type \"%s\" because column \"%s\".\"%s\" uses it",
3951+
origTypeName,
3952+
RelationGetRelationName(rel),
3953+
NameStr(att->attname))));
3954+
else if (origRelation->rd_rel->relkind == RELKIND_COMPOSITE_TYPE)
3955+
ereport(ERROR,
3956+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3957+
errmsg("cannot alter type \"%s\" because column \"%s\".\"%s\" uses it",
3958+
RelationGetRelationName(origRelation),
3959+
RelationGetRelationName(rel),
3960+
NameStr(att->attname))));
39523961
else if (origRelation->rd_rel->relkind == RELKIND_FOREIGN_TABLE)
3953-
msg = gettext_noop("cannot alter foreign table \"%s\" because column \"%s\".\"%s\" uses its rowtype");
3962+
ereport(ERROR,
3963+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3964+
errmsg("cannot alter foreign table \"%s\" because column \"%s\".\"%s\" uses its rowtype",
3965+
RelationGetRelationName(origRelation),
3966+
RelationGetRelationName(rel),
3967+
NameStr(att->attname))));
39543968
else
3955-
msg = gettext_noop("cannot alter table \"%s\" because column \"%s\".\"%s\" uses its rowtype");
3956-
3957-
ereport(ERROR,
3958-
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3959-
errmsg(msg,
3960-
origTypeName ? origTypeName
3961-
: RelationGetRelationName(origRelation),
3962-
RelationGetRelationName(rel),
3963-
NameStr(att->attname))));
3969+
ereport(ERROR,
3970+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3971+
errmsg("cannot alter table \"%s\" because column \"%s\".\"%s\" uses its rowtype",
3972+
RelationGetRelationName(origRelation),
3973+
RelationGetRelationName(rel),
3974+
NameStr(att->attname))));
39643975
}
39653976
else if (OidIsValid(rel->rd_rel->reltype))
39663977
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy