I want to mark some functions as parallel safe, but I think it’s difficult to understand 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.
Similarly, functions must be marked PARALLEL RESTRICTED if they access temporary tables, client connection state, cursors, prepared statements,
or miscellaneous backend-local state which the system cannot synchronize across workers.
For example, setseed and random are parallel restricted for this last reason."
For instance, is the following plpython3u function parallel safe?
create or replace function f1(key text, val_default in text default null) returns text as $$
$$ language plpython3u;
=> Is the Python GD dictionary a "miscellaneous backend-local state" ?
Same question for a function that raises an exception with the keyword "raise":
create or replace function ...
$$ language plpgsql;
=> Is it a transaction state change?
Same question for a function that performs an "execute into":
create or replace function f2(d date, n numeric) returns date as $$
execute format('select (''%s''::date + interval ''%s'')::date',d,concat(n,' day')) into ret;
$$ language plpgsql;
=> Is this execute statement be considered as a cursor?
Moody's monitors email communications through its networks for regulatory compliance purposes and to protect its customers, employees and business and where allowed to do so by applicable law. The information contained in this e-mail message, and any attachment thereto, is confidential and may not be disclosed without our express permission. If you are not the intended recipient or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that you have received this message in error and that any review, dissemination, distribution or copying of this message, or any attachment thereto, in whole or in part, is strictly prohibited. If you have received this message in error, please immediately notify us by telephone, fax or e-mail and delete the message and all of its attachments. Every effort is made to keep our network free from viruses. You should, however, review this e-mail message, as well as any attachment thereto, for viruses. We take no responsibility and have no liability for any computer virus which may be transferred via this e-mail message.
This email was sent to you by Moody’s Investors Service EMEA Limited Registered office address: One Canada Square Canary Wharf London, E14 5FA Registered in England and Wales No: 8922701