Make repmgr compile in 9.3.

Patch provided by Shawn Ellis with some fixes by me.
This commit is contained in:
Jaime Casanova
2013-11-14 00:43:35 -05:00
parent b410772627
commit 3c8df59eb9
2 changed files with 29 additions and 14 deletions

View File

@@ -10,3 +10,4 @@ Hannu Krosing <hannu@2ndQuadrant.com>
Cédric Villemain <cedric@2ndquadrant.com> Cédric Villemain <cedric@2ndquadrant.com>
Charles Duffy <charles@dyfis.net> Charles Duffy <charles@dyfis.net>
Daniel Farina <daniel@heroku.com> Daniel Farina <daniel@heroku.com>
Shawn Ellis <shawn.ellis17@gmail.com>

View File

@@ -45,6 +45,26 @@
const XLogRecPtr InvalidXLogRecPtr = {0, 0}; const XLogRecPtr InvalidXLogRecPtr = {0, 0};
#endif #endif
#if PG_VERSION_NUM >= 90300
#define XLAssign(a, b) \
a = b
#define XLAssignValue(a, xlogid, xrecoff) \
a = xrecoff
#define XLByteLT(a, b) \
(a < b)
#else
#define XLAssign(a, b) \
a.xlogid = b.xlogid; \
a.xrecoff = b.xrecoff
#define XLAssignValue(a, uxlogid, uxrecoff) \
a.xlogid = uxlogid; \
a.xrecoff = uxrecoff
#endif
/* /*
* Struct to keep info about the nodes, used in the voting process in * Struct to keep info about the nodes, used in the voting process in
* do_failover() * do_failover()
@@ -652,8 +672,7 @@ do_failover(void)
/* Initialize on false so if we can't reach this node we know that later */ /* Initialize on false so if we can't reach this node we know that later */
nodes[i].is_visible = false; nodes[i].is_visible = false;
nodes[i].is_ready = false; nodes[i].is_ready = false;
nodes[i].xlog_location.xlogid = 0; XLAssignValue(nodes[i].xlog_location, 0, 0);
nodes[i].xlog_location.xrecoff = 0;
log_debug(_("%s: node=%d conninfo=\"%s\" witness=%s\n"), log_debug(_("%s: node=%d conninfo=\"%s\" witness=%s\n"),
progname, nodes[i].nodeId, nodes[i].conninfostr, (nodes[i].is_witness) ? "true" : "false"); progname, nodes[i].nodeId, nodes[i].conninfostr, (nodes[i].is_witness) ? "true" : "false");
@@ -730,8 +749,7 @@ do_failover(void)
exit(ERR_FAILOVER_FAIL); exit(ERR_FAILOVER_FAIL);
} }
nodes[i].xlog_location.xlogid = uxlogid; XLAssignValue(nodes[i].xlog_location, uxlogid, uxrecoff);
nodes[i].xlog_location.xrecoff = uxrecoff;
PQclear(res); PQclear(res);
PQfinish(nodeConn); PQfinish(nodeConn);
@@ -811,18 +829,16 @@ do_failover(void)
if (uxlogid == 0 && uxrecoff == 0) if (uxlogid == 0 && uxrecoff == 0)
continue; continue;
xlog_recptr.xlogid = uxlogid; XLAssignValue(xlog_recptr, uxlogid, uxrecoff);
xlog_recptr.xrecoff = uxrecoff;
if (XLByteLT(nodes[i].xlog_location, xlog_recptr)) if (XLByteLT(nodes[i].xlog_location, xlog_recptr))
{ {
nodes[i].xlog_location.xlogid = uxlogid; XLAssignValue(nodes[i].xlog_location, uxlogid, uxrecoff);
nodes[i].xlog_location.xrecoff = uxrecoff;
} }
log_debug("Last XLog position of node %d: log id=%u (%X), offset=%u (%X)\n", log_debug("Last XLog position of node %d: log id=%u (%X), offset=%u (%X)\n",
nodes[i].nodeId, nodes[i].xlog_location.xlogid, nodes[i].xlog_location.xlogid, nodes[i].nodeId, uxlogid, uxlogid,
nodes[i].xlog_location.xrecoff, nodes[i].xlog_location.xrecoff); uxrecoff, uxrecoff);
ready_nodes++; ready_nodes++;
nodes[i].is_ready = true; nodes[i].is_ready = true;
@@ -848,8 +864,7 @@ do_failover(void)
{ {
/* start with the first ready node, and then move on to the next one */ /* start with the first ready node, and then move on to the next one */
best_candidate.nodeId = nodes[i].nodeId; best_candidate.nodeId = nodes[i].nodeId;
best_candidate.xlog_location.xlogid = nodes[i].xlog_location.xlogid; XLAssign(best_candidate.xlog_location, nodes[i].xlog_location);
best_candidate.xlog_location.xrecoff = nodes[i].xlog_location.xrecoff;
best_candidate.is_ready = nodes[i].is_ready; best_candidate.is_ready = nodes[i].is_ready;
best_candidate.is_witness = nodes[i].is_witness; best_candidate.is_witness = nodes[i].is_witness;
find_best = true; find_best = true;
@@ -864,8 +879,7 @@ do_failover(void)
if (XLByteLT(best_candidate.xlog_location, nodes[i].xlog_location)) if (XLByteLT(best_candidate.xlog_location, nodes[i].xlog_location))
{ {
best_candidate.nodeId = nodes[i].nodeId; best_candidate.nodeId = nodes[i].nodeId;
best_candidate.xlog_location.xlogid = nodes[i].xlog_location.xlogid; XLAssign(best_candidate.xlog_location, nodes[i].xlog_location);
best_candidate.xlog_location.xrecoff = nodes[i].xlog_location.xrecoff;
best_candidate.is_ready = nodes[i].is_ready; best_candidate.is_ready = nodes[i].is_ready;
best_candidate.is_witness = nodes[i].is_witness; best_candidate.is_witness = nodes[i].is_witness;
} }