Have make_pg_path() output to a PQexpBuffer

Calling functions are all using one anyway, so there's no point keeping
static buffers around.
This commit is contained in:
Ian Barwick
2020-09-02 15:30:02 +09:00
parent 1f7ac843fd
commit c8e52e486f
4 changed files with 42 additions and 32 deletions

View File

@@ -2733,9 +2733,9 @@ do_node_rejoin(void)
}
else
{
appendPQExpBuffer(&command,
"%s -D ",
make_pg_path("pg_rewind"));
make_pg_path(&command, "pg_rewind");
appendPQExpBufferStr(&command,
" -D ");
}
appendShellString(&command,

View File

@@ -6564,9 +6564,11 @@ initialise_direct_clone(t_node_info *local_node_record, t_node_info *upstream_no
static int
run_basebackup(t_node_info *node_record)
{
char script[MAXLEN] = "";
int r = SUCCESS;
PQExpBufferData params;
PQExpBufferData script;
int r = SUCCESS;
TablespaceListCell *cell = NULL;
t_basebackup_options backup_options = T_BASEBACKUP_OPTIONS_INITIALIZER;
@@ -6717,21 +6719,25 @@ run_basebackup(t_node_info *node_record)
}
}
maxlen_snprintf(script,
"%s -l \"repmgr base backup\" %s %s",
make_pg_path("pg_basebackup"),
params.data,
config_file_options.pg_basebackup_options);
initPQExpBuffer(&script);
make_pg_path(&script, "pg_basebackup");
appendPQExpBuffer(&script,
" -l \"repmgr base backup\" %s %s",
params.data,
config_file_options.pg_basebackup_options);
termPQExpBuffer(&params);
log_info(_("executing:\n %s"), script);
log_info(_("executing:\n %s"), script.data);
/*
* As of 9.4, pg_basebackup only ever returns 0 or 1
*/
r = system(script);
r = system(script.data);
termPQExpBuffer(&script);
if (r != 0)
return ERR_BAD_BASEBACKUP;

View File

@@ -262,7 +262,7 @@ extern int copy_remote_files(char *host, char *remote_user, char *remote_path,
extern void print_error_list(ItemList *error_list, int log_level);
extern char *make_pg_path(const char *file);
extern void make_pg_path(PQExpBufferData *buf, const char *file);
extern void get_superuser_connection(PGconn **conn, PGconn **superuser_conn, PGconn **privileged_conn);

View File

@@ -81,9 +81,7 @@ t_runtime_options runtime_options = T_RUNTIME_OPTIONS_INITIALIZER;
t_conninfo_param_list source_conninfo = T_CONNINFO_PARAM_LIST_INITIALIZER;
bool config_file_required = true;
char pg_bindir[MAXLEN] = "";
char path_buf[MAXLEN] = "";
char pg_bindir[MAXPGPATH] = "";
/*
* if --node-id/--node-name provided, place that node's record here
@@ -3057,7 +3055,6 @@ get_superuser_connection(PGconn **conn, PGconn **superuser_conn, PGconn **privil
}
standy_clone_mode
get_standby_clone_mode(void)
{
@@ -3072,12 +3069,11 @@ get_standby_clone_mode(void)
}
char *
make_pg_path(const char *file)
void
make_pg_path(PQExpBufferData *buf, const char *file)
{
maxlen_snprintf(path_buf, "%s%s", pg_bindir, file);
return path_buf;
appendPQExpBuffer(buf, "%s%s",
pg_bindir, file);
}
@@ -3293,9 +3289,10 @@ get_server_action(t_server_action action, char *script, char *data_dir)
{
initPQExpBuffer(&command);
make_pg_path(&command, "pg_ctl");
appendPQExpBuffer(&command,
"%s %s -w -D ",
make_pg_path("pg_ctl"),
" %s -w -D ",
config_file_options.pg_ctl_options);
appendShellString(&command,
@@ -3323,9 +3320,10 @@ get_server_action(t_server_action action, char *script, char *data_dir)
else
{
initPQExpBuffer(&command);
make_pg_path(&command, "pg_ctl");
appendPQExpBuffer(&command,
"%s %s -D ",
make_pg_path("pg_ctl"),
" %s -D ",
config_file_options.pg_ctl_options);
appendShellString(&command,
@@ -3358,9 +3356,11 @@ get_server_action(t_server_action action, char *script, char *data_dir)
else
{
initPQExpBuffer(&command);
make_pg_path(&command, "pg_ctl");
appendPQExpBuffer(&command,
"%s %s -w -D ",
make_pg_path("pg_ctl"),
" %s -w -D ",
config_file_options.pg_ctl_options);
appendShellString(&command,
@@ -3386,9 +3386,11 @@ get_server_action(t_server_action action, char *script, char *data_dir)
else
{
initPQExpBuffer(&command);
make_pg_path(&command, "pg_ctl");
appendPQExpBuffer(&command,
"%s %s -w -D ",
make_pg_path("pg_ctl"),
" %s -w -D ",
config_file_options.pg_ctl_options);
appendShellString(&command,
@@ -3415,9 +3417,11 @@ get_server_action(t_server_action action, char *script, char *data_dir)
else
{
initPQExpBuffer(&command);
make_pg_path(&command, "pg_ctl");
appendPQExpBuffer(&command,
"%s %s -w -D ",
make_pg_path("pg_ctl"),
" %s -w -D ",
config_file_options.pg_ctl_options);
appendShellString(&command,