Re: A doubt about a newly added errdetail - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: A doubt about a newly added errdetail
Date
Msg-id 20220928084641.xecjrgym476fihtn@alvherre.pgsql
Whole thread Raw
In response to Re: A doubt about a newly added errdetail  (Amit Kapila <amit.kapila16@gmail.com>)
List pgsql-hackers
On 2022-Sep-28, Amit Kapila wrote:

> On Wed, Sep 28, 2022 at 11:30 AM Kyotaro Horiguchi
> <horikyota.ntt@gmail.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
thepublication."));
 

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)



pgsql-hackers by date:

Previous
From: Aleksander Alekseev
Date:
Subject: Re: [PATCH] Improve amcheck to also check UNIQUE constraint in btree index.
Next
From: Kyotaro Horiguchi
Date:
Subject: Re: pg_rewind WAL segments deletion pitfall