Skip site navigation (1) Skip section navigation (2)

pgsql: Fix incorrect optimization of foreign-key checks.

From: tgl(at)postgresql(dot)org (Tom Lane)
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix incorrect optimization of foreign-key checks.
Date: 2007-07-17 17:45:28
Message-ID: 20070717174528.EBCC29FBA87@postgresql.org (view raw or flat)
Thread:
Lists: pgsql-committers
Log Message:
-----------
Fix incorrect optimization of foreign-key checks.  When an UPDATE on the
referencing table does not change the tuple's FK column(s), we don't bother
to check the PK table since the constraint was presumably already valid.
However, the check is still necessary if the tuple was inserted by our own
transaction, since in that case the INSERT trigger will conclude it need not
make the check (since its version of the tuple has been deleted).  We got this
right for simple cases, but not when the insert and update are in different
subtransactions of the current top-level transaction; in such cases the FK
check would never be made at all.  (Hence, problem dates back to 8.0 when
subtransactions were added --- it's actually the subtransaction version of a
bug fixed in 7.3.5.)  Fix, and add regression test cases.  Report and fix by
Affan Salman.

Modified Files:
--------------
    pgsql/src/backend/commands:
        trigger.c (r1.215 -> r1.216)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/trigger.c.diff?r1=1.215&r2=1.216)
    pgsql/src/test/regress/expected:
        foreign_key.out (r1.43 -> r1.44)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/expected/foreign_key.out.diff?r1=1.43&r2=1.44)
    pgsql/src/test/regress/sql:
        foreign_key.sql (r1.19 -> r1.20)
        (http://developer.postgresql.org/cvsweb.cgi/pgsql/src/test/regress/sql/foreign_key.sql.diff?r1=1.19&r2=1.20)

pgsql-committers by date

Next:From: Tom LaneDate: 2007-07-17 17:45:40
Subject: pgsql: Fix incorrect optimization of foreign-key checks.
Previous:From: Bruce MomjianDate: 2007-07-17 05:03:55
Subject: pgsql: Remove http://www.benchmarkresources.com, no longer resolves to a

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group