mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-22 22:56:29 +00:00
Move function parse_repmgr_version() to a more appropriate location
This commit is contained in:
@@ -260,5 +260,6 @@ extern void drop_replication_slot_if_exists(PGconn *conn, int node_id, char *slo
|
||||
extern bool check_node_can_attach(TimeLineID local_tli, XLogRecPtr local_xlogpos, PGconn *follow_target_conn, t_node_info *follow_target_node_record, bool is_rejoin);
|
||||
extern void check_shared_library(PGconn *conn);
|
||||
extern bool is_repmgrd_running(PGconn *conn);
|
||||
extern int parse_repmgr_version(const char *version_string);
|
||||
|
||||
#endif /* _REPMGR_CLIENT_GLOBAL_H_ */
|
||||
|
||||
@@ -3892,3 +3892,44 @@ is_repmgrd_running(PGconn *conn)
|
||||
|
||||
return is_running;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parse the string returned by "repmgr --version", e.g. "repmgr 4.1.2",
|
||||
* and return it as a version integer (e.g. 40102).
|
||||
*
|
||||
* This is required for backwards compatibility as versions prior to
|
||||
* 4.3 do not have the --version-number option.
|
||||
*/
|
||||
int
|
||||
parse_repmgr_version(const char *version_string)
|
||||
{
|
||||
int series, major, minor;
|
||||
int version_integer = UNKNOWN_REPMGR_VERSION_NUM;
|
||||
PQExpBufferData sscanf_string;
|
||||
|
||||
initPQExpBuffer(&sscanf_string);
|
||||
|
||||
appendPQExpBuffer(&sscanf_string, "%s ",
|
||||
progname());
|
||||
appendPQExpBufferStr(&sscanf_string, "%i.%i.%i");
|
||||
|
||||
if (sscanf(version_string, sscanf_string.data, &series, &major, &minor) == 3)
|
||||
{
|
||||
version_integer = (series * 10000) + (major * 100) + minor;
|
||||
}
|
||||
else
|
||||
{
|
||||
resetPQExpBuffer(&sscanf_string);
|
||||
appendPQExpBuffer(&sscanf_string, "%s ",
|
||||
progname());
|
||||
appendPQExpBufferStr(&sscanf_string, "%i.%i");
|
||||
|
||||
if (sscanf(version_string, "repmgr %i.%i", &series, &major) == 2)
|
||||
{
|
||||
version_integer = (series * 10000) + (major * 100);
|
||||
}
|
||||
}
|
||||
|
||||
return version_integer;
|
||||
}
|
||||
|
||||
39
sysutils.c
39
sysutils.c
@@ -373,42 +373,3 @@ enable_wal_receiver(PGconn *conn, bool wait_startup)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parse the string returned by "repmgr --version", e.g. "repmgr 4.1.2",
|
||||
* and return it as a version integer (e.g. 40102).
|
||||
*
|
||||
* This is required for backwards compatibility as versions prior to
|
||||
* 4.3 do not have the --version-number option.
|
||||
*/
|
||||
int
|
||||
parse_repmgr_version(const char *version_string)
|
||||
{
|
||||
int series, major, minor;
|
||||
int version_integer = UNKNOWN_REPMGR_VERSION_NUM;
|
||||
PQExpBufferData sscanf_string;
|
||||
|
||||
initPQExpBuffer(&sscanf_string);
|
||||
|
||||
appendPQExpBuffer(&sscanf_string, "%s ",
|
||||
progname());
|
||||
appendPQExpBufferStr(&sscanf_string, "%i.%i.%i");
|
||||
|
||||
if (sscanf(version_string, sscanf_string.data, &series, &major, &minor) == 3)
|
||||
{
|
||||
version_integer = (series * 10000) + (major * 100) + minor;
|
||||
}
|
||||
else
|
||||
{
|
||||
resetPQExpBuffer(&sscanf_string);
|
||||
appendPQExpBuffer(&sscanf_string, "%s ",
|
||||
progname());
|
||||
appendPQExpBufferStr(&sscanf_string, "%i.%i");
|
||||
|
||||
if (sscanf(version_string, "repmgr %i.%i", &series, &major) == 2)
|
||||
{
|
||||
version_integer = (series * 10000) + (major * 100);
|
||||
}
|
||||
}
|
||||
|
||||
return version_integer;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,4 @@ extern bool remote_command(const char *host, const char *user, const char *comma
|
||||
extern pid_t disable_wal_receiver(PGconn *conn);
|
||||
extern pid_t enable_wal_receiver(PGconn *conn, bool wait_startup);
|
||||
|
||||
extern int parse_repmgr_version(const char *version_string);
|
||||
|
||||
#endif /* _SYSUTILS_H_ */
|
||||
|
||||
Reference in New Issue
Block a user