Re: Error message inconsistency - Mailing list pgsql-hackers

From MBeena Emerson
Subject Re: Error message inconsistency
Date
Msg-id CANPX-3WzZMr-inZ8P8YMbCvZTgCUA20zAwFReib0M+zaFA9HCQ@mail.gmail.com
Whole thread Raw
In response to Re: Error message inconsistency  (Amit Kapila <amit.kapila16@gmail.com>)
Responses Re: Error message inconsistency  (Alvaro Herrera <alvherre@2ndquadrant.com>)
List pgsql-hackers
Hi Amit,

On Tue, 21 Jan 2020 at 10:49, Amit Kapila <amit.kapila16@gmail.com> wrote:
On Thu, Jan 9, 2020 at 5:42 PM MBeena Emerson <mbeena.emerson@gmail.com> wrote:
>

Hi Beena,

It is better to reply inline.

> Hi Mahendra,
>
> Thanks for the patch.
> I am not sure but maybe the relation name should also be added to the following test case?
>
> create table t4 (id int);
> insert into t4 values (1);
> ALTER TABLE t4 ADD CONSTRAINT c1 CHECK (id > 10) NOT VALID; -- succeeds
> ALTER TABLE t4 VALIDATE CONSTRAINT c1;
> ERROR:  check constraint "c1" is violated by some row
>

I see that in this case, we are using errtableconstraint which should
set table/schema name, but then that doesn't seem to be used.  Can we
explore it a bit from that angle?

The usage of the function errtableconstraint seems only to set the schema_name table_name constraint_name internally and not for display purposes. As seen in the following two cases where the relation name is displayed using RelationGetRelationName and errtableconstraint is called as part of errcode parameter not errmsg.

                  ereport(ERROR,
                    (errcode(ERRCODE_CHECK_VIOLATION),
                     errmsg("new row for relation \"%s\" violates check constraint \"%s\"",
                            RelationGetRelationName(orig_rel), failed),
                     val_desc ? errdetail("Failing row contains %s.", val_desc) : 0,
                     errtableconstraint(orig_rel, failed)));

                        ereport(ERROR,
                                (errcode(ERRCODE_UNIQUE_VIOLATION),
                                 errmsg("duplicate key value violates unique constraint \"%s\"",
                                        RelationGetRelationName(rel)),
                                 key_desc ? errdetail("Key %s already exists.",
                                                      key_desc) : 0,
                                 errtableconstraint(heapRel,
                                                    RelationGetRelationName(rel))));


--
M Beena Emerson

pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: Error message inconsistency
Next
From: Fujii Masao
Date:
Subject: Re: Increase psql's password buffer size