mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-24 23:56:29 +00:00
Store the replication user in repmgr.nodes
When creating recovery.conf outside of "repmgr standby clone", there was no way of knowing if a replication user had been explicitly provided with --replication-user, meaning the value of "primary_conninfo" would be set to the "conninfo" field of the node's upstream node record. We'll add an extra column to store the replication user for each node so it can be referenced at any time.
This commit is contained in:
37
dbutils.c
37
dbutils.c
@@ -1154,9 +1154,10 @@ _populate_node_record(PGresult *res, t_node_info *node_info, int row)
|
||||
|
||||
strncpy(node_info->node_name, PQgetvalue(res, row, 3), MAXLEN);
|
||||
strncpy(node_info->conninfo, PQgetvalue(res, row, 4), MAXLEN);
|
||||
strncpy(node_info->slot_name, PQgetvalue(res, row, 5), MAXLEN);
|
||||
node_info->priority = atoi(PQgetvalue(res, row, 6));
|
||||
node_info->active = atobool(PQgetvalue(res, row, 7));
|
||||
strncpy(node_info->repluser, PQgetvalue(res, row, 5), MAXLEN);
|
||||
strncpy(node_info->slot_name, PQgetvalue(res, row, 6), MAXLEN);
|
||||
node_info->priority = atoi(PQgetvalue(res, row, 7));
|
||||
node_info->active = atobool(PQgetvalue(res, row, 8));
|
||||
|
||||
/* Set remaining struct fields with default values */
|
||||
node_info->is_ready = false;
|
||||
@@ -1218,7 +1219,7 @@ get_node_record(PGconn *conn, int node_id, t_node_info *node_info)
|
||||
|
||||
initPQExpBuffer(&query);
|
||||
appendPQExpBuffer(&query,
|
||||
"SELECT node_id, type, upstream_node_id, node_name, conninfo, slot_name, priority, active"
|
||||
"SELECT node_id, type, upstream_node_id, node_name, conninfo, repluser, slot_name, priority, active"
|
||||
" FROM repmgr.nodes "
|
||||
" WHERE node_id = %i",
|
||||
node_id);
|
||||
@@ -1246,7 +1247,7 @@ get_node_record_by_name(PGconn *conn, const char *node_name, t_node_info *node_i
|
||||
initPQExpBuffer(&query);
|
||||
|
||||
appendPQExpBuffer(&query,
|
||||
"SELECT node_id, type, upstream_node_id, node_name, conninfo, slot_name, priority, active"
|
||||
"SELECT node_id, type, upstream_node_id, node_name, conninfo, repluser, slot_name, priority, active"
|
||||
" FROM repmgr.nodes "
|
||||
" WHERE node_name = '%s' ",
|
||||
node_name);
|
||||
@@ -1317,7 +1318,7 @@ get_downstream_node_records(PGconn *conn, int node_id, NodeInfoList *node_list)
|
||||
initPQExpBuffer(&query);
|
||||
|
||||
appendPQExpBuffer(&query,
|
||||
" SELECT node_id, type, upstream_node_id, node_name, conninfo, slot_name, priority, active"
|
||||
" SELECT node_id, type, upstream_node_id, node_name, conninfo, repluser, slot_name, priority, active"
|
||||
" FROM repmgr.nodes "
|
||||
" WHERE upstream_node_id = %i "
|
||||
"ORDER BY node_id ",
|
||||
@@ -1391,7 +1392,7 @@ _create_update_node_record(PGconn *conn, char *action, t_node_info *node_info)
|
||||
char slot_name[MAXLEN];
|
||||
char *slot_name_ptr = NULL;
|
||||
|
||||
int param_count = 8;
|
||||
int param_count = 9;
|
||||
const char *param_values[param_count];
|
||||
|
||||
PGresult *res;
|
||||
@@ -1423,10 +1424,11 @@ _create_update_node_record(PGconn *conn, char *action, t_node_info *node_info)
|
||||
param_values[1] = upstream_node_id_ptr;
|
||||
param_values[2] = node_info->node_name;
|
||||
param_values[3] = node_info->conninfo;
|
||||
param_values[4] = slot_name_ptr;
|
||||
param_values[5] = priority;
|
||||
param_values[6] = node_info->active == true ? "TRUE" : "FALSE";
|
||||
param_values[7] = node_id;
|
||||
param_values[4] = node_info->repluser;
|
||||
param_values[5] = slot_name_ptr;
|
||||
param_values[6] = priority;
|
||||
param_values[7] = node_info->active == true ? "TRUE" : "FALSE";
|
||||
param_values[8] = node_id;
|
||||
|
||||
initPQExpBuffer(&query);
|
||||
|
||||
@@ -1435,9 +1437,9 @@ _create_update_node_record(PGconn *conn, char *action, t_node_info *node_info)
|
||||
appendPQExpBuffer(&query,
|
||||
"INSERT INTO repmgr.nodes "
|
||||
" (node_id, type, upstream_node_id, "
|
||||
" node_name, conninfo, slot_name, "
|
||||
" node_name, conninfo, repluser, slot_name, "
|
||||
" priority, active) "
|
||||
"VALUES ($8, $1, $2, $3, $4, $5, $6, $7) ");
|
||||
"VALUES ($9, $1, $2, $3, $4, $5, $6, $7, $8) ");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1447,10 +1449,11 @@ _create_update_node_record(PGconn *conn, char *action, t_node_info *node_info)
|
||||
" upstream_node_id = $2, "
|
||||
" node_name = $3, "
|
||||
" conninfo = $4, "
|
||||
" slot_name = $5, "
|
||||
" priority = $6, "
|
||||
" active = $7 "
|
||||
" WHERE node_id = $8 ");
|
||||
" repluser = $5, "
|
||||
" slot_name = $7, "
|
||||
" priority = $7, "
|
||||
" active = $8 "
|
||||
" WHERE node_id = $9 ");
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user