Thanks to visit codestin.com
Credit goes to github.com

Skip to content

postgres 15 support #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions collector.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,12 +350,7 @@ collector_main(Datum main_arg)
pqsignal(SIGTERM, handle_sigterm);
pqsignal(SIGUSR1, procsignal_sigusr1_handler);
BackgroundWorkerUnblockSignals();

#if PG_VERSION_NUM >= 110000
InitPostgres(NULL, InvalidOid, NULL, InvalidOid, NULL, false);
#else
InitPostgres(NULL, InvalidOid, NULL, InvalidOid, NULL);
#endif
InitPostgresCompat(NULL, InvalidOid, NULL, InvalidOid, false, false, NULL);
SetProcessingMode(NormalProcessing);

/* Make pg_wait_sampling recognisable in pg_stat_activity */
Expand Down
20 changes: 20 additions & 0 deletions compat.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "postgres.h"

#include "access/tupdesc.h"
#include "miscadmin.h"

#include "pg_wait_sampling.h"

Expand Down Expand Up @@ -33,3 +35,21 @@ CreateTemplateTupleDescCompat(int nattrs, bool hasoid)
return CreateTemplateTupleDesc(nattrs, hasoid);
#endif
}

inline void
InitPostgresCompat(const char *in_dbname, Oid dboid,
const char *username, Oid useroid,
bool load_session_libraries,
bool override_allow_connections,
char *out_dbname)
{
#if PG_VERSION_NUM >= 150000
InitPostgres(in_dbname, dboid, username, useroid, load_session_libraries,
override_allow_connections, out_dbname);
#elif PG_VERSION_NUM >= 110000
InitPostgres(in_dbname, dboid, username, useroid, out_dbname,
override_allow_connections);
#else
InitPostgres(in_dbname, dboid, username, useroid, out_dbname);
#endif
}
5 changes: 5 additions & 0 deletions pg_wait_sampling.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,10 @@ extern shm_mq_result shm_mq_send_compat(shm_mq_handle *mqh, Size nbytes,
const void *data, bool nowait,
bool force_flush);
extern TupleDesc CreateTemplateTupleDescCompat(int nattrs, bool hasoid);
extern void InitPostgresCompat(const char *in_dbname, Oid dboid,
const char *username, Oid useroid,
bool load_session_libraries,
bool override_allow_connections,
char *out_dbname);

#endif