mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-26 00:26:30 +00:00
keep naming consistent
This commit is contained in:
committed by
Jaime Casanova
parent
c23e5858f2
commit
16da2f48c2
35
repmgr.c
35
repmgr.c
@@ -2324,13 +2324,14 @@ static bool
|
|||||||
copy_configuration(PGconn *masterconn, PGconn *witnessconn)
|
copy_configuration(PGconn *masterconn, PGconn *witnessconn)
|
||||||
{
|
{
|
||||||
char sqlquery[MAXLEN];
|
char sqlquery[MAXLEN];
|
||||||
PGresult *res, *res_witness;
|
PGresult *res1;
|
||||||
|
PGresult *res2;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
sqlquery_snprintf(sqlquery, "TRUNCATE TABLE %s.repl_nodes", repmgr_schema);
|
sqlquery_snprintf(sqlquery, "TRUNCATE TABLE %s.repl_nodes", repmgr_schema);
|
||||||
log_debug("copy_configuration: %s\n", sqlquery);
|
log_debug("copy_configuration: %s\n", sqlquery);
|
||||||
res = PQexec(witnessconn, sqlquery);
|
res1 = PQexec(witnessconn, sqlquery);
|
||||||
if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
|
if (!res1 || PQresultStatus(res1) != PGRES_COMMAND_OK)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Cannot clean node details in the witness, %s\n",
|
fprintf(stderr, "Cannot clean node details in the witness, %s\n",
|
||||||
PQerrorMessage(witnessconn));
|
PQerrorMessage(witnessconn));
|
||||||
@@ -2339,35 +2340,35 @@ copy_configuration(PGconn *masterconn, PGconn *witnessconn)
|
|||||||
|
|
||||||
sqlquery_snprintf(sqlquery, "SELECT id, name, conninfo, priority, witness FROM %s.repl_nodes",
|
sqlquery_snprintf(sqlquery, "SELECT id, name, conninfo, priority, witness FROM %s.repl_nodes",
|
||||||
repmgr_schema);
|
repmgr_schema);
|
||||||
res = PQexec(masterconn, sqlquery);
|
res1 = PQexec(masterconn, sqlquery);
|
||||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
if (PQresultStatus(res1) != PGRES_TUPLES_OK)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Can't get configuration from master: %s\n",
|
fprintf(stderr, "Can't get configuration from master: %s\n",
|
||||||
PQerrorMessage(masterconn));
|
PQerrorMessage(masterconn));
|
||||||
PQclear(res);
|
PQclear(res1);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (i = 0; i < PQntuples(res); i++)
|
for (i = 0; i < PQntuples(res1); i++)
|
||||||
{
|
{
|
||||||
sqlquery_snprintf(sqlquery, "INSERT INTO %s.repl_nodes(id, cluster, name, conninfo, priority, witness) "
|
sqlquery_snprintf(sqlquery, "INSERT INTO %s.repl_nodes(id, cluster, name, conninfo, priority, witness) "
|
||||||
"VALUES (%d, '%s', '%s', '%s', %d, '%s')",
|
"VALUES (%d, '%s', '%s', '%s', %d, '%s')",
|
||||||
repmgr_schema, atoi(PQgetvalue(res, i, 0)),
|
repmgr_schema, atoi(PQgetvalue(res1, i, 0)),
|
||||||
options.cluster_name, PQgetvalue(res, i, 1),
|
options.cluster_name, PQgetvalue(res1, i, 1),
|
||||||
PQgetvalue(res, i, 2),
|
PQgetvalue(res1, i, 2),
|
||||||
atoi(PQgetvalue(res, i, 3)),
|
atoi(PQgetvalue(res1, i, 3)),
|
||||||
PQgetvalue(res, i, 4));
|
PQgetvalue(res1, i, 4));
|
||||||
|
|
||||||
res_witness = PQexec(witnessconn, sqlquery);
|
res2 = PQexec(witnessconn, sqlquery);
|
||||||
if (!res_witness || PQresultStatus(res_witness) != PGRES_COMMAND_OK)
|
if (!res2 || PQresultStatus(res2) != PGRES_COMMAND_OK)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Cannot copy configuration to witness, %s\n",
|
fprintf(stderr, "Cannot copy configuration to witness, %s\n",
|
||||||
PQerrorMessage(witnessconn));
|
PQerrorMessage(witnessconn));
|
||||||
PQclear(res_witness);
|
PQclear(res2);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
PQclear(res_witness);
|
PQclear(res2);
|
||||||
}
|
}
|
||||||
PQclear(res);
|
PQclear(res1);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user