pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jim Finnerty <jfinnert@amazon.com>
To: pgsql-general@postgresql.org
Subject: Whan is it safe to mark a function PARALLEL SAFE?
Date: Sat, 7 Sep 2019 18:37:32 -0700 (MST)
Message-ID: <1567906652523-0.post@n3.nabble.com> (raw)

According to the documentation:

"Functions and aggregates must be marked PARALLEL UNSAFE if they write to
the database, access sequences, change the transaction state even
temporarily (e.g. a PL/pgSQL function which establishes an EXCEPTION block
to catch errors), or make persistent changes to settings."

If a LANGUAGE C function calls ereport(ERROR, ...), does that qualify as a
potential change to the transaction state that requires it to be marked
PARALLEL UNSAFE?  If an error is raised in one parallel worker, does this
cause the other parallel workers to be immediately terminated?

How about a C function f(x) that calls out to an external system and returns
a text value.  If f(x) is altered on the external system, it might return a
slightly different answer for some x.  Let's say that for some x it returns
"one" instead of "1", and we happen to know that users don't care if it
returns "one" or "1".  If someone were to declare f(x) to be PARALLEL SAFE,
what's the worst that could happen?



-----
Jim Finnerty, AWS, Amazon Aurora PostgreSQL
--
Sent from: https://www.postgresql-archive.org/PostgreSQL-general-f1843780.html





view thread (4+ messages)  latest in thread

Message-ID: <1567906652523-0.post@n3.nabble.com>
Permalink:  ../1567906652523-0.post@n3.nabble.com/
Also on:    postgresql.org/message-id/1567906652523-0.post@n3.nabble.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: jfinnert@amazon.com
  Subject: Re: Whan is it safe to mark a function PARALLEL SAFE?
  In-Reply-To: <1567906652523-0.post@n3.nabble.com>
  References: <1567906652523-0.post@n3.nabble.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