diff --git a/dbutils.c b/dbutils.c index c637c99a..4f3bb84b 100644 --- a/dbutils.c +++ b/dbutils.c @@ -1823,6 +1823,30 @@ get_timeline_history(PGconn *repl_conn, TimeLineID tli) } +pid_t +get_wal_receiver_pid(PGconn *conn) +{ + PGresult *res = NULL; + pid_t wal_receiver_pid = UNKNOWN_PID; + + res = PQexec(conn, "SELECT repmgr.get_wal_receiver_pid()"); + + if (PQresultStatus(res) != PGRES_TUPLES_OK) + { + log_error(_("unable to execute \"SELECT repmgr.get_wal_receiver_pid()\"")); + log_detail("%s", PQerrorMessage(conn)); + } + else if (!PQgetisnull(res, 0, 0)) + { + wal_receiver_pid = atoi(PQgetvalue(res, 0, 0)); + } + + PQclear(res); + + return wal_receiver_pid; +} + + /* =============================== */ /* user/role information functions */ /* =============================== */ @@ -2249,29 +2273,6 @@ repmgrd_pause(PGconn *conn, bool pause) return success; } -pid_t -get_wal_receiver_pid(PGconn *conn) -{ - PGresult *res = NULL; - pid_t wal_receiver_pid = UNKNOWN_PID; - - res = PQexec(conn, "SELECT repmgr.get_wal_receiver_pid()"); - - if (PQresultStatus(res) != PGRES_TUPLES_OK) - { - log_error(_("unable to execute \"SELECT repmgr.get_wal_receiver_pid()\"")); - log_detail("%s", PQerrorMessage(conn)); - } - else if (!PQgetisnull(res, 0, 0)) - { - wal_receiver_pid = atoi(PQgetvalue(res, 0, 0)); - } - - PQclear(res); - - return wal_receiver_pid; -} - int repmgrd_get_upstream_node_id(PGconn *conn) diff --git a/dbutils.h b/dbutils.h index f5ee6ab1..35387239 100644 --- a/dbutils.h +++ b/dbutils.h @@ -450,6 +450,7 @@ int get_ready_archive_files(PGconn *conn, const char *data_directory); bool identify_system(PGconn *repl_conn, t_system_identification *identification); uint64 system_identifier(PGconn *conn); TimeLineHistoryEntry *get_timeline_history(PGconn *repl_conn, TimeLineID tli); +pid_t get_wal_receiver_pid(PGconn *conn); /* user/role information functions */ bool can_execute_pg_promote(PGconn *conn); @@ -467,7 +468,6 @@ pid_t repmgrd_get_pid(PGconn *conn); bool repmgrd_is_running(PGconn *conn); bool repmgrd_is_paused(PGconn *conn); bool repmgrd_pause(PGconn *conn, bool pause); -pid_t get_wal_receiver_pid(PGconn *conn); int repmgrd_get_upstream_node_id(PGconn *conn); bool repmgrd_set_upstream_node_id(PGconn *conn, int node_id);