pgsql: Fix handling of R/W expanded datums that are passed to SQL funct

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Fix handling of R/W expanded datums that are passed to SQL funct
Дата
Msg-id E1oLpeM-0009f2-NH@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
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-qhuEiZoXJ82jpiQU4hOjOcrevYEDeoAvz6nR0IU4IHhXnaCA=@mackler.email
Discussion: https://postgr.es/m/187436.1660143060@sss.pgh.pa.us

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/1446612c5b25d74739dc1e3337edfba8fec9516d

Modified Files
--------------
src/backend/executor/functions.c                | 19 +++++++++++++++++--
src/test/regress/expected/create_function_3.out | 21 +++++++++++++++++++--
src/test/regress/sql/create_function_3.sql      | 14 +++++++++++++-
3 files changed, 49 insertions(+), 5 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Fix handling of R/W expanded datums that are passed to SQL funct
Следующее
От: Robert Haas
Дата:
Сообщение: pgsql: Move basebackup code to new directory src/backend/backup