pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: Dirk Lattermann <dlatt@alqualonde.de>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Trigger transaction isolation
Date: Tue, 01 Sep 2020 11:02:01 -0400
Message-ID: <54137.1598972521@sss.pgh.pa.us> (raw)
In-Reply-To: <fbdb4b5b-3616-7426-34c4-982e101186c0@aklaver.com>
References: <20200825111235.2c7193f0@walter>
	<20200901160706.169adf76@walter>
	<fbdb4b5b-3616-7426-34c4-982e101186c0@aklaver.com>

Adrian Klaver <adrian.klaver@aklaver.com> writes:
> As I understand it a trigger function runs in its own transaction so the 
> rules from below apply:
> https://www.postgresql.org/docs/12/transaction-iso.html

No, a trigger is part of the calling transaction.  There's nothing special
about it other than the condition causing the call; visibility rules are
the same as for any other function.  So the answer to the OP's question
depends on the transaction's isolation level and (for typical
PLs) on whether the function is VOLATILE or not.

serializable -> the transaction's initial snapshot is used throughout

non serializable, volatile function -> each statement in the function
takes a fresh snapshot

non serializable, non-volatile function -> the function uses a single
snapshot.  For a non-deferred trigger, I think it shares the snapshot
used by the triggering query.  Not sure about exactly when the snapshot
is taken for a deferred trigger.

			regards, tom lane





view thread (4+ messages)  latest in thread

Message-ID: <54137.1598972521@sss.pgh.pa.us>
Permalink:  ../54137.1598972521@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/54137.1598972521@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-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, adrian.klaver@aklaver.com, dlatt@alqualonde.de
  Subject: Re: Trigger transaction isolation
  In-Reply-To: <54137.1598972521@sss.pgh.pa.us>
  References: <20200825111235.2c7193f0@walter> <20200901160706.169adf76@walter> <fbdb4b5b-3616-7426-34c4-982e101186c0@aklaver.com> <54137.1598972521@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