mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-22 22:56: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:
1
HISTORY
1
HISTORY
@@ -1,5 +1,6 @@
|
||||
|
||||
4.1.1 2018-??-??
|
||||
repmgr: truncate version string, if necessary; GitHub #490 (Ian)
|
||||
repmgrd: ensure that sending SIGHUP always results in the log file
|
||||
being reopened; GitHub #485 (Ian)
|
||||
repmgrd: report version number *after* logger initialisation; GitHub #487 (Ian)
|
||||
|
||||
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