Re: A doubt about a newly added errdetail

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, houzj(dot)fnst(at)fujitsu(dot)com, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: A doubt about a newly added errdetail
Date: 2022-09-28 08:46:41
Message-ID: 20220928084641.xecjrgym476fihtn@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2022-Sep-28, Amit Kapila wrote:

> On Wed, Sep 28, 2022 at 11:30 AM Kyotaro Horiguchi
> <horikyota(dot)ntt(at)gmail(dot)com> wrote:

> > It looks tome that the errmsg and errordetail are reversed. Isn't the following order common?
> >
> > > errmsg("schemas cannot be added to or dropped from publication \"%s\".",
> > > NameStr(pubform->pubname)),
> > > errdetail("The publication is defined as FOR ALL TABLES.")));
> >
>
> This one seems to be matching with the below existing message:
> ereport(ERROR,
> (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
> errmsg("publication \"%s\" is defined as FOR ALL TABLES",
> NameStr(pubform->pubname)),
> errdetail("Tables cannot be added to or dropped from FOR ALL TABLES
> publications.")));

Well, that suggests we should change both together. I do agree that
they look suspicious; they should be more similar to this other one, I
think:

ereport(ERROR,
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("cannot add schema to publication \"%s\"",
stmt->pubname),
errdetail("Schemas cannot be added if any tables that specify a column list are already part of the publication."));

The errcodes appear not to agree with each other, also. Maybe that
needs some more thought as well. I don't think INVALID_PARAMETER_VALUE
is the right thing here, and I'm not sure about
OBJECT_NOT_IN_PREREQUISITE_STATE either.

FWIW, the latter is a whole category which is not defined by the SQL
standard, so I recall Tom got it from DB2. DB2 chose to subdivide in a
lot of different cases, see
https://www.ibm.com/docs/en/db2/9.7?topic=messages-sqlstate#rsttmsg__code55
for a (current?) table. Maybe we should define some additional 55Pxx
values -- say 55PR1 INCOMPATIBLE PUBLICATION DEFINITION (R for
"replication"-related matters; the P is what we chose for the
Postgres-specific subcategory).

--
Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/
"People get annoyed when you try to debug them." (Larry Wall)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kyotaro Horiguchi 2022-09-28 09:17:39 Re: pg_rewind WAL segments deletion pitfall
Previous Message Aleksander Alekseev 2022-09-28 08:43:57 Re: [PATCH] Improve amcheck to also check UNIQUE constraint in btree index.