BUG #16733: insert into on conflict(pk) do nothing error violates not-null constraint

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: zhongxuchen(at)gmail(dot)com
Subject: BUG #16733: insert into on conflict(pk) do nothing error violates not-null constraint
Date: 2020-11-20 05:39:35
Message-ID: 16733-fb8b26e66710b2a1@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 16733
Logged by: zhongxuchen
Email address: zhongxuchen(at)gmail(dot)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

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Amit Kapila 2020-11-20 05:48:21 Re: BUG #16643: PG13 - Logical replication - initial startup never finishes and gets stuck in startup loop
Previous Message Dilip Kumar 2020-11-20 05:29:13 Re: BUG #16643: PG13 - Logical replication - initial startup never finishes and gets stuck in startup loop