diff --git a/config.h.in b/config.h.in
index 69adebae..b977437d 100644
--- a/config.h.in
+++ b/config.h.in
@@ -2,4 +2,3 @@
/* Only build repmgr for BDR */
#undef BDR_ONLY
-
diff --git a/configure b/configure
index 71c256d4..08d3eca4 100755
--- a/configure
+++ b/configure
@@ -1841,7 +1841,7 @@ if test "$major_version_num" -lt '10'; then
version_num_int=$(echo "$version_num"|
$SED -e 's/^\([0-9]*\)\.\([0-9]*\)$/\1\2/')
- if test "$version_num_int" -lt '94'; then
+ if test "$version_num_int" -lt '93'; then
as_fn_error $? "repmgr is not compatible with detected PostgreSQL version: $version_num" "$LINENO" 5
fi
else
diff --git a/configure.in b/configure.in
index 7f036c11..3fd4f30a 100644
--- a/configure.in
+++ b/configure.in
@@ -38,7 +38,7 @@ if test "$major_version_num" -lt '10'; then
version_num_int=$(echo "$version_num"|
$SED -e 's/^\([[0-9]]*\)\.\([[0-9]]*\)$/\1\2/')
- if test "$version_num_int" -lt '94'; then
+ if test "$version_num_int" -lt '93'; then
AC_MSG_ERROR([repmgr is not compatible with detected PostgreSQL version: $version_num])
fi
else
diff --git a/repmgr--4.0.sql b/repmgr--4.0.sql
index 8621d921..b84c87f3 100644
--- a/repmgr--4.0.sql
+++ b/repmgr--4.0.sql
@@ -23,6 +23,16 @@ CREATE TABLE repmgr.events (
details TEXT NULL
);
+DO $repmgr$
+DECLARE
+ DECLARE server_version_num INT;
+BEGIN
+ SELECT setting
+ FROM pg_catalog.pg_settings
+ WHERE name = 'server_version_num'
+ INTO server_version_num;
+ IF server_version_num >= 90400 THEN
+ EXECUTE $repmgr_func$
CREATE TABLE repmgr.monitoring_history (
primary_node_id INTEGER NOT NULL,
standby_node_id INTEGER NOT NULL,
@@ -32,7 +42,26 @@ CREATE TABLE repmgr.monitoring_history (
last_wal_standby_location PG_LSN,
replication_lag BIGINT NOT NULL,
apply_lag BIGINT NOT NULL
-);
+)
+ $repmgr_func$;
+ ELSE
+ EXECUTE $repmgr_func$
+CREATE TABLE repmgr.monitoring_history (
+ primary_node_id INTEGER NOT NULL,
+ standby_node_id INTEGER NOT NULL,
+ last_monitor_time TIMESTAMP WITH TIME ZONE NOT NULL,
+ last_apply_time TIMESTAMP WITH TIME ZONE,
+ last_wal_primary_location TEXT NOT NULL,
+ last_wal_standby_location TEXT,
+ replication_lag BIGINT NOT NULL,
+ apply_lag BIGINT NOT NULL
+)
+ $repmgr_func$;
+ END IF;
+END$repmgr$;
+
+
+
CREATE INDEX idx_monitoring_history_time
ON repmgr.monitoring_history (last_monitor_time, standby_node_id);
@@ -73,10 +102,33 @@ CREATE FUNCTION standby_get_last_updated()
/* failover functions */
+
+DO $repmgr$
+DECLARE
+ DECLARE server_version_num INT;
+BEGIN
+ SELECT setting
+ FROM pg_catalog.pg_settings
+ WHERE name = 'server_version_num'
+ INTO server_version_num;
+
+ IF server_version_num >= 90400 THEN
+ EXECUTE $repmgr_func$
CREATE FUNCTION request_vote(INT,INT)
RETURNS pg_lsn
AS 'MODULE_PATHNAME', 'request_vote'
LANGUAGE C STRICT;
+ $repmgr_func$;
+ ELSE
+ EXECUTE $repmgr_func$
+CREATE FUNCTION request_vote(INT,INT)
+ RETURNS TEXT
+ AS 'MODULE_PATHNAME', 'request_vote'
+ LANGUAGE C STRICT;
+ $repmgr_func$;
+ END IF;
+END$repmgr$;
+
CREATE FUNCTION get_voting_status()
RETURNS INT
diff --git a/repmgr.c b/repmgr.c
index af54ecaf..de1deb3f 100644
--- a/repmgr.c
+++ b/repmgr.c
@@ -20,6 +20,7 @@
* along with this program. If not, see .
*/
+
#include "postgres.h"
#include "fmgr.h"
#include "access/xlog.h"
@@ -31,7 +32,13 @@
#include "storage/shmem.h"
#include "storage/spin.h"
#include "utils/builtins.h"
+
+#if (PG_VERSION_NUM >= 90400)
#include "utils/pg_lsn.h"
+#else
+#include "compat-lsn.h"
+#endif
+
#include "utils/timestamp.h"
#include "executor/spi.h"
diff --git a/repmgr.h b/repmgr.h
index 5b5ec855..ff8f4022 100644
--- a/repmgr.h
+++ b/repmgr.h
@@ -26,6 +26,8 @@
#include
#include
+#include
+#include
#include
#include
@@ -39,8 +41,8 @@
#include "dbutils.h"
#include "log.h"
-#define MIN_SUPPORTED_VERSION "9.4"
-#define MIN_SUPPORTED_VERSION_NUM 90400
+#define MIN_SUPPORTED_VERSION "9.3"
+#define MIN_SUPPORTED_VERSION_NUM 90300
#define REPLICATION_TYPE_PHYSICAL 1
#define REPLICATION_TYPE_BDR 2