From f9a150504a4d58f1f190529a4c10adca220b3e8e Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Mon, 4 Apr 2016 12:41:03 +0900 Subject: [PATCH] Enable repmgr to be compiled with PostgreSQL 9.6 --- repmgr.c | 29 ++++++++++++++++++++++++----- sql/repmgr_funcs.c | 9 +++++++++ 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/repmgr.c b/repmgr.c index 6be3a3e2..22c8477f 100644 --- a/repmgr.c +++ b/repmgr.c @@ -4872,22 +4872,41 @@ check_upstream_config(PGconn *conn, int server_version_num, bool exit_on_error) } else { - char *levels[] = { + char *levels_pre96[] = { "hot_standby", "logical", + NULL, }; - int j = 0; - wal_error_message = _("parameter 'wal_level' must be set to 'hot_standby' or 'logical'"); + char *levels_96plus[] = { + "replica", + "logical", + NULL, + }; - for(; j < 2; j++) + char **levels; + int j = 0; + + if (server_version_num < 90500) + { + levels = (char **)levels_pre96; + wal_error_message = _("parameter 'wal_level' must be set to 'hot_standby' or 'logical'"); + } + else + { + levels = (char **)levels_96plus; + wal_error_message = _("parameter 'wal_level' must be set to 'replica' or 'logical'"); + } + + do { i = guc_set(conn, "wal_level", "=", levels[j]); if (i) { break; } - } + j++; + } while (levels[j] != NULL); } if (i == 0 || i == -1) diff --git a/sql/repmgr_funcs.c b/sql/repmgr_funcs.c index 7ac1230d..a9aa9026 100644 --- a/sql/repmgr_funcs.c +++ b/sql/repmgr_funcs.c @@ -83,7 +83,12 @@ _PG_init(void) * resources in repmgr_shmem_startup(). */ RequestAddinShmemSpace(repmgr_memsize()); + +#if (PG_VERSION_NUM >= 90600) + RequestNamedLWLockTranche("repmgr", 1); +#else RequestAddinLWLocks(1); +#endif /* * Install hooks. @@ -128,7 +133,11 @@ repmgr_shmem_startup(void) if (!found) { /* First time through ... */ +#if (PG_VERSION_NUM >= 90600) + shared_state->lock = &(GetNamedLWLockTranche("repmgr"))->lock; +#else shared_state->lock = LWLockAssign(); +#endif snprintf(shared_state->location, sizeof(shared_state->location), "%X/%X", 0, 0); }