Initial changes for 9.3 support

This commit is contained in:
Ian Barwick
2017-09-15 10:27:37 +09:00
parent e040f95aaa
commit 687c8b4e27
6 changed files with 66 additions and 6 deletions

View File

@@ -2,4 +2,3 @@
/* Only build repmgr for BDR */ /* Only build repmgr for BDR */
#undef BDR_ONLY #undef BDR_ONLY

2
configure vendored
View File

@@ -1841,7 +1841,7 @@ if test "$major_version_num" -lt '10'; then
version_num_int=$(echo "$version_num"| version_num_int=$(echo "$version_num"|
$SED -e 's/^\([0-9]*\)\.\([0-9]*\)$/\1\2/') $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 as_fn_error $? "repmgr is not compatible with detected PostgreSQL version: $version_num" "$LINENO" 5
fi fi
else else

View File

@@ -38,7 +38,7 @@ if test "$major_version_num" -lt '10'; then
version_num_int=$(echo "$version_num"| version_num_int=$(echo "$version_num"|
$SED -e 's/^\([[0-9]]*\)\.\([[0-9]]*\)$/\1\2/') $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]) AC_MSG_ERROR([repmgr is not compatible with detected PostgreSQL version: $version_num])
fi fi
else else

View File

@@ -23,6 +23,16 @@ CREATE TABLE repmgr.events (
details TEXT NULL 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 ( CREATE TABLE repmgr.monitoring_history (
primary_node_id INTEGER NOT NULL, primary_node_id INTEGER NOT NULL,
standby_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, last_wal_standby_location PG_LSN,
replication_lag BIGINT NOT NULL, replication_lag BIGINT NOT NULL,
apply_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 CREATE INDEX idx_monitoring_history_time
ON repmgr.monitoring_history (last_monitor_time, standby_node_id); ON repmgr.monitoring_history (last_monitor_time, standby_node_id);
@@ -73,10 +102,33 @@ CREATE FUNCTION standby_get_last_updated()
/* failover functions */ /* 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) CREATE FUNCTION request_vote(INT,INT)
RETURNS pg_lsn RETURNS pg_lsn
AS 'MODULE_PATHNAME', 'request_vote' AS 'MODULE_PATHNAME', 'request_vote'
LANGUAGE C STRICT; 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() CREATE FUNCTION get_voting_status()
RETURNS INT RETURNS INT

View File

@@ -20,6 +20,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "postgres.h" #include "postgres.h"
#include "fmgr.h" #include "fmgr.h"
#include "access/xlog.h" #include "access/xlog.h"
@@ -31,7 +32,13 @@
#include "storage/shmem.h" #include "storage/shmem.h"
#include "storage/spin.h" #include "storage/spin.h"
#include "utils/builtins.h" #include "utils/builtins.h"
#if (PG_VERSION_NUM >= 90400)
#include "utils/pg_lsn.h" #include "utils/pg_lsn.h"
#else
#include "compat-lsn.h"
#endif
#include "utils/timestamp.h" #include "utils/timestamp.h"
#include "executor/spi.h" #include "executor/spi.h"

View File

@@ -26,6 +26,8 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <libpq-fe.h> #include <libpq-fe.h>
#include <postgres_fe.h> #include <postgres_fe.h>
@@ -39,8 +41,8 @@
#include "dbutils.h" #include "dbutils.h"
#include "log.h" #include "log.h"
#define MIN_SUPPORTED_VERSION "9.4" #define MIN_SUPPORTED_VERSION "9.3"
#define MIN_SUPPORTED_VERSION_NUM 90400 #define MIN_SUPPORTED_VERSION_NUM 90300
#define REPLICATION_TYPE_PHYSICAL 1 #define REPLICATION_TYPE_PHYSICAL 1
#define REPLICATION_TYPE_BDR 2 #define REPLICATION_TYPE_BDR 2