Re: Detaching a partition with a FK on itself is not possible

From: Jehan-Guillaume de Rorthais <jgdr(at)dalibo(dot)com>
To: Arne Roland <A(dot)Roland(at)index(dot)de>
Cc: Christophe Courtois <christophe(dot)courtois(at)dalibo(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Detaching a partition with a FK on itself is not possible
Date: 2022-03-21 10:36:34
Message-ID: 20220321113634.68c09d4b@karst
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

Hi,

On Thu, 17 Mar 2022 17:58:04 +0000
Arne Roland <A(dot)Roland(at)index(dot)de> wrote:

> I don't think this a bug, but a feature request. I therefore think hackers
> would be more appropriate.

+1

I changed the list destination

> I don't see how an additional syntax to modify the constraint should help.

Me neiher.

> If I'd want to fix this, I'd try to teach the detach partition code about
> self referencing foreign keys. It seems to me like that would be the cleanest
> solution, because the user doesn't need to care about this at all.

Teaching the detach partition about self referencing means either:

* it's safe to remove the FK
* we can rewrite the FK for self referencing

Both solution are not ideal from the original schema and user perspective.

Another solution could be to teach the create partition to detect a self
referencing FK and actually create a self referencing FK, not pointing to the
partitioned table, and of course issuing a NOTICE to the client.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Arne Roland 2022-03-21 10:50:46 Re: Detaching a partition with a FK on itself is not possible
Previous Message Julien Rouhaud 2022-03-21 09:21:58 Re: BUG #17443: Select command does not use brin index when enable_seqscan = on

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2022-03-21 10:38:59 Re: Column Filtering in Logical Replication
Previous Message Japin Li 2022-03-21 10:13:46 Re: [PATCH] Remove workarounds to format [u]int64's