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

From: tender wang <tndrwang(at)gmail(dot)com>
To: Jehan-Guillaume de Rorthais <jgdr(at)dalibo(dot)com>
Cc: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [BUG] Fix DETACH with FK pointing to a partitioned table fails
Date: 2023-10-25 11:51:45
Message-ID: CAHewXNmA88kB0sYYVmdozfdhqad4ADM5sRt1hussFiy0rm1Y1A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi
Is there any conclusion to this issue?

Jehan-Guillaume de Rorthais <jgdr(at)dalibo(dot)com> 于2023年8月10日周四 23:03写道:

> On Thu, 3 Aug 2023 11:02:43 +0200
> Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> wrote:
>
> > On 2023-Aug-03, tender wang wrote:
> >
> > > I think old "sub-FK" should not be dropped, that will be violates
> foreign
> > > key constraint.
> >
> > Yeah, I've been playing more with the patch and it is definitely not
> > doing the right things. Just eyeballing the contents of pg_trigger and
> > pg_constraint for partitions added by ALTER...ATTACH shows that the
> > catalog contents are inconsistent with those added by CREATE TABLE
> > PARTITION OF.
>
> Well, as stated in my orignal message, at the patch helps understanding the
> problem and sketch a possible solution. It definitely is not complete.
>
> After DETACHing the table, we surely needs to check everything again and
> recreating what is needed to keep the FK consistent.
>
> But should we keep the FK after DETACH? Did you check the two other
> discussions
> related to FK, self-FK & partition? Unfortunately, as Tender experienced,
> the
> more we dig the more we find bugs. Moreover, the second one might seems
> unsolvable and deserve a closer look. See:
>
> * FK broken after DETACHing referencing part
> https://www.postgresql.org/message-id/20230420144344.40744130%40karst
> * Issue attaching a table to a partitioned table with an auto-referenced
> foreign key
> https://www.postgresql.org/message-id/20230707175859.17c91538%40karst
>
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2023-10-25 11:53:48 Re: trying again to get incremental backup
Previous Message Heikki Linnakangas 2023-10-25 11:34:39 Re: ResourceOwner refactoring