mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-22 22:56:29 +00:00
Remove unneeded functions
This commit is contained in:
46
dbutils.c
46
dbutils.c
@@ -3774,52 +3774,6 @@ increment_current_term(PGconn *conn)
|
||||
}
|
||||
|
||||
|
||||
NodeVotingStatus
|
||||
get_voting_status(PGconn *conn)
|
||||
{
|
||||
PGresult *res = NULL;
|
||||
NodeVotingStatus voting_status = VS_UNKNOWN;
|
||||
|
||||
res = PQexec(conn, "SELECT repmgr.get_voting_status()");
|
||||
|
||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||
{
|
||||
log_error(_("unable to query repmgr.get_voting_status():\n %s"),
|
||||
PQerrorMessage(conn));
|
||||
PQclear(res);
|
||||
return VS_UNKNOWN;
|
||||
}
|
||||
|
||||
voting_status = atoi(PQgetvalue(res, 0, 0));
|
||||
|
||||
PQclear(res);
|
||||
return voting_status;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
set_voting_status_initiated(PGconn *conn, int electoral_term)
|
||||
{
|
||||
PQExpBufferData query;
|
||||
PGresult *res = NULL;
|
||||
|
||||
initPQExpBuffer(&query);
|
||||
|
||||
appendPQExpBuffer(&query,
|
||||
"SELECT repmgr.set_voting_status_initiated(%i)",
|
||||
electoral_term);
|
||||
|
||||
res = PQexec(conn, query.data);
|
||||
termPQExpBuffer(&query);
|
||||
|
||||
electoral_term = atoi(PQgetvalue(res, 0, 0));
|
||||
|
||||
PQclear(res);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
announce_candidature(PGconn *conn, t_node_info *this_node, t_node_info *other_node, int electoral_term)
|
||||
{
|
||||
|
||||
@@ -475,8 +475,6 @@ bool delete_monitoring_records(PGconn *primary_conn, int keep_history);
|
||||
/* node voting functions */
|
||||
int get_current_term(PGconn *conn);
|
||||
void increment_current_term(PGconn *conn);
|
||||
NodeVotingStatus get_voting_status(PGconn *conn);
|
||||
void set_voting_status_initiated(PGconn *conn, int electoral_term);
|
||||
bool announce_candidature(PGconn *conn, t_node_info *this_node, t_node_info *other_node, int electoral_term);
|
||||
void notify_follow_primary(PGconn *conn, int primary_node_id);
|
||||
bool get_new_primary(PGconn *conn, int *primary_node_id);
|
||||
|
||||
@@ -50,12 +50,6 @@ SELECT repmgr.get_new_primary();
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT repmgr.get_voting_status();
|
||||
get_voting_status
|
||||
-------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT repmgr.notify_follow_primary(-1);
|
||||
notify_follow_primary
|
||||
-----------------------
|
||||
@@ -68,54 +62,6 @@ SELECT repmgr.notify_follow_primary(NULL);
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT repmgr.other_node_is_candidate(-1,-1);
|
||||
other_node_is_candidate
|
||||
-------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT repmgr.other_node_is_candidate(-1,NULL);
|
||||
other_node_is_candidate
|
||||
-------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT repmgr.other_node_is_candidate(NULL,-1);
|
||||
other_node_is_candidate
|
||||
-------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT repmgr.other_node_is_candidate(NULL,NULL);
|
||||
other_node_is_candidate
|
||||
-------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT repmgr.request_vote(-1,-1);
|
||||
request_vote
|
||||
--------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT repmgr.request_vote(-1,NULL);
|
||||
request_vote
|
||||
--------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT repmgr.request_vote(NULL,-1);
|
||||
request_vote
|
||||
--------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT repmgr.request_vote(NULL,NULL);
|
||||
request_vote
|
||||
--------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT repmgr.reset_voting_status();
|
||||
reset_voting_status
|
||||
---------------------
|
||||
@@ -134,12 +80,6 @@ SELECT repmgr.set_local_node_id(NULL);
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT repmgr.set_voting_status_initiated();
|
||||
set_voting_status_initiated
|
||||
-----------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT repmgr.standby_get_last_updated();
|
||||
standby_get_last_updated
|
||||
--------------------------
|
||||
|
||||
@@ -123,11 +123,6 @@ CREATE FUNCTION standby_get_last_updated()
|
||||
|
||||
/* failover functions */
|
||||
|
||||
CREATE FUNCTION set_voting_status_initiated(INT)
|
||||
RETURNS VOID
|
||||
AS 'MODULE_PATHNAME', 'set_voting_status_initiated'
|
||||
LANGUAGE C STRICT;
|
||||
|
||||
CREATE FUNCTION notify_follow_primary(INT)
|
||||
RETURNS VOID
|
||||
AS 'MODULE_PATHNAME', 'notify_follow_primary'
|
||||
@@ -148,7 +143,6 @@ CREATE FUNCTION am_bdr_failover_handler(INT)
|
||||
AS 'MODULE_PATHNAME', 'am_bdr_failover_handler'
|
||||
LANGUAGE C STRICT;
|
||||
|
||||
|
||||
CREATE FUNCTION unset_bdr_failover_handler()
|
||||
RETURNS VOID
|
||||
AS 'MODULE_PATHNAME', 'unset_bdr_failover_handler'
|
||||
|
||||
@@ -133,11 +133,6 @@ CREATE FUNCTION standby_get_last_updated()
|
||||
|
||||
/* failover functions */
|
||||
|
||||
CREATE FUNCTION set_voting_status_initiated()
|
||||
RETURNS INT
|
||||
AS '$libdir/repmgr', 'set_voting_status_initiated'
|
||||
LANGUAGE C STRICT;
|
||||
|
||||
CREATE FUNCTION notify_follow_primary(INT)
|
||||
RETURNS VOID
|
||||
AS '$libdir/repmgr', 'notify_follow_primary'
|
||||
|
||||
39
repmgr.c
39
repmgr.c
@@ -97,9 +97,6 @@ PG_FUNCTION_INFO_V1(standby_set_last_updated);
|
||||
Datum standby_get_last_updated(PG_FUNCTION_ARGS);
|
||||
PG_FUNCTION_INFO_V1(standby_get_last_updated);
|
||||
|
||||
Datum set_voting_status_initiated(PG_FUNCTION_ARGS);
|
||||
PG_FUNCTION_INFO_V1(set_voting_status_initiated);
|
||||
|
||||
Datum notify_follow_primary(PG_FUNCTION_ARGS);
|
||||
PG_FUNCTION_INFO_V1(notify_follow_primary);
|
||||
|
||||
@@ -288,42 +285,6 @@ standby_get_last_updated(PG_FUNCTION_ARGS)
|
||||
/* ===================*/
|
||||
|
||||
|
||||
|
||||
Datum
|
||||
set_voting_status_initiated(PG_FUNCTION_ARGS)
|
||||
{
|
||||
#ifndef BDR_ONLY
|
||||
int electoral_term = -1;
|
||||
|
||||
if (!shared_state)
|
||||
PG_RETURN_VOID();
|
||||
|
||||
if (PG_ARGISNULL(0))
|
||||
PG_RETURN_VOID();
|
||||
|
||||
electoral_term = PG_GETARG_INT32(0);
|
||||
|
||||
LWLockAcquire(shared_state->lock, LW_SHARED);
|
||||
|
||||
/* only do something if local_node_id is initialised */
|
||||
if (shared_state->local_node_id != UNKNOWN_NODE_ID)
|
||||
{
|
||||
LWLockRelease(shared_state->lock);
|
||||
LWLockAcquire(shared_state->lock, LW_EXCLUSIVE);
|
||||
|
||||
shared_state->voting_status = VS_VOTE_INITIATED;
|
||||
shared_state->current_electoral_term = electoral_term;
|
||||
|
||||
elog(INFO, "setting voting term to %i", electoral_term);
|
||||
}
|
||||
|
||||
LWLockRelease(shared_state->lock);
|
||||
|
||||
#endif
|
||||
PG_RETURN_VOID();
|
||||
}
|
||||
|
||||
|
||||
Datum
|
||||
notify_follow_primary(PG_FUNCTION_ARGS)
|
||||
{
|
||||
|
||||
@@ -2395,14 +2395,6 @@ do_election(void)
|
||||
|
||||
local_node_info.last_wal_receive_lsn = InvalidXLogRecPtr;
|
||||
|
||||
/*
|
||||
* Here we mark ourselves as candidate, so any further vote requests are
|
||||
* rejected. However it's possible another node has done the same thing,
|
||||
* so when announcing ourselves as candidate to the other nodes, we'll
|
||||
* check for that and withdraw our candidature.
|
||||
*/
|
||||
set_voting_status_initiated(local_conn, electoral_term);
|
||||
|
||||
/* fast path if no other standbys (or witness) exists - normally win by default */
|
||||
if (standby_nodes.node_count == 0)
|
||||
{
|
||||
|
||||
@@ -20,21 +20,11 @@ SELECT * FROM repmgr.show_nodes;
|
||||
SELECT repmgr.am_bdr_failover_handler(-1);
|
||||
SELECT repmgr.am_bdr_failover_handler(NULL);
|
||||
SELECT repmgr.get_new_primary();
|
||||
SELECT repmgr.get_voting_status();
|
||||
SELECT repmgr.notify_follow_primary(-1);
|
||||
SELECT repmgr.notify_follow_primary(NULL);
|
||||
SELECT repmgr.other_node_is_candidate(-1,-1);
|
||||
SELECT repmgr.other_node_is_candidate(-1,NULL);
|
||||
SELECT repmgr.other_node_is_candidate(NULL,-1);
|
||||
SELECT repmgr.other_node_is_candidate(NULL,NULL);
|
||||
SELECT repmgr.request_vote(-1,-1);
|
||||
SELECT repmgr.request_vote(-1,NULL);
|
||||
SELECT repmgr.request_vote(NULL,-1);
|
||||
SELECT repmgr.request_vote(NULL,NULL);
|
||||
SELECT repmgr.reset_voting_status();
|
||||
SELECT repmgr.set_local_node_id(-1);
|
||||
SELECT repmgr.set_local_node_id(NULL);
|
||||
SELECT repmgr.set_voting_status_initiated();
|
||||
SELECT repmgr.standby_get_last_updated();
|
||||
SELECT repmgr.standby_set_last_updated();
|
||||
SELECT repmgr.unset_bdr_failover_handler();
|
||||
|
||||
Reference in New Issue
Block a user