Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kc8ug-0002tg-SZ for pgsql-bugs@arkaria.postgresql.org; Mon, 09 Nov 2020 15:16:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kc8uf-0000fM-8O for pgsql-bugs@arkaria.postgresql.org; Mon, 09 Nov 2020 15:16:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kc8uf-0000fF-2G for pgsql-bugs@lists.postgresql.org; Mon, 09 Nov 2020 15:16:57 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kc8uc-0002rz-Oe for pgsql-bugs@lists.postgresql.org; Mon, 09 Nov 2020 15:16:56 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 0A9FGpLt1974490; Mon, 9 Nov 2020 10:16:51 -0500 From: Tom Lane To: zhongxuchen@gmail.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16706: insert into on conflict(pk) do update error violates not-null constraint In-reply-to: <16706-08837c0cdaf4ce57@postgresql.org> References: <16706-08837c0cdaf4ce57@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Mon, 09 Nov 2020 09:13:10 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1974488.1604935011.1@sss.pgh.pa.us> Date: Mon, 09 Nov 2020 10:16:51 -0500 Message-ID: <1974489.1604935011@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk PG Bug reporting form writes: > 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) > ) > insert into TEST1 (ID, NAME,STATUS ) values('4','test','6') ; > 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); I get ERROR: null value in column "name" violates not-null constraint DETAIL: Failing row contains (4, null, 6). so this seems to have been fixed already. regards, tom lane