diff --git a/repmgr.c b/repmgr.c index a7fb4d2a..5ec9d01d 100644 --- a/repmgr.c +++ b/repmgr.c @@ -2324,7 +2324,7 @@ static bool copy_configuration(PGconn *masterconn, PGconn *witnessconn) { char sqlquery[MAXLEN]; - PGresult *res; + PGresult *res, *res_witness; int i; sqlquery_snprintf(sqlquery, "TRUNCATE TABLE %s.repl_nodes", repmgr_schema); @@ -2357,15 +2357,17 @@ copy_configuration(PGconn *masterconn, PGconn *witnessconn) atoi(PQgetvalue(res, i, 3)), PQgetvalue(res, i, 4)); - res = PQexec(witnessconn, sqlquery); - if (!res || PQresultStatus(res) != PGRES_COMMAND_OK) + res_witness = PQexec(witnessconn, sqlquery); + if (!res_witness || PQresultStatus(res_witness) != PGRES_COMMAND_OK) { fprintf(stderr, "Cannot copy configuration to witness, %s\n", PQerrorMessage(witnessconn)); - PQclear(res); + PQclear(res_witness); return false; } + PQclear(res_witness); } + PQclear(res); return true; } diff --git a/repmgrd.c b/repmgrd.c index 84ffb2a2..ad4dcd9b 100644 --- a/repmgrd.c +++ b/repmgrd.c @@ -551,7 +551,7 @@ witness_monitor(void) sqlquery_snprintf(sqlquery, "INSERT INTO %s.repl_monitor " "VALUES(%d, %d, '%s'::timestamp with time zone, " - " pg_current_xlog_location(), null, " + " null, pg_current_xlog_location(), null, " " 0, 0)", repmgr_schema, primary_options.node, local_options.node, monitor_witness_timestamp);