pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: zhongxuchen@gmail.com
Subject: BUG #16733: insert into on conflict(pk) do nothing error violates not-null constraint
Date: Fri, 20 Nov 2020 05:39:35 +0000
Message-ID: <16733-fb8b26e66710b2a1@postgresql.org> (raw)

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



view thread (2+ messages)  latest in thread

Message-ID: <16733-fb8b26e66710b2a1@postgresql.org>
Permalink:  ../16733-fb8b26e66710b2a1@postgresql.org/
Also on:    postgresql.org/message-id/16733-fb8b26e66710b2a1@postgresql.org

 · 

reply

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: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, zhongxuchen@gmail.com
  Subject: Re: BUG #16733: insert into on conflict(pk) do nothing error violates not-null constraint
  In-Reply-To: <16733-fb8b26e66710b2a1@postgresql.org>

* 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