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 1hYvhA-000377-JD for pgsql-general@arkaria.postgresql.org; Thu, 06 Jun 2019 16:56:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hYvh9-00051K-9B for pgsql-general@arkaria.postgresql.org; Thu, 06 Jun 2019 16:56:55 +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 1hYper-0007fe-QQ for pgsql-general@lists.postgresql.org; Thu, 06 Jun 2019 10:30:09 +0000 Received: from mail.thgp.ru ([81.200.241.50]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hYpeo-00086I-Gf for pgsql-general@lists.postgresql.org; Thu, 06 Jun 2019 10:30:08 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.thgp.ru (Postfix) with ESMTP id 1ED2935CA22; Thu, 6 Jun 2019 13:30:02 +0300 (MSK) Received: from mail.thgp.ru ([127.0.0.1]) by localhost (mail.thgp.ru [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id jdQqMW_TXnyE; Thu, 6 Jun 2019 13:30:01 +0300 (MSK) Received: from localhost (localhost [127.0.0.1]) by mail.thgp.ru (Postfix) with ESMTP id 4B69647C280; Thu, 6 Jun 2019 13:30:01 +0300 (MSK) X-Virus-Scanned: amavisd-new at thgp.ru Received: from mail.thgp.ru ([127.0.0.1]) by localhost (mail.thgp.ru [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id QSTmt9JxbIjC; Thu, 6 Jun 2019 13:30:01 +0300 (MSK) Received: from mail.thgp.ru (mail.thgp.ru [81.200.241.50]) by mail.thgp.ru (Postfix) with ESMTP id 27D0635CA22; Thu, 6 Jun 2019 13:30:01 +0300 (MSK) Date: Thu, 6 Jun 2019 13:30:00 +0300 (MSK) From: "Alex V." To: pgsql-general Cc: tgl Message-ID: <1985070938.2403.1559817000895.JavaMail.zimbra@pclovers.ru> Subject: Re: Table partition with primary key in 11.3 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [81.200.241.50] X-Mailer: Zimbra 8.8.12_GA_3794 (ZimbraWebClient - FF52.9 (Linux)/8.8.12_GA_3794) Thread-Index: V2Vg3UABQ8ws+DQJoNcAOE7Hk9fclQ== Thread-Topic: Table partition with primary key in 11.3 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk >> 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 I think that your position about primary keys in partitional tables is not right. If we see regular table, one-field primary key is cross-table unique. In partitional tables for users view we MUST also seen unique one-field primary key because this is user requirement and another keys can destroy logic between regular and partitional tables and functionality of partitioning becomes useless. For administrators of table we not-MAY, but MUST see one-field unique primary key in cross-table realisation. All another realizations are plugging holes in a hurry and non-logical at global review of engine.