Re: [BUG] Fix DETACH with FK pointing to a partitioned table fails

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Jehan-Guillaume de Rorthais <jgdr(at)dalibo(dot)com>
Cc: Tender Wang <tndrwang(at)gmail(dot)com>, Junwang Zhao <zhjwpku(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, Alexander Lakhin <exclusion(at)gmail(dot)com>, Guillaume Lelarge <guillaume(at)lelarge(dot)info>, Michael Paquier <michael(at)paquier(dot)xyz>
Subject: Re: [BUG] Fix DETACH with FK pointing to a partitioned table fails
Date: 2024-10-22 14:32:33
Message-ID: 202410221432.3qtqbk2q6o7q@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2024-Oct-22, Jehan-Guillaume de Rorthais wrote:

> On Fri, 18 Oct 2024 16:50:59 +0200
> Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> wrote:

> > For branch 14, I opted to make it delete the constraints on detach.
> > This isn't ideal but unless somebody wants to spend a lot more time on
> > this, it seems the best we can do. Leaving broken constraints around
> > seems worse.
>
> Keep that in mind, and move ahead to the next level: self-FK on partitioned
> table! ;-)
>
> https://www.postgresql.org/message-id/flat/20230707175859.17c91538%40karst#0dc7b8afd8b780899021bbb075598250

Yeah. I pushed these patches finally, thanks!

Now we can discuss what to do about self-referencing FKs ... maybe we
should consider dropping the FK on detach in problematic cases.

> > However, in the end I think this is a very good technique to verify that
> > the fix works correctly, but it's excessive to include these results in
> > the tests forevermore. So I've left them out for now. Maybe we should
> > reconsider on the older branches?
>
> The point here was to make sure futur work/refactoring don't forget/break
> anything in the catalog representation of FK on partitions.

There is that ... but I think testing for user-visible symptoms is
better. I'm not sure I want to bet against the odds that this will
become make-work to keep the output of internal catalog state up to date
for whatever other changes we need to do.

--
Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/
Are you not unsure you want to delete Firefox?
[Not unsure] [Not not unsure] [Cancel]
http://smylers.hates-software.com/2008/01/03/566e45b2.html

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2024-10-22 14:40:55 Re: Support regular expressions with nondeterministic collations
Previous Message Jehan-Guillaume de Rorthais 2024-10-22 14:23:12 Re: [BUG] Fix DETACH with FK pointing to a partitioned table fails