Re: problems with foreign keys on partitioned tables

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: problems with foreign keys on partitioned tables
Date: 2019-01-17 22:54:31
Message-ID: 201901172254.rciwyq3xwhkf@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2019-Jan-09, Amit Langote wrote:

> 1. Foreign keys of partitions stop working correctly after being detached
> from the parent table

> This happens because the action triggers defined on the PK relation (pk)
> refers to p as the referencing relation. On detaching p1 from p, p1's
> data is no longer accessible to that trigger.

Ouch.

> To fix this problem, we need create action triggers on PK relation
> that refer to p1 when it's detached (unless such triggers already
> exist which might be true in some cases). Attached patch 0001 shows
> this approach.

Hmm, okay. I'm not in love with the idea that such triggers might
already exist -- seems unclean. We should remove redundant action
triggers when we attach a table as a partition, no?

--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Mikael Kjellström 2019-01-17 22:54:46 Re: PSA: we lack TAP test coverage on NetBSD and OpenBSD
Previous Message Alvaro Herrera 2019-01-17 22:47:23 Re: Fixing findDependentObjects()'s dependency on scan order (regressions in DROP diagnostic messages)