Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eloDW-0003r0-T5 for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Feb 2018 03:58:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eloDV-0004a4-Bz for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Feb 2018 03:58:45 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eloDV-0004Zt-25 for pgsql-hackers@lists.postgresql.org; Wed, 14 Feb 2018 03:58:45 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eloDN-00062t-8S for pgsql-hackers@postgresql.org; Wed, 14 Feb 2018 03:58:43 +0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 3D5DF20C0F; Tue, 13 Feb 2018 22:58:36 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute7.internal (MEProxy); Tue, 13 Feb 2018 22:58:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=uKHryr9U1D6hOvf6JZ2bJnFkklfm4 TAST+0MGtmOV1w=; b=ipTKQumRGoUbgV0oy6IorOENTyMcf6AChPdikO7uYSdhf dyM8sIreg95KH5ulbhDKnNkOGr4GLHUTV35Y8vawFQMfMO02758lrhLxth5xNgJv 1B8zGrVxwPg3mxQpjE9bpUbAXGAukbrY2S53/Nv6WjjznHRkP2P9/GiaghxhMyMz 1sSUQ6uQGLWOu6Q0lDw5QdnyEGfLxTfksfuS/7OWr815rl2nI2RKZzki/kyh62H9 nHv9VhNP81bs/FsUJh8xBxHS99mJw3XfoCRA7Uc1YGWlHB8vypx6p8zYHGZj8PIX axEriMxgRf41QcNbb81dQHHmA25R3RZCH50RPVWRQ== X-ME-Sender: Received: from april.local (c-73-13-66-39.hsd1.pa.comcast.net [73.13.66.39]) by mail.messagingengine.com (Postfix) with ESMTPA id DBCD37E4C7; Tue, 13 Feb 2018 22:58:35 -0500 (EST) Subject: Re: unique indexes on partitioned tables To: Alvaro Herrera , Jesper Pedersen , Amit Langote References: <20180212202615.q33ula7dpeyti2ee@alvherre.pgsql> Cc: Pg Hackers From: Peter Eisentraut Organization: 2ndQuadrant Message-ID: Date: Tue, 13 Feb 2018 22:58:35 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180212202615.q33ula7dpeyti2ee@alvherre.pgsql> Content-Type: multipart/mixed; boundary="------------96944975DB3E1576A2C456C3" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------96944975DB3E1576A2C456C3 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Here is a mini-patch on top of yours to fix a few cosmetic things. I don't understand the variable name "third". I don't see a "first" or "second" nearby. I find some of the columns in pg_constraint confusing. For a primary key on a partitioned table, for the PK on the partition I get conislocal = false, coninhcount = 1, connoinherit = true The last part is confusing to me. I don't know if that's really on this patch. But perhaps it could be documented better. -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services --------------96944975DB3E1576A2C456C3 Content-Type: text/plain; charset=UTF-8; x-mac-type="0"; x-mac-creator="0"; name="0001-fixup-allow-indexes-on-partitioned-tables-to-be-uniq.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-fixup-allow-indexes-on-partitioned-tables-to-be-uniq.pa"; filename*1="tch" From 69fbe467e554f6f70195d0f40898eba62ddb9641 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Tue, 13 Feb 2018 22:53:55 -0500 Subject: [PATCH] fixup! allow indexes on partitioned tables to be unique --- doc/src/sgml/ref/alter_table.sgml | 5 ++--- doc/src/sgml/ref/create_table.sgml | 3 +-- src/backend/catalog/index.c | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/doc/src/sgml/ref/alter_table.sgml b/doc/src/sgml/ref/alter_table.sgml index 2d3b6d3960..5be56d4b28 100644 --- a/doc/src/sgml/ref/alter_table.sgml +++ b/doc/src/sgml/ref/alter_table.sgml @@ -839,9 +839,8 @@ Description This form attaches an existing table (which might itself be partitioned) as a partition of the target table. The table can be attached - as a partition for specific values using FOR VALUES - or as a default partition by using - DEFAULT. + as a partition for specific values using FOR VALUES + or as a default partition by using DEFAULT. For each index in the target table, a corresponding one will be created in the attached table; or, if an equivalent index already exists, will be attached to the target table's index, diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml index 83d3472da2..b7bf7bc1c8 100644 --- a/doc/src/sgml/ref/create_table.sgml +++ b/doc/src/sgml/ref/create_table.sgml @@ -546,8 +546,7 @@ Parameters - Partitioned tables do not support - EXCLUDE, or + Partitioned tables do not support EXCLUDE or FOREIGN KEY constraints; however, you can define these constraints on individual partitions. diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c index a5fa3540a7..5fb50a3a0e 100644 --- a/src/backend/catalog/index.c +++ b/src/backend/catalog/index.c @@ -1325,7 +1325,7 @@ index_constraint_create(Relation heapRelation, */ if (OidIsValid(parentConstraintId)) { - ObjectAddress third; + ObjectAddress third; // ??? ObjectAddressSet(third, ConstraintRelationId, parentConstraintId); recordDependencyOn(&referenced, &third, DEPENDENCY_INTERNAL_AUTO); -- 2.16.1 --------------96944975DB3E1576A2C456C3--