From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Vik Fearing <vik(at)postgresfriends(dot)org> |
Cc: | zhongxuchen(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Re: BUG #16706: insert into on conflict(pk) do update error violates not-null constraint |
Date: | 2020-11-09 20:15:01 |
Message-ID: | 1996438.1604952901@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Vik Fearing <vik(at)postgresfriends(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Wolfgang Walther | 2020-11-09 20:29:51 | Re: BUG #16706: insert into on conflict(pk) do update error violates not-null constraint |
Previous Message | Vik Fearing | 2020-11-09 19:45:13 | Re: BUG #16706: insert into on conflict(pk) do update error violates not-null constraint |