mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-22 22:56:29 +00:00
Disable non-BDR functions for BDR-only buils
This commit is contained in:
25
repmgr.c
25
repmgr.c
@@ -177,6 +177,7 @@ repmgr_shmem_startup(void)
|
|||||||
Datum
|
Datum
|
||||||
request_vote(PG_FUNCTION_ARGS)
|
request_vote(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
|
#ifndef BDR_ONLY
|
||||||
StringInfoData query;
|
StringInfoData query;
|
||||||
XLogRecPtr our_lsn = InvalidXLogRecPtr;
|
XLogRecPtr our_lsn = InvalidXLogRecPtr;
|
||||||
|
|
||||||
@@ -235,6 +236,9 @@ request_vote(PG_FUNCTION_ARGS)
|
|||||||
// should we free "query" here?
|
// should we free "query" here?
|
||||||
|
|
||||||
PG_RETURN_LSN(our_lsn);
|
PG_RETURN_LSN(our_lsn);
|
||||||
|
#else
|
||||||
|
PG_RETURN(InvalidOid);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -242,6 +246,7 @@ request_vote(PG_FUNCTION_ARGS)
|
|||||||
Datum
|
Datum
|
||||||
get_voting_status(PG_FUNCTION_ARGS)
|
get_voting_status(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
|
#ifndef BDR_ONLY
|
||||||
NodeVotingStatus voting_status;
|
NodeVotingStatus voting_status;
|
||||||
|
|
||||||
LWLockAcquire(shared_state->lock, LW_SHARED);
|
LWLockAcquire(shared_state->lock, LW_SHARED);
|
||||||
@@ -249,11 +254,15 @@ get_voting_status(PG_FUNCTION_ARGS)
|
|||||||
LWLockRelease(shared_state->lock);
|
LWLockRelease(shared_state->lock);
|
||||||
|
|
||||||
PG_RETURN_INT32(voting_status);
|
PG_RETURN_INT32(voting_status);
|
||||||
|
#else
|
||||||
|
PG_RETURN_INT32(VS_UNKNOWN);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Datum
|
Datum
|
||||||
set_voting_status_initiated(PG_FUNCTION_ARGS)
|
set_voting_status_initiated(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
|
#ifndef BDR_ONLY
|
||||||
int electoral_term;
|
int electoral_term;
|
||||||
|
|
||||||
LWLockAcquire(shared_state->lock, LW_SHARED);
|
LWLockAcquire(shared_state->lock, LW_SHARED);
|
||||||
@@ -266,11 +275,15 @@ set_voting_status_initiated(PG_FUNCTION_ARGS)
|
|||||||
elog(INFO, "setting voting term to %i", electoral_term);
|
elog(INFO, "setting voting term to %i", electoral_term);
|
||||||
|
|
||||||
PG_RETURN_INT32(electoral_term);
|
PG_RETURN_INT32(electoral_term);
|
||||||
|
#else
|
||||||
|
PG_RETURN_INT32(-1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Datum
|
Datum
|
||||||
other_node_is_candidate(PG_FUNCTION_ARGS)
|
other_node_is_candidate(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
|
#ifndef BDR_ONLY
|
||||||
int requesting_node_id = PG_GETARG_INT32(0);
|
int requesting_node_id = PG_GETARG_INT32(0);
|
||||||
int electoral_term = PG_GETARG_INT32(1);
|
int electoral_term = PG_GETARG_INT32(1);
|
||||||
|
|
||||||
@@ -292,11 +305,15 @@ other_node_is_candidate(PG_FUNCTION_ARGS)
|
|||||||
|
|
||||||
elog(INFO, "node %i is candidate", requesting_node_id);
|
elog(INFO, "node %i is candidate", requesting_node_id);
|
||||||
PG_RETURN_BOOL(true);
|
PG_RETURN_BOOL(true);
|
||||||
|
#else
|
||||||
|
PG_RETURN_BOOL(false);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Datum
|
Datum
|
||||||
notify_follow_primary(PG_FUNCTION_ARGS)
|
notify_follow_primary(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
|
#ifndef BDR_ONLY
|
||||||
int primary_node_id = PG_GETARG_INT32(0);
|
int primary_node_id = PG_GETARG_INT32(0);
|
||||||
|
|
||||||
elog(INFO, "received notification to follow node %i", primary_node_id);
|
elog(INFO, "received notification to follow node %i", primary_node_id);
|
||||||
@@ -307,7 +324,7 @@ notify_follow_primary(PG_FUNCTION_ARGS)
|
|||||||
shared_state->candidate_node_id = primary_node_id;
|
shared_state->candidate_node_id = primary_node_id;
|
||||||
shared_state->follow_new_primary = true;
|
shared_state->follow_new_primary = true;
|
||||||
LWLockRelease(shared_state->lock);
|
LWLockRelease(shared_state->lock);
|
||||||
|
#endif
|
||||||
PG_RETURN_VOID();
|
PG_RETURN_VOID();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -317,13 +334,14 @@ get_new_primary(PG_FUNCTION_ARGS)
|
|||||||
{
|
{
|
||||||
int new_primary_node_id = UNKNOWN_NODE_ID;
|
int new_primary_node_id = UNKNOWN_NODE_ID;
|
||||||
|
|
||||||
|
#ifndef BDR_ONLY
|
||||||
LWLockAcquire(shared_state->lock, LW_SHARED);
|
LWLockAcquire(shared_state->lock, LW_SHARED);
|
||||||
|
|
||||||
if (shared_state->follow_new_primary == true)
|
if (shared_state->follow_new_primary == true)
|
||||||
new_primary_node_id = shared_state->candidate_node_id;
|
new_primary_node_id = shared_state->candidate_node_id;
|
||||||
|
|
||||||
LWLockRelease(shared_state->lock);
|
LWLockRelease(shared_state->lock);
|
||||||
|
#endif
|
||||||
PG_RETURN_INT32(new_primary_node_id);
|
PG_RETURN_INT32(new_primary_node_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -331,6 +349,7 @@ get_new_primary(PG_FUNCTION_ARGS)
|
|||||||
Datum
|
Datum
|
||||||
reset_voting_status(PG_FUNCTION_ARGS)
|
reset_voting_status(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
|
#ifndef BDR_ONLY
|
||||||
LWLockAcquire(shared_state->lock, LW_SHARED);
|
LWLockAcquire(shared_state->lock, LW_SHARED);
|
||||||
|
|
||||||
shared_state->voting_status = VS_NO_VOTE;
|
shared_state->voting_status = VS_NO_VOTE;
|
||||||
@@ -338,7 +357,7 @@ reset_voting_status(PG_FUNCTION_ARGS)
|
|||||||
shared_state->follow_new_primary = false;
|
shared_state->follow_new_primary = false;
|
||||||
|
|
||||||
LWLockRelease(shared_state->lock);
|
LWLockRelease(shared_state->lock);
|
||||||
|
#endif
|
||||||
PG_RETURN_VOID();
|
PG_RETURN_VOID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user