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 1kNO18-0002qS-8Z for pgsql-bugs@arkaria.postgresql.org; Tue, 29 Sep 2020 22:22:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kNO17-000573-5D for pgsql-bugs@arkaria.postgresql.org; Tue, 29 Sep 2020 22:22:37 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kNO16-00056w-Vc for pgsql-bugs@lists.postgresql.org; Tue, 29 Sep 2020 22:22:36 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kNO14-0003UV-Li for pgsql-bugs@postgresql.org; Tue, 29 Sep 2020 22:22:35 +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 08TMMTcO724330; Tue, 29 Sep 2020 18:22:29 -0400 From: Tom Lane To: David Rowley cc: Alvaro Herrera , Nagaraj Raj , Pg Bugs Subject: Re: ERROR: insufficient columns in the PRIMARY KEY constraint definition In-reply-to: References: <64062533.78364.1601415362244.ref@mail.yahoo.com> <64062533.78364.1601415362244@mail.yahoo.com> Comments: In-reply-to David Rowley message dated "Wed, 30 Sep 2020 11:05:42 +1300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <724328.1601418149.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 29 Sep 2020 18:22:29 -0400 Message-ID: <724329.1601418149@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk David Rowley writes: > On Wed, 30 Sep 2020 at 10:36, Nagaraj Raj wrote: >> Is it mandatory/necessary that the `partition column` should be a prima= ry key? cause if I include `load_dttm` as `PK` then its working fine. > Yes, this is required. Indeed. However, this complaint shows that the error message is not clear enough. I propose changing it to ERROR: unique constraint on partitioned table must be a superset of the pa= rtitioning columns or perhaps ERROR: unique constraint on partitioned table must include all partitionin= g columns The DETAIL seems fine as-is: DETAIL: PRIMARY KEY constraint on table "l_billing_account_p" lacks colum= n "load_dttm" which is part of the partition key. > There's mention in [1] section 5.10.2.3. "Unique constraints on > partitioned tables must include all the partition key columns. This > limitation exists because PostgreSQL can only enforce uniqueness in > each partition individually.". That text likely should also mention > PRIMARY KEY constraints. That probably should be changed Meh. If you've read that bit you probably already understand that pkeys are unique constraints. I think the problem is with the error text not the docs. regards, tom lane