mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-22 22:56:29 +00:00
Add additional query error logging
It's unlikely we'll get an error in these cases, but you never know. Also, with queries which return a list of node records, it's necessary to call _populate_node_records() even if the query fails, so a properly initalised, albeit empty list is returned to the caller.
This commit is contained in:
39
dbutils.c
39
dbutils.c
@@ -2115,8 +2115,14 @@ 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);
|
||||
@@ -2143,8 +2149,14 @@ get_downstream_node_records(PGconn *conn, int node_id, NodeInfoList *node_list)
|
||||
|
||||
res = PQexec(conn, query.data);
|
||||
|
||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||
{
|
||||
log_db_error(conn, query.data, _("get_downstream_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);
|
||||
@@ -2175,8 +2187,14 @@ get_active_sibling_node_records(PGconn *conn, int node_id, int upstream_node_id,
|
||||
|
||||
res = PQexec(conn, query.data);
|
||||
|
||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||
{
|
||||
log_db_error(conn, query.data, _("get_active_sibling_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);
|
||||
@@ -2202,8 +2220,14 @@ get_node_records_by_priority(PGconn *conn, NodeInfoList *node_list)
|
||||
|
||||
res = PQexec(conn, query.data);
|
||||
|
||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||
{
|
||||
log_db_error(conn, query.data, _("get_node_records_by_priority(): 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);
|
||||
@@ -2241,10 +2265,10 @@ get_all_node_records_with_upstream(PGconn *conn, NodeInfoList *node_list)
|
||||
log_db_error(conn, query.data, _("get_all_node_records_with_upstream(): unable to retrieve node records"));
|
||||
success = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_populate_node_records(res, node_list);
|
||||
}
|
||||
|
||||
|
||||
/* this will return an empty list if there was an error executing the query */
|
||||
_populate_node_records(res, node_list);
|
||||
|
||||
termPQExpBuffer(&query);
|
||||
PQclear(res);
|
||||
@@ -2283,10 +2307,9 @@ get_downstream_nodes_with_missing_slot(PGconn *conn, int this_node_id, NodeInfoL
|
||||
log_db_error(conn, query.data, _("get_downstream_nodes_with_missing_slot(): unable to retrieve node records"));
|
||||
success = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_populate_node_records(res, node_list);
|
||||
}
|
||||
|
||||
/* this will return an empty list if there was an error executing the query */
|
||||
_populate_node_records(res, node_list);
|
||||
|
||||
termPQExpBuffer(&query);
|
||||
PQclear(res);
|
||||
|
||||
Reference in New Issue
Block a user