Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1boxiq-0002nV-LS for pgsql-bugs@arkaria.postgresql.org; Tue, 27 Sep 2016 19:07:20 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1boxiq-0006V2-7x for pgsql-bugs@arkaria.postgresql.org; Tue, 27 Sep 2016 19:07:20 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1boxiB-0003ir-OB for pgsql-bugs@postgresql.org; Tue, 27 Sep 2016 19:06:39 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1boxi9-0007aN-0m for pgsql-bugs@postgresql.org; Tue, 27 Sep 2016 19:06:39 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u8RJ6VWQ029584; Tue, 27 Sep 2016 15:06:31 -0400 From: Tom Lane To: reyes.r.ponce@gmail.com cc: pgsql-bugs@postgresql.org Subject: Re: BUG #14343: UPSERT (ON CONFLICT) doesn't check ON CONFLICT constraint first In-reply-to: <20160927175223.20214.60920@wrigleys.postgresql.org> References: <20160927175223.20214.60920@wrigleys.postgresql.org> Comments: In-reply-to reyes.r.ponce@gmail.com message dated "Tue, 27 Sep 2016 17:52:23 -0000" Date: Tue, 27 Sep 2016 15:06:31 -0400 Message-ID: <29583.1475003191@sss.pgh.pa.us> X-Pg-Spam-Score: -4.9 (----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org reyes.r.ponce@gmail.com writes: > ERROR: null value in column "col1" violates not-null constraint > DETAIL: Failing row contains (1, null, 5, 2016-09-27 17:32:51.054896+00, > pl_mstr_usr, 2016-09-27 17:32:51.054896+00, pl_mstr_usr). > CONTEXT: SQL statement "INSERT INTO public.MyTable( > MY_ID, COL1, COL2, CRETN_TS, CRETN_USER_ID, UPDT_TS, > UPDT_USER_ID) > VALUES ($1, $2, $3, NOW(), current_user, NOW(), current_user) > ON CONFLICT(MY_ID) > DO UPDATE SET UPDT_TS = NOW(), UPDT_USER_ID = current_user, COL2 = $3" > PL/pgSQL function upsert_mytable(integer,integer,integer) line 46 at > EXECUTE This test case seems rather overcomplicated, but AFAICS you are complaining because the NOT NULL constraint is checked before uniqueness is checked. Sorry, that is not a bug, that is by design. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs