mirror of
https://github.com/postgres/postgres.git
synced 2025-06-25 01:02:05 +03:00
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.
This commit is contained in:
@ -68,6 +68,8 @@ usage(void)
|
|||||||
printf(_(" %s [OPTION]...\n"), progname);
|
printf(_(" %s [OPTION]...\n"), progname);
|
||||||
printf(_("\nOptions:\n"));
|
printf(_("\nOptions:\n"));
|
||||||
printf(_(" -f, --file=FILE receive log into this file. - for stdout\n"));
|
printf(_(" -f, --file=FILE receive log into this file. - for stdout\n"));
|
||||||
|
printf(_(" -F --fsync-interval=SECS\n"
|
||||||
|
" frequency of syncs to the output file (default: %d)\n"), (fsync_interval / 1000));
|
||||||
printf(_(" -n, --no-loop do not loop on connection lost\n"));
|
printf(_(" -n, --no-loop do not loop on connection lost\n"));
|
||||||
printf(_(" -v, --verbose output verbose messages\n"));
|
printf(_(" -v, --verbose output verbose messages\n"));
|
||||||
printf(_(" -V, --version output version information, then exit\n"));
|
printf(_(" -V, --version output version information, then exit\n"));
|
||||||
@ -80,8 +82,7 @@ usage(void)
|
|||||||
printf(_(" -w, --no-password never prompt for password\n"));
|
printf(_(" -w, --no-password never prompt for password\n"));
|
||||||
printf(_(" -W, --password force password prompt (should happen automatically)\n"));
|
printf(_(" -W, --password force password prompt (should happen automatically)\n"));
|
||||||
printf(_("\nReplication options:\n"));
|
printf(_("\nReplication options:\n"));
|
||||||
printf(_(" -F --fsync-interval=SECS\n"
|
printf(_(" -I, --startpos=PTR where in an existing slot should the streaming start\n"));
|
||||||
" frequency of syncs to the output file (default: %d)\n"), (fsync_interval / 1000));
|
|
||||||
printf(_(" -o, --option=NAME[=VALUE]\n"
|
printf(_(" -o, --option=NAME[=VALUE]\n"
|
||||||
" specify option NAME with optional value VALUE, to be passed\n"
|
" specify option NAME with optional value VALUE, to be passed\n"
|
||||||
" to the output plugin\n"));
|
" to the output plugin\n"));
|
||||||
@ -89,7 +90,6 @@ usage(void)
|
|||||||
printf(_(" -s, --status-interval=SECS\n"
|
printf(_(" -s, --status-interval=SECS\n"
|
||||||
" time between status packets sent to server (default: %d)\n"), (standby_message_timeout / 1000));
|
" time between status packets sent to server (default: %d)\n"), (standby_message_timeout / 1000));
|
||||||
printf(_(" -S, --slot=SLOT use existing replication slot SLOT instead of starting a new one\n"));
|
printf(_(" -S, --slot=SLOT use existing replication slot SLOT instead of starting a new one\n"));
|
||||||
printf(_(" -I, --startpos=PTR where in an existing slot should the streaming start\n"));
|
|
||||||
printf(_("\nAction to be performed:\n"));
|
printf(_("\nAction to be performed:\n"));
|
||||||
printf(_(" --create create a new replication slot (for the slotname see --slot)\n"));
|
printf(_(" --create create a new replication slot (for the slotname see --slot)\n"));
|
||||||
printf(_(" --start start streaming in a replication slot (for the slotname see --slot)\n"));
|
printf(_(" --start start streaming in a replication slot (for the slotname see --slot)\n"));
|
||||||
@ -600,6 +600,7 @@ main(int argc, char **argv)
|
|||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
/* general options */
|
/* general options */
|
||||||
{"file", required_argument, NULL, 'f'},
|
{"file", required_argument, NULL, 'f'},
|
||||||
|
{"fsync-interval", required_argument, NULL, 'F'},
|
||||||
{"no-loop", no_argument, NULL, 'n'},
|
{"no-loop", no_argument, NULL, 'n'},
|
||||||
{"verbose", no_argument, NULL, 'v'},
|
{"verbose", no_argument, NULL, 'v'},
|
||||||
{"version", no_argument, NULL, 'V'},
|
{"version", no_argument, NULL, 'V'},
|
||||||
@ -612,12 +613,11 @@ main(int argc, char **argv)
|
|||||||
{"no-password", no_argument, NULL, 'w'},
|
{"no-password", no_argument, NULL, 'w'},
|
||||||
{"password", no_argument, NULL, 'W'},
|
{"password", no_argument, NULL, 'W'},
|
||||||
/* replication options */
|
/* replication options */
|
||||||
|
{"startpos", required_argument, NULL, 'I'},
|
||||||
{"option", required_argument, NULL, 'o'},
|
{"option", required_argument, NULL, 'o'},
|
||||||
{"plugin", required_argument, NULL, 'P'},
|
{"plugin", required_argument, NULL, 'P'},
|
||||||
{"status-interval", required_argument, NULL, 's'},
|
{"status-interval", required_argument, NULL, 's'},
|
||||||
{"fsync-interval", required_argument, NULL, 'F'},
|
|
||||||
{"slot", required_argument, NULL, 'S'},
|
{"slot", required_argument, NULL, 'S'},
|
||||||
{"startpos", required_argument, NULL, 'I'},
|
|
||||||
/* action */
|
/* action */
|
||||||
{"create", no_argument, NULL, 1},
|
{"create", no_argument, NULL, 1},
|
||||||
{"start", no_argument, NULL, 2},
|
{"start", no_argument, NULL, 2},
|
||||||
@ -647,7 +647,7 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((c = getopt_long(argc, argv, "f:F:nvd:h:o:p:U:wWP:s:S:",
|
while ((c = getopt_long(argc, argv, "f:F:nvd:h:p:U:wWI:o:P:s:S:",
|
||||||
long_options, &option_index)) != -1)
|
long_options, &option_index)) != -1)
|
||||||
{
|
{
|
||||||
switch (c)
|
switch (c)
|
||||||
@ -656,6 +656,15 @@ main(int argc, char **argv)
|
|||||||
case 'f':
|
case 'f':
|
||||||
outfile = pg_strdup(optarg);
|
outfile = pg_strdup(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'F':
|
||||||
|
fsync_interval = atoi(optarg) * 1000;
|
||||||
|
if (fsync_interval < 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, _("%s: invalid fsync interval \"%s\"\n"),
|
||||||
|
progname, optarg);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
noloop = 1;
|
noloop = 1;
|
||||||
break;
|
break;
|
||||||
@ -688,6 +697,16 @@ main(int argc, char **argv)
|
|||||||
dbgetpassword = 1;
|
dbgetpassword = 1;
|
||||||
break;
|
break;
|
||||||
/* replication options */
|
/* replication options */
|
||||||
|
case 'I':
|
||||||
|
if (sscanf(optarg, "%X/%X", &hi, &lo) != 2)
|
||||||
|
{
|
||||||
|
fprintf(stderr,
|
||||||
|
_("%s: could not parse start position \"%s\"\n"),
|
||||||
|
progname, optarg);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
startpos = ((uint64) hi) << 32 | lo;
|
||||||
|
break;
|
||||||
case 'o':
|
case 'o':
|
||||||
{
|
{
|
||||||
char *data = pg_strdup(optarg);
|
char *data = pg_strdup(optarg);
|
||||||
@ -720,28 +739,9 @@ main(int argc, char **argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'F':
|
|
||||||
fsync_interval = atoi(optarg) * 1000;
|
|
||||||
if (fsync_interval < 0)
|
|
||||||
{
|
|
||||||
fprintf(stderr, _("%s: invalid fsync interval \"%s\"\n"),
|
|
||||||
progname, optarg);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'S':
|
case 'S':
|
||||||
replication_slot = pg_strdup(optarg);
|
replication_slot = pg_strdup(optarg);
|
||||||
break;
|
break;
|
||||||
case 'I':
|
|
||||||
if (sscanf(optarg, "%X/%X", &hi, &lo) != 2)
|
|
||||||
{
|
|
||||||
fprintf(stderr,
|
|
||||||
_("%s: could not parse start position \"%s\"\n"),
|
|
||||||
progname, optarg);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
startpos = ((uint64) hi) << 32 | lo;
|
|
||||||
break;
|
|
||||||
/* action */
|
/* action */
|
||||||
case 1:
|
case 1:
|
||||||
do_create_slot = true;
|
do_create_slot = true;
|
||||||
|
Reference in New Issue
Block a user