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:
Ian Barwick
2014-12-29 15:52:53 +09:00
parent f94626bf7b
commit 8b69b1e16f
4 changed files with 27 additions and 17 deletions

View File

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