Re: [BUG] wrong FK constraint name when colliding name on ATTACH
Alvaro Herrera <alvherre@alvh.no-ip.org>
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Amit Langote <amitlangote09@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Andres Freund <andres@anarazel.de>, Jehan-Guillaume de Rorthais <jgdr@dalibo.com>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2022-09-09T10:31:49Z
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@sss.pgh.pa.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)
Commits
-
Create FKs properly when attaching table as partition
- c301e1c0c09c 15.1 landed
- b0284bfb1db5 16.0 landed
- ab70b3a52fde 12.13 landed
- 41b6e7c9a32e 13.9 landed
- 18865f4df9ca 14.6 landed
-
Fix self-referencing foreign keys with partitioned tables
- 7d520e68ea1e 13.9 landed
- 669803af04e6 12.13 landed
- 614a406b4ff1 16.0 landed
- 6083132abdd4 15.0 landed
- 483d26930b4c 14.6 landed
-
Fix GetForeignKey*Triggers for self-referential FKs
- 8c848cd4b8e9 16.0 landed
- 68b0da67794e 15.0 landed
-
Choose FK name correctly during partition attachment
- e7936f8b3e57 16.0 landed
- ade2409b18e9 15.0 landed
- 80ef25b1adb1 13.9 landed
- 640c20d6266d 14.6 landed
- 562e100aeeaf 12.13 landed
-
Update SQL features
- 7e367924e33e 15.0 cited
-
Restore the previous semantics of get_constraint_index().
- 641f3dffcdf1 15.0 cited