Re: wrong hint message for ALTER FOREIGN TABLE - Mailing list pgsql-hackers

From Tom Lane
Subject Re: wrong hint message for ALTER FOREIGN TABLE
Date
Msg-id 23442.1303776154@sss.pgh.pa.us
Whole thread Raw
In response to Re: wrong hint message for ALTER FOREIGN TABLE  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
Robert Haas <robertmhaas@gmail.com> writes:
> On Mon, Apr 25, 2011 at 7:03 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> As per the other thread today, this advice would usually be correct,
>> so I think that not offering any advice at all would be a step down from
>> that.

> Well, currently ALTER TABLE will work even if the argument is a view
> or sequence, but I view that as a backwards-compatibility kludge we
> should be looking to move away from, not something we want to further
> bake in.  However, I'm out of time to bikeshed on this issue, so fix
> it however you like.

Well, actually, having looked at the proposed patch in context I now
agree with Shigeru-san's fix:
   /*    * For compatibility with prior releases, we don't complain if ALTER TABLE    * or ALTER INDEX is used to
renamesome other type of relation.  But    * ALTER SEQUENCE/VIEW/FOREIGN TABLE are only to be used with relations of
*that type.    */   if (reltype == OBJECT_SEQUENCE && relkind != RELKIND_SEQUENCE)       ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),               errmsg("\"%s\" is not a sequence",
RelationGetRelationName(targetrelation))));
   if (reltype == OBJECT_VIEW && relkind != RELKIND_VIEW)       ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),               errmsg("\"%s\" is not a view",
RelationGetRelationName(targetrelation))));
   if (reltype == OBJECT_FOREIGN_TABLE && relkind != RELKIND_FOREIGN_TABLE)       ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),               errmsg("\"%s\" is not a foreign table",
RelationGetRelationName(targetrelation)),               errhint("Use ALTER FOREIGN TABLE instead.")));
 
   /*    * Don't allow ALTER TABLE on composite types. We want people to use ALTER    * TYPE for that.    */   if
(relkind== RELKIND_COMPOSITE_TYPE)       ereport(ERROR,               (errcode(ERRCODE_WRONG_OBJECT_TYPE),
 errmsg("\"%s\" is a composite type",                       RelationGetRelationName(targetrelation)),
errhint("UseALTER TYPE instead.")));
 

If we haven't felt a need for HINTs for the ALTER SEQUENCE or ALTER VIEW
cases, it seems unlikely that we need one for ALTER FOREIGN TABLE.
Probably whoever wrote this was analogizing to the ALTER TABLE/TYPE case
after it, but that's not the same kind of situation, as evidenced by the
fact that the primary error message is worded differently.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: branching for 9.2devel
Next
From: Andres Freund
Date:
Subject: Re: Improving the memory allocator