From 57fae0084400e96b0534d14cb42b6ef8089ced0c Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Mon, 22 May 2017 11:02:22 +0900 Subject: [PATCH] repmgrd: support latest round of PostgreSQL 10 WAL function renamings --- repmgrd.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/repmgrd.c b/repmgrd.c index 2f9b65a2..c1429ac2 100644 --- a/repmgrd.c +++ b/repmgrd.c @@ -1149,8 +1149,8 @@ standby_monitor(void) " replay_timestamp, " " COALESCE(receive_location, '0/0') >= replay_location AS receiving_streamed_wal " " FROM (SELECT CURRENT_TIMESTAMP AS ts, " - " pg_catalog.pg_last_wal_receive_location() AS receive_location, " - " pg_catalog.pg_last_wal_replay_location() AS replay_location, " + " pg_catalog.pg_last_wal_receive_lsn() AS receive_location, " + " pg_catalog.pg_last_wal_replay_lsn() AS replay_location, " " pg_catalog.pg_last_xact_replay_timestamp() AS replay_timestamp " " ) q "); @@ -1500,7 +1500,11 @@ do_master_failover(void) terminate(ERR_FAILOVER_FAIL); } - sqlquery_snprintf(sqlquery, "SELECT pg_catalog.pg_last_xlog_receive_location()"); + if (server_version_num >= 100000) + sqlquery_snprintf(sqlquery, "SELECT pg_catalog.pg_last_wal_receive_lsn()"); + else + sqlquery_snprintf(sqlquery, "SELECT pg_catalog.pg_last_xlog_receive_location()"); + res = PQexec(node_conn, sqlquery); if (PQresultStatus(res) != PGRES_TUPLES_OK) { @@ -1532,7 +1536,12 @@ do_master_failover(void) } /* last we get info about this node, and update shared memory */ - sprintf(sqlquery, "SELECT pg_catalog.pg_last_xlog_receive_location()"); + + if (server_version_num >= 100000) + sprintf(sqlquery, "SELECT pg_catalog.pg_last_wal_receive_lsn()"); + else + sprintf(sqlquery, "SELECT pg_catalog.pg_last_xlog_receive_location()"); + res = PQexec(my_local_conn, sqlquery); if (PQresultStatus(res) != PGRES_TUPLES_OK) {