Re: Multiple primary key on partition table?
Rajkumar Raghuwanshi <rajkumar.raghuwanshi@enterprisedb.com>
From: Rajkumar Raghuwanshi <rajkumar.raghuwanshi@enterprisedb.com>
To: amul sul <sulamul@gmail.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2018-10-01T06:39:14Z
Lists: pgsql-hackers
On Tue, Sep 18, 2018 at 11:20 AM amul sul <sulamul@gmail.com> wrote:
> On Mon, Sep 17, 2018 at 9:06 PM amul sul <sulamul@gmail.com> wrote:
> >
> > Nice catch Rajkumar.
> >
> > In index_check_primary_key(), relationHasPrimaryKey() called only for
> the an
> > alter command but I think we need to call in this case as well, like
> this:
> >
> > diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
> > index 7eb3e35166..c8714395fe 100644
> > --- a/src/backend/catalog/index.c
> > +++ b/src/backend/catalog/index.c
> > @@ -223,7 +223,7 @@ index_check_primary_key(Relation heapRel,
> > * and CREATE INDEX doesn't have a way to say PRIMARY KEY, so it's no
> > * problem either.
> > */
> > - if (is_alter_table &&
> > + if ((is_alter_table || heapRel->rd_rel->relispartition) &&
> > relationHasPrimaryKey(heapRel))
> > {
> > ereport(ERROR,
> >
> > Thoughts?
> >
>
> Here is the complete patch proposes the aforesaid fix with regression test.
>
Thanks, This worked for me.
>
> Regards,
> Amul
>
Commits
-
Fix duplicate primary keys in partitions
- fb9e93a2c5cf 12.0 landed
- ff347f8aff04 11.0 landed