From baae98b052f9bfb63e3a91ceecf70ea268c20d32 Mon Sep 17 00:00:00 2001 From: Andreas Karlsson Date: Fri, 8 May 2026 11:35:55 +0200 Subject: [PATCH] Use PG_MODULE_MAGIC_EXT in PostgreSQL 18 and later The PG_MODULE_MAGIC_EXT macro was added in PostgreSQL 18 and makes it possible to see which version of the library is actually loaded using pg_get_loaded_modules(). --- src/spock.c | 7 +++++++ src/spock_output.c | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/src/spock.c b/src/spock.c index 8def4d39..16be4ada 100644 --- a/src/spock.c +++ b/src/spock.c @@ -68,7 +68,14 @@ #include "spock_shmem.h" #include "spock.h" +#if PG_VERSION_NUM >= 180000 +PG_MODULE_MAGIC_EXT( + .name = "spock", + .version = SPOCK_VERSION +); +#else PG_MODULE_MAGIC; +#endif static const struct config_enum_entry SpockConflictResolvers[] = { /* diff --git a/src/spock_output.c b/src/spock_output.c index 0b75b404..4a511f97 100644 --- a/src/spock_output.c +++ b/src/spock_output.c @@ -16,7 +16,16 @@ #include "replication/logical.h" +#include "spock.h" + +#if PG_VERSION_NUM >= 180000 +PG_MODULE_MAGIC_EXT( + .name = "spock_output", + .version = SPOCK_VERSION +); +#else PG_MODULE_MAGIC; +#endif extern void _PG_output_plugin_init(OutputPluginCallbacks *cb);