From 99dae5cdcb6830a730958606c2fe33ffc66c34e1 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Tue, 27 Jan 2015 15:32:13 +0900 Subject: [PATCH] Function `is_witness()` no longer required Node type can be extracted directly from the metadata --- dbutils.c | 32 -------------------------------- dbutils.h | 1 - 2 files changed, 33 deletions(-) diff --git a/dbutils.c b/dbutils.c index fd7b554d..515ade7c 100644 --- a/dbutils.c +++ b/dbutils.c @@ -138,38 +138,6 @@ is_standby(PGconn *conn) } -int -is_witness(PGconn *conn, char *cluster, int node_id) -{ - PGresult *res; - int result = 0; - char sqlquery[QUERY_STR_LEN]; - - // ZZZ witness - sqlquery_snprintf(sqlquery, - "SELECT TRUE " - " FROM %s.repl_nodes " - " WHERE cluster = '%s' " - " AND id = %d " - " AND type = 'witness' ", - get_repmgr_schema_quoted(conn), - cluster, - node_id); - - res = PQexec(conn, sqlquery); - if (PQresultStatus(res) != PGRES_TUPLES_OK) - { - log_err(_("Can't query server mode: %s"), PQerrorMessage(conn)); - result = -1; - } - else if (PQntuples(res) == 1 && strcmp(PQgetvalue(res, 0, 0), "t") == 0) - result = 1; - - PQclear(res); - return result; -} - - /* check the PQStatus and try to 'select 1' to confirm good connection */ bool is_pgup(PGconn *conn, int timeout) diff --git a/dbutils.h b/dbutils.h index e9ab4535..dfd4115d 100644 --- a/dbutils.h +++ b/dbutils.h @@ -30,7 +30,6 @@ PGconn *establish_db_connection_by_params(const char *keywords[], const bool exit_on_error); bool check_cluster_schema(PGconn *conn); int is_standby(PGconn *conn); -int is_witness(PGconn *conn,char *cluster, int node_id); bool is_pgup(PGconn *conn, int timeout); int get_primary_node_id(PGconn *conn, char *cluster); int get_server_version(PGconn *conn, char *server_version);