Re: A doubt about a newly added errdetail
Alvaro Herrera <alvherre@alvh.no-ip.org>
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Amit Kapila <amit.kapila16@gmail.com>
Cc: Kyotaro Horiguchi <horikyota.ntt@gmail.com>, houzj.fnst@fujitsu.com, pgsql-hackers@lists.postgresql.org
Date: 2022-09-28T08:46:41Z
Lists: 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 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)
Commits
-
Remove publicationcmds.c's expr_allowed_in_node as a function
- d0b1dbcb9845 16.0 landed
- a60b11327bbd 15.0 landed
-
Improve some publication-related error messages
- f5441b912493 15.0 landed
- 4148c8b3daf9 16.0 landed