pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jim Finnerty <jfinnert@amazon.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BEFORE triggers that return NULL can circumvent referential integrity
Date: Tue, 30 Oct 2018 16:38:26 -0400
Message-ID: <17500.1540931906@sss.pgh.pa.us> (raw)
In-Reply-To: <1540931408693-0.post@n3.nabble.com>
References: <1540931408693-0.post@n3.nabble.com>

Jim Finnerty <jfinnert@amazon.com> writes:
> The non compliance issue reported previously (concerning the potential
> firing of user-defined AFTER triggers prior to firing immediate-mode foreign
> key constraint triggers) still guaranteed that the database would be left in
> a consistent state at the end of each statement. Even though you could run
> some SQL inside of a trigger that had access to inconsistent state, if that
> state was inconsistent at the end of the statement the statement would still
> fail; however, exploiting a PostgreSQL feature of BEFORE triggers allows
> users to run SQL statements that do not fail or rollback, and that can
> commit the database in a state that is inconsistent with the foreign key
> constraints.

Yes.  This is known, and documented, and we don't really intend to change
it.

> This is clearly not the
> intended behavior according to the PostgreSQL documentation

What documentation?  If there's a contrary promise somewhere, we need
to fix that.  The CREATE TRIGGER page is pretty clear about it though:

    There is also nonstandard behavior if BEFORE triggers modify rows or
    prevent updates during an update that is caused by a referential
    action. This can lead to constraint violations or stored data that
    does not honor the referential constraint.

			regards, tom lane




view thread (5+ messages)  latest in thread

Message-ID: <17500.1540931906@sss.pgh.pa.us>
Permalink:  ../17500.1540931906@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/17500.1540931906@sss.pgh.pa.us

 · 

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-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, jfinnert@amazon.com
  Subject: Re: BEFORE triggers that return NULL can circumvent referential integrity
  In-Reply-To: <17500.1540931906@sss.pgh.pa.us>
  References: <1540931408693-0.post@n3.nabble.com> <17500.1540931906@sss.pgh.pa.us>

* 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