mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-23 07:06:30 +00:00
Standardize if-statement formatting
"if(" -> "if ("
This commit is contained in:
64
config.c
64
config.c
@@ -56,7 +56,7 @@ load_config(const char *config_file, t_configuration_options *options, char *arg
|
||||
strncpy(config_file_path, config_file, MAXPGPATH);
|
||||
canonicalize_path(config_file_path);
|
||||
|
||||
if(stat(config_file_path, &config) != 0)
|
||||
if (stat(config_file_path, &config) != 0)
|
||||
{
|
||||
log_err(_("provided configuration file '%s' not found: %s\n"),
|
||||
config_file,
|
||||
@@ -71,7 +71,7 @@ load_config(const char *config_file, t_configuration_options *options, char *arg
|
||||
/*
|
||||
* If no configuration file was provided, attempt to find a default file
|
||||
*/
|
||||
if(config_file_provided == false)
|
||||
if (config_file_provided == false)
|
||||
{
|
||||
char my_exec_path[MAXPGPATH];
|
||||
char etc_path[MAXPGPATH];
|
||||
@@ -89,7 +89,7 @@ load_config(const char *config_file, t_configuration_options *options, char *arg
|
||||
|
||||
log_debug(_("Looking for configuration file in %s\n"), etc_path);
|
||||
|
||||
if(stat(config_file_path, &config) != 0)
|
||||
if (stat(config_file_path, &config) != 0)
|
||||
{
|
||||
/* Not found - default to ./repmgr.conf */
|
||||
strncpy(config_file_path, DEFAULT_CONFIG_FILE, MAXPGPATH);
|
||||
@@ -125,7 +125,7 @@ parse_config(t_configuration_options *options)
|
||||
*/
|
||||
if (fp == NULL)
|
||||
{
|
||||
if(config_file_provided)
|
||||
if (config_file_provided)
|
||||
{
|
||||
log_err(_("unable to open provided configuration file '%s'; terminating\n"), config_file_path);
|
||||
exit(ERR_BAD_CONFIG);
|
||||
@@ -179,7 +179,7 @@ parse_config(t_configuration_options *options)
|
||||
parse_line(buff, name, value);
|
||||
|
||||
/* Skip blank lines */
|
||||
if(!strlen(name))
|
||||
if (!strlen(name))
|
||||
continue;
|
||||
|
||||
/* Skip comments */
|
||||
@@ -269,7 +269,7 @@ parse_config(t_configuration_options *options)
|
||||
* we want to accept those, we'd need to add stricter default checking,
|
||||
* as currently e.g. an empty `node` value will be converted to '0'.
|
||||
*/
|
||||
if(known_parameter == true && !strlen(value)) {
|
||||
if (known_parameter == true && !strlen(value)) {
|
||||
log_err(_("no value provided for parameter '%s'\n"), name);
|
||||
exit(ERR_BAD_CONFIG);
|
||||
}
|
||||
@@ -341,7 +341,7 @@ trim(char *s)
|
||||
*s2 = &s[strlen(s) - 1];
|
||||
|
||||
/* If string is empty, no action needed */
|
||||
if(s2 < s1)
|
||||
if (s2 < s1)
|
||||
return s;
|
||||
|
||||
/* Trim and delimit right side */
|
||||
@@ -480,7 +480,7 @@ reload_config(t_configuration_options *orig_options)
|
||||
return false;
|
||||
}
|
||||
|
||||
if(strcmp(orig_options->conninfo, new_options.conninfo) != 0)
|
||||
if (strcmp(orig_options->conninfo, new_options.conninfo) != 0)
|
||||
{
|
||||
/* Test conninfo string */
|
||||
conn = establish_db_connection(new_options.conninfo, false);
|
||||
@@ -500,56 +500,56 @@ reload_config(t_configuration_options *orig_options)
|
||||
*/
|
||||
|
||||
/* cluster_name */
|
||||
if(strcmp(orig_options->cluster_name, new_options.cluster_name) != 0)
|
||||
if (strcmp(orig_options->cluster_name, new_options.cluster_name) != 0)
|
||||
{
|
||||
strcpy(orig_options->cluster_name, new_options.cluster_name);
|
||||
config_changed = true;
|
||||
}
|
||||
|
||||
/* conninfo */
|
||||
if(strcmp(orig_options->conninfo, new_options.conninfo) != 0)
|
||||
if (strcmp(orig_options->conninfo, new_options.conninfo) != 0)
|
||||
{
|
||||
strcpy(orig_options->conninfo, new_options.conninfo);
|
||||
config_changed = true;
|
||||
}
|
||||
|
||||
/* node */
|
||||
if(orig_options->node != new_options.node)
|
||||
if (orig_options->node != new_options.node)
|
||||
{
|
||||
orig_options->node = new_options.node;
|
||||
config_changed = true;
|
||||
}
|
||||
|
||||
/* failover */
|
||||
if(orig_options->failover != new_options.failover)
|
||||
if (orig_options->failover != new_options.failover)
|
||||
{
|
||||
orig_options->failover = new_options.failover;
|
||||
config_changed = true;
|
||||
}
|
||||
|
||||
/* priority */
|
||||
if(orig_options->priority != new_options.priority)
|
||||
if (orig_options->priority != new_options.priority)
|
||||
{
|
||||
orig_options->priority = new_options.priority;
|
||||
config_changed = true;
|
||||
}
|
||||
|
||||
/* node_name */
|
||||
if(strcmp(orig_options->node_name, new_options.node_name) != 0)
|
||||
if (strcmp(orig_options->node_name, new_options.node_name) != 0)
|
||||
{
|
||||
strcpy(orig_options->node_name, new_options.node_name);
|
||||
config_changed = true;
|
||||
}
|
||||
|
||||
/* promote_command */
|
||||
if(strcmp(orig_options->promote_command, new_options.promote_command) != 0)
|
||||
if (strcmp(orig_options->promote_command, new_options.promote_command) != 0)
|
||||
{
|
||||
strcpy(orig_options->promote_command, new_options.promote_command);
|
||||
config_changed = true;
|
||||
}
|
||||
|
||||
/* follow_command */
|
||||
if(strcmp(orig_options->follow_command, new_options.follow_command) != 0)
|
||||
if (strcmp(orig_options->follow_command, new_options.follow_command) != 0)
|
||||
{
|
||||
strcpy(orig_options->follow_command, new_options.follow_command);
|
||||
config_changed = true;
|
||||
@@ -566,76 +566,76 @@ reload_config(t_configuration_options *orig_options)
|
||||
*/
|
||||
|
||||
/* rsync_options */
|
||||
if(strcmp(orig_options->rsync_options, new_options.rsync_options) != 0)
|
||||
if (strcmp(orig_options->rsync_options, new_options.rsync_options) != 0)
|
||||
{
|
||||
strcpy(orig_options->rsync_options, new_options.rsync_options);
|
||||
config_changed = true;
|
||||
}
|
||||
|
||||
/* ssh_options */
|
||||
if(strcmp(orig_options->ssh_options, new_options.ssh_options) != 0)
|
||||
if (strcmp(orig_options->ssh_options, new_options.ssh_options) != 0)
|
||||
{
|
||||
strcpy(orig_options->ssh_options, new_options.ssh_options);
|
||||
config_changed = true;
|
||||
}
|
||||
|
||||
/* master_response_timeout */
|
||||
if(orig_options->master_response_timeout != new_options.master_response_timeout)
|
||||
if (orig_options->master_response_timeout != new_options.master_response_timeout)
|
||||
{
|
||||
orig_options->master_response_timeout = new_options.master_response_timeout;
|
||||
config_changed = true;
|
||||
}
|
||||
|
||||
/* reconnect_attempts */
|
||||
if(orig_options->reconnect_attempts != new_options.reconnect_attempts)
|
||||
if (orig_options->reconnect_attempts != new_options.reconnect_attempts)
|
||||
{
|
||||
orig_options->reconnect_attempts = new_options.reconnect_attempts;
|
||||
config_changed = true;
|
||||
}
|
||||
|
||||
/* reconnect_intvl */
|
||||
if(orig_options->reconnect_intvl != new_options.reconnect_intvl)
|
||||
if (orig_options->reconnect_intvl != new_options.reconnect_intvl)
|
||||
{
|
||||
orig_options->reconnect_intvl = new_options.reconnect_intvl;
|
||||
config_changed = true;
|
||||
}
|
||||
|
||||
/* pg_ctl_options */
|
||||
if(strcmp(orig_options->pg_ctl_options, new_options.pg_ctl_options) != 0)
|
||||
if (strcmp(orig_options->pg_ctl_options, new_options.pg_ctl_options) != 0)
|
||||
{
|
||||
strcpy(orig_options->pg_ctl_options, new_options.pg_ctl_options);
|
||||
config_changed = true;
|
||||
}
|
||||
|
||||
/* pg_basebackup_options */
|
||||
if(strcmp(orig_options->pg_basebackup_options, new_options.pg_basebackup_options) != 0)
|
||||
if (strcmp(orig_options->pg_basebackup_options, new_options.pg_basebackup_options) != 0)
|
||||
{
|
||||
strcpy(orig_options->pg_basebackup_options, new_options.pg_basebackup_options);
|
||||
config_changed = true;
|
||||
}
|
||||
|
||||
/* monitor_interval_secs */
|
||||
if(orig_options->monitor_interval_secs != new_options.monitor_interval_secs)
|
||||
if (orig_options->monitor_interval_secs != new_options.monitor_interval_secs)
|
||||
{
|
||||
orig_options->monitor_interval_secs = new_options.monitor_interval_secs;
|
||||
config_changed = true;
|
||||
}
|
||||
|
||||
/* retry_promote_interval_secs */
|
||||
if(orig_options->retry_promote_interval_secs != new_options.retry_promote_interval_secs)
|
||||
if (orig_options->retry_promote_interval_secs != new_options.retry_promote_interval_secs)
|
||||
{
|
||||
orig_options->retry_promote_interval_secs = new_options.retry_promote_interval_secs;
|
||||
config_changed = true;
|
||||
}
|
||||
|
||||
/* use_replication_slots */
|
||||
if(orig_options->use_replication_slots != new_options.use_replication_slots)
|
||||
if (orig_options->use_replication_slots != new_options.use_replication_slots)
|
||||
{
|
||||
orig_options->use_replication_slots = new_options.use_replication_slots;
|
||||
config_changed = true;
|
||||
}
|
||||
|
||||
if(config_changed == true)
|
||||
if (config_changed == true)
|
||||
{
|
||||
log_debug(_("reload_config(): configuration has changed\n"));
|
||||
}
|
||||
@@ -664,7 +664,7 @@ tablespace_list_append(t_configuration_options *options, const char *arg)
|
||||
const char *arg_ptr;
|
||||
|
||||
cell = (TablespaceListCell *) pg_malloc0(sizeof(TablespaceListCell));
|
||||
if(cell == NULL)
|
||||
if (cell == NULL)
|
||||
{
|
||||
log_err(_("unable to allocate memory; terminating\n"));
|
||||
exit(ERR_BAD_CONFIG);
|
||||
@@ -732,7 +732,7 @@ parse_event_notifications_list(t_configuration_options *options, const char *arg
|
||||
for (arg_ptr = arg; arg_ptr <= (arg + strlen(arg)); arg_ptr++)
|
||||
{
|
||||
/* ignore whitespace */
|
||||
if(*arg_ptr == ' ' || *arg_ptr == '\t')
|
||||
if (*arg_ptr == ' ' || *arg_ptr == '\t')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -741,13 +741,13 @@ parse_event_notifications_list(t_configuration_options *options, const char *arg
|
||||
* comma (or end-of-string) should mark the end of an event type -
|
||||
* just as long as there was something preceding it
|
||||
*/
|
||||
if((*arg_ptr == ',' || *arg_ptr == '\0') && event_type_buf[0] != '\0')
|
||||
if ((*arg_ptr == ',' || *arg_ptr == '\0') && event_type_buf[0] != '\0')
|
||||
{
|
||||
EventNotificationListCell *cell;
|
||||
|
||||
cell = (EventNotificationListCell *) pg_malloc0(sizeof(EventNotificationListCell));
|
||||
|
||||
if(cell == NULL)
|
||||
if (cell == NULL)
|
||||
{
|
||||
log_err(_("unable to allocate memory; terminating\n"));
|
||||
exit(ERR_BAD_CONFIG);
|
||||
@@ -770,7 +770,7 @@ parse_event_notifications_list(t_configuration_options *options, const char *arg
|
||||
dst_ptr = event_type_buf;
|
||||
}
|
||||
/* ignore duplicated commas */
|
||||
else if(*arg_ptr == ',')
|
||||
else if (*arg_ptr == ',')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
44
dbutils.c
44
dbutils.c
@@ -326,7 +326,7 @@ get_server_version(PGconn *conn, char *server_version)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(server_version != NULL)
|
||||
if (server_version != NULL)
|
||||
strcpy(server_version, PQgetvalue(res, 0, 0));
|
||||
|
||||
return atoi(PQgetvalue(res, 0, 0));
|
||||
@@ -465,7 +465,7 @@ get_pg_setting(PGconn *conn, const char *setting, char *output)
|
||||
}
|
||||
}
|
||||
|
||||
if(success == true)
|
||||
if (success == true)
|
||||
{
|
||||
log_debug(_("get_pg_setting(): returned value is '%s'\n"), output);
|
||||
}
|
||||
@@ -524,7 +524,7 @@ get_upstream_connection(PGconn *standby_conn, char *cluster, int node_id,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!PQntuples(res))
|
||||
if (!PQntuples(res))
|
||||
{
|
||||
log_notice(_("no record found for upstream server"));
|
||||
PQclear(res);
|
||||
@@ -533,7 +533,7 @@ get_upstream_connection(PGconn *standby_conn, char *cluster, int node_id,
|
||||
|
||||
strncpy(upstream_conninfo, PQgetvalue(res, 0, 0), MAXCONNINFO);
|
||||
|
||||
if(upstream_node_id_ptr != NULL)
|
||||
if (upstream_node_id_ptr != NULL)
|
||||
*upstream_node_id_ptr = atoi(PQgetvalue(res, 0, 1));
|
||||
|
||||
PQclear(res);
|
||||
@@ -575,7 +575,7 @@ get_master_connection(PGconn *standby_conn, char *cluster,
|
||||
int i,
|
||||
node_id;
|
||||
|
||||
if(master_id != NULL)
|
||||
if (master_id != NULL)
|
||||
{
|
||||
*master_id = NODE_NOT_FOUND;
|
||||
}
|
||||
@@ -636,7 +636,7 @@ get_master_connection(PGconn *standby_conn, char *cluster,
|
||||
PQclear(res1);
|
||||
log_debug(_("get_master_connection(): current master node is %i\n"), node_id);
|
||||
|
||||
if(master_id != NULL)
|
||||
if (master_id != NULL)
|
||||
{
|
||||
*master_id = node_id;
|
||||
}
|
||||
@@ -775,7 +775,7 @@ get_repmgr_schema(void)
|
||||
char *
|
||||
get_repmgr_schema_quoted(PGconn *conn)
|
||||
{
|
||||
if(strcmp(repmgr_schema_quoted, "") == 0)
|
||||
if (strcmp(repmgr_schema_quoted, "") == 0)
|
||||
{
|
||||
char *identifier = PQescapeIdentifier(conn, repmgr_schema,
|
||||
strlen(repmgr_schema));
|
||||
@@ -815,15 +815,15 @@ create_replication_slot(PGconn *conn, char *slot_name)
|
||||
return false;
|
||||
}
|
||||
|
||||
if(PQntuples(res))
|
||||
if (PQntuples(res))
|
||||
{
|
||||
if(strcmp(PQgetvalue(res, 0, 1), "physical") != 0)
|
||||
if (strcmp(PQgetvalue(res, 0, 1), "physical") != 0)
|
||||
{
|
||||
log_err(_("Slot '%s' exists and is not a physical slot\n"),
|
||||
slot_name);
|
||||
PQclear(res);
|
||||
}
|
||||
if(strcmp(PQgetvalue(res, 0, 0), "f") == 0)
|
||||
if (strcmp(PQgetvalue(res, 0, 0), "f") == 0)
|
||||
{
|
||||
PQclear(res);
|
||||
log_debug(_("Replication slot '%s' exists but is inactive; reusing\n"),
|
||||
@@ -1039,13 +1039,13 @@ create_node_record(PGconn *conn, char *action, int node, char *type, int upstrea
|
||||
char slot_name_buf[MAXLEN];
|
||||
PGresult *res;
|
||||
|
||||
if(upstream_node == NO_UPSTREAM_NODE)
|
||||
if (upstream_node == NO_UPSTREAM_NODE)
|
||||
{
|
||||
/*
|
||||
* No explicit upstream node id provided for standby - attempt to
|
||||
* get primary node id
|
||||
*/
|
||||
if(strcmp(type, "standby") == 0)
|
||||
if (strcmp(type, "standby") == 0)
|
||||
{
|
||||
int primary_node_id = get_master_node_id(conn, cluster_name);
|
||||
maxlen_snprintf(upstream_node_id, "%i", primary_node_id);
|
||||
@@ -1060,7 +1060,7 @@ create_node_record(PGconn *conn, char *action, int node, char *type, int upstrea
|
||||
maxlen_snprintf(upstream_node_id, "%i", upstream_node);
|
||||
}
|
||||
|
||||
if(slot_name != NULL && slot_name[0])
|
||||
if (slot_name != NULL && slot_name[0])
|
||||
{
|
||||
maxlen_snprintf(slot_name_buf, "'%s'", slot_name);
|
||||
}
|
||||
@@ -1084,7 +1084,7 @@ create_node_record(PGconn *conn, char *action, int node, char *type, int upstrea
|
||||
slot_name_buf,
|
||||
priority);
|
||||
|
||||
if(action != NULL)
|
||||
if (action != NULL)
|
||||
{
|
||||
log_debug(_("%s: %s\n"), action, sqlquery);
|
||||
}
|
||||
@@ -1115,7 +1115,7 @@ delete_node_record(PGconn *conn, int node, char *action)
|
||||
" WHERE id = %d",
|
||||
get_repmgr_schema_quoted(conn),
|
||||
node);
|
||||
if(action != NULL)
|
||||
if (action != NULL)
|
||||
{
|
||||
log_debug(_("%s: %s\n"), action, sqlquery);
|
||||
}
|
||||
@@ -1165,7 +1165,7 @@ create_event_record(PGconn *conn, t_configuration_options *options, int node_id,
|
||||
not it means no configuration file was provided, which can happen with
|
||||
e.g. `repmgr standby clone`, and we won't know which schema to write to.
|
||||
*/
|
||||
if(conn != NULL && strcmp(repmgr_schema, DEFAULT_REPMGR_SCHEMA_PREFIX) != 0)
|
||||
if (conn != NULL && strcmp(repmgr_schema, DEFAULT_REPMGR_SCHEMA_PREFIX) != 0)
|
||||
{
|
||||
int n_node_id = htonl(node_id);
|
||||
char *t_successful = successful ? "TRUE" : "FALSE";
|
||||
@@ -1228,7 +1228,7 @@ create_event_record(PGconn *conn, t_configuration_options *options, int node_id,
|
||||
* current timestamp ourselves. This isn't quite the same
|
||||
* format as PostgreSQL, but is close enough for diagnostic use.
|
||||
*/
|
||||
if(!strlen(event_timestamp))
|
||||
if (!strlen(event_timestamp))
|
||||
{
|
||||
time_t now;
|
||||
|
||||
@@ -1238,7 +1238,7 @@ create_event_record(PGconn *conn, t_configuration_options *options, int node_id,
|
||||
}
|
||||
|
||||
/* an event notification command was provided - parse and execute it */
|
||||
if(strlen(options->event_notification_command))
|
||||
if (strlen(options->event_notification_command))
|
||||
{
|
||||
char parsed_command[MAXPGPATH];
|
||||
const char *src_ptr;
|
||||
@@ -1254,14 +1254,14 @@ create_event_record(PGconn *conn, t_configuration_options *options, int node_id,
|
||||
* (If 'event_notifications' was not provided, we assume the script
|
||||
* should be executed for all events).
|
||||
*/
|
||||
if(options->event_notifications.head != NULL)
|
||||
if (options->event_notifications.head != NULL)
|
||||
{
|
||||
EventNotificationListCell *cell;
|
||||
bool notify_ok = false;
|
||||
|
||||
for (cell = options->event_notifications.head; cell; cell = cell->next)
|
||||
{
|
||||
if(strcmp(event, cell->event_type) == 0)
|
||||
if (strcmp(event, cell->event_type) == 0)
|
||||
{
|
||||
notify_ok = true;
|
||||
break;
|
||||
@@ -1271,7 +1271,7 @@ create_event_record(PGconn *conn, t_configuration_options *options, int node_id,
|
||||
/*
|
||||
* Event type not found in the 'event_notifications' list - return early
|
||||
*/
|
||||
if(notify_ok == false)
|
||||
if (notify_ok == false)
|
||||
{
|
||||
log_debug(_("Not executing notification script for event type '%s'\n"), event);
|
||||
return success;
|
||||
@@ -1303,7 +1303,7 @@ create_event_record(PGconn *conn, t_configuration_options *options, int node_id,
|
||||
case 'd':
|
||||
/* %d: details */
|
||||
src_ptr++;
|
||||
if(details != NULL)
|
||||
if (details != NULL)
|
||||
{
|
||||
strlcpy(dst_ptr, details, end_ptr - dst_ptr);
|
||||
dst_ptr += strlen(dst_ptr);
|
||||
|
||||
194
repmgr.c
194
repmgr.c
@@ -249,14 +249,14 @@ main(int argc, char **argv)
|
||||
case 3:
|
||||
targ = strtol(optarg, &ptr, 10);
|
||||
|
||||
if(targ < 1)
|
||||
if (targ < 1)
|
||||
{
|
||||
error_list_append(_("Invalid value provided for '-r/--recovery-min-apply-delay'"));
|
||||
break;
|
||||
}
|
||||
if(ptr && *ptr)
|
||||
if (ptr && *ptr)
|
||||
{
|
||||
if(strcmp(ptr, "ms") != 0 && strcmp(ptr, "s") != 0 &&
|
||||
if (strcmp(ptr, "ms") != 0 && strcmp(ptr, "s") != 0 &&
|
||||
strcmp(ptr, "min") != 0 && strcmp(ptr, "h") != 0 &&
|
||||
strcmp(ptr, "d") != 0)
|
||||
{
|
||||
@@ -282,13 +282,13 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
/* Exit here already if errors in command line options found */
|
||||
if(cli_errors.head != NULL)
|
||||
if (cli_errors.head != NULL)
|
||||
{
|
||||
exit_with_errors();
|
||||
}
|
||||
|
||||
|
||||
if(check_upstream_config == true)
|
||||
if (check_upstream_config == true)
|
||||
{
|
||||
do_check_upstream_config();
|
||||
exit(SUCCESS);
|
||||
@@ -356,7 +356,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (action == NO_ACTION) {
|
||||
if(server_cmd == NULL)
|
||||
if (server_cmd == NULL)
|
||||
{
|
||||
error_list_append("No server command provided");
|
||||
}
|
||||
@@ -399,7 +399,7 @@ main(int argc, char **argv)
|
||||
* Sanity checks for command line parameters completed by now;
|
||||
* any further errors will be runtime ones
|
||||
*/
|
||||
if(cli_errors.head != NULL)
|
||||
if (cli_errors.head != NULL)
|
||||
{
|
||||
exit_with_errors();
|
||||
}
|
||||
@@ -441,16 +441,16 @@ main(int argc, char **argv)
|
||||
* Initialise pg_bindir - command line parameter will override
|
||||
* any setting in the configuration file
|
||||
*/
|
||||
if(!strlen(runtime_options.pg_bindir))
|
||||
if (!strlen(runtime_options.pg_bindir))
|
||||
{
|
||||
strncpy(runtime_options.pg_bindir, options.pg_bindir, MAXLEN);
|
||||
}
|
||||
|
||||
/* Add trailing slash */
|
||||
if(strlen(runtime_options.pg_bindir))
|
||||
if (strlen(runtime_options.pg_bindir))
|
||||
{
|
||||
int len = strlen(runtime_options.pg_bindir);
|
||||
if(runtime_options.pg_bindir[len - 1] != '/')
|
||||
if (runtime_options.pg_bindir[len - 1] != '/')
|
||||
{
|
||||
maxlen_snprintf(pg_bindir, "%s/", runtime_options.pg_bindir);
|
||||
}
|
||||
@@ -488,7 +488,7 @@ main(int argc, char **argv)
|
||||
{
|
||||
if (options.node == NODE_NOT_FOUND)
|
||||
{
|
||||
if(config_file_parsed == true)
|
||||
if (config_file_parsed == true)
|
||||
{
|
||||
log_err(_("No node information was found. "
|
||||
"Check the configuration file.\n"));
|
||||
@@ -510,7 +510,7 @@ main(int argc, char **argv)
|
||||
* the version check for 9.4 or later is done in check_upstream_config()
|
||||
*/
|
||||
|
||||
if(options.use_replication_slots && wal_keep_segments_used)
|
||||
if (options.use_replication_slots && wal_keep_segments_used)
|
||||
{
|
||||
log_warning(_("-w/--wal-keep-segments has no effect when replication slots in use\n"));
|
||||
}
|
||||
@@ -527,7 +527,7 @@ main(int argc, char **argv)
|
||||
* the name of the slot, but does not imply a slot has been created.
|
||||
* The version check for 9.4 or later is done in check_upstream_config()
|
||||
*/
|
||||
if(options.use_replication_slots)
|
||||
if (options.use_replication_slots)
|
||||
{
|
||||
maxlen_snprintf(repmgr_slot_name, "repmgr_slot_%i", options.node);
|
||||
repmgr_slot_name_ptr = repmgr_slot_name;
|
||||
@@ -723,7 +723,7 @@ do_master_register(void)
|
||||
/* Create schema and associated database objects, if it does not exist */
|
||||
schema_exists = check_cluster_schema(conn);
|
||||
|
||||
if(!schema_exists)
|
||||
if (!schema_exists)
|
||||
{
|
||||
log_info(_("master register: creating database objects inside the %s schema\n"),
|
||||
get_repmgr_schema());
|
||||
@@ -800,7 +800,7 @@ do_master_register(void)
|
||||
options.priority,
|
||||
repmgr_slot_name_ptr);
|
||||
|
||||
if(record_created == false)
|
||||
if (record_created == false)
|
||||
{
|
||||
PQfinish(conn);
|
||||
exit(ERR_DB_QUERY);
|
||||
@@ -900,9 +900,9 @@ do_standby_register(void)
|
||||
|
||||
|
||||
|
||||
if(record_created == false)
|
||||
if (record_created == false)
|
||||
{
|
||||
if(!runtime_options.force)
|
||||
if (!runtime_options.force)
|
||||
{
|
||||
log_notice(_("HINT: use option -F/--force to overwrite an existing node record\n"));
|
||||
}
|
||||
@@ -1080,7 +1080,7 @@ do_standby_clone(void)
|
||||
|
||||
check_upstream_config(upstream_conn, server_version_num, true);
|
||||
|
||||
if(get_cluster_size(upstream_conn, cluster_size) == false)
|
||||
if (get_cluster_size(upstream_conn, cluster_size) == false)
|
||||
exit(ERR_DB_QUERY);
|
||||
|
||||
log_info(_("Successfully connected to upstream node. Current installation size is %s\n"),
|
||||
@@ -1091,9 +1091,9 @@ do_standby_clone(void)
|
||||
* we're connected to PostgreSQL 9.4 or later
|
||||
*/
|
||||
|
||||
if(*runtime_options.recovery_min_apply_delay)
|
||||
if (*runtime_options.recovery_min_apply_delay)
|
||||
{
|
||||
if(get_server_version(upstream_conn, NULL) < 90400)
|
||||
if (get_server_version(upstream_conn, NULL) < 90400)
|
||||
{
|
||||
log_err(_("PostgreSQL 9.4 or greater required for --recovery-min-apply-delay\n"));
|
||||
PQfinish(upstream_conn);
|
||||
@@ -1113,11 +1113,11 @@ do_standby_clone(void)
|
||||
# not set, fail with an error
|
||||
*/
|
||||
|
||||
if(options.tablespace_mapping.head != NULL)
|
||||
if (options.tablespace_mapping.head != NULL)
|
||||
{
|
||||
TablespaceListCell *cell;
|
||||
|
||||
if(get_server_version(upstream_conn, NULL) < 90400)
|
||||
if (get_server_version(upstream_conn, NULL) < 90400)
|
||||
{
|
||||
log_err(_("in PostgreSQL 9.3, tablespace mapping can only be used in conjunction with --rsync-only\n"));
|
||||
PQfinish(upstream_conn);
|
||||
@@ -1200,7 +1200,7 @@ do_standby_clone(void)
|
||||
}
|
||||
else if (strcmp(PQgetvalue(res, i, 0), "config_file") == 0)
|
||||
{
|
||||
if(strcmp(PQgetvalue(res, i, 2), "f") == 0)
|
||||
if (strcmp(PQgetvalue(res, i, 2), "f") == 0)
|
||||
{
|
||||
config_file_outside_pgdata = true;
|
||||
external_config_file_copy_required = true;
|
||||
@@ -1209,7 +1209,7 @@ do_standby_clone(void)
|
||||
}
|
||||
else if (strcmp(PQgetvalue(res, i, 0), "hba_file") == 0)
|
||||
{
|
||||
if(strcmp(PQgetvalue(res, i, 2), "f") == 0)
|
||||
if (strcmp(PQgetvalue(res, i, 2), "f") == 0)
|
||||
{
|
||||
hba_file_outside_pgdata = true;
|
||||
external_config_file_copy_required = true;
|
||||
@@ -1218,7 +1218,7 @@ do_standby_clone(void)
|
||||
}
|
||||
else if (strcmp(PQgetvalue(res, i, 0), "ident_file") == 0)
|
||||
{
|
||||
if(strcmp(PQgetvalue(res, i, 2), "f") == 0)
|
||||
if (strcmp(PQgetvalue(res, i, 2), "f") == 0)
|
||||
{
|
||||
ident_file_outside_pgdata = true;
|
||||
external_config_file_copy_required = true;
|
||||
@@ -1259,7 +1259,7 @@ do_standby_clone(void)
|
||||
/*
|
||||
* When using rsync only, we need to check the SSH connection early
|
||||
*/
|
||||
if(runtime_options.rsync_only)
|
||||
if (runtime_options.rsync_only)
|
||||
{
|
||||
r = test_ssh_connection(runtime_options.host, runtime_options.remote_user);
|
||||
if (r != 0)
|
||||
@@ -1283,19 +1283,19 @@ do_standby_clone(void)
|
||||
goto stop_backup;
|
||||
}
|
||||
|
||||
if(runtime_options.rsync_only)
|
||||
if (runtime_options.rsync_only)
|
||||
{
|
||||
/*
|
||||
* From pg 9.1 default is to wait for a sync standby to ack, avoid that by
|
||||
* turning off sync rep for this session
|
||||
*/
|
||||
if(set_config_bool(upstream_conn, "synchronous_commit", false) == false)
|
||||
if (set_config_bool(upstream_conn, "synchronous_commit", false) == false)
|
||||
{
|
||||
PQfinish(upstream_conn);
|
||||
exit(ERR_BAD_CONFIG);
|
||||
}
|
||||
|
||||
if(start_backup(upstream_conn, first_wal_segment, runtime_options.fast_checkpoint) == false)
|
||||
if (start_backup(upstream_conn, first_wal_segment, runtime_options.fast_checkpoint) == false)
|
||||
{
|
||||
r = ERR_BAD_BASEBACKUP;
|
||||
retval = ERR_BAD_BASEBACKUP;
|
||||
@@ -1364,11 +1364,11 @@ do_standby_clone(void)
|
||||
|
||||
/* Check if tablespace path matches one of the provided tablespace mappings */
|
||||
|
||||
if(options.tablespace_mapping.head != NULL)
|
||||
if (options.tablespace_mapping.head != NULL)
|
||||
{
|
||||
for (cell = options.tablespace_mapping.head; cell; cell = cell->next)
|
||||
{
|
||||
if(strcmp( tblspc_dir_src.data, cell->old_dir) == 0)
|
||||
if (strcmp( tblspc_dir_src.data, cell->old_dir) == 0)
|
||||
{
|
||||
mapping_found = true;
|
||||
break;
|
||||
@@ -1376,7 +1376,7 @@ do_standby_clone(void)
|
||||
}
|
||||
}
|
||||
|
||||
if(mapping_found == true)
|
||||
if (mapping_found == true)
|
||||
{
|
||||
appendPQExpBuffer(&tblspc_dir_dst, "%s", cell->new_dir);
|
||||
log_debug(_("mapping source tablespace '%s' (OID %s) to '%s'\n"),
|
||||
@@ -1394,7 +1394,7 @@ do_standby_clone(void)
|
||||
true, server_version_num);
|
||||
|
||||
/* Update symlink in pg_tblspc */
|
||||
if(mapping_found == true)
|
||||
if (mapping_found == true)
|
||||
{
|
||||
PQExpBufferData tblspc_symlink;
|
||||
|
||||
@@ -1439,7 +1439,7 @@ do_standby_clone(void)
|
||||
* standby server as on the primary?
|
||||
*/
|
||||
|
||||
if(external_config_file_copy_required && !runtime_options.ignore_external_config_files)
|
||||
if (external_config_file_copy_required && !runtime_options.ignore_external_config_files)
|
||||
{
|
||||
log_notice(_("copying configuration files from master\n"));
|
||||
r = test_ssh_connection(runtime_options.host, runtime_options.remote_user);
|
||||
@@ -1451,7 +1451,7 @@ do_standby_clone(void)
|
||||
goto stop_backup;
|
||||
}
|
||||
|
||||
if(config_file_outside_pgdata)
|
||||
if (config_file_outside_pgdata)
|
||||
{
|
||||
log_info(_("standby clone: master config file '%s'\n"), master_config_file);
|
||||
r = copy_remote_files(runtime_options.host, runtime_options.remote_user,
|
||||
@@ -1465,7 +1465,7 @@ do_standby_clone(void)
|
||||
}
|
||||
}
|
||||
|
||||
if(hba_file_outside_pgdata)
|
||||
if (hba_file_outside_pgdata)
|
||||
{
|
||||
log_info(_("standby clone: master hba file '%s'\n"), master_hba_file);
|
||||
r = copy_remote_files(runtime_options.host, runtime_options.remote_user,
|
||||
@@ -1479,7 +1479,7 @@ do_standby_clone(void)
|
||||
}
|
||||
}
|
||||
|
||||
if(ident_file_outside_pgdata)
|
||||
if (ident_file_outside_pgdata)
|
||||
{
|
||||
log_info(_("standby clone: master ident file '%s'\n"), master_ident_file);
|
||||
r = copy_remote_files(runtime_options.host, runtime_options.remote_user,
|
||||
@@ -1498,7 +1498,7 @@ do_standby_clone(void)
|
||||
* When using rsync, copy pg_control file last, emulating the base backup
|
||||
* protocol.
|
||||
*/
|
||||
if(runtime_options.rsync_only)
|
||||
if (runtime_options.rsync_only)
|
||||
{
|
||||
maxlen_snprintf(local_control_file, "%s/global", local_data_directory);
|
||||
|
||||
@@ -1530,10 +1530,10 @@ do_standby_clone(void)
|
||||
|
||||
stop_backup:
|
||||
|
||||
if(runtime_options.rsync_only && pg_start_backup_executed)
|
||||
if (runtime_options.rsync_only && pg_start_backup_executed)
|
||||
{
|
||||
log_notice(_("notifying master about backup completion...\n"));
|
||||
if(stop_backup(upstream_conn, last_wal_segment) == false)
|
||||
if (stop_backup(upstream_conn, last_wal_segment) == false)
|
||||
{
|
||||
r = ERR_BAD_BASEBACKUP;
|
||||
retval = ERR_BAD_BASEBACKUP;
|
||||
@@ -1576,16 +1576,16 @@ stop_backup:
|
||||
* create_recovery_file() will already have written `primary_slot_name` into
|
||||
* `recovery.conf`
|
||||
*/
|
||||
if(options.use_replication_slots)
|
||||
if (options.use_replication_slots)
|
||||
{
|
||||
if(create_replication_slot(upstream_conn, repmgr_slot_name) == false)
|
||||
if (create_replication_slot(upstream_conn, repmgr_slot_name) == false)
|
||||
{
|
||||
PQfinish(upstream_conn);
|
||||
exit(ERR_DB_QUERY);
|
||||
}
|
||||
}
|
||||
|
||||
if(runtime_options.rsync_only)
|
||||
if (runtime_options.rsync_only)
|
||||
{
|
||||
log_notice(_("standby clone (using rsync) complete\n"));
|
||||
}
|
||||
@@ -1730,7 +1730,7 @@ do_standby_promote(void)
|
||||
for(i = 0; i < promote_check_timeout; i += promote_check_interval)
|
||||
{
|
||||
retval = is_standby(conn);
|
||||
if(!retval)
|
||||
if (!retval)
|
||||
{
|
||||
promote_success = true;
|
||||
break;
|
||||
@@ -1748,7 +1748,7 @@ do_standby_promote(void)
|
||||
|
||||
|
||||
/* update node information to reflect new status */
|
||||
if(update_node_record_set_master(conn, options.node) == false)
|
||||
if (update_node_record_set_master(conn, options.node) == false)
|
||||
{
|
||||
initPQExpBuffer(&details);
|
||||
appendPQExpBuffer(&details,
|
||||
@@ -1904,7 +1904,7 @@ do_standby_follow(void)
|
||||
exit(ERR_NO_RESTART);
|
||||
}
|
||||
|
||||
if(update_node_record_set_upstream(master_conn, options.cluster_name,
|
||||
if (update_node_record_set_upstream(master_conn, options.cluster_name,
|
||||
options.node, master_id) == false)
|
||||
{
|
||||
log_err(_("unable to update upstream node"));
|
||||
@@ -2148,7 +2148,7 @@ do_witness_create(void)
|
||||
}
|
||||
|
||||
/* check if we need to create a database */
|
||||
if(runtime_options.dbname[0] && strcmp(runtime_options.dbname,"postgres") != 0 && runtime_options.localport[0])
|
||||
if (runtime_options.dbname[0] && strcmp(runtime_options.dbname,"postgres") != 0 && runtime_options.localport[0])
|
||||
{
|
||||
/* create required db */
|
||||
sprintf(script, "%s -p %s -U %s --owner=%s %s",
|
||||
@@ -2245,7 +2245,7 @@ do_witness_create(void)
|
||||
options.priority,
|
||||
NULL);
|
||||
|
||||
if(record_created == false)
|
||||
if (record_created == false)
|
||||
{
|
||||
create_event_record(masterconn,
|
||||
&options,
|
||||
@@ -2412,7 +2412,7 @@ create_recovery_file(const char *data_dir)
|
||||
/* standby_mode = 'on' */
|
||||
maxlen_snprintf(line, "standby_mode = 'on'\n");
|
||||
|
||||
if(write_recovery_file_line(recovery_file, recovery_file_path, line) == false)
|
||||
if (write_recovery_file_line(recovery_file, recovery_file_path, line) == false)
|
||||
return false;
|
||||
|
||||
log_debug(_("recovery.conf: %s"), line);
|
||||
@@ -2420,7 +2420,7 @@ create_recovery_file(const char *data_dir)
|
||||
/* primary_conninfo = '...' */
|
||||
write_primary_conninfo(line);
|
||||
|
||||
if(write_recovery_file_line(recovery_file, recovery_file_path, line) == false)
|
||||
if (write_recovery_file_line(recovery_file, recovery_file_path, line) == false)
|
||||
return false;
|
||||
|
||||
log_debug(_("recovery.conf: %s"), line);
|
||||
@@ -2428,28 +2428,28 @@ create_recovery_file(const char *data_dir)
|
||||
/* recovery_target_timeline = 'latest' */
|
||||
maxlen_snprintf(line, "recovery_target_timeline = 'latest'\n");
|
||||
|
||||
if(write_recovery_file_line(recovery_file, recovery_file_path, line) == false)
|
||||
if (write_recovery_file_line(recovery_file, recovery_file_path, line) == false)
|
||||
return false;
|
||||
|
||||
log_debug(_("recovery.conf: %s"), line);
|
||||
|
||||
/* recovery_min_apply_delay = ... (optional) */
|
||||
if(*runtime_options.recovery_min_apply_delay)
|
||||
if (*runtime_options.recovery_min_apply_delay)
|
||||
{
|
||||
maxlen_snprintf(line, "recovery_min_apply_delay = %s\n",
|
||||
runtime_options.recovery_min_apply_delay);
|
||||
if(write_recovery_file_line(recovery_file, recovery_file_path, line) == false)
|
||||
if (write_recovery_file_line(recovery_file, recovery_file_path, line) == false)
|
||||
return false;
|
||||
|
||||
log_debug(_("recovery.conf: %s"), line);
|
||||
}
|
||||
|
||||
/* primary_slot_name = '...' (optional, for 9.4 and later) */
|
||||
if(options.use_replication_slots)
|
||||
if (options.use_replication_slots)
|
||||
{
|
||||
maxlen_snprintf(line, "primary_slot_name = %s\n",
|
||||
repmgr_slot_name);
|
||||
if(write_recovery_file_line(recovery_file, recovery_file_path, line) == false)
|
||||
if (write_recovery_file_line(recovery_file, recovery_file_path, line) == false)
|
||||
return false;
|
||||
|
||||
log_debug(_("recovery.conf: %s"), line);
|
||||
@@ -2563,7 +2563,7 @@ copy_remote_files(char *host, char *remote_user, char *remote_path,
|
||||
appendPQExpBuffer(&rsync_flags, "%s",
|
||||
" --exclude=postmaster.pid --exclude=postmaster.opts --exclude=global/pg_control");
|
||||
|
||||
if(server_version_num >= 90400)
|
||||
if (server_version_num >= 90400)
|
||||
{
|
||||
/*
|
||||
* Ideally we'd use PG_AUTOCONF_FILENAME from utils/guc.h, but
|
||||
@@ -2581,7 +2581,7 @@ copy_remote_files(char *host, char *remote_user, char *remote_path,
|
||||
appendPQExpBuffer(&rsync_flags, "%s",
|
||||
" --exclude=pg_xlog/* --exclude=pg_log/* --exclude=pg_stat_tmp/*");
|
||||
|
||||
if(server_version_num >= 90400)
|
||||
if (server_version_num >= 90400)
|
||||
{
|
||||
appendPQExpBuffer(&rsync_flags, "%s",
|
||||
" --exclude=pg_replslot/*");
|
||||
@@ -2622,26 +2622,26 @@ run_basebackup(const char *data_dir)
|
||||
|
||||
appendPQExpBuffer(¶ms, " -D %s", data_dir);
|
||||
|
||||
if(strlen(runtime_options.host))
|
||||
if (strlen(runtime_options.host))
|
||||
{
|
||||
appendPQExpBuffer(¶ms, " -h %s", runtime_options.host);
|
||||
}
|
||||
|
||||
if(strlen(runtime_options.masterport))
|
||||
if (strlen(runtime_options.masterport))
|
||||
{
|
||||
appendPQExpBuffer(¶ms, " -p %s", runtime_options.masterport);
|
||||
}
|
||||
|
||||
if(strlen(runtime_options.username))
|
||||
if (strlen(runtime_options.username))
|
||||
{
|
||||
appendPQExpBuffer(¶ms, " -U %s", runtime_options.username);
|
||||
}
|
||||
|
||||
if(runtime_options.fast_checkpoint) {
|
||||
if (runtime_options.fast_checkpoint) {
|
||||
appendPQExpBuffer(¶ms, " -c fast");
|
||||
}
|
||||
|
||||
if(options.tablespace_mapping.head != NULL)
|
||||
if (options.tablespace_mapping.head != NULL)
|
||||
{
|
||||
for (cell = options.tablespace_mapping.head; cell; cell = cell->next)
|
||||
{
|
||||
@@ -2801,24 +2801,24 @@ check_parameters_for_action(const int action)
|
||||
break;
|
||||
}
|
||||
|
||||
if(action != STANDBY_CLONE)
|
||||
if (action != STANDBY_CLONE)
|
||||
{
|
||||
if(runtime_options.rsync_only)
|
||||
if (runtime_options.rsync_only)
|
||||
{
|
||||
error_list_append(_("--rsync-only can only be used when executing STANDBY CLONE"));
|
||||
}
|
||||
|
||||
if(runtime_options.fast_checkpoint)
|
||||
if (runtime_options.fast_checkpoint)
|
||||
{
|
||||
error_list_append(_("--fast-checkpoint can only be used when executing STANDBY CLONE"));
|
||||
}
|
||||
|
||||
if(runtime_options.ignore_external_config_files)
|
||||
if (runtime_options.ignore_external_config_files)
|
||||
{
|
||||
error_list_append(_("--ignore-external-config-files can only be used when executing STANDBY CLONE"));
|
||||
}
|
||||
|
||||
if(*runtime_options.recovery_min_apply_delay)
|
||||
if (*runtime_options.recovery_min_apply_delay)
|
||||
{
|
||||
error_list_append(_("--recovery-min-apply-delay can only be used when executing STANDBY CLONE"));
|
||||
}
|
||||
@@ -2844,7 +2844,7 @@ create_schema(PGconn *conn)
|
||||
log_err(_("unable to create the schema %s: %s\n"),
|
||||
get_repmgr_schema(), PQerrorMessage(conn));
|
||||
|
||||
if(res != NULL)
|
||||
if (res != NULL)
|
||||
PQclear(res);
|
||||
|
||||
return false;
|
||||
@@ -2871,7 +2871,7 @@ create_schema(PGconn *conn)
|
||||
log_err(_("unable to create the function repmgr_update_last_updated: %s\n"),
|
||||
PQerrorMessage(conn));
|
||||
|
||||
if(res != NULL)
|
||||
if (res != NULL)
|
||||
PQclear(res);
|
||||
|
||||
return false;
|
||||
@@ -2892,7 +2892,7 @@ create_schema(PGconn *conn)
|
||||
log_err(_("unable to create the function repmgr_get_last_updated: %s\n"),
|
||||
PQerrorMessage(conn));
|
||||
|
||||
if(res != NULL)
|
||||
if (res != NULL)
|
||||
PQclear(res);
|
||||
|
||||
return false;
|
||||
@@ -2924,7 +2924,7 @@ create_schema(PGconn *conn)
|
||||
log_err(_("unable to create table '%s.repl_nodes': %s\n"),
|
||||
get_repmgr_schema_quoted(conn), PQerrorMessage(conn));
|
||||
|
||||
if(res != NULL)
|
||||
if (res != NULL)
|
||||
PQclear(res);
|
||||
|
||||
return false;
|
||||
@@ -2951,7 +2951,7 @@ create_schema(PGconn *conn)
|
||||
log_err(_("unable to create table '%s.repl_monitor': %s\n"),
|
||||
get_repmgr_schema_quoted(conn), PQerrorMessage(conn));
|
||||
|
||||
if(res != NULL)
|
||||
if (res != NULL)
|
||||
PQclear(res);
|
||||
|
||||
return false;
|
||||
@@ -2977,7 +2977,7 @@ create_schema(PGconn *conn)
|
||||
log_err(_("unable to create table '%s.repl_events': %s\n"),
|
||||
get_repmgr_schema_quoted(conn), PQerrorMessage(conn));
|
||||
|
||||
if(res != NULL)
|
||||
if (res != NULL)
|
||||
PQclear(res);
|
||||
|
||||
return false;
|
||||
@@ -3014,7 +3014,7 @@ create_schema(PGconn *conn)
|
||||
log_err(_("unable to create view %s.repl_status: %s\n"),
|
||||
get_repmgr_schema_quoted(conn), PQerrorMessage(conn));
|
||||
|
||||
if(res != NULL)
|
||||
if (res != NULL)
|
||||
PQclear(res);
|
||||
|
||||
return false;
|
||||
@@ -3034,7 +3034,7 @@ create_schema(PGconn *conn)
|
||||
log_err(_("unable to create index 'idx_repl_status_sort' on '%s.repl_monitor': %s\n"),
|
||||
get_repmgr_schema_quoted(conn), PQerrorMessage(conn));
|
||||
|
||||
if(res != NULL)
|
||||
if (res != NULL)
|
||||
PQclear(res);
|
||||
|
||||
return false;
|
||||
@@ -3058,7 +3058,7 @@ create_schema(PGconn *conn)
|
||||
fprintf(stderr, "Cannot create the function repmgr_update_standby_location: %s\n",
|
||||
PQerrorMessage(conn));
|
||||
|
||||
if(res != NULL)
|
||||
if (res != NULL)
|
||||
PQclear(res);
|
||||
|
||||
return false;
|
||||
@@ -3078,7 +3078,7 @@ create_schema(PGconn *conn)
|
||||
fprintf(stderr, "Cannot create the function repmgr_get_last_standby_location: %s\n",
|
||||
PQerrorMessage(conn));
|
||||
|
||||
if(res != NULL)
|
||||
if (res != NULL)
|
||||
PQclear(res);
|
||||
|
||||
return false;
|
||||
@@ -3162,7 +3162,7 @@ check_server_version(PGconn *conn, char *server_type, bool exit_on_error, char *
|
||||
int server_version_num = 0;
|
||||
|
||||
server_version_num = get_server_version(conn, server_version_string);
|
||||
if(server_version_num < MIN_SUPPORTED_VERSION_NUM)
|
||||
if (server_version_num < MIN_SUPPORTED_VERSION_NUM)
|
||||
{
|
||||
if (server_version_num > 0)
|
||||
log_err(_("%s requires %s to be PostgreSQL %s or later\n"),
|
||||
@@ -3171,7 +3171,7 @@ check_server_version(PGconn *conn, char *server_type, bool exit_on_error, char *
|
||||
MIN_SUPPORTED_VERSION
|
||||
);
|
||||
|
||||
if(exit_on_error == true)
|
||||
if (exit_on_error == true)
|
||||
{
|
||||
PQfinish(conn);
|
||||
exit(ERR_BAD_CONFIG);
|
||||
@@ -3205,7 +3205,7 @@ check_master_standby_version_match(PGconn *conn, PGconn *master_conn)
|
||||
|
||||
/* Verify that master is a supported server version */
|
||||
master_version_num = check_server_version(conn, "master", false, master_version);
|
||||
if(master_version_num < 0)
|
||||
if (master_version_num < 0)
|
||||
{
|
||||
PQfinish(conn);
|
||||
PQfinish(master_conn);
|
||||
@@ -3242,7 +3242,7 @@ check_upstream_config(PGconn *conn, int server_version_num, bool exit_on_error)
|
||||
char *wal_error_message = NULL;
|
||||
|
||||
/* Check that WAL level is set correctly */
|
||||
if(server_version_num < 90300)
|
||||
if (server_version_num < 90300)
|
||||
{
|
||||
i = guc_set(conn, "wal_level", "=", "hot_standby");
|
||||
wal_error_message = _("parameter 'wal_level' must be set to 'hot_standby'");
|
||||
@@ -3260,7 +3260,7 @@ check_upstream_config(PGconn *conn, int server_version_num, bool exit_on_error)
|
||||
for(; j < 2; j++)
|
||||
{
|
||||
i = guc_set(conn, "wal_level", "=", levels[j]);
|
||||
if(i)
|
||||
if (i)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -3273,7 +3273,7 @@ check_upstream_config(PGconn *conn, int server_version_num, bool exit_on_error)
|
||||
log_err("%s\n",
|
||||
wal_error_message);
|
||||
|
||||
if(exit_on_error == true)
|
||||
if (exit_on_error == true)
|
||||
{
|
||||
PQfinish(conn);
|
||||
exit(ERR_BAD_CONFIG);
|
||||
@@ -3282,14 +3282,14 @@ check_upstream_config(PGconn *conn, int server_version_num, bool exit_on_error)
|
||||
config_ok = false;
|
||||
}
|
||||
|
||||
if(options.use_replication_slots)
|
||||
if (options.use_replication_slots)
|
||||
{
|
||||
/* Does the server support physical replication slots? */
|
||||
if(server_version_num < 90400)
|
||||
if (server_version_num < 90400)
|
||||
{
|
||||
log_err(_("server version must be 9.4 or later to enable replication slots\n"));
|
||||
|
||||
if(exit_on_error == true)
|
||||
if (exit_on_error == true)
|
||||
{
|
||||
PQfinish(conn);
|
||||
exit(ERR_BAD_CONFIG);
|
||||
@@ -3308,7 +3308,7 @@ check_upstream_config(PGconn *conn, int server_version_num, bool exit_on_error)
|
||||
{
|
||||
log_err(_("parameter 'max_replication_slots' must be set to at least 1 to enable replication slots\n"));
|
||||
log_notice(_("HINT: 'max_replication_slots' should be set to at least the number of expected standbys\n"));
|
||||
if(exit_on_error == true)
|
||||
if (exit_on_error == true)
|
||||
{
|
||||
PQfinish(conn);
|
||||
exit(ERR_BAD_CONFIG);
|
||||
@@ -3334,7 +3334,7 @@ check_upstream_config(PGconn *conn, int server_version_num, bool exit_on_error)
|
||||
{
|
||||
log_err(_("parameter 'wal_keep_segments' must be be set to %s or greater (see the '-w' option or edit the postgresql.conf of the upstream server.)\n"),
|
||||
runtime_options.wal_keep_segments);
|
||||
if(server_version_num >= 90400)
|
||||
if (server_version_num >= 90400)
|
||||
{
|
||||
log_notice(_("HINT: in PostgreSQL 9.4 and later, replication slots can be used, which "
|
||||
"do not require 'wal_keep_segments' to be set to a high value "
|
||||
@@ -3343,7 +3343,7 @@ check_upstream_config(PGconn *conn, int server_version_num, bool exit_on_error)
|
||||
}
|
||||
}
|
||||
|
||||
if(exit_on_error == true)
|
||||
if (exit_on_error == true)
|
||||
{
|
||||
PQfinish(conn);
|
||||
exit(ERR_BAD_CONFIG);
|
||||
@@ -3359,7 +3359,7 @@ check_upstream_config(PGconn *conn, int server_version_num, bool exit_on_error)
|
||||
if (i == 0)
|
||||
log_err(_("parameter 'archive_mode' must be set to 'on'\n"));
|
||||
|
||||
if(exit_on_error == true)
|
||||
if (exit_on_error == true)
|
||||
{
|
||||
PQfinish(conn);
|
||||
exit(ERR_BAD_CONFIG);
|
||||
@@ -3378,7 +3378,7 @@ check_upstream_config(PGconn *conn, int server_version_num, bool exit_on_error)
|
||||
* properly check it.
|
||||
*/
|
||||
|
||||
if(guc_set(conn, "archive_mode", "=", "on"))
|
||||
if (guc_set(conn, "archive_mode", "=", "on"))
|
||||
{
|
||||
i = guc_set(conn, "archive_command", "!=", "");
|
||||
|
||||
@@ -3387,7 +3387,7 @@ check_upstream_config(PGconn *conn, int server_version_num, bool exit_on_error)
|
||||
if (i == 0)
|
||||
log_err(_("parameter 'archive_command' must be set to a valid command\n"));
|
||||
|
||||
if(exit_on_error == true)
|
||||
if (exit_on_error == true)
|
||||
{
|
||||
PQfinish(conn);
|
||||
exit(ERR_BAD_CONFIG);
|
||||
@@ -3404,7 +3404,7 @@ check_upstream_config(PGconn *conn, int server_version_num, bool exit_on_error)
|
||||
if (i == 0)
|
||||
log_err(_("parameter 'hot_standby' must be set to 'on'\n"));
|
||||
|
||||
if(exit_on_error == true)
|
||||
if (exit_on_error == true)
|
||||
{
|
||||
PQfinish(conn);
|
||||
exit(ERR_BAD_CONFIG);
|
||||
@@ -3422,7 +3422,7 @@ check_upstream_config(PGconn *conn, int server_version_num, bool exit_on_error)
|
||||
log_notice(_("HINT: 'max_wal_senders' should be set to at least the number of expected standbys\n"));
|
||||
}
|
||||
|
||||
if(exit_on_error == true)
|
||||
if (exit_on_error == true)
|
||||
{
|
||||
PQfinish(conn);
|
||||
exit(ERR_BAD_CONFIG);
|
||||
@@ -3524,7 +3524,7 @@ do_check_upstream_config(void)
|
||||
|
||||
config_ok = check_upstream_config(conn, server_version_num, false);
|
||||
|
||||
if(config_ok == true)
|
||||
if (config_ok == true)
|
||||
{
|
||||
puts(_("No configuration problems found with the upstream server"));
|
||||
}
|
||||
@@ -3549,7 +3549,7 @@ error_list_append(char *error_message)
|
||||
|
||||
cell = (ErrorListCell *) pg_malloc0(sizeof(ErrorListCell));
|
||||
|
||||
if(cell == NULL)
|
||||
if (cell == NULL)
|
||||
{
|
||||
log_err(_("unable to allocate memory; terminating.\n"));
|
||||
exit(ERR_BAD_CONFIG);
|
||||
@@ -3557,7 +3557,7 @@ error_list_append(char *error_message)
|
||||
|
||||
cell->error_message = error_message;
|
||||
|
||||
if(cli_errors.tail)
|
||||
if (cli_errors.tail)
|
||||
{
|
||||
cli_errors.tail->next = cell;
|
||||
}
|
||||
|
||||
64
repmgrd.c
64
repmgrd.c
@@ -259,7 +259,7 @@ main(int argc, char **argv)
|
||||
|
||||
server_version_num = get_server_version(my_local_conn, NULL);
|
||||
|
||||
if(server_version_num < MIN_SUPPORTED_VERSION_NUM)
|
||||
if (server_version_num < MIN_SUPPORTED_VERSION_NUM)
|
||||
{
|
||||
if (server_version_num > 0)
|
||||
{
|
||||
@@ -279,7 +279,7 @@ main(int argc, char **argv)
|
||||
node_info = get_node_info(my_local_conn, local_options.cluster_name, local_options.node);
|
||||
|
||||
/* No node record found - exit gracefully */
|
||||
if(node_info.node_id == NODE_NOT_FOUND)
|
||||
if (node_info.node_id == NODE_NOT_FOUND)
|
||||
{
|
||||
log_err(_("No metadata record found for this node - terminating\n"));
|
||||
log_notice(_("HINT: was this node registered with 'repmgr (master|standby) register'?\n"));
|
||||
@@ -320,7 +320,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
/* Log startup event */
|
||||
if(startup_event_logged == false)
|
||||
if (startup_event_logged == false)
|
||||
{
|
||||
create_event_record(master_conn,
|
||||
&local_options,
|
||||
@@ -431,7 +431,7 @@ main(int argc, char **argv)
|
||||
update_registration();
|
||||
}
|
||||
/* Log startup event */
|
||||
if(startup_event_logged == false)
|
||||
if (startup_event_logged == false)
|
||||
{
|
||||
create_event_record(master_conn,
|
||||
&local_options,
|
||||
@@ -483,7 +483,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
got_SIGHUP = false;
|
||||
}
|
||||
if(failover_done)
|
||||
if (failover_done)
|
||||
{
|
||||
log_debug(_("standby check loop will terminate\n"));
|
||||
}
|
||||
@@ -530,7 +530,7 @@ witness_monitor(void)
|
||||
*/
|
||||
connection_ok = check_connection(&master_conn, "master", NULL);
|
||||
|
||||
if(connection_ok == false)
|
||||
if (connection_ok == false)
|
||||
{
|
||||
int connection_retries;
|
||||
log_debug(_("old master node ID: %i\n"), master_options.node);
|
||||
@@ -581,7 +581,7 @@ witness_monitor(void)
|
||||
}
|
||||
}
|
||||
|
||||
if(connection_ok == false)
|
||||
if (connection_ok == false)
|
||||
{
|
||||
PQExpBufferData errmsg;
|
||||
initPQExpBuffer(&errmsg);
|
||||
@@ -809,7 +809,7 @@ standby_monitor(void)
|
||||
*/
|
||||
upstream_node = get_node_info(my_local_conn, local_options.cluster_name, node_info.upstream_node_id);
|
||||
|
||||
if(upstream_node.type == MASTER)
|
||||
if (upstream_node.type == MASTER)
|
||||
{
|
||||
log_debug(_("failure detected on master node (%i); attempting to promote a standby\n"),
|
||||
node_info.upstream_node_id);
|
||||
@@ -820,7 +820,7 @@ standby_monitor(void)
|
||||
log_debug(_("failure detected on upstream node %i; attempting to reconnect to new upstream node\n"),
|
||||
node_info.upstream_node_id);
|
||||
|
||||
if(!do_upstream_standby_failover(upstream_node))
|
||||
if (!do_upstream_standby_failover(upstream_node))
|
||||
{
|
||||
PQExpBufferData errmsg;
|
||||
initPQExpBuffer(&errmsg);
|
||||
@@ -917,7 +917,7 @@ standby_monitor(void)
|
||||
return;
|
||||
}
|
||||
|
||||
if(PQntuples(res) == 0)
|
||||
if (PQntuples(res) == 0)
|
||||
{
|
||||
log_err(_("standby_monitor(): no active master found\n"));
|
||||
PQclear(res);
|
||||
@@ -927,10 +927,10 @@ standby_monitor(void)
|
||||
active_master_id = atoi(PQgetvalue(res, 0, 0));
|
||||
PQclear(res);
|
||||
|
||||
if(active_master_id != master_options.node)
|
||||
if (active_master_id != master_options.node)
|
||||
{
|
||||
log_notice(_("connecting to active master (node %i)...\n"), active_master_id); \
|
||||
if(master_conn != NULL)
|
||||
if (master_conn != NULL)
|
||||
{
|
||||
PQfinish(master_conn);
|
||||
}
|
||||
@@ -1102,7 +1102,7 @@ do_master_failover(void)
|
||||
|
||||
/* Copy details of the failed node */
|
||||
/* XXX only node_id is actually used later */
|
||||
if(nodes[i].type == MASTER)
|
||||
if (nodes[i].type == MASTER)
|
||||
{
|
||||
failed_master.node_id = nodes[i].node_id;
|
||||
failed_master.xlog_location = nodes[i].xlog_location;
|
||||
@@ -1208,7 +1208,7 @@ do_master_failover(void)
|
||||
|
||||
/* If position is 0/0, error */
|
||||
/* XXX do we need to terminate ourselves if the queried node has a problem? */
|
||||
if(xlog_recptr == InvalidXLogRecPtr)
|
||||
if (xlog_recptr == InvalidXLogRecPtr)
|
||||
{
|
||||
log_err(_("InvalidXLogRecPtr detected on standby node %i\n"), nodes[i].node_id);
|
||||
terminate(ERR_FAILOVER_FAIL);
|
||||
@@ -1298,12 +1298,12 @@ do_master_failover(void)
|
||||
* empty string; otherwise position is 0/0 and we need to continue
|
||||
* looping until a valid LSN is reported
|
||||
*/
|
||||
if(xlog_recptr == InvalidXLogRecPtr)
|
||||
if (xlog_recptr == InvalidXLogRecPtr)
|
||||
{
|
||||
if(lsn_format_ok == false)
|
||||
if (lsn_format_ok == false)
|
||||
{
|
||||
/* Unable to parse value returned by `repmgr_get_last_standby_location()` */
|
||||
if(*PQgetvalue(res, 0, 0) == '\0')
|
||||
if (*PQgetvalue(res, 0, 0) == '\0')
|
||||
{
|
||||
log_crit(
|
||||
_("unable to obtain LSN from node %i"), nodes[i].node_id
|
||||
@@ -1483,9 +1483,9 @@ do_master_failover(void)
|
||||
*/
|
||||
new_master_conn = establish_db_connection(best_candidate.conninfo_str, true);
|
||||
|
||||
if(local_options.use_replication_slots)
|
||||
if (local_options.use_replication_slots)
|
||||
{
|
||||
if(create_replication_slot(new_master_conn, node_info.slot_name) == false)
|
||||
if (create_replication_slot(new_master_conn, node_info.slot_name) == false)
|
||||
{
|
||||
|
||||
appendPQExpBuffer(&event_details,
|
||||
@@ -1518,7 +1518,7 @@ do_master_failover(void)
|
||||
my_local_conn = establish_db_connection(local_options.conninfo, true);
|
||||
|
||||
/* update node information to reflect new status */
|
||||
if(update_node_record_set_upstream(new_master_conn, local_options.cluster_name, node_info.node_id, best_candidate.node_id) == false)
|
||||
if (update_node_record_set_upstream(new_master_conn, local_options.cluster_name, node_info.node_id, best_candidate.node_id) == false)
|
||||
{
|
||||
appendPQExpBuffer(&event_details,
|
||||
_("Unable to update node record for node %i (following new upstream node %i)"),
|
||||
@@ -1610,7 +1610,7 @@ do_upstream_standby_failover(t_node_info upstream_node)
|
||||
return false;
|
||||
}
|
||||
|
||||
if(PQntuples(res) == 0)
|
||||
if (PQntuples(res) == 0)
|
||||
{
|
||||
log_err(_("no node with id %i found"), upstream_node_id);
|
||||
PQclear(res);
|
||||
@@ -1618,7 +1618,7 @@ do_upstream_standby_failover(t_node_info upstream_node)
|
||||
}
|
||||
|
||||
/* upstream node is inactive */
|
||||
if(strcmp(PQgetvalue(res, 0, 1), "f") == 0)
|
||||
if (strcmp(PQgetvalue(res, 0, 1), "f") == 0)
|
||||
{
|
||||
/*
|
||||
* Upstream node is an inactive master, meaning no there are no direct
|
||||
@@ -1628,7 +1628,7 @@ do_upstream_standby_failover(t_node_info upstream_node)
|
||||
* provide an option to either try and find the current master and/or
|
||||
* a strategy to connect to a different upstream node
|
||||
*/
|
||||
if(strcmp(PQgetvalue(res, 0, 4), "master") == 0)
|
||||
if (strcmp(PQgetvalue(res, 0, 4), "master") == 0)
|
||||
{
|
||||
log_err(_("unable to find active master node\n"));
|
||||
PQclear(res);
|
||||
@@ -1662,7 +1662,7 @@ do_upstream_standby_failover(t_node_info upstream_node)
|
||||
terminate(ERR_BAD_CONFIG);
|
||||
}
|
||||
|
||||
if(update_node_record_set_upstream(master_conn, local_options.cluster_name, node_info.node_id, upstream_node_id) == false)
|
||||
if (update_node_record_set_upstream(master_conn, local_options.cluster_name, node_info.node_id, upstream_node_id) == false)
|
||||
{
|
||||
terminate(ERR_BAD_CONFIG);
|
||||
}
|
||||
@@ -1771,7 +1771,7 @@ set_local_node_failed(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!PQntuples(res))
|
||||
if (!PQntuples(res))
|
||||
{
|
||||
log_err(_("no active master record found\n"));
|
||||
return false;
|
||||
@@ -1781,14 +1781,14 @@ set_local_node_failed(void)
|
||||
strncpy(master_conninfo, PQgetvalue(res, 0, 1), MAXLEN);
|
||||
PQclear(res);
|
||||
|
||||
if(active_master_node_id != master_options.node)
|
||||
if (active_master_node_id != master_options.node)
|
||||
{
|
||||
log_notice(_("current active master is %i; attempting to connect\n"),
|
||||
active_master_node_id);
|
||||
PQfinish(master_conn);
|
||||
master_conn = establish_db_connection(master_conninfo, false);
|
||||
|
||||
if(PQstatus(master_conn) != CONNECTION_OK)
|
||||
if (PQstatus(master_conn) != CONNECTION_OK)
|
||||
{
|
||||
log_err(_("unable to connect to active master\n"));
|
||||
return false;
|
||||
@@ -1946,13 +1946,13 @@ lsn_to_xlogrecptr(char *lsn, bool *format_ok)
|
||||
|
||||
if (sscanf(lsn, "%X/%X", &xlogid, &xrecoff) != 2)
|
||||
{
|
||||
if(format_ok != NULL)
|
||||
if (format_ok != NULL)
|
||||
*format_ok = false;
|
||||
log_err(_("incorrect log location format: %s\n"), lsn);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(format_ok != NULL)
|
||||
if (format_ok != NULL)
|
||||
*format_ok = true;
|
||||
|
||||
return (((XLogRecPtr) xlogid * 16 * 1024 * 1024 * 255) + xrecoff);
|
||||
@@ -2280,15 +2280,15 @@ get_node_info(PGconn *conn, char *cluster, int node_id)
|
||||
static t_server_type
|
||||
parse_node_type(const char *type)
|
||||
{
|
||||
if(strcmp(type, "master") == 0)
|
||||
if (strcmp(type, "master") == 0)
|
||||
{
|
||||
return MASTER;
|
||||
}
|
||||
else if(strcmp(type, "standby") == 0)
|
||||
else if (strcmp(type, "standby") == 0)
|
||||
{
|
||||
return STANDBY;
|
||||
}
|
||||
else if(strcmp(type, "witness") == 0)
|
||||
else if (strcmp(type, "witness") == 0)
|
||||
{
|
||||
return WITNESS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user