From 28c5ac3d9106c39cf112c295a11559209d2c3ce7 Mon Sep 17 00:00:00 2001 From: Jaime Casanova Date: Tue, 26 Jul 2011 18:36:27 -0500 Subject: [PATCH] Make is_standby() and is_witness() work the same way, actually is_standby() can show the segmentation fault problem but for code clearity --- dbutils.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/dbutils.c b/dbutils.c index 668dd0dd..9e3defd2 100644 --- a/dbutils.c +++ b/dbutils.c @@ -73,7 +73,7 @@ bool is_standby(PGconn *conn) { PGresult *res; - bool result; + bool result = false; res = PQexec(conn, "SELECT pg_is_in_recovery()"); @@ -86,9 +86,7 @@ is_standby(PGconn *conn) exit(ERR_DB_QUERY); } - if (strcmp(PQgetvalue(res, 0, 0), "f") == 0) - result = false; - else + if (PQntuples(res) == 1 && strcmp(PQgetvalue(res, 0, 0), "t") == 0) result = true; PQclear(res);