Skip to content

Commit 69f8643

Browse files
authored
PostgreSQL 18 support. (#91)
No code changes are required for PostgreSQL 18 but the PG_MODULE_MAGIC_EXT() macro was added to support module name and version. Since this macro is only supported in the new version add a define for backward compatibility. Reviewed by John Harvey (@crunchyjohn).
1 parent 8855b82 commit 69f8643

File tree

5 files changed

+23
-4
lines changed

5 files changed

+23
-4
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
4.2.0
2+
=====
3+
4+
NEW FEATURES
5+
------------
6+
- Add PG_MODULE_MAGIC_EXT() macro for PostgreSQL >= 18.
7+
- Remove support for PostgreSQL 12.
8+
19
4.1.0
210
=====
311

set_user.control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# set_user extension
22
comment = 'similar to SET ROLE but with added logging'
3-
default_version = '4.1.0'
3+
default_version = '4.2.0'
44
module_pathname = '$libdir/set_user'
55
relocatable = false

src/compatibility.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@
1616
#define NO_ASSERT_AUTH_UID_ONCE !USE_ASSERT_CHECKING
1717
#endif
1818

19+
/*
20+
* Define PG_MODULE_MAGIC_EXT() as PG_MODULE_MAGIC for versions where the new
21+
* macro does not exist
22+
*/
23+
#if PG_VERSION_NUM < 180000
24+
25+
#define PG_MODULE_MAGIC_EXT(...) PG_MODULE_MAGIC
26+
27+
#endif /* PG_VERSION_NUM < 180000 */
28+
1929
/*
2030
* PostgreSQL version 17+
2131
*

src/set_user.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,10 @@
5353
#include "utils/varlena.h"
5454

5555
#include "set_user.h"
56-
57-
PG_MODULE_MAGIC;
58-
5956
#include "compatibility.h"
6057

58+
PG_MODULE_MAGIC_EXT(.name = "set_user", .version = "4.2.0");
59+
6160
#define ALLOWLIST_WILDCARD "*"
6261
#define SUPERUSER_AUDIT_TAG "AUDIT"
6362

updates/set_user--4.1.0--4.2.0.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- complain if script is sourced in psql, rather than via ALTER EXTENSION
2+
\echo Use "ALTER EXTENSION set_user UPDATE" to load this file. \quit

0 commit comments

Comments
 (0)