Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kkUnA-0001Nv-9v for pgsql-sql@arkaria.postgresql.org; Wed, 02 Dec 2020 16:15:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kkUn9-0002MV-7f for pgsql-sql@arkaria.postgresql.org; Wed, 02 Dec 2020 16:15:43 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kkUn9-0002MO-1M for pgsql-sql@lists.postgresql.org; Wed, 02 Dec 2020 16:15:43 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kkUn2-0002g6-O0 for pgsql-sql@lists.postgresql.org; Wed, 02 Dec 2020 16:15:42 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 0B2GFZVR1574258; Wed, 2 Dec 2020 11:15:35 -0500 From: Tom Lane To: "Voillequin, Jean-Marc" cc: "pgsql-sql@lists.postgresql.org" Subject: Re: parallel safe on user defined functions In-reply-to: References: Comments: In-reply-to "Voillequin, Jean-Marc" message dated "Wed, 02 Dec 2020 15:25:37 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1574256.1606925735.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2020 11:15:35 -0500 Message-ID: <1574257.1606925735@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk "Voillequin, Jean-Marc" 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. > =3D> 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; > =3D> Is this execute statement be considered as a cursor? No, it's just a weird way of spelling a variable assignment. regards, tom lane