Re: Macros bundling RELKIND_* conditions

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: Ashutosh Bapat <ashutosh(dot)bapat(at)enterprisedb(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Joe Conway <mail(at)joeconway(dot)com>
Subject: Re: Macros bundling RELKIND_* conditions
Date: 2017-08-02 17:53:51
Message-ID: 20170802175351.qsk3sb37gtm6muyo@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Peter Eisentraut wrote:

> I don't find this style of error message optimal anyway. If I do, for
> example
>
> ALTER TABLE someview ADD CONSTRAINT ...
> ERROR: "someview" is not a table, foreign table, whatever
>
> then this information is not helpful. It's not like I'm going to turn
> my view into a foreign table in order to be able to proceed with that
> command.

Hmm, this is a good point ... not against my proposal, but rather
against the current coding. I agree it could be more user-friendly.

> The actual error, from the perspective of the user, is something like
>
> ERROR: "someview" is a view
> DETAIL: Views cannot have constraints.

OK. "%s is a %s" is a reasonable set of errors -- we just need one for
each relkind. So the first one is easy.

But the second one is not easy, because we'd need one message per
relkind per operation kind. We cannot possibly write/translate that
many messages. If we make the relkind generic in the errdetail message,
maybe it can work; something like "Relations of that type cannot have
constraints" would work, for example. Or "Relations of type "view"
cannot have constraints", although this reads very strangely. Maybe
someone has a better idea?

--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2017-08-02 17:57:57 Re: pg_stop_backup(wait_for_archive := true) on standby server
Previous Message Robert Haas 2017-08-02 17:53:05 Re: reload-through-the-top-parent switch the partition table