Re: BUG #16706: insert into on conflict(pk) do update error violates not-null constraint

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: BUG #16706: insert into on conflict(pk) do update error violates not-null constraint
Дата
Msg-id 1996438.1604952901@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: BUG #16706: insert into on conflict(pk) do update error violates not-null constraint  (Vik Fearing <vik@postgresfriends.org>)
Ответы Re: BUG #16706: insert into on conflict(pk) do update error violates not-null constraint  (Wolfgang Walther <walther@technowledgy.de>)
Список pgsql-bugs
Vik Fearing <vik@postgresfriends.org> writes:
> On 11/9/20 4:16 PM, Tom Lane wrote:
>> I get
>> ERROR:  null value in column "name" violates not-null constraint
>> DETAIL:  Failing row contains (4, null, 6).

> That's the complaint.

Oh ... it wasn't expressed very well then.  I thought the OP was
reporting that the not-null constraint wasn't being enforced,
which surely *would* be a bug.

> I think the issue is the not null constraint is evaluated before the ON
> CONFLICT and so there is no chance to "heal" the row by coalescing the
> old and new values.

Ah.  Well, ON CONFLICT is for resolving duplicate-key errors;
it's not a get-out-of-jail-free card for every sort of error.

I think the right way to handle this example would be with a
before-update trigger, which IIRC can modify the row before
we apply any table constraint checks.

            regards, tom lane



В списке pgsql-bugs по дате отправления:

Предыдущее
От: Vik Fearing
Дата:
Сообщение: Re: BUG #16706: insert into on conflict(pk) do update error violates not-null constraint
Следующее
От: Wolfgang Walther
Дата:
Сообщение: Re: BUG #16706: insert into on conflict(pk) do update error violates not-null constraint