postgresql/src/backend
Tom Lane 95bfadd4e8 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 BRIN: mask BRIN_EVACUATE_PAGE for WAL consistency checking 2022-08-05 18:00:17 +02:00
bootstrap Rethink definition of pg_attribute.attcompression. 2021-05-27 13:24:27 -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 Update copyright for 2021 2021-01-02 13:06:25 -05:00
jit Back-patch LLVM 14 API changes. 2022-03-16 11:42:00 +13:00
lib Fix lock assertions in dshash.c. 2022-07-11 15:47:12 +12:00
libpq Remove misguided SSL key file ownership check in libpq. 2022-05-26 14:14:05 -04:00
main Update copyright for 2021 2021-01-02 13:06:25 -05:00
nodes Fix ENABLE/DISABLE TRIGGER to handle recursion correctly 2022-08-05 09:47:11 +02:00
optimizer Fix incorrect tests for SRFs in relation_can_be_sorted_early(). 2022-08-03 17:33:42 -04:00
parser In extensions, don't replace objects not belonging to the extension. 2022-08-08 11:12:31 -04:00
partitioning Avoid using ambiguous word "non-negative" in error messages. 2021-07-28 01:21:35 +09:00
po Translation updates 2022-08-08 12:39:52 +02:00
port Reject huge_pages=on if shared_memory_type=sysv. 2021-10-26 13:09:00 +13:00
postmaster Wake up for latches in CheckpointWriteDelay(). 2022-03-16 13:57:07 +13:00
regex Make pg_regexec() robust against out-of-range search_start. 2021-09-11 15:19:43 -04:00
replication Prevent BASE_BACKUP in the middle of another backup in the same session. 2022-07-20 09:52:11 +09:00
rewrite Fix incautious CTE matching in rewriteSearchAndCycle(). 2022-04-23 12:16:12 -04:00
snowball Update snowball 2021-02-19 08:10:15 +01:00
statistics Partially undo commit 94da73281. 2022-08-05 15:57:46 -04:00
storage Add HINT for restartpoint race with KeepFileRestoredFromArchive(). 2022-08-05 08:30:58 -07:00
tcop Force immediate commit after CREATE DATABASE etc in extended protocol. 2022-07-26 13:07:03 -04:00
tsearch Invent qsort_interruptible(). 2022-07-12 16:30:36 -04:00
utils Fix trim_array() for zero-dimensional array argument. 2022-07-31 13:43:17 -04:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
Makefile Use sort_template.h for qsort_tuple() and qsort_ssup(). 2021-03-03 17:02:32 +13:00
nls.mk Translation updates 2021-09-20 16:23:13 +02:00