pgsql: Tighten enforcement of variable CONSTANT markings in plpgsql.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Tighten enforcement of variable CONSTANT markings in plpgsql.
Date: 2022-04-30 15:54:34
Message-ID: E1nkpQY-001tCs-6p@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Jeff Davis 2022-04-30 16:21:33 pgsql: pg_walinspect: fix case where flush LSN is in the middle of a re
Previous Message Andrew Dunstan 2022-04-29 13:07:40 pgsql: Claim SQL standard compliance for SQL/JSON features