Whan is it safe to mark a function PARALLEL SAFE? - Mailing list pgsql-general

From Jim Finnerty
Subject Whan is it safe to mark a function PARALLEL SAFE?
Date
Msg-id 1567906652523-0.post@n3.nabble.com
Whole thread Raw
Responses Re: Whan is it safe to mark a function PARALLEL SAFE?
List 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



pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: How to access Postgres .pgpass file from php?
Next
From: Chris Travers
Date:
Subject: Re: kind of a bag of attributes in a DB . . .