Whan is it safe to mark a function PARALLEL SAFE?

From: Jim Finnerty <jfinnert(at)amazon(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Whan is it safe to mark a function PARALLEL SAFE?
Date: 2019-09-08 01:37:32
Message-ID: 1567906652523-0.post@n3.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Chris Travers 2019-09-08 10:01:10 Re: kind of a bag of attributes in a DB . . .
Previous Message Adrian Klaver 2019-09-07 22:40:22 Re: How to access Postgres .pgpass file from php?