pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Trigger functions and parallelism
3+ messages / 2 participants
[nested] [flat]

* Trigger functions and parallelism
@ 2023-10-02 16:49 Karl O. Pinc <kop@karlpinc.com>
  2023-10-02 17:07 ` Re: Trigger functions and parallelism Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 3+ messages in thread

From: Karl O. Pinc @ 2023-10-02 16:49 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

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





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Trigger functions and parallelism
  2023-10-02 16:49 Trigger functions and parallelism Karl O. Pinc <kop@karlpinc.com>
@ 2023-10-02 17:07 ` Tom Lane <tgl@sss.pgh.pa.us>
  2023-10-02 19:23   ` Re: Trigger functions and parallelism Karl O. Pinc <kop@karlpinc.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Tom Lane @ 2023-10-02 17:07 UTC (permalink / raw)
  To: Karl O. Pinc <kop@karlpinc.com>; +Cc: pgsql-general@lists.postgresql.org

"Karl O. Pinc" <kop@karlpinc.com> writes:
> 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 doesn't, which is why the docs are silent on the point.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Trigger functions and parallelism
  2023-10-02 16:49 Trigger functions and parallelism Karl O. Pinc <kop@karlpinc.com>
  2023-10-02 17:07 ` Re: Trigger functions and parallelism Tom Lane <tgl@sss.pgh.pa.us>
@ 2023-10-02 19:23   ` Karl O. Pinc <kop@karlpinc.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Karl O. Pinc @ 2023-10-02 19:23 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-general@lists.postgresql.org

On Mon, 02 Oct 2023 13:07:19 -0400
Tom Lane <tgl@sss.pgh.pa.us> wrote:

> "Karl O. Pinc" <kop@karlpinc.com> writes:
> > 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 doesn't, which is why the docs are silent on the point.

Thanks.

Regards,

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





^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2023-10-02 19:23 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-10-02 16:49 Trigger functions and parallelism Karl O. Pinc <kop@karlpinc.com>
2023-10-02 17:07 ` Tom Lane <tgl@sss.pgh.pa.us>
2023-10-02 19:23   ` Karl O. Pinc <kop@karlpinc.com>

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