mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-23 07:06:30 +00:00
Add optional check for unsupported future PostgreSQL releases
This is for backbranches to prevent them running against newer PostgreSQL versions with which they are not compatible, for example 4.4.x with PostgreSQL 12 and later.
This commit is contained in:
@@ -1000,6 +1000,9 @@ _do_create_recovery_conf(void)
|
||||
/* check connection */
|
||||
source_conn = establish_db_connection_by_params(&source_conninfo, true);
|
||||
|
||||
/* Verify that source is a supported server version */
|
||||
(void) check_server_version(source_conn, "source node", true, NULL);
|
||||
|
||||
/* determine node for primary_conninfo */
|
||||
|
||||
if (runtime_options.upstream_node_id != UNKNOWN_NODE_ID)
|
||||
|
||||
@@ -2834,15 +2834,25 @@ create_repmgr_extension(PGconn *conn)
|
||||
int
|
||||
check_server_version(PGconn *conn, char *server_type, bool exit_on_error, char *server_version_string)
|
||||
{
|
||||
int conn_server_version_num = get_server_version(conn, server_version_string);
|
||||
char version_string[MAXVERSIONSTR] = "";
|
||||
int conn_server_version_num = get_server_version(conn, version_string);
|
||||
|
||||
/* Copy the version string, if the caller wants it */
|
||||
if (server_version_string != NULL)
|
||||
strncpy(server_version_string, version_string, MAXVERSIONSTR);
|
||||
|
||||
if (conn_server_version_num < MIN_SUPPORTED_VERSION_NUM)
|
||||
{
|
||||
if (conn_server_version_num > 0)
|
||||
{
|
||||
log_error(_("%s requires %s to be PostgreSQL %s or later"),
|
||||
progname(),
|
||||
server_type,
|
||||
MIN_SUPPORTED_VERSION);
|
||||
log_detail(_("%s server version is %s"),
|
||||
server_type,
|
||||
version_string);
|
||||
}
|
||||
|
||||
if (exit_on_error == true)
|
||||
{
|
||||
@@ -2853,6 +2863,38 @@ check_server_version(PGconn *conn, char *server_type, bool exit_on_error, char *
|
||||
return UNKNOWN_SERVER_VERSION_NUM;
|
||||
}
|
||||
|
||||
/*
|
||||
* If it's clear a particular repmgr feature branch won't be able to support
|
||||
* PostgreSQL from a particular PostgreSQL release onwards (e.g. 4.4 with PostgreSQL
|
||||
* 12 and later due to recovery.conf removal), set MAX_UNSUPPORTED_VERSION and
|
||||
* MAX_UNSUPPORTED_VERSION_NUM in "repmgr.h" to define the first PostgreSQL
|
||||
* version which can't be suppored.
|
||||
*/
|
||||
#ifdef MAX_UNSUPPORTED_VERSION_NUM
|
||||
if (conn_server_version_num >= MAX_UNSUPPORTED_VERSION_NUM)
|
||||
{
|
||||
if (conn_server_version_num > 0)
|
||||
{
|
||||
log_error(_("%s %s does not support PostgreSQL %s or later"),
|
||||
progname(),
|
||||
REPMGR_VERSION,
|
||||
MAX_UNSUPPORTED_VERSION);
|
||||
log_detail(_("%s server version is %s"),
|
||||
server_type,
|
||||
version_string);
|
||||
log_hint(_("For details of supported versions see: https://repmgr.org/docs/current/install-requirements.html#INSTALL-COMPATIBILITY-MATRIX"));
|
||||
}
|
||||
|
||||
if (exit_on_error == true)
|
||||
{
|
||||
PQfinish(conn);
|
||||
exit(ERR_BAD_CONFIG);
|
||||
}
|
||||
|
||||
return UNKNOWN_SERVER_VERSION_NUM;
|
||||
}
|
||||
#endif
|
||||
|
||||
return conn_server_version_num;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user