Re: Error message inconsistency

Поиск
Список
Период
Сортировка
От MBeena Emerson
Тема Re: Error message inconsistency
Дата
Msg-id CANPX-3WzZMr-inZ8P8YMbCvZTgCUA20zAwFReib0M+zaFA9HCQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Error message inconsistency  (Amit Kapila <amit.kapila16@gmail.com>)
Ответы Re: Error message inconsistency
Список 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 по дате отправления:

Предыдущее
От: Amit Kapila
Дата:
Сообщение: Re: Error message inconsistency
Следующее
От: Fujii Masao
Дата:
Сообщение: Re: Increase psql's password buffer size