Re: ERROR: insufficient columns in the PRIMARY KEY constraint definition

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Nagaraj Raj <nagaraj(dot)sf(at)yahoo(dot)com>
Cc: Pg Bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: ERROR: insufficient columns in the PRIMARY KEY constraint definition
Date: 2020-09-29 22:05:42
Message-ID: CAApHDvrGCKVEQeJ0Tchxkq86NXvF=HzVoROv_jGAGYv61P8Tuw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, 30 Sep 2020 at 10:36, Nagaraj Raj <nagaraj(dot)sf(at)yahoo(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2020-09-29 22:22:29 Re: ERROR: insufficient columns in the PRIMARY KEY constraint definition
Previous Message PG Bug reporting form 2020-09-29 21:50:15 BUG #16644: null value for defaults in OLD variable for trigger