Re: Detaching a partition with a FK on itself is not possible - Mailing list pgsql-hackers

From Jehan-Guillaume de Rorthais
Subject Re: Detaching a partition with a FK on itself is not possible
Date
Msg-id 20220321113634.68c09d4b@karst
Whole thread Raw
Responses Re: Detaching a partition with a FK on itself is not possible
List pgsql-hackers
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.




pgsql-hackers by date:

Previous
From: Japin Li
Date:
Subject: Re: [PATCH] Remove workarounds to format [u]int64's
Next
From: Amit Kapila
Date:
Subject: Re: Column Filtering in Logical Replication