repmgrd: always unset upstream node ID when monitoring a primary

This commit is contained in:
Ian Barwick
2019-04-12 12:26:39 +09:00
parent 1a344d488a
commit 27803f93ff
6 changed files with 74 additions and 1 deletions

View File

@@ -1965,6 +1965,36 @@ repmgrd_get_upstream_node_id(PGconn *conn)
return upstream_node_id;
}
bool
repmgrd_set_upstream_node_id(PGconn *conn, int node_id)
{
PQExpBufferData query;
PGresult *res = NULL;
bool success = true;
initPQExpBuffer(&query);
appendPQExpBuffer(&query,
" SELECT repmgr.set_upstream_node_id(%i) ",
node_id);
log_verbose(LOG_DEBUG, "repmgrd_set_upstream_node_id():\n %s", query.data);
res = PQexec(conn, query.data);
if (PQresultStatus(res) != PGRES_TUPLES_OK)
{
log_db_error(conn, query.data,
_("repmgrd_set_upstream_node_id(): unable to set upstream node ID (provided value: %i)"), node_id);
success = false;
}
termPQExpBuffer(&query);
PQclear(res);
return success;
}
/* ================ */
/* result functions */
/* ================ */