repmgr: miscelleanous code cleanup

This commit is contained in:
Ian Barwick
2016-12-26 09:57:58 +09:00
parent e88a8a9708
commit a336d22bd9
2 changed files with 23 additions and 12 deletions

View File

@@ -1436,10 +1436,11 @@ create_event_record(PGconn *conn, t_configuration_options *options, int node_id,
bool success = true;
struct tm ts;
/* Only attempt to write a record if a connection handle was provided.
Also check that the repmgr schema has been properly intialised - if
not it means no configuration file was provided, which can happen with
e.g. `repmgr standby clone`, and we won't know which schema to write to.
/*
* Only attempt to write a record if a connection handle was provided.
* Also check that the repmgr schema has been properly initialised - if
* not it means no configuration file was provided, which can happen with
* e.g. `repmgr standby clone`, and we won't know which schema to write to.
*/
if (conn != NULL && strcmp(repmgr_schema, DEFAULT_REPMGR_SCHEMA_PREFIX) != 0)
{

View File

@@ -1841,7 +1841,15 @@ do_cluster_cleanup(void)
sqlquery_snprintf(sqlquery, "VACUUM %s.repl_monitor", get_repmgr_schema_quoted(master_conn));
res = PQexec(master_conn, sqlquery);
/* XXX There is any need to check this VACUUM happens without problems? */
if (PQresultStatus(res) != PGRES_COMMAND_OK)
{
/*
* Unlikely to happen and not a problem per-se, but we'll issue a warning
* just in case
*/
log_warning(_("Unable to vacuum table %s.repl_monitor"), get_repmgr_schema_quoted(master_conn));
}
PQclear(res);
PQfinish(master_conn);
@@ -2521,17 +2529,19 @@ get_tablespace_data(PGconn *upstream_conn, TablespaceDataList *list)
res = PQexec(upstream_conn, sqlquery);
if (PQresultStatus(res) != PGRES_TUPLES_OK)
{
log_err(_("unable to execute tablespace query: %s\n"),
PQerrorMessage(upstream_conn));
{
log_err(_("unable to execute tablespace query: %s\n"),
PQerrorMessage(upstream_conn));
PQclear(res);
PQclear(res);
return ERR_DB_QUERY;
}
return ERR_DB_QUERY;
}
for (i = 0; i < PQntuples(res); i++)
tablespace_data_append(list, PQgetvalue(res, i, 0), PQgetvalue(res, i, 1),
tablespace_data_append(list,
PQgetvalue(res, i, 0),
PQgetvalue(res, i, 1),
PQgetvalue(res, i, 2));
PQclear(res);