mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-26 08:36:30 +00:00
Clean up calls to repmgr_atoi()
In some places we were still providing "false" from the original implementation, which was intended to indicate whether a negative value was allowed. This has not been a problem, as it merely means we have been providing "0", which is the same thing; however we can finer-tune some of the calls (e.g. node ID must be or greater).
This commit is contained in:
@@ -473,7 +473,7 @@ _parse_config(t_configuration_options *options, ItemList *error_list, ItemList *
|
|||||||
/* Copy into correct entry in parameters struct */
|
/* Copy into correct entry in parameters struct */
|
||||||
if (strcmp(name, "node_id") == 0)
|
if (strcmp(name, "node_id") == 0)
|
||||||
{
|
{
|
||||||
options->node_id = repmgr_atoi(value, name, error_list, 1);
|
options->node_id = repmgr_atoi(value, name, error_list, MIN_NODE_ID);
|
||||||
node_id_found = true;
|
node_id_found = true;
|
||||||
}
|
}
|
||||||
else if (strcmp(name, "node_name") == 0)
|
else if (strcmp(name, "node_name") == 0)
|
||||||
|
|||||||
@@ -294,7 +294,12 @@ main(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'p':
|
case 'p':
|
||||||
(void) repmgr_atoi(optarg, "-p/--port", &cli_errors, false);
|
/*
|
||||||
|
* minimum TCP port number is 1; in practice PostgreSQL
|
||||||
|
* won't be running on a privileged port, but we don't want
|
||||||
|
* to be concerned with that level of checking
|
||||||
|
*/
|
||||||
|
(void) repmgr_atoi(optarg, "-p/--port", &cli_errors, 1);
|
||||||
param_set(&source_conninfo, "port", optarg);
|
param_set(&source_conninfo, "port", optarg);
|
||||||
strncpy(runtime_options.port,
|
strncpy(runtime_options.port,
|
||||||
optarg,
|
optarg,
|
||||||
@@ -336,7 +341,7 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
/* --node-id */
|
/* --node-id */
|
||||||
case OPT_NODE_ID:
|
case OPT_NODE_ID:
|
||||||
runtime_options.node_id = repmgr_atoi(optarg, "--node-id", &cli_errors, false);
|
runtime_options.node_id = repmgr_atoi(optarg, "--node-id", &cli_errors, MIN_NODE_ID);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* --node-name */
|
/* --node-name */
|
||||||
@@ -346,7 +351,7 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
/* --remote-node-id */
|
/* --remote-node-id */
|
||||||
case OPT_REMOTE_NODE_ID:
|
case OPT_REMOTE_NODE_ID:
|
||||||
runtime_options.remote_node_id = repmgr_atoi(optarg, "--remote-node-id", &cli_errors, false);
|
runtime_options.remote_node_id = repmgr_atoi(optarg, "--remote-node-id", &cli_errors, MIN_NODE_ID);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -355,7 +360,7 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
/* --upstream-node-id */
|
/* --upstream-node-id */
|
||||||
case OPT_UPSTREAM_NODE_ID:
|
case OPT_UPSTREAM_NODE_ID:
|
||||||
runtime_options.upstream_node_id = repmgr_atoi(optarg, "--upstream-node-id", &cli_errors, false);
|
runtime_options.upstream_node_id = repmgr_atoi(optarg, "--upstream-node-id", &cli_errors, MIN_NODE_ID);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/*------------------------
|
/*------------------------
|
||||||
@@ -415,14 +420,14 @@ main(int argc, char **argv)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
case OPT_WAIT_START:
|
case OPT_WAIT_START:
|
||||||
runtime_options.wait_start = repmgr_atoi(optarg, "--wait-start", &cli_errors, false);
|
runtime_options.wait_start = repmgr_atoi(optarg, "--wait-start", &cli_errors, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OPT_WAIT_SYNC:
|
case OPT_WAIT_SYNC:
|
||||||
runtime_options.wait_register_sync = true;
|
runtime_options.wait_register_sync = true;
|
||||||
if (optarg != NULL)
|
if (optarg != NULL)
|
||||||
{
|
{
|
||||||
runtime_options.wait_register_sync_seconds = repmgr_atoi(optarg, "--wait-sync", &cli_errors, false);
|
runtime_options.wait_register_sync_seconds = repmgr_atoi(optarg, "--wait-sync", &cli_errors, 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -543,7 +548,7 @@ main(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case OPT_LIMIT:
|
case OPT_LIMIT:
|
||||||
runtime_options.limit = repmgr_atoi(optarg, "--limit", &cli_errors, false);
|
runtime_options.limit = repmgr_atoi(optarg, "--limit", &cli_errors, 1);
|
||||||
runtime_options.limit_provided = true;
|
runtime_options.limit_provided = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -558,7 +563,7 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
/* -k/--keep-history */
|
/* -k/--keep-history */
|
||||||
case 'k':
|
case 'k':
|
||||||
runtime_options.keep_history = repmgr_atoi(optarg, "-k/--keep-history", &cli_errors, false);
|
runtime_options.keep_history = repmgr_atoi(optarg, "-k/--keep-history", &cli_errors, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/*----------------
|
/*----------------
|
||||||
@@ -1679,12 +1684,6 @@ check_cli_parameters(const int action)
|
|||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
case CLUSTER_EVENT:
|
case CLUSTER_EVENT:
|
||||||
if (runtime_options.limit < 1)
|
|
||||||
{
|
|
||||||
item_list_append_format(&cli_errors,
|
|
||||||
_("value for --limit must be 1 or greater (provided: %i)"),
|
|
||||||
runtime_options.limit);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
item_list_append_format(&cli_warnings,
|
item_list_append_format(&cli_warnings,
|
||||||
|
|||||||
2
repmgr.h
2
repmgr.h
@@ -58,7 +58,7 @@
|
|||||||
#define NODE_NOT_FOUND -1
|
#define NODE_NOT_FOUND -1
|
||||||
#define NO_UPSTREAM_NODE -1
|
#define NO_UPSTREAM_NODE -1
|
||||||
#define UNKNOWN_NODE_ID -1
|
#define UNKNOWN_NODE_ID -1
|
||||||
|
#define MIN_NODE_ID 1
|
||||||
#define VOTING_TERM_NOT_SET -1
|
#define VOTING_TERM_NOT_SET -1
|
||||||
|
|
||||||
#define BDR2_REPLICATION_SET_NAME "repmgr"
|
#define BDR2_REPLICATION_SET_NAME "repmgr"
|
||||||
|
|||||||
Reference in New Issue
Block a user