Re: Postgres 11: Table Partitioning and Primary Keys

2019-07-10 Thread Michael Paquier
On Tue, Jul 09, 2019 at 06:59:59PM -0400, Tom Lane wrote: > Alvaro Herrera writes: >> >> >>Unique constraints on partitioned tables (as well as primary keys) >>must constrain all the partition key columns. This limitation exists >>because PostgreSQL can only e

Re: Postgres 11: Table Partitioning and Primary Keys

2019-07-09 Thread Amit Langote
On Wed, Jul 10, 2019 at 7:53 AM Alvaro Herrera wrote: > On 2019-Jul-09, Amit Langote wrote: > > "While defining a primary key and unique constraints on partitioned > > tables is supported, the set of columns being constrained must include > > all of the partition key columns. This limitation exis

Re: Postgres 11: Table Partitioning and Primary Keys

2019-07-09 Thread Tom Lane
Alvaro Herrera writes: > That's a mild personal preference only though. Anyway, based on your > proposed wording, I wrote this: > > >Unique constraints on partitioned tables (as well as primary keys) >must constrain all the partition key columns. This limitation exi

Re: Postgres 11: Table Partitioning and Primary Keys

2019-07-09 Thread Alvaro Herrera
On 2019-Jul-09, Amit Langote wrote: > As mentioned in the docs, defining exclusion constraints on > partitioned tables is not supported. Right. > "While defining a primary key and unique constraints on partitioned > tables is supported, the set of columns being constrained must include > all of

Re: Postgres 11: Table Partitioning and Primary Keys

2019-07-09 Thread Amit Langote
Sorry for jumping in late here. On Tue, Jul 9, 2019 at 3:51 PM Michael Paquier wrote: > On Tue, Jul 09, 2019 at 03:34:48PM +0900, Michael Paquier wrote: > > Looking closely at the code in DefineIndex() (and as Rajkumar has > > mentioned upthread for unique constraints) this can happen for primary

Re: Postgres 11: Table Partitioning and Primary Keys

2019-07-09 Thread David G. Johnston
On Mon, Jul 8, 2019 at 11:34 PM Michael Paquier wrote: > On Mon, Jul 08, 2019 at 08:12:18PM -0700, David G. Johnston wrote: > > Reads a bit backward. How about: > > > > "As uniqueness can only be enforced within an individual partition when > > defining a primary key on a partitioned table all c

Re: Postgres 11: Table Partitioning and Primary Keys

2019-07-08 Thread Michael Paquier
On Tue, Jul 09, 2019 at 03:34:48PM +0900, Michael Paquier wrote: > Looking closely at the code in DefineIndex() (and as Rajkumar has > mentioned upthread for unique constraints) this can happen for primary > keys, unique constraints and exclusion constraints. So we had better > mention all three o

Re: Postgres 11: Table Partitioning and Primary Keys

2019-07-08 Thread Michael Paquier
On Mon, Jul 08, 2019 at 11:10:51PM -0400, Tom Lane wrote: > Isn't it the other way around, that the partition key column(s) must > be > included in the primary key? Maybe I'm confused, but it seems like > we couldn't enforce PK uniqueness otherwise. Yes you are right. The full column list of the

Re: Postgres 11: Table Partitioning and Primary Keys

2019-07-08 Thread Michael Paquier
On Mon, Jul 08, 2019 at 08:12:18PM -0700, David G. Johnston wrote: > Reads a bit backward. How about: > > "As uniqueness can only be enforced within an individual partition when > defining a primary key on a partitioned table all columns present in the > partition key must also exist in the prima

Re: Postgres 11: Table Partitioning and Primary Keys

2019-07-08 Thread Rajkumar Raghuwanshi
On Tue, Jul 9, 2019 at 8:29 AM Michael Paquier wrote: > On Mon, Jul 08, 2019 at 10:37:37PM -0400, Bruce Momjian wrote: > > On Fri, Jul 5, 2019 at 09:20:07PM +, PG Doc comments form wrote: > >> In the documentation for Postgres 11 table partitioning, there is no > mention > >> of the requirem

Re: Postgres 11: Table Partitioning and Primary Keys

2019-07-08 Thread David G. Johnston
On Mon, Jul 8, 2019 at 7:59 PM Michael Paquier wrote: > Attached is an idea of patch for the documentation, using this > wording: > + > + > + When defining a primary key on a partitioned table, the primary > + key column must be included in the partition key. > + > +

Re: Postgres 11: Table Partitioning and Primary Keys

2019-07-08 Thread Tom Lane
Michael Paquier writes: > Attached is an idea of patch for the documentation, using this > wording: > + > + > + When defining a primary key on a partitioned table, the primary > + key column must be included in the partition key. > + > + Isn't it the other way ar

Re: Postgres 11: Table Partitioning and Primary Keys

2019-07-08 Thread Michael Paquier
On Mon, Jul 08, 2019 at 10:37:37PM -0400, Bruce Momjian wrote: > On Fri, Jul 5, 2019 at 09:20:07PM +, 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 >> th

Re: Postgres 11: Table Partitioning and Primary Keys

2019-07-08 Thread Bruce Momjian
On Fri, Jul 5, 2019 at 09:20:07PM +, PG Doc comments form wrote: > The following documentation comment has been logged on the website: > > Page: https://www.postgresql.org/docs/11/ddl-partitioning.html > Description: > > In the documentation for Postgres 11 table partitioning, there is no me