From 31c7cb4e9a3aa6581221cc9db222735d90fb33fd Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Fri, 15 Sep 2017 17:13:17 +0900 Subject: [PATCH] Fixes for 9.3 support --- dbutils.c | 4 ---- repmgr.c | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/dbutils.c b/dbutils.c index 00e02ecb..1cc83377 100644 --- a/dbutils.c +++ b/dbutils.c @@ -3619,10 +3619,6 @@ request_vote(PGconn *conn, t_node_info *this_node, t_node_info *other_node, int "SELECT repmgr.request_vote(%i, %i)", this_node->node_id, electoral_term); -/* "SELECT repmgr.request_vote(%i, '%X/%X'::pg_lsn)", - this_node->node_id, - (uint32) (last_wal_receive_lsn >> 32), - (uint32) last_wal_receive_lsn);*/ res = PQexec(conn, query.data); termPQExpBuffer(&query); diff --git a/repmgr.c b/repmgr.c index de1deb3f..22f62a4c 100644 --- a/repmgr.c +++ b/repmgr.c @@ -333,7 +333,12 @@ request_vote(PG_FUNCTION_ARGS) { SPI_finish(); elog(WARNING, "unable to retrieve last received LSN"); + +#if (PG_VERSION_NUM >= 90400) PG_RETURN_LSN(InvalidOid); +#else + PG_RETURN_TEXT_P(cstring_to_text("0/0")); +#endif } our_lsn = DatumGetLSN(SPI_getbinval(SPI_tuptable->vals[0], @@ -354,7 +359,19 @@ request_vote(PG_FUNCTION_ARGS) /* should we free "query" here? */ SPI_finish(); +#if (PG_VERSION_NUM >= 90400) PG_RETURN_LSN(our_lsn); +#else + { + char lsn_text[64] = ""; + snprintf(lsn_text, 64, + "%X/%X", + (uint32) (our_lsn >> 32), + (uint32) our_lsn); + + PG_RETURN_TEXT_P(cstring_to_text(lsn_text)); + } +#endif #else PG_RETURN(InvalidOid); #endif