From 36d94c88ac9ad82e987995a565a86dc770e440d0 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Tue, 27 Jan 2015 16:28:17 +0900 Subject: [PATCH] Handle empty result set Should never happen, but just in case.` --- dbutils.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dbutils.c b/dbutils.c index 515ade7c..f8f48df4 100644 --- a/dbutils.c +++ b/dbutils.c @@ -448,6 +448,13 @@ get_upstream_connection(PGconn *standby_conn, char *cluster, int node_id, return NULL; } + if(!PQntuples(res)) + { + log_notice(_("No upstream server record found")); + PQclear(res); + return NULL; + } + strncpy(upstream_conninfo, PQgetvalue(res, 0, 0), MAXCONNINFO); if(upstream_node_id_ptr != NULL)