pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix thinko in construction of old_conpfeqop list.
Date: Tue, 16 Jul 2019 22:18:10 +0000
Message-ID: <E1hnVly-00068U-JH@gemulon.postgresql.org> (raw)

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
------
REL9_5_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/f9208f2469635c372bf3c2ccfc9835dc11bd8c1c

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



view thread (7+ messages)

Message-ID: <E1hnVly-00068U-JH@gemulon.postgresql.org>
Permalink:  ../E1hnVly-00068U-JH@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1hnVly-00068U-JH@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Fix thinko in construction of old_conpfeqop list.
  In-Reply-To: <E1hnVly-00068U-JH@gemulon.postgresql.org>
  References: <E1hnVly-00068U-JH@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox