mirror of
https://github.com/postgres/postgres.git
synced 2025-08-05 07:41:25 +03:00
Clean up overly complex code for issuing some related error messages.
The original version was unreadable, and not mechanically checkable either.
This commit is contained in:
@@ -3944,23 +3944,34 @@ find_composite_type_dependencies(Oid typeOid, Relation origRelation,
|
|||||||
|
|
||||||
if (rel->rd_rel->relkind == RELKIND_RELATION)
|
if (rel->rd_rel->relkind == RELKIND_RELATION)
|
||||||
{
|
{
|
||||||
const char *msg;
|
if (origTypeName)
|
||||||
|
ereport(ERROR,
|
||||||
if (origTypeName
|
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||||
|| origRelation->rd_rel->relkind == RELKIND_COMPOSITE_TYPE)
|
errmsg("cannot alter type \"%s\" because column \"%s\".\"%s\" uses it",
|
||||||
msg = gettext_noop("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)
|
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
|
else
|
||||||
msg = gettext_noop("cannot alter table \"%s\" because column \"%s\".\"%s\" uses its rowtype");
|
ereport(ERROR,
|
||||||
|
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||||
ereport(ERROR,
|
errmsg("cannot alter table \"%s\" because column \"%s\".\"%s\" uses its rowtype",
|
||||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
RelationGetRelationName(origRelation),
|
||||||
errmsg(msg,
|
RelationGetRelationName(rel),
|
||||||
origTypeName ? origTypeName
|
NameStr(att->attname))));
|
||||||
: RelationGetRelationName(origRelation),
|
|
||||||
RelationGetRelationName(rel),
|
|
||||||
NameStr(att->attname))));
|
|
||||||
}
|
}
|
||||||
else if (OidIsValid(rel->rd_rel->reltype))
|
else if (OidIsValid(rel->rd_rel->reltype))
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user