diff options
author | Peter Eisentraut <peter@eisentraut.org> | 2022-12-12 14:33:41 +0100 |
---|---|---|
committer | Peter Eisentraut <peter@eisentraut.org> | 2022-12-12 15:20:00 +0100 |
commit | df8b8968d4095f44acd6de03b4add65f9709b79d (patch) | |
tree | 249063ed382f2d9fc913729de73bac3d915afcab /src/bin/pg_basebackup/pg_basebackup.c | |
parent | 840ff5f451cd9a391d237fc60894fea7ad82a189 (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/pg_basebackup/pg_basebackup.c')
-rw-r--r-- | src/bin/pg_basebackup/pg_basebackup.c | 108 |
1 files changed, 54 insertions, 54 deletions
diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c index 920569e4474..931e2013b89 100644 --- a/src/bin/pg_basebackup/pg_basebackup.c +++ b/src/bin/pg_basebackup/pg_basebackup.c @@ -2295,14 +2295,26 @@ main(int argc, char **argv) atexit(cleanup_directories_atexit); - while ((c = getopt_long(argc, argv, "CD:F:r:RS:t:T:X:l:nNzZ:d:c:h:p:U:s:wWvP", + while ((c = getopt_long(argc, argv, "c:Cd:D:F:h:l:nNp:Pr:Rs:S:t:T:U:vwWX:zZ:", long_options, &option_index)) != -1) { switch (c) { + case 'c': + if (pg_strcasecmp(optarg, "fast") == 0) + fastcheckpoint = true; + else if (pg_strcasecmp(optarg, "spread") == 0) + fastcheckpoint = false; + else + pg_fatal("invalid checkpoint argument \"%s\", must be \"fast\" or \"spread\"", + optarg); + break; case 'C': create_slot = true; break; + case 'd': + connection_string = pg_strdup(optarg); + break; case 'D': basedir = pg_strdup(optarg); break; @@ -2315,12 +2327,37 @@ main(int argc, char **argv) pg_fatal("invalid output format \"%s\", must be \"plain\" or \"tar\"", optarg); break; + case 'h': + dbhost = pg_strdup(optarg); + break; + case 'l': + label = pg_strdup(optarg); + break; + case 'n': + noclean = true; + break; + case 'N': + do_sync = false; + break; + case 'p': + dbport = pg_strdup(optarg); + break; + case 'P': + showprogress = true; + break; case 'r': maxrate = parse_max_rate(optarg); break; case 'R': writerecoveryconf = true; break; + case 's': + if (!option_parse_int(optarg, "-s/--status-interval", 0, + INT_MAX / 1000, + &standby_message_timeout)) + exit(1); + standby_message_timeout *= 1000; + break; case 'S': /* @@ -2330,15 +2367,24 @@ main(int argc, char **argv) replication_slot = pg_strdup(optarg); temp_replication_slot = false; break; - case 2: - no_slot = true; - break; case 't': backup_target = pg_strdup(optarg); break; case 'T': tablespace_list_append(optarg); break; + case 'U': + dbuser = pg_strdup(optarg); + break; + case 'v': + verbose++; + break; + case 'w': + dbgetpassword = -1; + break; + case 'W': + dbgetpassword = 1; + break; case 'X': if (strcmp(optarg, "n") == 0 || strcmp(optarg, "none") == 0) @@ -2359,18 +2405,6 @@ main(int argc, char **argv) pg_fatal("invalid wal-method option \"%s\", must be \"fetch\", \"stream\", or \"none\"", optarg); break; - case 1: - xlog_dir = pg_strdup(optarg); - break; - case 'l': - label = pg_strdup(optarg); - break; - case 'n': - noclean = true; - break; - case 'N': - do_sync = false; - break; case 'z': compression_algorithm = "gzip"; compression_detail = NULL; @@ -2380,45 +2414,11 @@ main(int argc, char **argv) backup_parse_compress_options(optarg, &compression_algorithm, &compression_detail, &compressloc); break; - case 'c': - if (pg_strcasecmp(optarg, "fast") == 0) - fastcheckpoint = true; - else if (pg_strcasecmp(optarg, "spread") == 0) - fastcheckpoint = false; - else - pg_fatal("invalid checkpoint argument \"%s\", must be \"fast\" or \"spread\"", - optarg); - break; - case 'd': - connection_string = pg_strdup(optarg); - break; - case 'h': - dbhost = pg_strdup(optarg); - break; - case 'p': - dbport = pg_strdup(optarg); - break; - case 'U': - dbuser = pg_strdup(optarg); - break; - case 'w': - dbgetpassword = -1; - break; - case 'W': - dbgetpassword = 1; - break; - case 's': - if (!option_parse_int(optarg, "-s/--status-interval", 0, - INT_MAX / 1000, - &standby_message_timeout)) - exit(1); - standby_message_timeout *= 1000; - break; - case 'v': - verbose++; + case 1: + xlog_dir = pg_strdup(optarg); break; - case 'P': - showprogress = true; + case 2: + no_slot = true; break; case 3: verify_checksums = false; |