inherited primary key misbehavior

From: Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Subject: inherited primary key misbehavior
Date: 2019-01-23 09:34:06
Message-ID: c1c9b688-b886-84f7-4048-1e4ebe9b1d06@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

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"

select conname, conislocal, coninhcount from pg_constraint where conrelid
= 'p2'::regclass;
conname │ conislocal │ coninhcount
─────────┼────────────┼─────────────
p2_pkey │ f │ 1
(1 row)

How about the attached patch?

Thanks,
Amit

Attachment Content-Type Size
0001-Detach-primary-key-constraint-when-detaching-partiti.patch text/plain 3.7 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Chris Travers 2019-01-23 10:55:09 Re: Proposal for Signal Detection Refactoring
Previous Message Fabien COELHO 2019-01-23 09:08:34 Re: pg_dump multi VALUES INSERT