pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dirk Lattermann <dlatt@alqualonde.de>
To: pgsql-general@lists.postgresql.org
Subject: Re: Trigger transaction isolation
Date: Thu, 3 Sep 2020 08:20:27 +0200
Message-ID: <20200903082027.50efd235@walter> (raw)
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>

Thank you, Tom, for this valuable information.

On Tue, 01 Sep 2020 11:02:01 -0400
1Tom Lane <tgl@sss.pgh.pa.us> wrote:

> 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

I suppose by writing serializable, you include repeatable read here,
too?

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

This is the needed behaviour for the validations I intend to do, then.

> 
> 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.

So this case seems to be trickier than it looks at a first glance.
It depends heavily on the use case, of course, in how far the snapshot
time influences the correctness of a trigger written in this mode.

I suggest adding this to the documentation and will try to use the
commenting function there for it.

Thanks!
Dirk





view thread (4+ messages)

Message-ID: <20200903082027.50efd235@walter>
Permalink:  ../20200903082027.50efd235@walter/
Also on:    postgresql.org/message-id/20200903082027.50efd235@walter

 · 

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: dlatt@alqualonde.de
  Subject: Re: Trigger transaction isolation
  In-Reply-To: <20200903082027.50efd235@walter>
  References: <20200825111235.2c7193f0@walter> <20200901160706.169adf76@walter> <fbdb4b5b-3616-7426-34c4-982e101186c0@aklaver.com> <54137.1598972521@sss.pgh.pa.us> <20200903082027.50efd235@walter>

* 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