mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-26 08:36:30 +00:00
get_all_node_records(): display any error encountered and return success status
In many cases we'll want to bail out with an error if the node list can't be retrieved for any reason. This saves some repetitive coding.
This commit is contained in:
23
dbutils.c
23
dbutils.c
@@ -2098,12 +2098,12 @@ _populate_node_records(PGresult *res, NodeInfoList *node_list)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
bool
|
||||
get_all_node_records(PGconn *conn, NodeInfoList *node_list)
|
||||
{
|
||||
PQExpBufferData query;
|
||||
PGresult *res = NULL;
|
||||
|
||||
bool success = true;
|
||||
initPQExpBuffer(&query);
|
||||
|
||||
appendPQExpBuffer(&query,
|
||||
@@ -2115,21 +2115,22 @@ get_all_node_records(PGconn *conn, NodeInfoList *node_list)
|
||||
|
||||
res = PQexec(conn, query.data);
|
||||
|
||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||
{
|
||||
log_db_error(conn, query.data, _("get_all_node_records(): unable to execute query"));
|
||||
}
|
||||
|
||||
termPQExpBuffer(&query);
|
||||
|
||||
/* this will return an empty list if there was an error executing the query */
|
||||
_populate_node_records(res, node_list);
|
||||
|
||||
PQclear(res);
|
||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||
{
|
||||
log_db_error(conn, query.data, _("get_all_node_records(): unable to execute query"));
|
||||
success = false;
|
||||
}
|
||||
|
||||
return;
|
||||
PQclear(res);
|
||||
termPQExpBuffer(&query);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
get_downstream_node_records(PGconn *conn, int node_id, NodeInfoList *node_list)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user