From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Marc Millas <marc.millas@mokadb.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: prepare in a do loop
Date: Mon, 15 Feb 2021 10:08:45 -0800
Message-ID: <3d94209d-b100-0f07-e2b0-213d4467e870@aklaver.com> (raw)
In-Reply-To: <CADX_1aZqb8T0heF_ROEiMCn3oM5n8a_up66aZWj8_T7JBV_wYA@mail.gmail.com>
References: <CADX_1aa2ZT2aCZJuG4NLZjgUt-QiBiY+P5nKsBSegyhLAq8-jw@mail.gmail.com>
<2254393.1613406469@sss.pgh.pa.us>
<CADX_1aZqb8T0heF_ROEiMCn3oM5n8a_up66aZWj8_T7JBV_wYA@mail.gmail.com>
On 2/15/21 9:55 AM, Marc Millas wrote:
> Hi Tom,
>
> I do read the doc, and understand the caching behaviour of plpgsql.
This is not about plpgsql caching. It is about EXECUTE in plpgsql
meaning something different then the PREPARE/EXECUTE combination in SQL.
You are trying to run EXECUTE moninsert(randname()) in plpgsql where
moninsert was a PREPARE statement. In plpgsql EXECUTE is something
different so it does not recognize moninsert(randname()) as a prepared
statement and fails.
> if in psql I write begin;execute moninsert(randname()); execute
> moninsert(randname());end;
> it does work. And if I put this (begin execute end) inside a do loop it
> doesnt anymore.
> ok the begin execute end is ""pure"" SQL, and the same thing within a do
> loop is plpgsql
> so
> postgres=# create function testexec()returns void as $$
> postgres$# execute moninsert(randname());
> postgres$# end;
> postgres$# $$ language plpgsql;
> ERREUR: erreur de syntaxe sur ou près de « execute »
> LIGNE 2 : execute moninsert(randname());
> fine, quite coherent.
> then
--
Adrian Klaver
adrian.klaver@aklaver.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: adrian.klaver@aklaver.com, marc.millas@mokadb.com, tgl@sss.pgh.pa.us
Subject: Re: prepare in a do loop
In-Reply-To: <3d94209d-b100-0f07-e2b0-213d4467e870@aklaver.com>
References: <CADX_1aa2ZT2aCZJuG4NLZjgUt-QiBiY+P5nKsBSegyhLAq8-jw@mail.gmail.com> <2254393.1613406469@sss.pgh.pa.us> <CADX_1aZqb8T0heF_ROEiMCn3oM5n8a_up66aZWj8_T7JBV_wYA@mail.gmail.com> <3d94209d-b100-0f07-e2b0-213d4467e870@aklaver.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox