Re: inherited primary key misbehavior

From: Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: inherited primary key misbehavior
Date: 2019-01-24 01:34:17
Message-ID: a09708e1-6cb3-71bc-56fb-22ba9c5b9beb@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2019/01/24 6:10, Alvaro Herrera wrote:
> Hello
>
> On 2019-Jan-23, Amit Langote wrote:
>
>> It seems that ATExecDetachPartition misses to mark a child's primary key
>> constraint entry (if any) as local (conislocal=true, coninhcount=0), which
>> causes this:
>>
>> create table p (a int primary key) partition by list (a);
>> create table p2 partition of p for values in (2);
>> alter table p detach partition p2;
>> alter table p2 drop constraint p2_pkey ;
>> ERROR: cannot drop inherited constraint "p2_pkey" of relation "p2"
>
> Ugh.
>
> I suppose unique keys would have the same problem, so the check for
> indisprimary is wrong.

Fixed in the attached. We don't support inheriting EXCLUSION constraints
yet, so no need to consider their indexes.

Thanks,
Amit

Attachment Content-Type Size
v2-0001-Detach-primary-key-constraint-when-detaching-part.patch text/plain 4.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2019-01-24 01:44:41 Re: Making all nbtree entries unique by having heap TIDs participate in comparisons
Previous Message David Rowley 2019-01-24 00:56:36 Re: Delay locking partitions during INSERT and UPDATE