Skip to content

Commit

Permalink
PostgreSQL 17 support. (#81)
Browse files Browse the repository at this point in the history
The only change that breaks compatibility for PostgreSQL 17 is the InitializeSessionUserId() function signature change: postgres/postgres@e768919

Also add 17beta2 to the test matrix.

Reviewed by David Steele (@dwsteele).
  • Loading branch information
artemgavrilov authored Aug 1, 2024
1 parent a867b55 commit 7f063e5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/regression-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
strategy:
fail-fast: false
matrix:
pgver: [12, 13, 14, 15, 16]
pgver: [12, 13, 14, 15, 16, 17beta2]

steps:
- name: Checkout set_user repo
Expand All @@ -30,7 +30,9 @@ jobs:
- name: Set DEVPKG to pgver if unset
if: ${{ env.DEVPKG == '' }}
run: |
echo "DEVPKG=${{ matrix.pgver }}" >> $GITHUB_ENV;
# Cut off label and leave only major version number (17beta2 -> 17)
DEVPKG=$(echo ${{ matrix.pgver }} | sed 's/^\([0-9]\{2\}\).*/\1/')
echo "DEVPKG=$DEVPKG" >> $GITHUB_ENV;
- name: Build set_user
run: |
Expand Down
16 changes: 16 additions & 0 deletions src/compatibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@
#define NO_ASSERT_AUTH_UID_ONCE !USE_ASSERT_CHECKING
#endif

/*
* PostgreSQL version 17+
*
* - Sets bypass_login_check parameter to false in InitializeSessionUserId funcion
*/
#if PG_VERSION_NUM >= 170000

#ifndef INITSESSIONUSER
#define INITSESSIONUSER
#define _InitializeSessionUserId(name,ouserid) InitializeSessionUserId(name,ouserid,false)
#endif

#endif /* 17+ */

/*
* PostgreSQL version 14+
*
Expand Down Expand Up @@ -135,8 +149,10 @@ _heap_tuple_get_oid(HeapTuple tuple, Oid catalogID)
#if PG_VERSION_NUM >= 90500
#define GETUSERNAMEFROMID(ouserid) GetUserNameFromId(ouserid, false)

#ifndef INITSESSIONUSER
#define INITSESSIONUSER
#define _InitializeSessionUserId(name,ouserid) InitializeSessionUserId(name,ouserid)
#endif

#endif /* 9.5+ */

Expand Down

0 comments on commit 7f063e5

Please sign in to comment.