summaryrefslogtreecommitdiff
path: root/src/bin/pgbench
diff options
context:
space:
mode:
authorPeter Eisentraut2022-12-12 13:33:41 +0000
committerPeter Eisentraut2022-12-12 14:20:00 +0000
commitdf8b8968d4095f44acd6de03b4add65f9709b79d (patch)
tree249063ed382f2d9fc913729de73bac3d915afcab /src/bin/pgbench
parent840ff5f451cd9a391d237fc60894fea7ad82a189 (diff)
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
Diffstat (limited to 'src/bin/pgbench')
-rw-r--r--src/bin/pgbench/pgbench.c206
1 files changed, 103 insertions, 103 deletions
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
index ee1a33c9ee8..3182a73ad72 100644
--- a/src/bin/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -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,80 +6651,12 @@ main(int argc, char **argv)
}
#endif /* HAVE_GETRLIMIT */
break;
- case 'j': /* jobs */
- benchmarking_option_set = true;
- if (!option_parse_int(optarg, "-j/--jobs", 1, INT_MAX,
- &nthreads))
- {
- exit(1);
- }
-#ifndef ENABLE_THREAD_SAFETY
- if (nthreads != 1)
- pg_fatal("threads are not supported on this platform; use -j1");
-#endif /* !ENABLE_THREAD_SAFETY */
- break;
case 'C':
benchmarking_option_set = true;
is_connect = true;
break;
- case 'r':
- benchmarking_option_set = true;
- report_per_command = true;
- break;
- case 's':
- scale_given = true;
- if (!option_parse_int(optarg, "-s/--scale", 1, INT_MAX,
- &scale))
- exit(1);
- break;
- case 't':
- benchmarking_option_set = true;
- if (!option_parse_int(optarg, "-t/--transactions", 1, INT_MAX,
- &nxacts))
- exit(1);
- break;
- case 'T':
- benchmarking_option_set = true;
- if (!option_parse_int(optarg, "-T/--time", 1, INT_MAX,
- &duration))
- exit(1);
- break;
- case 'U':
- username = pg_strdup(optarg);
- break;
- case 'l':
- 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;
+ case 'd':
+ pg_logging_increase_verbosity();
break;
case 'D':
{
@@ -6754,12 +6672,55 @@ main(int argc, char **argv)
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,
+ &nthreads))
+ {
+ exit(1);
+ }
+#ifndef ENABLE_THREAD_SAFETY
+ if (nthreads != 1)
+ pg_fatal("threads are not supported on this platform; use -j1");
+#endif /* !ENABLE_THREAD_SAFETY */
+ break;
+ case 'l':
+ benchmarking_option_set = 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++)
@@ -6768,12 +6729,31 @@ main(int argc, char **argv)
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 */
@@ -6787,15 +6767,35 @@ main(int argc, char **argv)
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);
- }
+ 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,
+ &nxacts))
+ exit(1);
+ break;
+ case 'T':
+ benchmarking_option_set = true;
+ if (!option_parse_int(optarg, "-T/--time", 1, INT_MAX,
+ &duration))
+ exit(1);
+ break;
+ case 'U':
+ username = pg_strdup(optarg);
+ break;
+ case 'v':
+ benchmarking_option_set = true;
+ do_vacuum_accounts = true;
break;
case 1: /* unlogged-tables */
initialization_option_set = true;