mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-26 08:36:30 +00:00
repmgr: fix --replication-user option when using conninfo string
In "standby clone", if a conninfo string was provided, this was passed as-is to pg_basebackup - rewrite conninfo string to include the value passed with --replication-user, if provided.
This commit is contained in:
4
HISTORY
4
HISTORY
@@ -1,3 +1,7 @@
|
|||||||
|
3.3.2 2017-05-
|
||||||
|
repmgr: ensure --replication-user option is honoured when passing database
|
||||||
|
connection parameters as a conninfo string (Ian)
|
||||||
|
|
||||||
3.3.1 2017-03-
|
3.3.1 2017-03-
|
||||||
repmgrd: prevent invalid apply lag value being written to the
|
repmgrd: prevent invalid apply lag value being written to the
|
||||||
monitoring table (Ian)
|
monitoring table (Ian)
|
||||||
|
|||||||
53
repmgr.c
53
repmgr.c
@@ -158,6 +158,7 @@ static void param_set(t_conninfo_param_list *param_list, const char *param, cons
|
|||||||
static char *param_get(t_conninfo_param_list *param_list, const char *param);
|
static char *param_get(t_conninfo_param_list *param_list, const char *param);
|
||||||
static bool parse_conninfo_string(const char *conninfo_str, t_conninfo_param_list *param_list, char *errmsg, bool ignore_application_name);
|
static bool parse_conninfo_string(const char *conninfo_str, t_conninfo_param_list *param_list, char *errmsg, bool ignore_application_name);
|
||||||
static void conn_to_param_list(PGconn *conn, t_conninfo_param_list *param_list);
|
static void conn_to_param_list(PGconn *conn, t_conninfo_param_list *param_list);
|
||||||
|
static char *param_list_to_string(t_conninfo_param_list *param_list);
|
||||||
static void parse_pg_basebackup_options(const char *pg_basebackup_options, t_basebackup_options *backup_options);
|
static void parse_pg_basebackup_options(const char *pg_basebackup_options, t_basebackup_options *backup_options);
|
||||||
|
|
||||||
static void config_file_list_init(t_configfile_list *list, int max_size);
|
static void config_file_list_init(t_configfile_list *list, int max_size);
|
||||||
@@ -7033,7 +7034,22 @@ run_basebackup(const char *data_dir, int server_version)
|
|||||||
*/
|
*/
|
||||||
if (runtime_options.conninfo_provided == true)
|
if (runtime_options.conninfo_provided == true)
|
||||||
{
|
{
|
||||||
appendPQExpBuffer(¶ms, " -d '%s'", runtime_options.dbname);
|
t_conninfo_param_list conninfo;
|
||||||
|
char *conninfo_str;
|
||||||
|
|
||||||
|
initialize_conninfo_params(&conninfo, false);
|
||||||
|
|
||||||
|
/* string will already have been parsed */
|
||||||
|
(void) parse_conninfo_string(runtime_options.dbname, &conninfo, NULL, false);
|
||||||
|
|
||||||
|
if (*runtime_options.replication_user)
|
||||||
|
param_set(&conninfo, "user", runtime_options.replication_user);
|
||||||
|
|
||||||
|
conninfo_str = param_list_to_string(&conninfo);
|
||||||
|
|
||||||
|
appendPQExpBuffer(¶ms, " -d '%s'", conninfo_str);
|
||||||
|
|
||||||
|
pfree(conninfo_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -8699,6 +8715,41 @@ conn_to_param_list(PGconn *conn, t_conninfo_param_list *param_list)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static char *
|
||||||
|
param_list_to_string(t_conninfo_param_list *param_list)
|
||||||
|
{
|
||||||
|
int c;
|
||||||
|
PQExpBufferData conninfo_buf;
|
||||||
|
char *conninfo_str;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
initPQExpBuffer(&conninfo_buf);
|
||||||
|
|
||||||
|
for (c = 0; c < param_list->size && param_list->keywords[c] != NULL; c++)
|
||||||
|
{
|
||||||
|
if (param_list->values[c] != NULL && param_list->values[c][0] != '\0')
|
||||||
|
{
|
||||||
|
if (c > 0)
|
||||||
|
appendPQExpBufferChar(&conninfo_buf, ' ');
|
||||||
|
|
||||||
|
appendPQExpBuffer(&conninfo_buf,
|
||||||
|
"%s=%s",
|
||||||
|
param_list->keywords[c],
|
||||||
|
param_list->values[c]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
len = strlen(conninfo_buf.data) + 1;
|
||||||
|
conninfo_str = pg_malloc0(len);
|
||||||
|
|
||||||
|
strncpy(conninfo_str, conninfo_buf.data, len);
|
||||||
|
|
||||||
|
termPQExpBuffer(&conninfo_buf);
|
||||||
|
|
||||||
|
return conninfo_str;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
parse_pg_basebackup_options(const char *pg_basebackup_options, t_basebackup_options *backup_options)
|
parse_pg_basebackup_options(const char *pg_basebackup_options, t_basebackup_options *backup_options)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user