postgresql/src/backend
Tom Lane 309857f9c1 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
2022-08-10 13:37:25 -04:00
..
access Fix obsolete comment in commit_ts.c. 2022-08-09 12:58:04 +12:00
bootstrap Process session_preload_libraries within InitPostgres's transaction. 2022-07-25 10:27:43 -04:00
catalog In extensions, don't replace objects not belonging to the extension. 2022-08-08 11:12:31 -04:00
commands In extensions, don't replace objects not belonging to the extension. 2022-08-08 11:12:31 -04:00
executor Fix handling of R/W expanded datums that are passed to SQL functions. 2022-08-10 13:37:25 -04:00
foreign Create routine able to set single-call SRFs for Materialize mode 2022-03-07 10:26:29 +09:00
jit Improve performance of ORDER BY / DISTINCT aggregates 2022-08-02 23:11:45 +12:00
lib Fix lock assertions in dshash.c. 2022-07-11 16:43:29 +12:00
libpq Make consistent a couple of log messages when parsing HBA files 2022-08-05 09:50:27 +09:00
main windows: Remove HAVE_MINIDUMP_TYPE test 2022-08-07 09:36:01 -07:00
nodes Fix MSVC build script's check for obsolete node support functions. 2022-08-08 14:43:35 -04:00
optimizer Fix failure to set correct operator in window run condition 2022-08-05 10:14:00 +12:00
parser In extensions, don't replace objects not belonging to the extension. 2022-08-08 11:12:31 -04:00
partitioning Have ExecFindPartition cache the last found partition 2022-08-02 09:55:27 +12:00
po NLS: Put list of available languages into LINGUAS files 2022-07-13 08:19:17 +02:00
port windows: Remove HAVE_MINIDUMP_TYPE test 2022-08-07 09:36:01 -07:00
postmaster Use hba_file/ident_file GUCs rather than pg_hba.conf/pg_ident.conf in logs 2022-08-05 09:37:12 +09:00
regex Remove redundant null pointer checks before free() 2022-07-03 11:47:15 +02:00
replication Replace pgwin32_is_junction() with lstat(). 2022-08-06 12:50:59 +12:00
rewrite Replace many MemSet calls with struct initialization 2022-07-16 08:50:49 +02:00
snowball Move snowball_create.sql creation into perl file 2022-07-18 12:24:27 -07:00
statistics Partially undo commit 94da73281. 2022-08-05 15:57:46 -04:00
storage Rely on __func__ being supported 2022-08-07 09:36:01 -07:00
tcop Remove configure probe and related tests for getrlimit. 2022-08-05 09:18:34 +12:00
tsearch Invent qsort_interruptible(). 2022-07-12 16:30:36 -04:00
utils Fix some inconsistencies with GUC categories 2022-08-09 20:01:44 +09:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
Makefile aix: fix misreading of condition in 8f12a4e7ad 2022-08-07 11:34:42 -07:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
nls.mk NLS: Put list of available languages into LINGUAS files 2022-07-13 08:19:17 +02:00