From 8e9173ed662bf024fe5a096a0301bebcc2b5b57c Mon Sep 17 00:00:00 2001 From: Devrim Gunduz Date: Fri, 10 Jul 2026 12:01:45 +0300 Subject: [PATCH] Fix build against PostgreSQL 19 plprofiler.h: * PG19's header include-what-you-use (IWYU) cleanup means , and are no longer pulled in transitively by the headers plprofiler.h already included. Without them, LWLockAcquire/LWLockRelease, RequestAddinShmemSpace/RequestNamedLWLockTranche, ShmemInitStruct/ ShmemInitHash/GetNamedLWLockTranche and tuplestore_begin_heap/ tuplestore_putvalues were all implicitly declared, producing the "call to undeclared function" / "incompatible integer to pointer conversion" errors seen on both clang (LLVM bitcode build) and gcc. Add the three missing includes to plprofiler.h. * profilerSharedState.lock was declared as "LWLockId", a typedef that was removed from PostgreSQL back in 9.4 when LWLocks moved to a pointer-based API. The plprofiler code itself already treats plpss->lock as a pointer (e.g. "plpss->lock = &(GetNamedLWLockTranche(...))->lock;"), so the struct member had been silently relying on an implicit int-to- pointer conversion that recent compilers (and C99+) no longer allow. Change the member to the correct "LWLock *" type. plprofiler.c: * PG19 changed the signature of ShmemInitHash() from HTAB *ShmemInitHash(const char *name, long init_size, long max_size, HASHCTL *infoP, int hash_flags); to HTAB *ShmemInitHash(const char *name, int64 nelems, HASHCTL *infoP, int hash_flags); collapsing the separate init_size/max_size arguments into a single nelems argument. Both call sites in profiler_shmem_startup() (for the "plprofiler functions" and "plprofiler callgraph" shared hash tables) were passing the old 5-argument form, which now fails to compile ("too many arguments to function call" / argument-type mismatches). Drop the redundant init_size argument at both call sites so only one size argument (nelems) is passed. Hacked by Claude, tested by me. --- plprofiler.c | 2 -- plprofiler.h | 5 ++++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/plprofiler.c b/plprofiler.c index 24a39eb..a30f024 100755 --- a/plprofiler.c +++ b/plprofiler.c @@ -681,7 +681,6 @@ profiler_shmem_startup(void) hash_ctl.hash = line_hash_fn; hash_ctl.match = line_match_fn; functions_shared = ShmemInitHash("plprofiler functions", - profiler_max_functions, profiler_max_functions, &hash_ctl, HASH_ELEM | HASH_FUNCTION | HASH_COMPARE); @@ -693,7 +692,6 @@ profiler_shmem_startup(void) hash_ctl.hash = callgraph_hash_fn; hash_ctl.match = callgraph_match_fn; callgraph_shared = ShmemInitHash("plprofiler callgraph", - profiler_max_callgraph, profiler_max_callgraph, &hash_ctl, HASH_ELEM | HASH_FUNCTION | HASH_COMPARE); diff --git a/plprofiler.h b/plprofiler.h index 8158454..8ac4d49 100644 --- a/plprofiler.h +++ b/plprofiler.h @@ -40,6 +40,8 @@ #include "pgstat.h" #include "plpgsql.h" #include "storage/ipc.h" +#include "storage/lwlock.h" +#include "storage/shmem.h" #include "storage/spin.h" #include "utils/array.h" #include "utils/builtins.h" @@ -49,6 +51,7 @@ #include "utils/memutils.h" #include "utils/palloc.h" #include "utils/syscache.h" +#include "utils/tuplestore.h" PG_MODULE_MAGIC; @@ -161,7 +164,7 @@ typedef struct callGraphEntry typedef struct { - LWLockId lock; + LWLock *lock; bool profiler_enabled_global; int profiler_enabled_pid; int profiler_collect_interval;