postgresql/src
Heikki Linnakangas d65995cbc6 Change PointerGetDatum() back to a macro
The argument was marked as "const void *X", but that might rightly
give the compiler the idea that *X cannot be modified through the
resulting Datum, and make incorrect optimizations based on that. Some
functions use pointer Datums to pass output arguments, like GIN
support functions. Coverity started to complain after commit
6f5ad00ab7 that there's dead code in ginExtractEntries(), because it
didn't see that it passes PointerGetDatum(&nentries) to a function
that sets it.

This issue goes back to commit c8b2ef05f4 (version 16), which
changed PointerGetDatum() from a macro to a static inline function.
This commit changes it back to a macro, but uses a trick with a dummy
conditional expression to still produce a compiler error if you try to
pass a non-pointer as the argument.

Even though this goes back to v16, I'm only committing this to
'master' for now, to verify that this silences the Coverity warning.
If this works, we might want to introduce separate const and non-const
versions of PointerGetDatum() instead of this, but that's a bigger
patch.  It's also not decided yet whether to back-patch this (or some
other fix), given that we haven't yet seen any hard evidence of
compilers actually producing buggy code because of this.

Discussion: https://www.postgresql.org/message-id/342012.1776017102@sss.pgh.pa.us
2026-04-17 22:14:40 +03:00
..
backend Reject invalid databases in pg_get_database_ddl() 2026-04-17 13:19:56 +09:00
bin psql: Fix incorrect tab completion after CREATE PUBLICATION ... EXCEPT (...) 2026-04-17 14:31:05 +09:00
common Fix comments for Korean encodings in encnames.c 2026-04-16 18:17:05 +12:00
fe_utils Rework signal handler infrastructure to pass sender info as argument. 2026-04-15 07:30:34 -04:00
include Change PointerGetDatum() back to a macro 2026-04-17 22:14:40 +03:00
interfaces Rework signal handler infrastructure to pass sender info as argument. 2026-04-15 07:30:34 -04:00
makefiles Add CONCURRENTLY option to REPACK 2026-04-06 21:55:08 +02:00
pl Remove MULE_INTERNAL encoding. 2026-04-08 17:40:06 +12:00
port Rework signal handler infrastructure to pass sender info as argument. 2026-04-15 07:30:34 -04:00
template Switch the semaphore API on Solaris to unnamed POSIX. 2026-03-14 14:10:32 -04:00
test Fix COPY TO FORMAT JSON to exclude generated columns. 2026-04-15 07:58:17 -04:00
timezone Use fallthrough attribute instead of comment 2026-02-19 08:51:12 +01:00
tools Rework signal handler infrastructure to pass sender info as argument. 2026-04-15 07:30:34 -04:00
tutorial Force standard_conforming_strings to always be ON. 2026-01-21 15:08:38 -05:00
.gitignore
DEVELOPERS
Makefile Add CONCURRENTLY option to REPACK 2026-04-06 21:55:08 +02:00
Makefile.global.in Update Unicode data to CLDR 48.2 2026-04-13 11:13:36 +02:00
Makefile.shlib Restore AIX support. 2026-02-23 13:34:22 -05:00
meson.build Update copyright for 2026 2026-01-01 13:24:10 -05:00
nls-global.mk Fix update-po for the PGXS case 2025-10-16 20:21:05 +02:00