Re: [BUG] wrong FK constraint name when colliding name on ATTACH

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Amit Langote <amitlangote09(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andres Freund <andres(at)anarazel(dot)de>, Jehan-Guillaume de Rorthais <jgdr(at)dalibo(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [BUG] wrong FK constraint name when colliding name on ATTACH
Date: 2022-09-09 10:31:49
Message-ID: 20220909103149.lk5n3vvb2taxejfp@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2022-Sep-09, Amit Langote wrote:

> Yes, the loop in GetForeignKeyActionTriggers() needs this:
>
> + /* Only ever look at "action" triggers on the PK side. */
> + if (RI_FKey_trigger_type(trgform->tgfoid) != RI_TRIGGER_PK)
> + continue;
>
> Likewise, GetForeignKeyActionTriggers() needs this:
>
> + /* Only ever look at "check" triggers on the FK side. */
> + if (RI_FKey_trigger_type(trgform->tgfoid) != RI_TRIGGER_FK)
> + continue;
>
> We evidently missed this in f4566345cf40b0.

Ouch. Thank you, pushed.

> On Fri, Sep 9, 2022 at 4:54 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> > I'd counsel dropping the early-exit optimization; it doesn't
> > save much I expect, and it evidently hides bugs. Or maybe
> > make it conditional on !USE_ASSERT_CHECKING.
>
> While neither of these functions are called in hot paths, I am
> inclined to keep the early-exit bit in non-assert builds.

I kept it that way.

--
Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/
"El hombre nunca sabe de lo que es capaz hasta que lo intenta" (C. Dickens)

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Dilip Kumar 2022-09-09 10:57:45 Re: SI-read predicate locks on materialized views
Previous Message Drouvot, Bertrand 2022-09-09 10:31:08 Re: Patch proposal: make use of regular expressions for the username in pg_hba.conf