From 93c35618a2a6295e23e0fbd2a2efd966b2d3b9d1 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Mon, 24 Jul 2017 19:09:09 +0900 Subject: [PATCH] Use bdr.bdr_is_active_in_db() when checking for BDR presence --- dbutils.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/dbutils.c b/dbutils.c index 5b3a3dc3..a2689b86 100644 --- a/dbutils.c +++ b/dbutils.c @@ -2920,7 +2920,6 @@ get_last_wal_receive_location(PGconn *conn) /* BDR functions */ /* ============= */ -/* possibly use bdr.bdr_is_active_in_db() ? */ bool is_bdr_db(PGconn *conn) { @@ -2948,6 +2947,30 @@ is_bdr_db(PGconn *conn) PQclear(res); + if (is_bdr_db == false) + { + log_warning(_("BDR extension is not available for this database")); + return is_bdr_db; + } + + initPQExpBuffer(&query); + + appendPQExpBuffer( + &query, + "SELECT bdr.bdr_is_active_in_db()"); + res = PQexec(conn, query.data); + termPQExpBuffer(&query); + + is_bdr_db = strcmp(PQgetvalue(res, 0, 0), "t") == 0 ? true : false; + + if (is_bdr_db == false) + { + log_warning(_("BDR extension available for this database, but the database is not configured for BDR")); + + } + PQclear(res); + + return is_bdr_db; }