Skip to content

Commit

Permalink
PostgreSQL 17 support.
Browse files Browse the repository at this point in the history
  Caused by:
  - 4800a5dfb4c46d22b5d05f16c615bea6ff24a2bb (PostgreSQL)
    Refactor InitPostgres() to use bitwise option flags
  • Loading branch information
antamel committed Nov 8, 2023
1 parent 92097fd commit 22212ba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion collector.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ pgws_collector_main(Datum main_arg)
pqsignal(SIGTERM, handle_sigterm);
pqsignal(SIGUSR1, procsignal_sigusr1_handler);
BackgroundWorkerUnblockSignals();
InitPostgresCompat(NULL, InvalidOid, NULL, InvalidOid, false, false, NULL);
InitPostgresCompat(NULL, InvalidOid, NULL, InvalidOid, 0, NULL);
SetProcessingMode(NormalProcessing);

/* Make pg_wait_sampling recognisable in pg_stat_activity */
Expand Down
18 changes: 11 additions & 7 deletions compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,26 @@ shm_mq_send_compat(shm_mq_handle *mqh, Size nbytes, const void *data,
#endif
}

#if PG_VERSION_NUM < 170000
#define INIT_PG_LOAD_SESSION_LIBS 0x0001
#define INIT_PG_OVERRIDE_ALLOW_CONNS 0x0002
#endif

static inline void
InitPostgresCompat(const char *in_dbname, Oid dboid,
const char *username, Oid useroid,
bool load_session_libraries,
bool override_allow_connections,
bits32 flags,
char *out_dbname)
{
#if PG_VERSION_NUM >= 170000
InitPostgres(in_dbname, dboid, username, useroid, (load_session_libraries ? INIT_PG_LOAD_SESSION_LIBS : 0) |
(override_allow_connections ? INIT_PG_OVERRIDE_ALLOW_CONNS : 0), out_dbname);
InitPostgres(in_dbname, dboid, username, useroid, flags, out_dbname);
#elif PG_VERSION_NUM >= 150000
InitPostgres(in_dbname, dboid, username, useroid, load_session_libraries,
override_allow_connections, out_dbname);
InitPostgres(in_dbname, dboid, username, useroid,
flags & INIT_PG_LOAD_SESSION_LIBS,
flags & INIT_PG_OVERRIDE_ALLOW_CONNS, out_dbname);
#elif PG_VERSION_NUM >= 110000
InitPostgres(in_dbname, dboid, username, useroid, out_dbname,
override_allow_connections);
flags & INIT_PG_OVERRIDE_ALLOW_CONNS);
#else
InitPostgres(in_dbname, dboid, username, useroid, out_dbname);
#endif
Expand Down

0 comments on commit 22212ba

Please sign in to comment.