Skip to content

Commit

Permalink
Fix build failure on Postgres master (#280)
Browse files Browse the repository at this point in the history
Use dlist BackgroundWorkerList in PG18

Compatibility with commit b43100f
  • Loading branch information
adamguo0 authored Aug 12, 2024
1 parent 1b12a5c commit f557f0c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/code_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
version: [master, REL_16_STABLE, REL_15_STABLE, REL_14_STABLE, REL_13_STABLE, REL_12_STABLE, REL_11_STABLE]
version: [master, REL_17_STABLE, REL_16_STABLE, REL_15_STABLE, REL_14_STABLE, REL_13_STABLE, REL_12_STABLE, REL_11_STABLE]

runs-on: ${{ matrix.os }}
timeout-minutes: 120
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
version: [master, REL_16_STABLE, REL_15_STABLE, REL_14_STABLE, REL_13_STABLE, REL_12_STABLE, REL_11_STABLE]
version: [master, REL_17_STABLE, REL_16_STABLE, REL_15_STABLE, REL_14_STABLE, REL_13_STABLE, REL_12_STABLE, REL_11_STABLE]

runs-on: ${{ matrix.os }}
timeout-minutes: 120
Expand Down
15 changes: 15 additions & 0 deletions include/compatibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -578,4 +578,19 @@ CastCreate(Oid sourcetypeid, Oid targettypeid, Oid funcid, char castcontext,
#define WAIT_EVENT_MESSAGE_QUEUE_RECEIVE WAIT_EVENT_MQ_RECEIVE
#endif

/*
* PostgreSQL version 18+
*
* b43100f changes BackgroundWorkerList from an slist to a dlist
*/
#if (PG_VERSION_NUM >= 180000)
#define BGW_LIST_ITER dlist_iter
#define BGW_LIST_FOREACH dlist_foreach
#define BGW_LIST_CONTAINER dlist_container
#else
#define BGW_LIST_ITER slist_iter
#define BGW_LIST_FOREACH slist_foreach
#define BGW_LIST_CONTAINER slist_container
#endif

#endif /* SET_USER_COMPAT_H */
7 changes: 4 additions & 3 deletions src/clientauth.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ void
clientauth_init(void)
{
BackgroundWorker worker;
slist_iter siter;
BGW_LIST_ITER bgw_iter;
int num_registered_workers = 0;

/* Define our GUC parameters */
Expand Down Expand Up @@ -344,11 +344,12 @@ clientauth_init(void)
* Check the backgroud worker registered list. If any clientauth workers
* failed to register, then throw an error.
*/
slist_foreach(siter, &BackgroundWorkerList)
BGW_LIST_FOREACH(bgw_iter, &BackgroundWorkerList)
{
RegisteredBgWorker *rw;

rw = slist_container(RegisteredBgWorker, rw_lnode, siter.cur);
rw = BGW_LIST_CONTAINER(RegisteredBgWorker, rw_lnode, bgw_iter.cur);

if (strncmp(rw->rw_worker.bgw_type, clientauth_worker_name, BGW_MAXLEN) == 0)
num_registered_workers++;
}
Expand Down

0 comments on commit f557f0c

Please sign in to comment.