From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix handling of R/W expanded datums that are passed to SQL funct
Date: Wed, 10 Aug 2022 17:37:47 +0000
Message-ID: <E1oLpeM-0009et-Lm@gemulon.postgresql.org> (raw)
Fix handling of R/W expanded datums that are passed to SQL functions.
fmgr_sql must make expanded-datum arguments read-only, because
it's possible that the function body will pass the argument to
more than one callee function. If one of those functions takes
the datum's R/W property as license to scribble on it, then later
callees will see an unexpected value, leading to wrong answers.
From a performance standpoint, it'd be nice to skip this in the
common case that the argument value is passed to only one callee.
However, detecting that seems fairly hard, and certainly not
something that I care to attempt in a back-patched bug fix.
Per report from Adam Mackler. This has been broken since we
invented expanded datums, so back-patch to all supported branches.
Discussion: https://postgr.es/m/WScDU5qfoZ7PB2gXwNqwGGgDPmWzz08VdydcPFLhOwUKZcdWbblbo-0Lku-qhuEiZoXJ82jpiQU4hOjO...
Discussion: https://postgr.es/m/187436.1660143060@sss.pgh.pa.us
Branch
------
REL_13_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/71caf3c4da1c85a2ec7cfce914f1ccb723c8e991
Modified Files
--------------
src/backend/executor/functions.c | 19 +++++++++++++++++--
src/test/regress/expected/create_function_3.out | 19 ++++++++++++++++++-
src/test/regress/sql/create_function_3.sql | 13 +++++++++++++
3 files changed, 48 insertions(+), 3 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: Fix handling of R/W expanded datums that are passed to SQL funct
In-Reply-To: <E1oLpeM-0009et-Lm@gemulon.postgresql.org>
References: <E1oLpeM-0009et-Lm@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