mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-26 08:36:30 +00:00
Fixes for PostgreSQL 9.3 support
This commit is contained in:
27
compat-lsn.h
27
compat-lsn.h
@@ -1,27 +0,0 @@
|
|||||||
/*-------------------------------------------------------------------------
|
|
||||||
*
|
|
||||||
* pg_lsn.h
|
|
||||||
* Declarations for operations on log sequence numbers (LSNs) of
|
|
||||||
* PostgreSQL.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
|
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
|
||||||
*
|
|
||||||
* src/include/utils/pg_lsn.h
|
|
||||||
*
|
|
||||||
*-------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
#ifndef PG_LSN_H
|
|
||||||
#define PG_LSN_H
|
|
||||||
|
|
||||||
#include "fmgr.h"
|
|
||||||
#include "access/xlogdefs.h"
|
|
||||||
|
|
||||||
#define DatumGetLSN(X) ((XLogRecPtr) DatumGetInt64(X))
|
|
||||||
#define LSNGetDatum(X) (Int64GetDatum((int64) (X)))
|
|
||||||
|
|
||||||
#define PG_GETARG_LSN(n) DatumGetLSN(PG_GETARG_DATUM(n))
|
|
||||||
#define PG_RETURN_LSN(x) return LSNGetDatum(x)
|
|
||||||
|
|
||||||
#endif /* PG_LSN_H */
|
|
||||||
34
repmgr.c
34
repmgr.c
@@ -35,8 +35,6 @@
|
|||||||
|
|
||||||
#if (PG_VERSION_NUM >= 90400)
|
#if (PG_VERSION_NUM >= 90400)
|
||||||
#include "utils/pg_lsn.h"
|
#include "utils/pg_lsn.h"
|
||||||
#else
|
|
||||||
#include "compat-lsn.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "utils/timestamp.h"
|
#include "utils/timestamp.h"
|
||||||
@@ -287,14 +285,24 @@ request_vote(PG_FUNCTION_ARGS)
|
|||||||
{
|
{
|
||||||
#ifndef BDR_ONLY
|
#ifndef BDR_ONLY
|
||||||
StringInfoData query;
|
StringInfoData query;
|
||||||
|
|
||||||
|
#if (PG_VERSION_NUM >= 90400)
|
||||||
XLogRecPtr our_lsn = InvalidXLogRecPtr;
|
XLogRecPtr our_lsn = InvalidXLogRecPtr;
|
||||||
|
bool isnull;
|
||||||
|
#else
|
||||||
|
char *value = NULL;
|
||||||
|
char lsn_text[64] = "";
|
||||||
|
#endif
|
||||||
|
|
||||||
/* node_id used for logging purposes */
|
/* node_id used for logging purposes */
|
||||||
int requesting_node_id = PG_GETARG_INT32(0);
|
int requesting_node_id = PG_GETARG_INT32(0);
|
||||||
int current_electoral_term = PG_GETARG_INT32(1);
|
int current_electoral_term = PG_GETARG_INT32(1);
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
bool isnull;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!shared_state)
|
if (!shared_state)
|
||||||
PG_RETURN_NULL();
|
PG_RETURN_NULL();
|
||||||
@@ -341,14 +349,22 @@ request_vote(PG_FUNCTION_ARGS)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (PG_VERSION_NUM >= 90400)
|
||||||
our_lsn = DatumGetLSN(SPI_getbinval(SPI_tuptable->vals[0],
|
our_lsn = DatumGetLSN(SPI_getbinval(SPI_tuptable->vals[0],
|
||||||
SPI_tuptable->tupdesc,
|
SPI_tuptable->tupdesc,
|
||||||
1, &isnull));
|
1, &isnull));
|
||||||
|
|
||||||
|
|
||||||
elog(DEBUG1, "our LSN is %X/%X",
|
elog(DEBUG1, "our LSN is %X/%X",
|
||||||
(uint32) (our_lsn >> 32),
|
(uint32) (our_lsn >> 32),
|
||||||
(uint32) our_lsn);
|
(uint32) our_lsn);
|
||||||
|
#else
|
||||||
|
value = SPI_getvalue(SPI_tuptable->vals[0],
|
||||||
|
SPI_tuptable->tupdesc,
|
||||||
|
1);
|
||||||
|
strncpy(lsn_text, value, 64);
|
||||||
|
pfree(value);
|
||||||
|
elog(DEBUG1, "our LSN is %s", lsn_text);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* indicate this node has responded to a vote request */
|
/* indicate this node has responded to a vote request */
|
||||||
shared_state->voting_status = VS_VOTE_REQUEST_RECEIVED;
|
shared_state->voting_status = VS_VOTE_REQUEST_RECEIVED;
|
||||||
@@ -362,15 +378,7 @@ request_vote(PG_FUNCTION_ARGS)
|
|||||||
#if (PG_VERSION_NUM >= 90400)
|
#if (PG_VERSION_NUM >= 90400)
|
||||||
PG_RETURN_LSN(our_lsn);
|
PG_RETURN_LSN(our_lsn);
|
||||||
#else
|
#else
|
||||||
{
|
PG_RETURN_TEXT_P(cstring_to_text(lsn_text));
|
||||||
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
|
#endif
|
||||||
#else
|
#else
|
||||||
PG_RETURN(InvalidOid);
|
PG_RETURN(InvalidOid);
|
||||||
|
|||||||
Reference in New Issue
Block a user