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

From: Tender Wang <tndrwang(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: Junwang Zhao <zhjwpku(at)gmail(dot)com>, Jehan-Guillaume de Rorthais <jgdr(at)dalibo(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, Alexander Lakhin <exclusion(at)gmail(dot)com>, Baehler Thomas SBB CFF FFS <thomas(dot)baehler2(at)sbb(dot)ch>, Guillaume Lelarge <guillaume(at)lelarge(dot)info>
Subject: Re: [BUG] Fix DETACH with FK pointing to a partitioned table fails
Date: 2024-08-23 02:44:19
Message-ID: CAHewXNmubkxLLCkS3D8tetbXDhCaYgdd-3UTLgE3C-HFfsHCRA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> 于2024年8月23日周五 02:41写道:

> On 2024-Aug-22, Tender Wang wrote:
>
> > I apply the v14 patch on branch REL_14_STABLE. I run this thread issue
> and I
> > find below error.
> > [...]
> > ERROR: cache lookup failed for constraint 16400
> >
> > I haven't look into details to find out where cause above error.
>
> Right, we try to drop the constraint twice. We can dodge this by
> collecting all constraints to drop in the loop and process them in a
> single performMultipleDeletions, as in the attached v14-2.
>

Can we move the CommandCounterIncrement() in
if (get_rel_relkind(fk->confrelid) == RELKIND_PARTITIONED_TABLE) block
to be close to performMultipleDeletions().

Others look good to me.

TBH I think it's a bit infuriating that we lose the constraint (which
> was explicitly declared) because of ATTACH/DETACH.

Agree.
Do you think it is friendly to users if we add hints that inform them the
constraint was dropped?

--
Tender Wang

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Richard Guo 2024-08-23 03:08:47 Re: Redundant Result node
Previous Message David G. Johnston 2024-08-23 02:33:47 Re: slru bank