pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jesper Pedersen <jesper.pedersen@redhat.com>
To: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
Cc: Pg Hackers <pgsql-hackers@postgresql.org>
Cc: amitlangote09@gmail.com
Subject: Re: partitioned tables referenced by FKs
Date: Fri, 29 Mar 2019 15:39:53 -0400
Message-ID: <6c6bcb5b-34a2-80ea-07d7-58f1eb7f4a0a@redhat.com> (raw)
In-Reply-To: <20190328185925.GA23624@alvherre.pgsql>
References: <20190328185925.GA23624@alvherre.pgsql>

Hi Alvaro,

On 3/28/19 2:59 PM, Alvaro Herrera wrote:
> I ended up revising the dependencies that we give to the constraint in
> the partition -- instead of giving it partition-type dependencies, we
> give it an INTERNAL dependency.  Now when you request to drop the
> partition, it says this:
> 
> create table pk (a int primary key) partition by list (a);
> create table fk (a int references pk);
> create table pk1 partition of pk for values in (1);
> 
> alvherre=# drop table pk1;
> ERROR:  cannot drop table pk1 because other objects depend on it
> DETAIL:  constraint fk_a_fkey on table fk depends on table pk1
> HINT:  Use DROP ... CASCADE to drop the dependent objects too.
> 
> If you do say CASCADE, the constraint is dropped.  Not really ideal (I
> would prefer that the drop is prevented completely), but at least it's
> not completely bogus.  If you do "DROP TABLE pk", it works sanely.
> Also, if you DETACH the partition that pg_depend row goes away, so a
> subsequent drop of the partition works sanely.
> 
> Fixed the psql issue pointed out by Amit L too.
> 

I ran my test cases for this feature, and havn't seen any issues.

Therefore I'm marking 1877 as Ready for Committer. If others have 
additional feedback feel free to switch it back.

Best regards,
  Jesper





view thread (61+ messages)  latest in thread

Message-ID: <6c6bcb5b-34a2-80ea-07d7-58f1eb7f4a0a@redhat.com>
Permalink:  ../6c6bcb5b-34a2-80ea-07d7-58f1eb7f4a0a@redhat.com/
Also on:    postgresql.org/message-id/6c6bcb5b-34a2-80ea-07d7-58f1eb7f4a0a@redhat.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: jesper.pedersen@redhat.com, alvherre@2ndquadrant.com, Langote_Amit_f8@lab.ntt.co.jp, amitlangote09@gmail.com
  Subject: Re: partitioned tables referenced by FKs
  In-Reply-To: <6c6bcb5b-34a2-80ea-07d7-58f1eb7f4a0a@redhat.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox