mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-24 23:56:29 +00:00
Optionally retrieve server_version string as well
In a couple of places we'll need to report the human-readable version number
This commit is contained in:
10
dbutils.c
10
dbutils.c
@@ -181,20 +181,24 @@ is_pgup(PGconn *conn, int timeout)
|
||||
* Return the server version number for the connection provided
|
||||
*/
|
||||
int
|
||||
get_server_version_num(PGconn *conn)
|
||||
get_server_version(PGconn *conn, char *server_version)
|
||||
{
|
||||
PGresult *res;
|
||||
res = PQexec(conn,
|
||||
"SELECT current_setting('server_version_num')");
|
||||
"SELECT current_setting('server_version_num'), "
|
||||
"current_setting('server_version')");
|
||||
|
||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||
{
|
||||
log_err(_("Unable to determine server verson number:\n%s"),
|
||||
log_err(_("Unable to determine server version number:\n%s"),
|
||||
PQerrorMessage(conn));
|
||||
PQclear(res);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(server_version != NULL)
|
||||
strcpy(server_version, PQgetvalue(res, 0, 0));
|
||||
|
||||
return atoi(PQgetvalue(res, 0, 0));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user