postgresql/src
Tom Lane a1168855e0 Fix NULLIF()'s handling of read-write expanded objects.
If passed a read-write expanded object pointer, the EEOP_NULLIF
code would hand that same pointer to the equality function
and then (unless equality was reported) also return the same
pointer as its value.  This is no good, because a function that
receives a read-write expanded object pointer is fully entitled
to scribble on or even delete the object, thus corrupting the
NULLIF output.  (This problem is likely unobservable with the
equality functions provided in core Postgres, but it's easy to
demonstrate with one coded in plpgsql.)

To fix, make sure the pointer passed to the equality function
is read-only.  We can still return the original read-write
pointer as the NULLIF result, allowing optimization of later
operations.

Per bug #18722 from Alexander Lakhin.  This has been wrong
since we invented expanded objects, so back-patch to all
supported branches.

Discussion: https://postgr.es/m/18722-fd9e645448cc78b4@postgresql.org
2024-11-25 18:09:10 -05:00
..
backend Fix NULLIF()'s handling of read-write expanded objects. 2024-11-25 18:09:10 -05:00
bin Fix newly introduced 010_keep_recycled_wals.pl 2024-11-21 17:06:48 +01:00
common Replace pgwin32_is_junction() with lstat(). 2024-11-08 09:36:53 +10:30
fe_utils Don't spuriously report FD_SETSIZE exhaustion on Windows. 2023-10-14 15:54:49 -07:00
include Fix NULLIF()'s handling of read-write expanded objects. 2024-11-25 18:09:10 -05:00
interfaces Translation updates 2024-11-11 13:57:37 +01:00
makefiles Add NO_INSTALL option to pgxs 2021-05-27 13:58:29 +02:00
pl Add support for Tcl 9 2024-11-25 13:11:18 +01:00
port Replace pgwin32_is_junction() with lstat(). 2024-11-08 09:36:53 +10:30
template On NetBSD, force dynamic symbol resolution at postmaster start. 2022-08-30 17:29:03 -04:00
test Fix NULLIF()'s handling of read-write expanded objects. 2024-11-25 18:09:10 -05:00
timezone Update time zone data files to tzdata release 2024b. 2024-10-29 11:50:05 -04:00
tools Assume that <stdbool.h> conforms to the C standard. 2024-11-25 20:53:41 +13:00
tutorial Doc: sync src/tutorial/basics.source with SGML documentation. 2022-11-19 13:09:14 -05:00
.gitignore
DEVELOPERS
Makefile Remove the option to build thread_test.c outside configure. 2020-10-21 12:08:48 -04:00
Makefile.global.in Suppress macOS warnings about duplicate libraries in link commands. 2023-09-29 14:07:30 -04:00
Makefile.shlib Stop using "-multiply_defined suppress" on macOS. 2023-09-26 21:06:21 -04:00
nls-global.mk Add errhint_plural() function and make use of it 2021-03-31 09:16:25 +02:00