From 22212ba7406b043653d478c00385bd376f47d4b3 Mon Sep 17 00:00:00 2001 From: "Anton A. Melnikov" Date: Wed, 8 Nov 2023 15:48:04 +0300 Subject: [PATCH] PostgreSQL 17 support. Caused by: - 4800a5dfb4c46d22b5d05f16c615bea6ff24a2bb (PostgreSQL) Refactor InitPostgres() to use bitwise option flags --- collector.c | 2 +- compat.h | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/collector.c b/collector.c index dcb9695..7f5a914 100644 --- a/collector.c +++ b/collector.c @@ -351,7 +351,7 @@ pgws_collector_main(Datum main_arg) pqsignal(SIGTERM, handle_sigterm); pqsignal(SIGUSR1, procsignal_sigusr1_handler); BackgroundWorkerUnblockSignals(); - InitPostgresCompat(NULL, InvalidOid, NULL, InvalidOid, false, false, NULL); + InitPostgresCompat(NULL, InvalidOid, NULL, InvalidOid, 0, NULL); SetProcessingMode(NormalProcessing); /* Make pg_wait_sampling recognisable in pg_stat_activity */ diff --git a/compat.h b/compat.h index 5fcc814..a425c2a 100644 --- a/compat.h +++ b/compat.h @@ -48,22 +48,26 @@ shm_mq_send_compat(shm_mq_handle *mqh, Size nbytes, const void *data, #endif } +#if PG_VERSION_NUM < 170000 +#define INIT_PG_LOAD_SESSION_LIBS 0x0001 +#define INIT_PG_OVERRIDE_ALLOW_CONNS 0x0002 +#endif + static inline void InitPostgresCompat(const char *in_dbname, Oid dboid, const char *username, Oid useroid, - bool load_session_libraries, - bool override_allow_connections, + bits32 flags, char *out_dbname) { #if PG_VERSION_NUM >= 170000 - InitPostgres(in_dbname, dboid, username, useroid, (load_session_libraries ? INIT_PG_LOAD_SESSION_LIBS : 0) | - (override_allow_connections ? INIT_PG_OVERRIDE_ALLOW_CONNS : 0), out_dbname); + InitPostgres(in_dbname, dboid, username, useroid, flags, out_dbname); #elif PG_VERSION_NUM >= 150000 - InitPostgres(in_dbname, dboid, username, useroid, load_session_libraries, - override_allow_connections, out_dbname); + InitPostgres(in_dbname, dboid, username, useroid, + flags & INIT_PG_LOAD_SESSION_LIBS, + flags & INIT_PG_OVERRIDE_ALLOW_CONNS, out_dbname); #elif PG_VERSION_NUM >= 110000 InitPostgres(in_dbname, dboid, username, useroid, out_dbname, - override_allow_connections); + flags & INIT_PG_OVERRIDE_ALLOW_CONNS); #else InitPostgres(in_dbname, dboid, username, useroid, out_dbname); #endif