Use bdr.bdr_is_active_in_db() when checking for BDR presence

This commit is contained in:
Ian Barwick
2017-07-24 19:09:09 +09:00
parent d3c2a0f505
commit 93c35618a2

View File

@@ -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;
}