From aa6936bf7a7deb5a62cbab2c905b0313b6ed1599 Mon Sep 17 00:00:00 2001 From: Kathia Barahona Date: Thu, 15 Aug 2024 14:29:08 +0200 Subject: [PATCH] Build PG17 Support PG17. `session_auth_is_superuser` was renamed to `current_role_is_superuser` in https://github.com/postgres/postgres/commit/0fef8775382886bef023aee67cb744711ed7a32f --- .github/workflows/build.yml | 4 ++-- src/aiven_gatekeeper.c | 10 ++++++++-- src/aiven_gatekeeper.h | 2 ++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1b8de7a..5dca70b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,7 @@ jobs: strategy: max-parallel: 3 matrix: - pg-version: [11, 12, 13, 14, 15, 16] + pg-version: [11, 12, 13, 14, 15, 16, 17] steps: - id: install run: | @@ -25,7 +25,7 @@ jobs: # Get the postgresql gpg key sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7FCC7D46ACCC4CF8 # Setup the Postgres repositories - sudo sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' + sudo sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main ${{ matrix.pg-version }}" > /etc/apt/sources.list.d/pgdg.list' sudo apt-get update # Install build deps sudo apt-get install -y postgresql-server-dev-${{ matrix.pg-version }} diff --git a/src/aiven_gatekeeper.c b/src/aiven_gatekeeper.c index 4a4355d..f007785 100644 --- a/src/aiven_gatekeeper.c +++ b/src/aiven_gatekeeper.c @@ -36,6 +36,13 @@ PG_MODULE_MAGIC; +/* session_auth_is_superuser was renamed to current_role_is_superuser */ +#if PG17_GTE +#define CURRENT_ROLE_IS_SUPERUSER current_role_is_superuser +#else +#define CURRENT_ROLE_IS_SUPERUSER session_auth_is_superuser +#endif + void _PG_init(void); void _PG_fini(void); @@ -139,9 +146,8 @@ is_elevated(void) } is_superuser = superuser_arg(currentUserId); - /* elevated to supersuser when the session auth user does not have superuser privileges */ - return is_superuser && !session_auth_is_superuser; + return is_superuser && !CURRENT_ROLE_IS_SUPERUSER; } static bool diff --git a/src/aiven_gatekeeper.h b/src/aiven_gatekeeper.h index bd42990..9aa0667 100644 --- a/src/aiven_gatekeeper.h +++ b/src/aiven_gatekeeper.h @@ -14,6 +14,8 @@ #define PG13_GTE (PG_VERSION_NUM >= 130000) #define PG14_GTE (PG_VERSION_NUM >= 140000) #define PG16_GTE (PG_VERSION_NUM >= 160000) +#define PG17_GTE (PG_VERSION_NUM >= 170000) + /* The process_utility_hook function changed in PG13 and again in PG14 * versions from introduction (PG9) through PG12 have the same 7 argument structure