pg.ddx.io reorg/pg_repack GitHub issues and pull requests
help / color / mirror / Atom feedFrom: jeltz (@jeltz) <noreply+jeltz@github.com>
To: reorg/pg_repack <noreply+reorg-pg_repack@github.com>
Subject: [reorg/pg_repack] PR #484: Use PG_MODULE_MAGIC_EXT in PostgreSQL 18 and later
Date: Fri, 08 May 2026 09:23:32 +0000
Message-ID: <gh-reorg-pg_repack-484@github.com> (raw)
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()`.
inline patch 1: lib/repack.c (+16/-9 lines) download inline-1.patch
diff --git a/lib/repack.c b/lib/repack.c
index 6aa519b..ca2c91a 100644
--- a/lib/repack.c
+++ b/lib/repack.c
@@ -64,7 +64,23 @@
#include "utils/ruleutils.h"
#endif
+#ifdef REPACK_VERSION
+/* macro trick to stringify a macro expansion */
+#define xstr(s) str(s)
+#define str(s) #s
+#define LIBRARY_VERSION xstr(REPACK_VERSION)
+#else
+#define LIBRARY_VERSION "unknown"
+#endif
+
+#if PG_VERSION_NUM >= 180000
+PG_MODULE_MAGIC_EXT(
+ .name = "pg_repack",
+ .version = LIBRARY_VERSION
+);
+#else
PG_MODULE_MAGIC;
+#endif
extern Datum PGUT_EXPORT repack_version(PG_FUNCTION_ARGS);
extern Datum PGUT_EXPORT repack_trigger(PG_FUNCTION_ARGS);
@@ -136,15 +152,6 @@ must_be_owner(Oid relId)
#define RENAME_INDEX(relid, newrelname) RenameRelationInternal(relid, newrelname, true, true);
#endif
-#ifdef REPACK_VERSION
-/* macro trick to stringify a macro expansion */
-#define xstr(s) str(s)
-#define str(s) #s
-#define LIBRARY_VERSION xstr(REPACK_VERSION)
-#else
-#define LIBRARY_VERSION "unknown"
-#endif
-
Datum
repack_version(PG_FUNCTION_ARGS)
{
view thread (4+ messages) latest in thread
Message-ID: <gh-reorg-pg_repack-484@github.com>
Permalink: ../gh-reorg-pg_repack-484@github.com/
· ·
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox