mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-25 08:06:29 +00:00
repmgr: truncate version string if necessary
Some distributions may add extra information to PG_VERSION after the actual version number (e.g. "10.4 (Debian 10.4-2.pgdg90+1)"), so copy the version number string up until the first space is found. GitHub #490.
This commit is contained in:
23
dbutils.c
23
dbutils.c
@@ -1095,7 +1095,28 @@ get_server_version(PGconn *conn, char *server_version)
|
||||
}
|
||||
|
||||
if (server_version != NULL)
|
||||
strncpy(server_version, PQgetvalue(res, 0, 1), MAXVERSIONSTR);
|
||||
{
|
||||
char server_version_buf[MAXVERSIONSTR];
|
||||
int i;
|
||||
|
||||
memset(server_version_buf, 0, MAXVERSIONSTR);
|
||||
|
||||
/*
|
||||
* Some distributions may add extra info after the actual version number,
|
||||
* e.g. "10.4 (Debian 10.4-2.pgdg90+1)", so copy everything up until the
|
||||
* first space.
|
||||
*/
|
||||
|
||||
strncpy(server_version_buf, PQgetvalue(res, 0, 1), MAXVERSIONSTR);
|
||||
|
||||
for (i = 0; i < MAXVERSIONSTR; i++)
|
||||
{
|
||||
if (server_version_buf[i] == ' ')
|
||||
break;
|
||||
|
||||
*server_version++ = server_version_buf[i];
|
||||
}
|
||||
}
|
||||
|
||||
server_version_num = atoi(PQgetvalue(res, 0, 0));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user