From: zhongxuchen@gmail.com <zhongxuchen@gmail.com>
To: Andres Freund <andres@anarazel.de>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Vik Fearing <vik@postgresfriends.org>
Cc: pgsql-bugs <pgsql-bugs@lists.postgresql.org>
Subject: Re: Re: BUG #16706: insert into on conflict(pk) do update error violates not-null constraint
Date: Tue, 10 Nov 2020 18:43:24 +0800
Message-ID: <2020111018432320226511@gmail.com> (raw)
References: <16706-08837c0cdaf4ce57@postgresql.org>
<1974489.1604935011@sss.pgh.pa.us>
<de53948f-ff64-95dd-222e-cd0233d3399f@postgresfriends.org>
<1996438.1604952901@sss.pgh.pa.us>
<20201110042524.voeknzrrke7hschl@alap3.anarazel.de>
HI!
Will this problem provide support?
Personally, if this problem is not solved, it means that "on conflict () do update" is meaningless!
非常希望postgresql可以解决此问题,让postgresql更加完美!也让个人的开源orm项目更加完美(https://github.com/sagframe/sagacity-sqltoy)
非常感谢各位的辛苦和付出!
zhongxuchen@gmail.com
From: Andres Freund
Date: 2020-11-10 12:25
To: Tom Lane
CC: Vik Fearing; zhongxuchen; pgsql-bugs
Subject: Re: BUG #16706: insert into on conflict(pk) do update error violates not-null constraint
Hi,
On 2020-11-09 15:15:01 -0500, Tom Lane wrote:
> Vik Fearing <vik@postgresfriends.org> writes:
> > 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.
Sounds like the to-be-upserted row could never be inserted, but only
updated. In which case an UPDATE sounds more appropriate than an INSERT
... ON CONFLICT SET ... - am I missing something?
Greetings,
Andres Freund
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: zhongxuchen@gmail.com, andres@anarazel.de, tgl@sss.pgh.pa.us, vik@postgresfriends.org, pgsql-bugs@lists.postgresql.org
Subject: Re: Re: BUG #16706: insert into on conflict(pk) do update error violates not-null constraint
In-Reply-To: <2020111018432320226511@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox