Re: [v9.2] DROP statement reworks - Mailing list pgsql-hackers

From Robert Haas
Subject Re: [v9.2] DROP statement reworks
Date
Msg-id CA+Tgmob53G0OWgtxUy-jdB4NV-TepMfXD5k13RajCd0ME7wQnw@mail.gmail.com
Whole thread Raw
In response to Re: [v9.2] DROP statement reworks  (Kohei KaiGai <kaigai@kaigai.gr.jp>)
Responses Re: [v9.2] DROP statement reworks
List pgsql-hackers
On Wed, Oct 12, 2011 at 8:07 AM, Kohei KaiGai <kaigai@kaigai.gr.jp> wrote:
> I'm currently trying to revise my patches according to your suggestions,
> but I'm facing a trouble about error messages when user tries to drop
> a non-exists object.
>
> Because the ObjectProperty array has an entry for each catalogs, it is
> unavailable to hold the name of object type (such as "table" or "index")
> when multiple object types are associated with a particular system
> catalog, such as pg_class, pg_type or pg_proc.
>
> How should I implement the following block?
>
>        if (!OidIsValid(address.objectId))
>        {
>            ereport(NOTICE,
>                    (errmsg("%s \"%s\" does not exist, skipping",
>                            get_object_property_typetext(stmt->removeType),
>                            NameListToString(objname))));
>            continue;
>        }
>
> One idea is to add a separated array to translate from OBJECT_* to
> its text representation. (Maybe, it can be used to translattions with
> opposite direction.)

For reasons of translation, you can't do something like "%s \"%s\"
does not exist, skipping".  Instead I think you need an array that
works something like dropmsgstringarray[], but based on the OBJECT_*
constants rather than the RELKIND_* constants.  IOW, it maps the
object type to the full error message, not just the name of the object
type.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


pgsql-hackers by date:

Previous
From: Florian Pflug
Date:
Subject: Re: Overhead cost of Serializable Snapshot Isolation
Next
From: Kohei KaiGai
Date:
Subject: Re: [v9.2] DROP statement reworks