pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #16733: insert into on conflict(pk) do nothing error violates not-null constraint
2+ messages / 2 participants
[nested] [flat]
* BUG #16733: insert into on conflict(pk) do nothing error violates not-null constraint
@ 2020-11-20 05:39 PG Bug reporting form <noreply@postgresql.org>
2020-11-20 13:44 ` Re: BUG #16733: insert into on conflict(pk) do nothing error violates not-null constraint Heikki Linnakangas <hlinnaka@iki.fi>
0 siblings, 1 reply; 2+ messages in thread
From: PG Bug reporting form @ 2020-11-20 05:39 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org; +Cc: zhongxuchen@gmail.com
The following bug has been logged on the website:
Bug reference: 16733
Logged by: zhongxuchen
Email address: zhongxuchen@gmail.com
PostgreSQL version: 12.3
Operating system: centos8
Description:
sorry ,A scene that was missed before!
1、postgresql insert()values()on conflict (pk) do update/ do nothing
当某个字段在数据库中设置为not null,SQL 错误 [23502]: ERROR: null value in column "name"
violates not-null constraint
example:
CREATE TABLE TEST1 (
id varchar(100) NOT NULL,
name varchar(100) NOT NULL,
status varchar(100) NOT NULL,
CONSTRAINT test1_pkey PRIMARY KEY (id)
)
Initialization data
insert into TEST1 (ID, NAME,STATUS ) values('4','test','6') ;
Error scenarios:
1、insert into TEST1 as t1 (ID, NAME,STATUS ) values('4',null,'6') on
conflict
(id) do update set NAME=COALESCE(excluded.NAME,t1.NAME),
STATUS=COALESCE(excluded.STATUS,t1.STATUS);
2、insert into TEST1 as t1 (ID, NAME,STATUS ) values('4',null,'6') on
conflict
(id) do nothing
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: BUG #16733: insert into on conflict(pk) do nothing error violates not-null constraint
2020-11-20 05:39 BUG #16733: insert into on conflict(pk) do nothing error violates not-null constraint PG Bug reporting form <noreply@postgresql.org>
@ 2020-11-20 13:44 ` Heikki Linnakangas <hlinnaka@iki.fi>
0 siblings, 0 replies; 2+ messages in thread
From: Heikki Linnakangas @ 2020-11-20 13:44 UTC (permalink / raw)
To: zhongxuchen@gmail.com, pgsql-bugs@lists.postgresql.org, PG Bug reporting form <noreply@postgresql.org>
On 20/11/2020 07:39, PG Bug reporting form wrote:
> The following bug has been logged on the website:
>
> Bug reference: 16733
> Logged by: zhongxuchen
> Email address: zhongxuchen@gmail.com
> PostgreSQL version: 12.3
> Operating system: centos8
> Description:
>
> sorry ,A scene that was missed before!
For the archives: I believe you're referring to
https://www.postgresql.org/message-id/16706-08837c0cdaf4ce57%40postgresql.org.
> 1、postgresql insert()values()on conflict (pk) do update/ do nothing
> 当某个字段在数据库中设置为not null,SQL 错误 [23502]: ERROR: null value in column "name"
> violates not-null constraint
>
> example:
> CREATE TABLE TEST1 (
> id varchar(100) NOT NULL,
> name varchar(100) NOT NULL,
> status varchar(100) NOT NULL,
> CONSTRAINT test1_pkey PRIMARY KEY (id)
> )
>
> Initialization data
> insert into TEST1 (ID, NAME,STATUS ) values('4','test','6') ;
>
> Error scenarios:
> 1、insert into TEST1 as t1 (ID, NAME,STATUS ) values('4',null,'6') on
> conflict
> (id) do update set NAME=COALESCE(excluded.NAME,t1.NAME),
> STATUS=COALESCE(excluded.STATUS,t1.STATUS);
>
> 2、insert into TEST1 as t1 (ID, NAME,STATUS ) values('4',null,'6') on
> conflict
> (id) do nothing
Both of these fail with an error:
ERROR: null value in column "name" of relation "test1" violates
not-null constraint
DETAIL: Failing row contains (4, null, 6).
This is not a bug. The NOT NULL constraint is checked before checking
for conflicts.
- Heikki
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2020-11-20 13:44 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-11-20 05:39 BUG #16733: insert into on conflict(pk) do nothing error violates not-null constraint PG Bug reporting form <noreply@postgresql.org>
2020-11-20 13:44 ` Heikki Linnakangas <hlinnaka@iki.fi>
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