"repmgr standby": use appendPQExpBufferStr/-Char() consistently

This commit is contained in:
Ian Barwick
2018-10-03 17:31:12 +09:00
parent 61c91df332
commit 15a5d2ee9d

View File

@@ -731,16 +731,16 @@ do_standby_clone(void)
runtime_options.host, runtime_options.host,
runtime_options.port); runtime_options.port);
appendPQExpBuffer(&event_details, appendPQExpBufferStr(&event_details,
_("; backup method: ")); _("; backup method: "));
switch (mode) switch (mode)
{ {
case pg_basebackup: case pg_basebackup:
appendPQExpBuffer(&event_details, "pg_basebackup"); appendPQExpBufferStr(&event_details, "pg_basebackup");
break; break;
case barman: case barman:
appendPQExpBuffer(&event_details, "barman"); appendPQExpBufferStr(&event_details, "barman");
break; break;
} }
@@ -1672,12 +1672,12 @@ do_standby_register(void)
if (record_created == false) if (record_created == false)
{ {
appendPQExpBuffer(&details, appendPQExpBufferStr(&details,
"standby registration failed"); "standby registration failed");
if (runtime_options.force == true) if (runtime_options.force == true)
appendPQExpBuffer(&details, appendPQExpBufferStr(&details,
" (-F/--force option was used)"); " (-F/--force option was used)");
create_event_notification_extended( create_event_notification_extended(
primary_conn, primary_conn,
@@ -1697,12 +1697,12 @@ do_standby_register(void)
exit(ERR_BAD_CONFIG); exit(ERR_BAD_CONFIG);
} }
appendPQExpBuffer(&details, appendPQExpBufferStr(&details,
"standby registration succeeded"); "standby registration succeeded");
if (runtime_options.force == true) if (runtime_options.force == true)
appendPQExpBuffer(&details, appendPQExpBufferStr(&details,
" (-F/--force option was used)"); " (-F/--force option was used)");
/* Log the event */ /* Log the event */
@@ -2771,8 +2771,8 @@ do_standby_follow_internal(PGconn *primary_conn, t_node_info *primary_node_recor
primary_node_record->node_id, primary_node_record->node_id,
true) == false) true) == false)
{ {
appendPQExpBuffer(output, appendPQExpBufferStr(output,
_("unable to update upstream node")); _("unable to update upstream node"));
return false; return false;
} }
@@ -3010,8 +3010,8 @@ do_standby_switchover(void)
termPQExpBuffer(&reason); termPQExpBuffer(&reason);
initPQExpBuffer(&msg); initPQExpBuffer(&msg);
appendPQExpBuffer(&msg, appendPQExpBufferStr(&msg,
_("prerequisites for using pg_rewind are met")); _("prerequisites for using pg_rewind are met"));
if (runtime_options.dry_run == true) if (runtime_options.dry_run == true)
{ {
@@ -3069,7 +3069,7 @@ do_standby_switchover(void)
initPQExpBuffer(&remote_command_str); initPQExpBuffer(&remote_command_str);
make_remote_repmgr_path(&remote_command_str, &remote_node_record); make_remote_repmgr_path(&remote_command_str, &remote_node_record);
appendPQExpBuffer(&remote_command_str, "--version 2>/dev/null && echo \"1\" || echo \"0\""); appendPQExpBufferStr(&remote_command_str, "--version 2>/dev/null && echo \"1\" || echo \"0\"");
initPQExpBuffer(&command_output); initPQExpBuffer(&command_output);
command_success = remote_command(remote_host, command_success = remote_command(remote_host,
runtime_options.remote_user, runtime_options.remote_user,
@@ -3091,8 +3091,8 @@ do_standby_switchover(void)
termPQExpBuffer(&command_output); termPQExpBuffer(&command_output);
initPQExpBuffer(&hint); initPQExpBuffer(&hint);
appendPQExpBuffer(&hint, appendPQExpBufferStr(&hint,
_("check \"pg_bindir\" is set to the correct path in \"repmgr.conf\"; current value: ")); _("check \"pg_bindir\" is set to the correct path in \"repmgr.conf\"; current value: "));
if (strlen(config_file_options.pg_bindir)) if (strlen(config_file_options.pg_bindir))
{ {
@@ -3101,8 +3101,8 @@ do_standby_switchover(void)
} }
else else
{ {
appendPQExpBuffer(&hint, appendPQExpBufferStr(&hint,
"(not set)"); "(not set)");
} }
@@ -3349,8 +3349,8 @@ do_standby_switchover(void)
initPQExpBuffer(&remote_command_str); initPQExpBuffer(&remote_command_str);
make_remote_repmgr_path(&remote_command_str, &remote_node_record); make_remote_repmgr_path(&remote_command_str, &remote_node_record);
appendPQExpBuffer(&remote_command_str, appendPQExpBufferStr(&remote_command_str,
"node check --terse -LERROR --archive-ready --optformat"); "node check --terse -LERROR --archive-ready --optformat");
initPQExpBuffer(&command_output); initPQExpBuffer(&command_output);
@@ -3760,8 +3760,8 @@ do_standby_switchover(void)
if (runtime_options.dry_run == true) if (runtime_options.dry_run == true)
{ {
appendPQExpBuffer(&remote_command_str, appendPQExpBufferStr(&remote_command_str,
"node service --terse -LERROR --list-actions --action=stop"); "node service --terse -LERROR --list-actions --action=stop");
} }
else else
@@ -3769,8 +3769,8 @@ do_standby_switchover(void)
log_notice(_("stopping current primary node \"%s\" (ID: %i)"), log_notice(_("stopping current primary node \"%s\" (ID: %i)"),
remote_node_record.node_name, remote_node_record.node_name,
remote_node_record.node_id); remote_node_record.node_id);
appendPQExpBuffer(&remote_command_str, appendPQExpBufferStr(&remote_command_str,
"node service --action=stop --checkpoint"); "node service --action=stop --checkpoint");
} }
/* XXX handle failure */ /* XXX handle failure */
@@ -3838,8 +3838,8 @@ do_standby_switchover(void)
initPQExpBuffer(&remote_command_str); initPQExpBuffer(&remote_command_str);
make_remote_repmgr_path(&remote_command_str, &remote_node_record); make_remote_repmgr_path(&remote_command_str, &remote_node_record);
appendPQExpBuffer(&remote_command_str, appendPQExpBufferStr(&remote_command_str,
"node status --is-shutdown-cleanly"); "node status --is-shutdown-cleanly");
initPQExpBuffer(&command_output); initPQExpBuffer(&command_output);
@@ -3971,7 +3971,7 @@ do_standby_switchover(void)
exit(ERR_SWITCHOVER_FAIL); exit(ERR_SWITCHOVER_FAIL);
} }
appendPQExpBuffer(&node_rejoin_options, appendPQExpBufferStr(&node_rejoin_options,
" --force-rewind"); " --force-rewind");
if (runtime_options.force_rewind_path[0] != '\0') if (runtime_options.force_rewind_path[0] != '\0')
@@ -3980,20 +3980,20 @@ do_standby_switchover(void)
"=%s", "=%s",
runtime_options.force_rewind_path); runtime_options.force_rewind_path);
} }
appendPQExpBuffer(&node_rejoin_options, appendPQExpBufferStr(&node_rejoin_options,
" --config-files="); " --config-files=");
for (cell = remote_config_files.head; cell; cell = cell->next) for (cell = remote_config_files.head; cell; cell = cell->next)
{ {
if (first_entry == false) if (first_entry == false)
appendPQExpBuffer(&node_rejoin_options, ","); appendPQExpBufferChar(&node_rejoin_options, ',');
else else
first_entry = false; first_entry = false;
appendPQExpBuffer(&node_rejoin_options, "%s", cell->key); appendPQExpBufferStr(&node_rejoin_options, cell->key);
} }
appendPQExpBuffer(&node_rejoin_options, " "); appendPQExpBufferChar(&node_rejoin_options, ' ');
} }
key_value_list_free(&remote_config_files); key_value_list_free(&remote_config_files);
@@ -4093,8 +4093,8 @@ do_standby_switchover(void)
} }
else else
{ {
appendPQExpBuffer(&remote_command_str, appendPQExpBufferStr(&remote_command_str,
"standby follow 2>/dev/null && echo \"1\" || echo \"0\""); "standby follow 2>/dev/null && echo \"1\" || echo \"0\"");
} }
get_conninfo_value(cell->node_info->conninfo, "host", host); get_conninfo_value(cell->node_info->conninfo, "host", host);
log_debug("executing:\n %s", remote_command_str.data); log_debug("executing:\n %s", remote_command_str.data);
@@ -5252,7 +5252,7 @@ run_basebackup(t_node_info *node_record)
if (runtime_options.fast_checkpoint) if (runtime_options.fast_checkpoint)
{ {
appendPQExpBuffer(&params, " -c fast"); appendPQExpBufferStr(&params, " -c fast");
} }
if (config_file_options.tablespace_mapping.head != NULL) if (config_file_options.tablespace_mapping.head != NULL)
@@ -5274,7 +5274,7 @@ run_basebackup(t_node_info *node_record)
*/ */
if (!strlen(backup_options.xlog_method)) if (!strlen(backup_options.xlog_method))
{ {
appendPQExpBuffer(&params, " -X stream"); appendPQExpBufferStr(&params, " -X stream");
} }
/* /*
@@ -6314,8 +6314,8 @@ create_recovery_file(t_node_info *node_record, t_conninfo_param_list *recovery_c
initPQExpBuffer(&recovery_file_buf); initPQExpBuffer(&recovery_file_buf);
/* standby_mode = 'on' */ /* standby_mode = 'on' */
appendPQExpBuffer(&recovery_file_buf, appendPQExpBufferStr(&recovery_file_buf,
"standby_mode = 'on'\n"); "standby_mode = 'on'\n");
/* primary_conninfo = '...' */ /* primary_conninfo = '...' */
@@ -6343,8 +6343,8 @@ create_recovery_file(t_node_info *node_record, t_conninfo_param_list *recovery_c
} }
/* recovery_target_timeline = 'latest' */ /* recovery_target_timeline = 'latest' */
appendPQExpBuffer(&recovery_file_buf, appendPQExpBufferStr(&recovery_file_buf,
"recovery_target_timeline = 'latest'\n"); "recovery_target_timeline = 'latest'\n");
/* recovery_min_apply_delay = ... (optional) */ /* recovery_min_apply_delay = ... (optional) */
@@ -6477,12 +6477,12 @@ write_primary_conninfo(PQExpBufferData *dest, t_conninfo_param_list *param_list)
{ {
if (strlen(config_file_options.node_name)) if (strlen(config_file_options.node_name))
{ {
appendPQExpBuffer(&conninfo_buf, " application_name="); appendPQExpBufferStr(&conninfo_buf, " application_name=");
appendConnStrVal(&conninfo_buf, config_file_options.node_name); appendConnStrVal(&conninfo_buf, config_file_options.node_name);
} }
else else
{ {
appendPQExpBuffer(&conninfo_buf, " application_name=repmgr"); appendPQExpBufferStr(&conninfo_buf, " application_name=repmgr");
} }
} }
@@ -6495,7 +6495,7 @@ write_primary_conninfo(PQExpBufferData *dest, t_conninfo_param_list *param_list)
if (password != NULL) if (password != NULL)
{ {
appendPQExpBuffer(&conninfo_buf, " password="); appendPQExpBufferStr(&conninfo_buf, " password=");
appendConnStrVal(&conninfo_buf, password); appendConnStrVal(&conninfo_buf, password);
} }
} }
@@ -6507,7 +6507,7 @@ write_primary_conninfo(PQExpBufferData *dest, t_conninfo_param_list *param_list)
/* check if the libpq we're using supports "passfile=" */ /* check if the libpq we're using supports "passfile=" */
if (has_passfile() == true) if (has_passfile() == true)
{ {
appendPQExpBuffer(&conninfo_buf, " passfile="); appendPQExpBufferStr(&conninfo_buf, " passfile=");
appendConnStrVal(&conninfo_buf, config_file_options.passfile); appendConnStrVal(&conninfo_buf, config_file_options.passfile);
} }
} }