Skip to content

Commit bf2e70b

Browse files
committed
Fix pg_recvlogical to accept the documented -I instead only --startpos.
The bug was caused by omitting 'I:' from the short argument list to getopt_long(). To make similar bugs in the future less likely reorder options in --help, long and short option lists to be in the same, alphabetical within groups, order. Report and fix by Michael Paquier, some additional reordering by me.
1 parent 0a5faaa commit bf2e70b

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

src/bin/pg_basebackup/pg_recvlogical.c

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ usage(void)
6868
printf(_(" %s [OPTION]...\n"), progname);
6969
printf(_("\nOptions:\n"));
7070
printf(_(" -f, --file=FILE receive log into this file. - for stdout\n"));
71+
printf(_(" -F --fsync-interval=SECS\n"
72+
" frequency of syncs to the output file (default: %d)\n"), (fsync_interval / 1000));
7173
printf(_(" -n, --no-loop do not loop on connection lost\n"));
7274
printf(_(" -v, --verbose output verbose messages\n"));
7375
printf(_(" -V, --version output version information, then exit\n"));
@@ -80,16 +82,14 @@ usage(void)
8082
printf(_(" -w, --no-password never prompt for password\n"));
8183
printf(_(" -W, --password force password prompt (should happen automatically)\n"));
8284
printf(_("\nReplication options:\n"));
83-
printf(_(" -F --fsync-interval=SECS\n"
84-
" frequency of syncs to the output file (default: %d)\n"), (fsync_interval / 1000));
85+
printf(_(" -I, --startpos=PTR where in an existing slot should the streaming start\n"));
8586
printf(_(" -o, --option=NAME[=VALUE]\n"
8687
" specify option NAME with optional value VALUE, to be passed\n"
8788
" to the output plugin\n"));
8889
printf(_(" -P, --plugin=PLUGIN use output plugin PLUGIN (default: %s)\n"), plugin);
8990
printf(_(" -s, --status-interval=SECS\n"
9091
" time between status packets sent to server (default: %d)\n"), (standby_message_timeout / 1000));
9192
printf(_(" -S, --slot=SLOT use existing replication slot SLOT instead of starting a new one\n"));
92-
printf(_(" -I, --startpos=PTR where in an existing slot should the streaming start\n"));
9393
printf(_("\nAction to be performed:\n"));
9494
printf(_(" --create create a new replication slot (for the slotname see --slot)\n"));
9595
printf(_(" --start start streaming in a replication slot (for the slotname see --slot)\n"));
@@ -600,6 +600,7 @@ main(int argc, char **argv)
600600
static struct option long_options[] = {
601601
/* general options */
602602
{"file", required_argument, NULL, 'f'},
603+
{"fsync-interval", required_argument, NULL, 'F'},
603604
{"no-loop", no_argument, NULL, 'n'},
604605
{"verbose", no_argument, NULL, 'v'},
605606
{"version", no_argument, NULL, 'V'},
@@ -612,12 +613,11 @@ main(int argc, char **argv)
612613
{"no-password", no_argument, NULL, 'w'},
613614
{"password", no_argument, NULL, 'W'},
614615
/* replication options */
616+
{"startpos", required_argument, NULL, 'I'},
615617
{"option", required_argument, NULL, 'o'},
616618
{"plugin", required_argument, NULL, 'P'},
617619
{"status-interval", required_argument, NULL, 's'},
618-
{"fsync-interval", required_argument, NULL, 'F'},
619620
{"slot", required_argument, NULL, 'S'},
620-
{"startpos", required_argument, NULL, 'I'},
621621
/* action */
622622
{"create", no_argument, NULL, 1},
623623
{"start", no_argument, NULL, 2},
@@ -647,7 +647,7 @@ main(int argc, char **argv)
647647
}
648648
}
649649

650-
while ((c = getopt_long(argc, argv, "f:F:nvd:h:o:p:U:wWP:s:S:",
650+
while ((c = getopt_long(argc, argv, "f:F:nvd:h:p:U:wWI:o:P:s:S:",
651651
long_options, &option_index)) != -1)
652652
{
653653
switch (c)
@@ -656,6 +656,15 @@ main(int argc, char **argv)
656656
case 'f':
657657
outfile = pg_strdup(optarg);
658658
break;
659+
case 'F':
660+
fsync_interval = atoi(optarg) * 1000;
661+
if (fsync_interval < 0)
662+
{
663+
fprintf(stderr, _("%s: invalid fsync interval \"%s\"\n"),
664+
progname, optarg);
665+
exit(1);
666+
}
667+
break;
659668
case 'n':
660669
noloop = 1;
661670
break;
@@ -688,6 +697,16 @@ main(int argc, char **argv)
688697
dbgetpassword = 1;
689698
break;
690699
/* replication options */
700+
case 'I':
701+
if (sscanf(optarg, "%X/%X", &hi, &lo) != 2)
702+
{
703+
fprintf(stderr,
704+
_("%s: could not parse start position \"%s\"\n"),
705+
progname, optarg);
706+
exit(1);
707+
}
708+
startpos = ((uint64) hi) << 32 | lo;
709+
break;
691710
case 'o':
692711
{
693712
char *data = pg_strdup(optarg);
@@ -720,28 +739,9 @@ main(int argc, char **argv)
720739
exit(1);
721740
}
722741
break;
723-
case 'F':
724-
fsync_interval = atoi(optarg) * 1000;
725-
if (fsync_interval < 0)
726-
{
727-
fprintf(stderr, _("%s: invalid fsync interval \"%s\"\n"),
728-
progname, optarg);
729-
exit(1);
730-
}
731-
break;
732742
case 'S':
733743
replication_slot = pg_strdup(optarg);
734744
break;
735-
case 'I':
736-
if (sscanf(optarg, "%X/%X", &hi, &lo) != 2)
737-
{
738-
fprintf(stderr,
739-
_("%s: could not parse start position \"%s\"\n"),
740-
progname, optarg);
741-
exit(1);
742-
}
743-
startpos = ((uint64) hi) << 32 | lo;
744-
break;
745745
/* action */
746746
case 1:
747747
do_create_slot = true;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy