Re: ERROR: insufficient columns in the PRIMARY KEY constraint definition - Mailing list pgsql-bugs

From David Rowley
Subject Re: ERROR: insufficient columns in the PRIMARY KEY constraint definition
Date
Msg-id CAApHDvrGCKVEQeJ0Tchxkq86NXvF=HzVoROv_jGAGYv61P8Tuw@mail.gmail.com
Whole thread Raw
In response to ERROR: insufficient columns in the PRIMARY KEY constraint definition  (Nagaraj Raj <nagaraj.sf@yahoo.com>)
Responses Re: ERROR: insufficient columns in the PRIMARY KEY constraint definition
List pgsql-bugs
On Wed, 30 Sep 2020 at 10:36, Nagaraj Raj <nagaraj.sf@yahoo.com> wrote:
> Is it mandatory/necessary that the `partition column` should be a primary key? cause if I  include `load_dttm` as
`PK`then its working fine.
 

Yes, this is required.  There is no concept of an index over all
partitions in PostgreSQL.  The requirement of having the partition key
a subset of the primary key allows us to implement primary keys by
just having individual unique indexes on each partition.  The fact
that it does not work is not a bug.

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

David

[1] https://www.postgresql.org/docs/11/ddl-partitioning.html



pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #16644: null value for defaults in OLD variable for trigger
Next
From: Tom Lane
Date:
Subject: Re: ERROR: insufficient columns in the PRIMARY KEY constraint definition