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

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

From
Jehan-Guillaume de Rorthais
Date:
Hi,

On Thu, 17 Mar 2022 17:58:04 +0000
Arne Roland <A.Roland@index.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.




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

From
Arne Roland
Date:

From: Jehan-Guillaume de Rorthais <jgdr@dalibo.com>

Sent: Monday, March 21, 2022 11:36
Subject: Re: Detaching a partition with a FK on itself is not possible
 > I changed the list destination
Thanks

> 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.
That's what I meant. I didn't think about the NOTICE, but that's a good idea.

Regards
Arne