postgresql/src/include
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
..
access Add EXPLAIN (IO) infrastructure with BitmapHeapScan support 2026-04-07 22:33:34 +02:00
archive Update copyright for 2026 2026-01-01 13:24:10 -05:00
backup Update copyright for 2026 2026-01-01 13:24:10 -05:00
bootstrap Reduce header inclusions via execnodes.h 2026-03-16 14:34:57 +01:00
catalog Reduce presence of syscache.h in src/include/ 2026-04-09 08:49:36 +09:00
commands Add missing initialization 2026-04-16 22:27:04 +02:00
common Add log file support to logging.c 2026-04-13 10:44:02 +02:00
datatype Update copyright for 2026 2026-01-01 13:24:10 -05:00
executor instrumentation: Allocate query level instrumentation in ExecutorStart 2026-04-08 00:06:45 -04:00
fe_utils Harden astreamer tar parsing logic against archives it can't handle. 2026-04-02 12:20:36 -04:00
foreign Add support for importing statistics from remote servers. 2026-04-08 19:15:00 +09:00
jit jit: No backport::SectionMemoryManager for LLVM 22. 2026-04-03 14:55:11 +13:00
lib Use standard C23 and C++ attributes if available 2026-04-01 08:15:02 +02:00
libpq Remove RADIUS support. 2026-04-08 22:38:43 +12:00
mb Remove MULE_INTERNAL encoding. 2026-04-08 17:40:06 +12:00
nodes Add EXPLAIN (IO) instrumentation for TidRangeScan 2026-04-07 23:25:05 +02:00
optimizer Fix var_is_nonnullable() to handle invalid NOT NULL constraints 2026-04-15 09:38:56 +09:00
parser Mark JumbleState as a const in the post_parse_analyze hook 2026-04-07 15:22:49 +09:00
partitioning Update copyright for 2026 2026-01-01 13:24:10 -05:00
pch Update copyright for 2026 2026-01-01 13:24:10 -05:00
port Allow retrieving x86 TSC frequency/flags from CPUID 2026-04-07 13:00:24 -04:00
portability Add missing PGDLLIMPORT markings 2026-04-08 15:49:33 +02:00
postmaster Convert all remaining subsystems to use the new shmem allocation API 2026-04-06 02:13:10 +03:00
regex Update copyright for 2026 2026-01-01 13:24:10 -05:00
replication Adjust log level of logical decoding messages by context 2026-04-10 22:59:34 +09:00
rewrite Add some const qualifiers enabled by typeof_unqual change on copyObject 2026-03-19 06:35:54 +01:00
snowball Update to latest Snowball sources. 2026-01-05 15:22:37 -05:00
statistics Add support for importing statistics from remote servers. 2026-04-08 19:15:00 +09:00
storage aio: Adjust I/O worker pool automatically. 2026-04-08 19:08:32 +12:00
tcop SQL Property Graph Queries (SQL/PGQ) 2026-03-16 10:14:18 +01:00
tsearch Replace pg_mblen() with bounds-checked versions. 2026-02-09 12:44:04 +13:00
utils Fix var_is_nonnullable() to handle invalid NOT NULL constraints 2026-04-15 09:38:56 +09:00
.gitignore Use <stdint.h> and <inttypes.h> for c.h integers. 2024-12-04 15:05:38 +13:00
c.h Rework signal handler infrastructure to pass sender info as argument. 2026-04-15 07:30:34 -04:00
fmgr.h Improve type handling of varlena structures 2026-02-11 07:33:24 +09:00
funcapi.h Remove bits* typedefs. 2026-03-30 16:12:08 -05:00
getopt_long.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
Makefile Fix build inconsistency due to the generation of wait-event code 2026-02-02 08:02:39 +09:00
meson.build Ensure that all three build methods install the same set of files. 2026-02-16 15:20:15 -05:00
miscadmin.h Add missing PGDLLIMPORT markings 2026-04-08 15:49:33 +02:00
pg_config.h.in Add errdetail() with PID and UID about source of termination signal. 2026-04-07 10:22:33 -04:00
pg_config_manual.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
pg_getopt.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
pg_trace.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
pgstat.h Fix double-free in pg_stat_autovacuum_scores. 2026-04-09 13:07:06 -05:00
pgtar.h Harden astreamer tar parsing logic against archives it can't handle. 2026-04-02 12:20:36 -04:00
pgtime.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
port.h Rework signal handler infrastructure to pass sender info as argument. 2026-04-15 07:30:34 -04:00
postgres.h Change PointerGetDatum() back to a macro 2026-04-17 22:14:40 +03:00
postgres_ext.h Move pg_int64 back to postgres_ext.h 2025-09-16 10:48:56 +02:00
postgres_fe.h Update copyright for 2026 2026-01-01 13:24:10 -05:00
varatt.h Improve type handling of varlena structures 2026-02-11 07:33:24 +09:00
windowapi.h Update copyright for 2026 2026-01-01 13:24:10 -05:00