FKey not enforced resulting in broken Dump/Reload

From: Rod Taylor <rod(dot)taylor(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: FKey not enforced resulting in broken Dump/Reload
Date: 2013-07-19 16:58:10
Message-ID: CAKddOFANAYN358LMdt0yh2Cm1zFrA942WmDU3C0d-aGHR3RZcQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

A poorly coded trigger on the referencing table has the ability to break
foreign keys, and as a result create a database which cannot be dumped and
reloaded.

The BEFORE DELETE trigger accidentally does RETURN NEW, which suppresses
the DELETE action by the foreign key trigger. This allows the record from
the referenced table to be deleted and the record in the referencing table
to remain in place.

While I don't expect Pg to do what the coder meant, but it should throw an
error and not leave foreign key'd data in an invalid state.

This applies to both 9.1 and 9.2.

Please see attached bug.sql.

Attachment Content-Type Size
bug.sql application/octet-stream 836 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2013-07-19 17:13:37 Re: [HACKERS] getting rid of SnapshotNow
Previous Message Alvaro Herrera 2013-07-19 16:51:02 Re: getting rid of SnapshotNow