Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Clean up overly complex code for issuing some related error messages.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 29 Mar 2011 21:54:27 +0000 (17:54 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 9 Apr 2011 21:59:03 +0000 (17:59 -0400)
The original version was unreadable, and not mechanically checkable
either.

src/backend/commands/tablecmds.c

index bd18db3b831aeff5942b284425bce628cbd4d39d..886b656b4376e51b920714b24ce983c9d4342a26 100644 (file)
@@ -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))
        {