From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Tighten enforcement of variable CONSTANT markings in plpgsql.
Date: Sat, 30 Apr 2022 15:54:34 +0000
Message-ID: <E1nkpQY-001tCs-6p@gemulon.postgresql.org> (raw)
Tighten enforcement of variable CONSTANT markings in plpgsql.
I noticed that plpgsql would allow assignment of a new value to a
variable even when that variable is marked CONSTANT, if the variable
is used as an output parameter in CALL or is a refcursor variable
that OPEN assigns a new value to. Fix these oversights.
In the CALL case, the check has to be done at runtime because we
cannot know at parse time which parameters are OUT parameters.
For OPEN, it seems best to likewise enforce at runtime because
then we needn't throw error if the variable has a nonnull value
(since OPEN will only try to overwrite a null value).
Although this is surely a bug fix, no back-patch: it seems unlikely
that anyone would thank us for breaking formerly-working code in
minor releases.
Discussion: https://postgr.es/m/214453.1651182729@sss.pgh.pa.us
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/ccd10a9bfa54c1aad3561232bf24222f1b455e1c
Modified Files
--------------
src/pl/plpgsql/src/expected/plpgsql_call.out | 12 ++++++
src/pl/plpgsql/src/pl_exec.c | 63 ++++++++++++++++++++++++++--
src/pl/plpgsql/src/sql/plpgsql_call.sql | 12 ++++++
src/test/regress/expected/plpgsql.out | 27 ++++++++++++
src/test/regress/sql/plpgsql.sql | 24 +++++++++++
5 files changed, 134 insertions(+), 4 deletions(-)
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-committers@postgresql.org
Cc: tgl@sss.pgh.pa.us
Subject: Re: pgsql: Tighten enforcement of variable CONSTANT markings in plpgsql.
In-Reply-To: <E1nkpQY-001tCs-6p@gemulon.postgresql.org>
References: <E1nkpQY-001tCs-6p@gemulon.postgresql.org>
* 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