pgsql: Fix thinko in construction of old_conpfeqop list. - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Fix thinko in construction of old_conpfeqop list.
Date
Msg-id E1hnVly-00068O-IY@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Fix thinko in construction of old_conpfeqop list.

This should lappend the OIDs, not lcons them; the existing code produced
a list in reversed order.  This is harmless for single-key FKs or FKs
where all the key columns are of the same type, which probably explains
how it went unnoticed.  But if those conditions are not met,
ATAddForeignKeyConstraint would make the wrong decision about whether an
existing FK needs to be revalidated.  I think it would almost always err
in the safe direction by revalidating a constraint that didn't need it.
You could imagine scenarios where the pfeqop check was fooled by
swapping the types of two FK columns in one ALTER TABLE, but that case
would probably be rejected by other tests, so it might be impossible to
get to the worst-case scenario where an FK should be revalidated and
isn't.  (And even then, it's likely to be fine, unless there are weird
inconsistencies in the equality behavior of the replacement types.)
However, this is a performance bug at least.

Noted while poking around to see whether lcons calls could be converted
to lappend.

This bug is old, dating to commit cb3a7c2b9, so back-patch to all
supported branches.

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/46e2a18d0dfd140bfa36e5d543feeac5f5600244

Modified Files
--------------
src/backend/commands/tablecmds.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Remove lappend_cell...() family of List functions.
Next
From: Thomas Munro
Date:
Subject: pgsql: Move some md.c-specific logic from smgr.c to md.c.