pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: Bruce Momjian <bruce@momjian.us>
Cc: phil.bayer@gmail.com, pgsql-docs@lists.postgresql.org, PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: Re: Postgres 11: Table Partitioning and Primary Keys
Date: Tue, 9 Jul 2019 11:58:56 +0900
Message-ID: <20190709025856.GC1345@paquier.xyz> (raw)
In-Reply-To: <20190709023737.vhrd4pxe4hgnd3ks@momjian.us>
References: <156236160709.1192.4498528196556144085@wrigleys.postgresql.org>
	<20190709023737.vhrd4pxe4hgnd3ks@momjian.us>

On Mon, Jul 08, 2019 at 10:37:37PM -0400, Bruce Momjian wrote:
> On Fri, Jul  5, 2019 at 09:20:07PM +0000, PG Doc comments form wrote:
>> In the documentation for Postgres 11 table partitioning, there is no mention
>> of the requirement that the Primary Key of a partitioned table must contain
>> the partition key.
>> In fact the documentation on primary keys is so light that I am not even
>> 100% sure the above is correct.  If the following table is not possible in
>> Postgres 11, the documentation should find some way to make that clear.  
>> 
>> I believe this should be documented in section "5.10.2.3. Limitations"
> 
> Can someone comment on this?  CC to hackers.

Yep, that's the case:
=# CREATE TABLE parent_tab (id int, id2 int primary key)
     PARTITION BY RANGE (id);
ERROR:  0A000: insufficient columns in PRIMARY KEY constraint
definition
DETAIL:  PRIMARY KEY constraint on table "parent_tab" lacks column
"id" which is part of the partition key.
LOCATION:  DefineIndex, indexcmds.c:894

I agree with the report here that adding one sentence to 5.10.2.3
which is for the limitations of declarative partitioning would be a
good idea.  We don't mention the limitation in CREATE TABLE either
(which would be rather incorrect IMO).

Attached is an idea of patch for the documentation, using this
wording:
+     <listitem>
+      <para>
+       When defining a primary key on a partitioned table, the primary
+       key column must be included in the partition key.
+      </para>
+     </listitem>
If somebody has any better idea for that paragraph, please feel free.
--
Michael

Attachments:

  [application/pgp-signature] signature.asc (832B, ../20190709025856.GC1345@paquier.xyz/2-signature.asc)
  download

view thread (15+ messages)  latest in thread

Message-ID: <20190709025856.GC1345@paquier.xyz>
Permalink:  ../20190709025856.GC1345@paquier.xyz/
Also on:    postgresql.org/message-id/20190709025856.GC1345@paquier.xyz

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-docs@postgresql.org
  Cc: michael@paquier.xyz, bruce@momjian.us, pgsql-hackers@postgresql.org
  Subject: Re: Postgres 11: Table Partitioning and Primary Keys
  In-Reply-To: <20190709025856.GC1345@paquier.xyz>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox