Re: parallel safe on user defined functions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Voillequin, Jean-Marc" <Jean-Marc(dot)Voillequin(at)moodys(dot)com>
Cc: "pgsql-sql(at)lists(dot)postgresql(dot)org" <pgsql-sql(at)lists(dot)postgresql(dot)org>
Subject: Re: parallel safe on user defined functions
Date: 2020-12-02 16:15:35
Message-ID: 1574257.1606925735@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"Voillequin, Jean-Marc" <Jean-Marc(dot)Voillequin(at)moodys(dot)com> writes:
> 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 $$
> return GD.get(key.lower(),val_default)
> $$ language plpython3u;

No. There's no mechanism for sharing Python interpreter state across
processes.

> => Is it a transaction state change?

Throwing an error is always OK (we could hardly decree otherwise).

> execute format('select (''%s''::date + interval ''%s'')::date',d,concat(n,' day')) into ret;

> => Is this execute statement be considered as a cursor?

No, it's just a weird way of spelling a variable assignment.

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Yambu 2020-12-03 03:47:21 calling function
Previous Message Voillequin, Jean-Marc 2020-12-02 15:25:37 parallel safe on user defined functions