pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Karl O. Pinc <kop@karlpinc.com>
To: pgsql-general@lists.postgresql.org
Subject: Trigger functions and parallelism
Date: Mon, 2 Oct 2023 11:49:42 -0500
Message-ID: <20231002114942.56a6f656@slate.karlpinc.com> (raw)

Hi,

It's not entirely clear to me what the conditions
are for function parallel safety.  While the documentation
seems pretty clear in most cases, there still some
verbiage that requires knowledge of internals
in order to be useful.

What I'm looking for is some general statements about
parallel safety for trigger functions.  I don't know
enough about parallelism to even know if it applies
to data modification statements.

It seems to me that, because raising any sort of exception
affects transaction state, that triggers which 
validate data integrity and raise errors must be PARALLEL UNSAFE.

But are any sort of AFTER INSERT trigger on a generated sequential key
parallel UNSAFE because they access sequence state via NEW?

Can something generic be said, like: "Most trigger functions should
be declared PARALLEL UNSAFE (the default) with the possible exception
of BEFORE triggers that raise no exceptions and control system
behavior by their return value."?  

What can be said to provide some overview which gives
guidance on parallelism to trigger authors?

Regards,

Karl <kop@karlpinc.com>
Free Software:  "You don't pay back, you pay forward."
                 -- Robert A. Heinlein





view thread (3+ messages)  latest in thread

Message-ID: <20231002114942.56a6f656@slate.karlpinc.com>
Permalink:  ../20231002114942.56a6f656@slate.karlpinc.com/
Also on:    postgresql.org/message-id/20231002114942.56a6f656@slate.karlpinc.com

 · 

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: kop@karlpinc.com
  Subject: Re: Trigger functions and parallelism
  In-Reply-To: <20231002114942.56a6f656@slate.karlpinc.com>
  References: <20231002114942.56a6f656@slate.karlpinc.com>

* 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