Re: partitioned tables referenced by FKs

Jesper Pedersen <jesper.pedersen@redhat.com>

From: Jesper Pedersen <jesper.pedersen@redhat.com>
To: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>, Pg Hackers <pgsql-hackers@postgresql.org>
Date: 2019-03-27T14:22:21Z
Lists: pgsql-hackers
Hi,

On 3/26/19 5:39 PM, Alvaro Herrera wrote:
>>> As I said before, I'm thinking of getting rid of the whole business of
>>> checking partitions on the referenced side of an FK at DROP time, and
>>> instead jut forbid the DROP completely if any FKs reference an ancestor
>>> of that partition.
>>
>> Will that allow `DROP TABLE parted_pk CASCADE` to succeed even if
>> partitions still contain referenced data?  I suppose that's the example
>> you cited upthread as a bug that remains to be solved.
> 
> That's the idea, yes, it should do that: only allow a DROP of a
> partition referenced by an FK if the topmost constraint is also being
> dropped.  Maybe this means I need to get rid of 0002 completely.  But I
> haven't got to doing that yet.
> 

I think that is ok, if doc/src/sgml/ref/drop_table.sgml is updated with 
a description of how CASCADE works in this scenario.

Best regards,
  Jesper



Commits

  1. Support foreign keys that reference partitioned tables

  2. Fix partitioned index creation bug with dropped columns

  3. Improve psql's \d display of foreign key constraints

  4. Fix dependency recording bug for partitioned PKs

  5. Add index_get_partition convenience function

  6. Restore RI trigger sanity check

  7. Foreign keys on partitioned tables