From 57de7451676506f79a99681338efcb0a1f956c3c Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Wed, 9 Apr 2025 16:08:21 +0200 Subject: [PATCH v1 1/2] Avoid symbol clashes of dynahash with OS The dynahash routines were originally modeled after routines in some BSD operating systems. They continue to exist at least in macOS (see strhash.h), but they are incompatible, and depending on link order or symbol lookup order, a dynamically-loaded module might end up calling the one in the OS and crash. To avoid that, we rename the symbols known to clash, so that we can continue to use the existing API names. Discussion: https://www.postgresql.org/message-id/170e7e57-fe43-4e7e-8566-a96fcdf23075%40eisentraut.org --- src/include/utils/hsearch.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/include/utils/hsearch.h b/src/include/utils/hsearch.h index 932cc4f34d9..4d742301ebd 100644 --- a/src/include/utils/hsearch.h +++ b/src/include/utils/hsearch.h @@ -126,6 +126,21 @@ typedef struct uint32 hashvalue; /* hashvalue to start seqscan over hash */ } HASH_SEQ_STATUS; +/* + * Redefine symbols to avoid clashes with OS. + * + * These routines were originally modeled after routines in some BSD operating + * systems. They continue to exist at least in macOS (see strhash.h), but + * they are incompatible, and depending on link order or symbol lookup order, + * a dynamically-loaded module might end up calling the one in the OS and + * crash. To avoid that, we rename the symbols known to clash, so that we can + * continue to use the existing API names. + */ +#define hash_create pg_hash_create +#define hash_destroy pg_hash_destroy +#define hash_search pg_hash_search +#define hash_stats pg_hash_stats + /* * prototypes for functions in dynahash.c */ -- 2.49.0