Re: postgres_fdw: batch inserts vs. before row triggers - Mailing list pgsql-hackers

From Tom Lane
Subject Re: postgres_fdw: batch inserts vs. before row triggers
Date
Msg-id 3245064.1659563877@sss.pgh.pa.us
Whole thread Raw
In response to Re: postgres_fdw: batch inserts vs. before row triggers  (Matthias van de Meent <boekewurm+postgres@gmail.com>)
Responses Re: postgres_fdw: batch inserts vs. before row triggers
List pgsql-hackers
Matthias van de Meent <boekewurm+postgres@gmail.com> writes:
> I don't have a current version of the SQL spec, but one preliminary
> version of SQL:2012 I retrieved via the wiki details that all BEFORE
> triggers on INSERT/UPDATE/DELETE statements are all executed before
> _any_ of that statements' affected data is modified.
> ...
> I don't know about the semantics of triggers in the latest SQL
> standard versions, but based on that sample it seems like we're
> non-compliant on BEFORE trigger behaviour, and it doesn't seem like
> it's documented in the trigger documentation.

I think we're compliant if you declare the trigger functions as
stable (or immutable, but in any case where this matters, I think
you'd be lying).  They'll then run with the snapshot of the calling
query, in which those updates are not yet visible.

This is documented somewhere, but maybe not anywhere near triggers.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Matthias van de Meent
Date:
Subject: Re: postgres_fdw: batch inserts vs. before row triggers
Next
From: Andres Freund
Date:
Subject: Re: Unstable tests for recovery conflict handling