Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hTVUp-0006CA-5U for pgsql-general@arkaria.postgresql.org; Wed, 22 May 2019 17:57:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hTVUn-0004ED-O8 for pgsql-general@arkaria.postgresql.org; Wed, 22 May 2019 17:57:45 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hTVUn-0004E6-Bn for pgsql-general@lists.postgresql.org; Wed, 22 May 2019 17:57:45 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hTVUk-00046L-RF for pgsql-general@lists.postgresql.org; Wed, 22 May 2019 17:57:44 +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 x4MHvejC006832; Wed, 22 May 2019 13:57:40 -0400 From: Tom Lane To: User cc: pgsql-general@lists.postgresql.org Subject: Re: Table partition with primary key in 11.3 In-reply-to: <94935ac5-2f65-3c41-c14d-1b13da8e19ca@penek.org> References: <94935ac5-2f65-3c41-c14d-1b13da8e19ca@penek.org> Comments: In-reply-to User message dated "Wed, 22 May 2019 20:46:39 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <6830.1558547860.1@sss.pgh.pa.us> Date: Wed, 22 May 2019 13:57:40 -0400 Message-ID: <6831.1558547860@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk User writes: > CREATE TABLE public.test1 ( > x1 integer NOT NULL, > x2 integer NOT NULL, > CONSTRAINT test1_pkey PRIMARY KEY (x1) INCLUDE(x2) > ) PARTITION BY RANGE (x2); > This query works in 11.1 but fails in 11.3 with messages: > ERROR: insufficient columns in PRIMARY KEY constraint definition > DETAIL: PRIMARY KEY constraint on table "test1" lacks column "x2" which > is part of the partition key. > SQL state: 0A000 Indeed, that primary key is no good. It was a bug that 11.1 allowed it, which was fixed here: Author: Alvaro Herrera Branch: master [0ad41cf53] 2019-01-14 19:28:10 -0300 Branch: REL_11_STABLE Release: REL_11_2 [74aa7e046] 2019-01-14 19:25:19 -0300 Fix unique INCLUDE indexes on partitioned tables We were considering the INCLUDE columns as part of the key, allowing unicity-violating rows to be inserted in different partitions. Concurrent development conflict in eb7ed3f30634 and 8224de4f42cc. Reported-by: Justin Pryzby Discussion: https://postgr.es/m/20190109065109.GA4285@telsasoft.com regards, tom lane