mirror of
https://github.com/postgres/postgres.git
synced 2025-10-28 11:55:03 +03:00
Order getopt arguments
Order the letters in the arguments of getopt() and getopt_long(), as well as in the subsequent switch statements. In most cases, I used alphabetical with lower case first. In a few cases, existing different orders (e.g., upper case first) was kept to reduce the diff size. Discussion: https://www.postgresql.org/message-id/flat/3efd0fe8-351b-f836-9122-886002602357%40enterprisedb.com
This commit is contained in:
@@ -6615,36 +6615,22 @@ main(int argc, char **argv)
|
||||
if (!set_random_seed(getenv("PGBENCH_RANDOM_SEED")))
|
||||
pg_fatal("error while setting random seed from PGBENCH_RANDOM_SEED environment variable");
|
||||
|
||||
while ((c = getopt_long(argc, argv, "iI:h:nvp:dqb:SNc:j:Crs:t:T:U:lf:D:F:M:P:R:L:", long_options, &optindex)) != -1)
|
||||
while ((c = getopt_long(argc, argv, "b:c:CdD:f:F:h:iI:j:lL:M:nNp:P:qrR:s:St:T:U:v", long_options, &optindex)) != -1)
|
||||
{
|
||||
char *script;
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case 'i':
|
||||
is_init_mode = true;
|
||||
break;
|
||||
case 'I':
|
||||
pg_free(initialize_steps);
|
||||
initialize_steps = pg_strdup(optarg);
|
||||
checkInitSteps(initialize_steps);
|
||||
initialization_option_set = true;
|
||||
break;
|
||||
case 'h':
|
||||
pghost = pg_strdup(optarg);
|
||||
break;
|
||||
case 'n':
|
||||
is_no_vacuum = true;
|
||||
break;
|
||||
case 'v':
|
||||
case 'b':
|
||||
if (strcmp(optarg, "list") == 0)
|
||||
{
|
||||
listAvailableScripts();
|
||||
exit(0);
|
||||
}
|
||||
weight = parseScriptWeight(optarg, &script);
|
||||
process_builtin(findBuiltin(script), weight);
|
||||
benchmarking_option_set = true;
|
||||
do_vacuum_accounts = true;
|
||||
break;
|
||||
case 'p':
|
||||
pgport = pg_strdup(optarg);
|
||||
break;
|
||||
case 'd':
|
||||
pg_logging_increase_verbosity();
|
||||
internal_script_used = true;
|
||||
break;
|
||||
case 'c':
|
||||
benchmarking_option_set = true;
|
||||
@@ -6665,6 +6651,50 @@ main(int argc, char **argv)
|
||||
}
|
||||
#endif /* HAVE_GETRLIMIT */
|
||||
break;
|
||||
case 'C':
|
||||
benchmarking_option_set = true;
|
||||
is_connect = true;
|
||||
break;
|
||||
case 'd':
|
||||
pg_logging_increase_verbosity();
|
||||
break;
|
||||
case 'D':
|
||||
{
|
||||
char *p;
|
||||
|
||||
benchmarking_option_set = true;
|
||||
|
||||
if ((p = strchr(optarg, '=')) == NULL || p == optarg || *(p + 1) == '\0')
|
||||
pg_fatal("invalid variable definition: \"%s\"", optarg);
|
||||
|
||||
*p++ = '\0';
|
||||
if (!putVariable(&state[0].variables, "option", optarg, p))
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
case 'f':
|
||||
weight = parseScriptWeight(optarg, &script);
|
||||
process_file(script, weight);
|
||||
benchmarking_option_set = true;
|
||||
break;
|
||||
case 'F':
|
||||
initialization_option_set = true;
|
||||
if (!option_parse_int(optarg, "-F/--fillfactor", 10, 100,
|
||||
&fillfactor))
|
||||
exit(1);
|
||||
break;
|
||||
case 'h':
|
||||
pghost = pg_strdup(optarg);
|
||||
break;
|
||||
case 'i':
|
||||
is_init_mode = true;
|
||||
break;
|
||||
case 'I':
|
||||
pg_free(initialize_steps);
|
||||
initialize_steps = pg_strdup(optarg);
|
||||
checkInitSteps(initialize_steps);
|
||||
initialization_option_set = true;
|
||||
break;
|
||||
case 'j': /* jobs */
|
||||
benchmarking_option_set = true;
|
||||
if (!option_parse_int(optarg, "-j/--jobs", 1, INT_MAX,
|
||||
@@ -6677,20 +6707,77 @@ main(int argc, char **argv)
|
||||
pg_fatal("threads are not supported on this platform; use -j1");
|
||||
#endif /* !ENABLE_THREAD_SAFETY */
|
||||
break;
|
||||
case 'C':
|
||||
case 'l':
|
||||
benchmarking_option_set = true;
|
||||
is_connect = true;
|
||||
use_log = true;
|
||||
break;
|
||||
case 'L':
|
||||
{
|
||||
double limit_ms = atof(optarg);
|
||||
|
||||
if (limit_ms <= 0.0)
|
||||
pg_fatal("invalid latency limit: \"%s\"", optarg);
|
||||
benchmarking_option_set = true;
|
||||
latency_limit = (int64) (limit_ms * 1000);
|
||||
}
|
||||
break;
|
||||
case 'M':
|
||||
benchmarking_option_set = true;
|
||||
for (querymode = 0; querymode < NUM_QUERYMODE; querymode++)
|
||||
if (strcmp(optarg, QUERYMODE[querymode]) == 0)
|
||||
break;
|
||||
if (querymode >= NUM_QUERYMODE)
|
||||
pg_fatal("invalid query mode (-M): \"%s\"", optarg);
|
||||
break;
|
||||
case 'n':
|
||||
is_no_vacuum = true;
|
||||
break;
|
||||
case 'N':
|
||||
process_builtin(findBuiltin("simple-update"), 1);
|
||||
benchmarking_option_set = true;
|
||||
internal_script_used = true;
|
||||
break;
|
||||
case 'p':
|
||||
pgport = pg_strdup(optarg);
|
||||
break;
|
||||
case 'P':
|
||||
benchmarking_option_set = true;
|
||||
if (!option_parse_int(optarg, "-P/--progress", 1, INT_MAX,
|
||||
&progress))
|
||||
exit(1);
|
||||
break;
|
||||
case 'q':
|
||||
initialization_option_set = true;
|
||||
use_quiet = true;
|
||||
break;
|
||||
case 'r':
|
||||
benchmarking_option_set = true;
|
||||
report_per_command = true;
|
||||
break;
|
||||
case 'R':
|
||||
{
|
||||
/* get a double from the beginning of option value */
|
||||
double throttle_value = atof(optarg);
|
||||
|
||||
benchmarking_option_set = true;
|
||||
|
||||
if (throttle_value <= 0.0)
|
||||
pg_fatal("invalid rate limit: \"%s\"", optarg);
|
||||
/* Invert rate limit into per-transaction delay in usec */
|
||||
throttle_delay = 1000000.0 / throttle_value;
|
||||
}
|
||||
break;
|
||||
case 's':
|
||||
scale_given = true;
|
||||
if (!option_parse_int(optarg, "-s/--scale", 1, INT_MAX,
|
||||
&scale))
|
||||
exit(1);
|
||||
break;
|
||||
case 'S':
|
||||
process_builtin(findBuiltin("select-only"), 1);
|
||||
benchmarking_option_set = true;
|
||||
internal_script_used = true;
|
||||
break;
|
||||
case 't':
|
||||
benchmarking_option_set = true;
|
||||
if (!option_parse_int(optarg, "-t/--transactions", 1, INT_MAX,
|
||||
@@ -6706,96 +6793,9 @@ main(int argc, char **argv)
|
||||
case 'U':
|
||||
username = pg_strdup(optarg);
|
||||
break;
|
||||
case 'l':
|
||||
case 'v':
|
||||
benchmarking_option_set = true;
|
||||
use_log = true;
|
||||
break;
|
||||
case 'q':
|
||||
initialization_option_set = true;
|
||||
use_quiet = true;
|
||||
break;
|
||||
case 'b':
|
||||
if (strcmp(optarg, "list") == 0)
|
||||
{
|
||||
listAvailableScripts();
|
||||
exit(0);
|
||||
}
|
||||
weight = parseScriptWeight(optarg, &script);
|
||||
process_builtin(findBuiltin(script), weight);
|
||||
benchmarking_option_set = true;
|
||||
internal_script_used = true;
|
||||
break;
|
||||
case 'S':
|
||||
process_builtin(findBuiltin("select-only"), 1);
|
||||
benchmarking_option_set = true;
|
||||
internal_script_used = true;
|
||||
break;
|
||||
case 'N':
|
||||
process_builtin(findBuiltin("simple-update"), 1);
|
||||
benchmarking_option_set = true;
|
||||
internal_script_used = true;
|
||||
break;
|
||||
case 'f':
|
||||
weight = parseScriptWeight(optarg, &script);
|
||||
process_file(script, weight);
|
||||
benchmarking_option_set = true;
|
||||
break;
|
||||
case 'D':
|
||||
{
|
||||
char *p;
|
||||
|
||||
benchmarking_option_set = true;
|
||||
|
||||
if ((p = strchr(optarg, '=')) == NULL || p == optarg || *(p + 1) == '\0')
|
||||
pg_fatal("invalid variable definition: \"%s\"", optarg);
|
||||
|
||||
*p++ = '\0';
|
||||
if (!putVariable(&state[0].variables, "option", optarg, p))
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
case 'F':
|
||||
initialization_option_set = true;
|
||||
if (!option_parse_int(optarg, "-F/--fillfactor", 10, 100,
|
||||
&fillfactor))
|
||||
exit(1);
|
||||
break;
|
||||
case 'M':
|
||||
benchmarking_option_set = true;
|
||||
for (querymode = 0; querymode < NUM_QUERYMODE; querymode++)
|
||||
if (strcmp(optarg, QUERYMODE[querymode]) == 0)
|
||||
break;
|
||||
if (querymode >= NUM_QUERYMODE)
|
||||
pg_fatal("invalid query mode (-M): \"%s\"", optarg);
|
||||
break;
|
||||
case 'P':
|
||||
benchmarking_option_set = true;
|
||||
if (!option_parse_int(optarg, "-P/--progress", 1, INT_MAX,
|
||||
&progress))
|
||||
exit(1);
|
||||
break;
|
||||
case 'R':
|
||||
{
|
||||
/* get a double from the beginning of option value */
|
||||
double throttle_value = atof(optarg);
|
||||
|
||||
benchmarking_option_set = true;
|
||||
|
||||
if (throttle_value <= 0.0)
|
||||
pg_fatal("invalid rate limit: \"%s\"", optarg);
|
||||
/* Invert rate limit into per-transaction delay in usec */
|
||||
throttle_delay = 1000000.0 / throttle_value;
|
||||
}
|
||||
break;
|
||||
case 'L':
|
||||
{
|
||||
double limit_ms = atof(optarg);
|
||||
|
||||
if (limit_ms <= 0.0)
|
||||
pg_fatal("invalid latency limit: \"%s\"", optarg);
|
||||
benchmarking_option_set = true;
|
||||
latency_limit = (int64) (limit_ms * 1000);
|
||||
}
|
||||
do_vacuum_accounts = true;
|
||||
break;
|
||||
case 1: /* unlogged-tables */
|
||||
initialization_option_set = true;
|
||||
|
||||
Reference in New Issue
Block a user