Skip to content

Commit

Permalink
Build PG17
Browse files Browse the repository at this point in the history
Support PG17. `session_auth_is_superuser` was renamed to `current_role_is_superuser` in
postgres/postgres@0fef877
  • Loading branch information
kathia-barahona committed Aug 19, 2024
1 parent 1da6e18 commit aa6936b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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 }}
Expand Down
10 changes: 8 additions & 2 deletions src/aiven_gatekeeper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/aiven_gatekeeper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit aa6936b

Please sign in to comment.