mirror of
https://github.com/postgres/postgres.git
synced 2025-04-27 22:56:53 +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:
parent
840ff5f451
commit
df8b8968d4
@ -228,6 +228,32 @@ BootstrapModeMain(int argc, char *argv[], bool check_only)
|
|||||||
case 'B':
|
case 'B':
|
||||||
SetConfigOption("shared_buffers", optarg, PGC_POSTMASTER, PGC_S_ARGV);
|
SetConfigOption("shared_buffers", optarg, PGC_POSTMASTER, PGC_S_ARGV);
|
||||||
break;
|
break;
|
||||||
|
case 'c':
|
||||||
|
case '-':
|
||||||
|
{
|
||||||
|
char *name,
|
||||||
|
*value;
|
||||||
|
|
||||||
|
ParseLongOption(optarg, &name, &value);
|
||||||
|
if (!value)
|
||||||
|
{
|
||||||
|
if (flag == '-')
|
||||||
|
ereport(ERROR,
|
||||||
|
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||||
|
errmsg("--%s requires a value",
|
||||||
|
optarg)));
|
||||||
|
else
|
||||||
|
ereport(ERROR,
|
||||||
|
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||||
|
errmsg("-c %s requires a value",
|
||||||
|
optarg)));
|
||||||
|
}
|
||||||
|
|
||||||
|
SetConfigOption(name, value, PGC_POSTMASTER, PGC_S_ARGV);
|
||||||
|
pfree(name);
|
||||||
|
pfree(value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case 'D':
|
case 'D':
|
||||||
userDoption = pstrdup(optarg);
|
userDoption = pstrdup(optarg);
|
||||||
break;
|
break;
|
||||||
@ -265,32 +291,6 @@ BootstrapModeMain(int argc, char *argv[], bool check_only)
|
|||||||
PGC_S_DYNAMIC_DEFAULT);
|
PGC_S_DYNAMIC_DEFAULT);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'c':
|
|
||||||
case '-':
|
|
||||||
{
|
|
||||||
char *name,
|
|
||||||
*value;
|
|
||||||
|
|
||||||
ParseLongOption(optarg, &name, &value);
|
|
||||||
if (!value)
|
|
||||||
{
|
|
||||||
if (flag == '-')
|
|
||||||
ereport(ERROR,
|
|
||||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
|
||||||
errmsg("--%s requires a value",
|
|
||||||
optarg)));
|
|
||||||
else
|
|
||||||
ereport(ERROR,
|
|
||||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
|
||||||
errmsg("-c %s requires a value",
|
|
||||||
optarg)));
|
|
||||||
}
|
|
||||||
|
|
||||||
SetConfigOption(name, value, PGC_POSTMASTER, PGC_S_ARGV);
|
|
||||||
pfree(name);
|
|
||||||
pfree(value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
write_stderr("Try \"%s --help\" for more information.\n",
|
write_stderr("Try \"%s --help\" for more information.\n",
|
||||||
progname);
|
progname);
|
||||||
|
@ -690,7 +690,7 @@ PostmasterMain(int argc, char *argv[])
|
|||||||
* tcop/postgres.c (the option sets should not conflict) and with the
|
* tcop/postgres.c (the option sets should not conflict) and with the
|
||||||
* common help() function in main/main.c.
|
* common help() function in main/main.c.
|
||||||
*/
|
*/
|
||||||
while ((opt = getopt(argc, argv, "B:bc:C:D:d:EeFf:h:ijk:lN:OPp:r:S:sTt:W:-:")) != -1)
|
while ((opt = getopt(argc, argv, "B:bC:c:D:d:EeFf:h:ijk:lN:OPp:r:S:sTt:W:-:")) != -1)
|
||||||
{
|
{
|
||||||
switch (opt)
|
switch (opt)
|
||||||
{
|
{
|
||||||
@ -707,6 +707,33 @@ PostmasterMain(int argc, char *argv[])
|
|||||||
output_config_variable = strdup(optarg);
|
output_config_variable = strdup(optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'c':
|
||||||
|
case '-':
|
||||||
|
{
|
||||||
|
char *name,
|
||||||
|
*value;
|
||||||
|
|
||||||
|
ParseLongOption(optarg, &name, &value);
|
||||||
|
if (!value)
|
||||||
|
{
|
||||||
|
if (opt == '-')
|
||||||
|
ereport(ERROR,
|
||||||
|
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||||
|
errmsg("--%s requires a value",
|
||||||
|
optarg)));
|
||||||
|
else
|
||||||
|
ereport(ERROR,
|
||||||
|
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||||
|
errmsg("-c %s requires a value",
|
||||||
|
optarg)));
|
||||||
|
}
|
||||||
|
|
||||||
|
SetConfigOption(name, value, PGC_POSTMASTER, PGC_S_ARGV);
|
||||||
|
pfree(name);
|
||||||
|
pfree(value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case 'D':
|
case 'D':
|
||||||
userDoption = strdup(optarg);
|
userDoption = strdup(optarg);
|
||||||
break;
|
break;
|
||||||
@ -814,33 +841,6 @@ PostmasterMain(int argc, char *argv[])
|
|||||||
SetConfigOption("post_auth_delay", optarg, PGC_POSTMASTER, PGC_S_ARGV);
|
SetConfigOption("post_auth_delay", optarg, PGC_POSTMASTER, PGC_S_ARGV);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'c':
|
|
||||||
case '-':
|
|
||||||
{
|
|
||||||
char *name,
|
|
||||||
*value;
|
|
||||||
|
|
||||||
ParseLongOption(optarg, &name, &value);
|
|
||||||
if (!value)
|
|
||||||
{
|
|
||||||
if (opt == '-')
|
|
||||||
ereport(ERROR,
|
|
||||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
|
||||||
errmsg("--%s requires a value",
|
|
||||||
optarg)));
|
|
||||||
else
|
|
||||||
ereport(ERROR,
|
|
||||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
|
||||||
errmsg("-c %s requires a value",
|
|
||||||
optarg)));
|
|
||||||
}
|
|
||||||
|
|
||||||
SetConfigOption(name, value, PGC_POSTMASTER, PGC_S_ARGV);
|
|
||||||
pfree(name);
|
|
||||||
pfree(value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
write_stderr("Try \"%s --help\" for more information.\n",
|
write_stderr("Try \"%s --help\" for more information.\n",
|
||||||
progname);
|
progname);
|
||||||
|
@ -3718,7 +3718,7 @@ process_postgres_switches(int argc, char *argv[], GucContext ctx,
|
|||||||
* postmaster/postmaster.c (the option sets should not conflict) and with
|
* postmaster/postmaster.c (the option sets should not conflict) and with
|
||||||
* the common help() function in main/main.c.
|
* the common help() function in main/main.c.
|
||||||
*/
|
*/
|
||||||
while ((flag = getopt(argc, argv, "B:bc:C:D:d:EeFf:h:ijk:lN:nOPp:r:S:sTt:v:W:-:")) != -1)
|
while ((flag = getopt(argc, argv, "B:bC:c:D:d:EeFf:h:ijk:lN:nOPp:r:S:sTt:v:W:-:")) != -1)
|
||||||
{
|
{
|
||||||
switch (flag)
|
switch (flag)
|
||||||
{
|
{
|
||||||
@ -3736,6 +3736,32 @@ process_postgres_switches(int argc, char *argv[], GucContext ctx,
|
|||||||
/* ignored for consistency with the postmaster */
|
/* ignored for consistency with the postmaster */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'c':
|
||||||
|
case '-':
|
||||||
|
{
|
||||||
|
char *name,
|
||||||
|
*value;
|
||||||
|
|
||||||
|
ParseLongOption(optarg, &name, &value);
|
||||||
|
if (!value)
|
||||||
|
{
|
||||||
|
if (flag == '-')
|
||||||
|
ereport(ERROR,
|
||||||
|
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||||
|
errmsg("--%s requires a value",
|
||||||
|
optarg)));
|
||||||
|
else
|
||||||
|
ereport(ERROR,
|
||||||
|
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||||
|
errmsg("-c %s requires a value",
|
||||||
|
optarg)));
|
||||||
|
}
|
||||||
|
SetConfigOption(name, value, ctx, gucsource);
|
||||||
|
pfree(name);
|
||||||
|
pfree(value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case 'D':
|
case 'D':
|
||||||
if (secure)
|
if (secure)
|
||||||
userDoption = strdup(optarg);
|
userDoption = strdup(optarg);
|
||||||
@ -3850,32 +3876,6 @@ process_postgres_switches(int argc, char *argv[], GucContext ctx,
|
|||||||
SetConfigOption("post_auth_delay", optarg, ctx, gucsource);
|
SetConfigOption("post_auth_delay", optarg, ctx, gucsource);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'c':
|
|
||||||
case '-':
|
|
||||||
{
|
|
||||||
char *name,
|
|
||||||
*value;
|
|
||||||
|
|
||||||
ParseLongOption(optarg, &name, &value);
|
|
||||||
if (!value)
|
|
||||||
{
|
|
||||||
if (flag == '-')
|
|
||||||
ereport(ERROR,
|
|
||||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
|
||||||
errmsg("--%s requires a value",
|
|
||||||
optarg)));
|
|
||||||
else
|
|
||||||
ereport(ERROR,
|
|
||||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
|
||||||
errmsg("-c %s requires a value",
|
|
||||||
optarg)));
|
|
||||||
}
|
|
||||||
SetConfigOption(name, value, ctx, gucsource);
|
|
||||||
pfree(name);
|
|
||||||
pfree(value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
errs++;
|
errs++;
|
||||||
break;
|
break;
|
||||||
|
@ -291,7 +291,7 @@ main(int argc, char *argv[])
|
|||||||
handle_help_version_opts(argc, argv, progname, help);
|
handle_help_version_opts(argc, argv, progname, help);
|
||||||
|
|
||||||
/* process command-line options */
|
/* process command-line options */
|
||||||
while ((c = getopt_long(argc, argv, "ad:D:eh:Hi:I:j:p:Pr:R:s:S:t:T:U:wWv",
|
while ((c = getopt_long(argc, argv, "ad:D:eh:Hi:I:j:p:Pr:R:s:S:t:T:U:vwW",
|
||||||
long_options, &optindex)) != -1)
|
long_options, &optindex)) != -1)
|
||||||
{
|
{
|
||||||
char *endptr;
|
char *endptr;
|
||||||
@ -363,16 +363,16 @@ main(int argc, char *argv[])
|
|||||||
case 'U':
|
case 'U':
|
||||||
username = pg_strdup(optarg);
|
username = pg_strdup(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'v':
|
||||||
|
opts.verbose = true;
|
||||||
|
pg_logging_increase_verbosity();
|
||||||
|
break;
|
||||||
case 'w':
|
case 'w':
|
||||||
prompt_password = TRI_NO;
|
prompt_password = TRI_NO;
|
||||||
break;
|
break;
|
||||||
case 'W':
|
case 'W':
|
||||||
prompt_password = TRI_YES;
|
prompt_password = TRI_YES;
|
||||||
break;
|
break;
|
||||||
case 'v':
|
|
||||||
opts.verbose = true;
|
|
||||||
pg_logging_increase_verbosity();
|
|
||||||
break;
|
|
||||||
case 1:
|
case 1:
|
||||||
maintenance_db = pg_strdup(optarg);
|
maintenance_db = pg_strdup(optarg);
|
||||||
break;
|
break;
|
||||||
|
@ -294,7 +294,7 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "x:dn")) != -1)
|
while ((c = getopt(argc, argv, "dnx:")) != -1)
|
||||||
{
|
{
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
|
@ -2295,14 +2295,26 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
atexit(cleanup_directories_atexit);
|
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)
|
long_options, &option_index)) != -1)
|
||||||
{
|
{
|
||||||
switch (c)
|
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':
|
case 'C':
|
||||||
create_slot = true;
|
create_slot = true;
|
||||||
break;
|
break;
|
||||||
|
case 'd':
|
||||||
|
connection_string = pg_strdup(optarg);
|
||||||
|
break;
|
||||||
case 'D':
|
case 'D':
|
||||||
basedir = pg_strdup(optarg);
|
basedir = pg_strdup(optarg);
|
||||||
break;
|
break;
|
||||||
@ -2315,12 +2327,37 @@ main(int argc, char **argv)
|
|||||||
pg_fatal("invalid output format \"%s\", must be \"plain\" or \"tar\"",
|
pg_fatal("invalid output format \"%s\", must be \"plain\" or \"tar\"",
|
||||||
optarg);
|
optarg);
|
||||||
break;
|
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':
|
case 'r':
|
||||||
maxrate = parse_max_rate(optarg);
|
maxrate = parse_max_rate(optarg);
|
||||||
break;
|
break;
|
||||||
case 'R':
|
case 'R':
|
||||||
writerecoveryconf = true;
|
writerecoveryconf = true;
|
||||||
break;
|
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':
|
case 'S':
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2330,15 +2367,24 @@ main(int argc, char **argv)
|
|||||||
replication_slot = pg_strdup(optarg);
|
replication_slot = pg_strdup(optarg);
|
||||||
temp_replication_slot = false;
|
temp_replication_slot = false;
|
||||||
break;
|
break;
|
||||||
case 2:
|
|
||||||
no_slot = true;
|
|
||||||
break;
|
|
||||||
case 't':
|
case 't':
|
||||||
backup_target = pg_strdup(optarg);
|
backup_target = pg_strdup(optarg);
|
||||||
break;
|
break;
|
||||||
case 'T':
|
case 'T':
|
||||||
tablespace_list_append(optarg);
|
tablespace_list_append(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'U':
|
||||||
|
dbuser = pg_strdup(optarg);
|
||||||
|
break;
|
||||||
|
case 'v':
|
||||||
|
verbose++;
|
||||||
|
break;
|
||||||
|
case 'w':
|
||||||
|
dbgetpassword = -1;
|
||||||
|
break;
|
||||||
|
case 'W':
|
||||||
|
dbgetpassword = 1;
|
||||||
|
break;
|
||||||
case 'X':
|
case 'X':
|
||||||
if (strcmp(optarg, "n") == 0 ||
|
if (strcmp(optarg, "n") == 0 ||
|
||||||
strcmp(optarg, "none") == 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\"",
|
pg_fatal("invalid wal-method option \"%s\", must be \"fetch\", \"stream\", or \"none\"",
|
||||||
optarg);
|
optarg);
|
||||||
break;
|
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':
|
case 'z':
|
||||||
compression_algorithm = "gzip";
|
compression_algorithm = "gzip";
|
||||||
compression_detail = NULL;
|
compression_detail = NULL;
|
||||||
@ -2380,45 +2414,11 @@ main(int argc, char **argv)
|
|||||||
backup_parse_compress_options(optarg, &compression_algorithm,
|
backup_parse_compress_options(optarg, &compression_algorithm,
|
||||||
&compression_detail, &compressloc);
|
&compression_detail, &compressloc);
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 1:
|
||||||
if (pg_strcasecmp(optarg, "fast") == 0)
|
xlog_dir = pg_strdup(optarg);
|
||||||
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;
|
break;
|
||||||
case 'd':
|
case 2:
|
||||||
connection_string = pg_strdup(optarg);
|
no_slot = true;
|
||||||
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++;
|
|
||||||
break;
|
|
||||||
case 'P':
|
|
||||||
showprogress = true;
|
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
verify_checksums = false;
|
verify_checksums = false;
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
static char *basedir = NULL;
|
static char *basedir = NULL;
|
||||||
static int verbose = 0;
|
static int verbose = 0;
|
||||||
static int compresslevel = 0;
|
static int compresslevel = 0;
|
||||||
static int noloop = 0;
|
static bool noloop = false;
|
||||||
static int standby_message_timeout = 10 * 1000; /* 10 sec = default */
|
static int standby_message_timeout = 10 * 1000; /* 10 sec = default */
|
||||||
static volatile sig_atomic_t time_to_stop = false;
|
static volatile sig_atomic_t time_to_stop = false;
|
||||||
static bool do_create_slot = false;
|
static bool do_create_slot = false;
|
||||||
@ -677,32 +677,31 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((c = getopt_long(argc, argv, "D:d:E:h:p:U:s:S:nwWvZ:",
|
while ((c = getopt_long(argc, argv, "d:D:E:h:np:s:S:U:vwWZ:",
|
||||||
long_options, &option_index)) != -1)
|
long_options, &option_index)) != -1)
|
||||||
{
|
{
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
|
case 'd':
|
||||||
|
connection_string = pg_strdup(optarg);
|
||||||
|
break;
|
||||||
case 'D':
|
case 'D':
|
||||||
basedir = pg_strdup(optarg);
|
basedir = pg_strdup(optarg);
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'E':
|
||||||
connection_string = pg_strdup(optarg);
|
if (sscanf(optarg, "%X/%X", &hi, &lo) != 2)
|
||||||
|
pg_fatal("could not parse end position \"%s\"", optarg);
|
||||||
|
endpos = ((uint64) hi) << 32 | lo;
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
dbhost = pg_strdup(optarg);
|
dbhost = pg_strdup(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'n':
|
||||||
|
noloop = true;
|
||||||
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
dbport = pg_strdup(optarg);
|
dbport = pg_strdup(optarg);
|
||||||
break;
|
break;
|
||||||
case 'U':
|
|
||||||
dbuser = pg_strdup(optarg);
|
|
||||||
break;
|
|
||||||
case 'w':
|
|
||||||
dbgetpassword = -1;
|
|
||||||
break;
|
|
||||||
case 'W':
|
|
||||||
dbgetpassword = 1;
|
|
||||||
break;
|
|
||||||
case 's':
|
case 's':
|
||||||
if (!option_parse_int(optarg, "-s/--status-interval", 0,
|
if (!option_parse_int(optarg, "-s/--status-interval", 0,
|
||||||
INT_MAX / 1000,
|
INT_MAX / 1000,
|
||||||
@ -713,22 +712,22 @@ main(int argc, char **argv)
|
|||||||
case 'S':
|
case 'S':
|
||||||
replication_slot = pg_strdup(optarg);
|
replication_slot = pg_strdup(optarg);
|
||||||
break;
|
break;
|
||||||
case 'E':
|
case 'U':
|
||||||
if (sscanf(optarg, "%X/%X", &hi, &lo) != 2)
|
dbuser = pg_strdup(optarg);
|
||||||
pg_fatal("could not parse end position \"%s\"", optarg);
|
|
||||||
endpos = ((uint64) hi) << 32 | lo;
|
|
||||||
break;
|
|
||||||
case 'n':
|
|
||||||
noloop = 1;
|
|
||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
verbose++;
|
verbose++;
|
||||||
break;
|
break;
|
||||||
|
case 'w':
|
||||||
|
dbgetpassword = -1;
|
||||||
|
break;
|
||||||
|
case 'W':
|
||||||
|
dbgetpassword = 1;
|
||||||
|
break;
|
||||||
case 'Z':
|
case 'Z':
|
||||||
parse_compress_options(optarg, &compression_algorithm_str,
|
parse_compress_options(optarg, &compression_algorithm_str,
|
||||||
&compression_detail);
|
&compression_detail);
|
||||||
break;
|
break;
|
||||||
/* action */
|
|
||||||
case 1:
|
case 1:
|
||||||
do_create_slot = true;
|
do_create_slot = true;
|
||||||
break;
|
break;
|
||||||
|
@ -728,7 +728,7 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((c = getopt_long(argc, argv, "E:f:F:nvtd:h:p:U:wWI:o:P:s:S:",
|
while ((c = getopt_long(argc, argv, "E:f:F:ntvd:h:p:U:wWI:o:P:s:S:",
|
||||||
long_options, &option_index)) != -1)
|
long_options, &option_index)) != -1)
|
||||||
{
|
{
|
||||||
switch (c)
|
switch (c)
|
||||||
@ -747,12 +747,12 @@ main(int argc, char **argv)
|
|||||||
case 'n':
|
case 'n':
|
||||||
noloop = 1;
|
noloop = 1;
|
||||||
break;
|
break;
|
||||||
case 'v':
|
|
||||||
verbose++;
|
|
||||||
break;
|
|
||||||
case 't':
|
case 't':
|
||||||
two_phase = true;
|
two_phase = true;
|
||||||
break;
|
break;
|
||||||
|
case 'v':
|
||||||
|
verbose++;
|
||||||
|
break;
|
||||||
/* connection options */
|
/* connection options */
|
||||||
case 'd':
|
case 'd':
|
||||||
dbname = pg_strdup(optarg);
|
dbname = pg_strdup(optarg);
|
||||||
|
@ -471,7 +471,7 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((c = getopt_long(argc, argv, "cD:deNPf:v", long_options, &option_index)) != -1)
|
while ((c = getopt_long(argc, argv, "cdD:ef:NPv", long_options, &option_index)) != -1)
|
||||||
{
|
{
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
@ -481,6 +481,9 @@ main(int argc, char *argv[])
|
|||||||
case 'd':
|
case 'd':
|
||||||
mode = PG_MODE_DISABLE;
|
mode = PG_MODE_DISABLE;
|
||||||
break;
|
break;
|
||||||
|
case 'D':
|
||||||
|
DataDir = optarg;
|
||||||
|
break;
|
||||||
case 'e':
|
case 'e':
|
||||||
mode = PG_MODE_ENABLE;
|
mode = PG_MODE_ENABLE;
|
||||||
break;
|
break;
|
||||||
@ -494,15 +497,12 @@ main(int argc, char *argv[])
|
|||||||
case 'N':
|
case 'N':
|
||||||
do_sync = false;
|
do_sync = false;
|
||||||
break;
|
break;
|
||||||
case 'v':
|
|
||||||
verbose = true;
|
|
||||||
break;
|
|
||||||
case 'D':
|
|
||||||
DataDir = optarg;
|
|
||||||
break;
|
|
||||||
case 'P':
|
case 'P':
|
||||||
showprogress = true;
|
showprogress = true;
|
||||||
break;
|
break;
|
||||||
|
case 'v':
|
||||||
|
verbose = true;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
/* getopt_long already emitted a complaint */
|
/* getopt_long already emitted a complaint */
|
||||||
pg_log_error_hint("Try \"%s --help\" for more information.", progname);
|
pg_log_error_hint("Try \"%s --help\" for more information.", progname);
|
||||||
|
@ -99,7 +99,7 @@ parseCommandLine(int argc, char *argv[])
|
|||||||
if (os_user_effective_id == 0)
|
if (os_user_effective_id == 0)
|
||||||
pg_fatal("%s: cannot be run as root", os_info.progname);
|
pg_fatal("%s: cannot be run as root", os_info.progname);
|
||||||
|
|
||||||
while ((option = getopt_long(argc, argv, "d:D:b:B:cj:kNo:O:p:P:rs:U:v",
|
while ((option = getopt_long(argc, argv, "b:B:cd:D:j:kNo:O:p:P:rs:U:v",
|
||||||
long_options, &optindex)) != -1)
|
long_options, &optindex)) != -1)
|
||||||
{
|
{
|
||||||
switch (option)
|
switch (option)
|
||||||
|
@ -6615,36 +6615,22 @@ main(int argc, char **argv)
|
|||||||
if (!set_random_seed(getenv("PGBENCH_RANDOM_SEED")))
|
if (!set_random_seed(getenv("PGBENCH_RANDOM_SEED")))
|
||||||
pg_fatal("error while setting random seed from PGBENCH_RANDOM_SEED environment variable");
|
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;
|
char *script;
|
||||||
|
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case 'i':
|
case 'b':
|
||||||
is_init_mode = true;
|
if (strcmp(optarg, "list") == 0)
|
||||||
break;
|
{
|
||||||
case 'I':
|
listAvailableScripts();
|
||||||
pg_free(initialize_steps);
|
exit(0);
|
||||||
initialize_steps = pg_strdup(optarg);
|
}
|
||||||
checkInitSteps(initialize_steps);
|
weight = parseScriptWeight(optarg, &script);
|
||||||
initialization_option_set = true;
|
process_builtin(findBuiltin(script), weight);
|
||||||
break;
|
|
||||||
case 'h':
|
|
||||||
pghost = pg_strdup(optarg);
|
|
||||||
break;
|
|
||||||
case 'n':
|
|
||||||
is_no_vacuum = true;
|
|
||||||
break;
|
|
||||||
case 'v':
|
|
||||||
benchmarking_option_set = true;
|
benchmarking_option_set = true;
|
||||||
do_vacuum_accounts = true;
|
internal_script_used = true;
|
||||||
break;
|
|
||||||
case 'p':
|
|
||||||
pgport = pg_strdup(optarg);
|
|
||||||
break;
|
|
||||||
case 'd':
|
|
||||||
pg_logging_increase_verbosity();
|
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
benchmarking_option_set = true;
|
benchmarking_option_set = true;
|
||||||
@ -6665,6 +6651,50 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
#endif /* HAVE_GETRLIMIT */
|
#endif /* HAVE_GETRLIMIT */
|
||||||
break;
|
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 */
|
case 'j': /* jobs */
|
||||||
benchmarking_option_set = true;
|
benchmarking_option_set = true;
|
||||||
if (!option_parse_int(optarg, "-j/--jobs", 1, INT_MAX,
|
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");
|
pg_fatal("threads are not supported on this platform; use -j1");
|
||||||
#endif /* !ENABLE_THREAD_SAFETY */
|
#endif /* !ENABLE_THREAD_SAFETY */
|
||||||
break;
|
break;
|
||||||
case 'C':
|
case 'l':
|
||||||
benchmarking_option_set = true;
|
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;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
benchmarking_option_set = true;
|
benchmarking_option_set = true;
|
||||||
report_per_command = true;
|
report_per_command = true;
|
||||||
break;
|
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':
|
case 's':
|
||||||
scale_given = true;
|
scale_given = true;
|
||||||
if (!option_parse_int(optarg, "-s/--scale", 1, INT_MAX,
|
if (!option_parse_int(optarg, "-s/--scale", 1, INT_MAX,
|
||||||
&scale))
|
&scale))
|
||||||
exit(1);
|
exit(1);
|
||||||
break;
|
break;
|
||||||
|
case 'S':
|
||||||
|
process_builtin(findBuiltin("select-only"), 1);
|
||||||
|
benchmarking_option_set = true;
|
||||||
|
internal_script_used = true;
|
||||||
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
benchmarking_option_set = true;
|
benchmarking_option_set = true;
|
||||||
if (!option_parse_int(optarg, "-t/--transactions", 1, INT_MAX,
|
if (!option_parse_int(optarg, "-t/--transactions", 1, INT_MAX,
|
||||||
@ -6706,96 +6793,9 @@ main(int argc, char **argv)
|
|||||||
case 'U':
|
case 'U':
|
||||||
username = pg_strdup(optarg);
|
username = pg_strdup(optarg);
|
||||||
break;
|
break;
|
||||||
case 'l':
|
case 'v':
|
||||||
benchmarking_option_set = true;
|
benchmarking_option_set = true;
|
||||||
use_log = true;
|
do_vacuum_accounts = 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);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 1: /* unlogged-tables */
|
case 1: /* unlogged-tables */
|
||||||
initialization_option_set = true;
|
initialization_option_set = true;
|
||||||
|
@ -68,43 +68,43 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
handle_help_version_opts(argc, argv, "clusterdb", help);
|
handle_help_version_opts(argc, argv, "clusterdb", help);
|
||||||
|
|
||||||
while ((c = getopt_long(argc, argv, "h:p:U:wWeqd:at:v", long_options, &optindex)) != -1)
|
while ((c = getopt_long(argc, argv, "ad:eh:p:qt:U:vwW", long_options, &optindex)) != -1)
|
||||||
{
|
{
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
|
case 'a':
|
||||||
|
alldb = true;
|
||||||
|
break;
|
||||||
|
case 'd':
|
||||||
|
dbname = pg_strdup(optarg);
|
||||||
|
break;
|
||||||
|
case 'e':
|
||||||
|
echo = true;
|
||||||
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
host = pg_strdup(optarg);
|
host = pg_strdup(optarg);
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
port = pg_strdup(optarg);
|
port = pg_strdup(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'q':
|
||||||
|
quiet = true;
|
||||||
|
break;
|
||||||
|
case 't':
|
||||||
|
simple_string_list_append(&tables, optarg);
|
||||||
|
break;
|
||||||
case 'U':
|
case 'U':
|
||||||
username = pg_strdup(optarg);
|
username = pg_strdup(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'v':
|
||||||
|
verbose = true;
|
||||||
|
break;
|
||||||
case 'w':
|
case 'w':
|
||||||
prompt_password = TRI_NO;
|
prompt_password = TRI_NO;
|
||||||
break;
|
break;
|
||||||
case 'W':
|
case 'W':
|
||||||
prompt_password = TRI_YES;
|
prompt_password = TRI_YES;
|
||||||
break;
|
break;
|
||||||
case 'e':
|
|
||||||
echo = true;
|
|
||||||
break;
|
|
||||||
case 'q':
|
|
||||||
quiet = true;
|
|
||||||
break;
|
|
||||||
case 'd':
|
|
||||||
dbname = pg_strdup(optarg);
|
|
||||||
break;
|
|
||||||
case 'a':
|
|
||||||
alldb = true;
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
simple_string_list_append(&tables, optarg);
|
|
||||||
break;
|
|
||||||
case 'v':
|
|
||||||
verbose = true;
|
|
||||||
break;
|
|
||||||
case 2:
|
case 2:
|
||||||
maintenance_db = pg_strdup(optarg);
|
maintenance_db = pg_strdup(optarg);
|
||||||
break;
|
break;
|
||||||
|
@ -79,16 +79,37 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
handle_help_version_opts(argc, argv, "createdb", help);
|
handle_help_version_opts(argc, argv, "createdb", help);
|
||||||
|
|
||||||
while ((c = getopt_long(argc, argv, "h:p:U:wWeO:D:T:E:l:S:", long_options, &optindex)) != -1)
|
while ((c = getopt_long(argc, argv, "D:eE:h:l:O:p:S:T:U:wW", long_options, &optindex)) != -1)
|
||||||
{
|
{
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
|
case 'D':
|
||||||
|
tablespace = pg_strdup(optarg);
|
||||||
|
break;
|
||||||
|
case 'e':
|
||||||
|
echo = true;
|
||||||
|
break;
|
||||||
|
case 'E':
|
||||||
|
encoding = pg_strdup(optarg);
|
||||||
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
host = pg_strdup(optarg);
|
host = pg_strdup(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'l':
|
||||||
|
locale = pg_strdup(optarg);
|
||||||
|
break;
|
||||||
|
case 'O':
|
||||||
|
owner = pg_strdup(optarg);
|
||||||
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
port = pg_strdup(optarg);
|
port = pg_strdup(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'S':
|
||||||
|
strategy = pg_strdup(optarg);
|
||||||
|
break;
|
||||||
|
case 'T':
|
||||||
|
template = pg_strdup(optarg);
|
||||||
|
break;
|
||||||
case 'U':
|
case 'U':
|
||||||
username = pg_strdup(optarg);
|
username = pg_strdup(optarg);
|
||||||
break;
|
break;
|
||||||
@ -98,33 +119,12 @@ main(int argc, char *argv[])
|
|||||||
case 'W':
|
case 'W':
|
||||||
prompt_password = TRI_YES;
|
prompt_password = TRI_YES;
|
||||||
break;
|
break;
|
||||||
case 'e':
|
|
||||||
echo = true;
|
|
||||||
break;
|
|
||||||
case 'O':
|
|
||||||
owner = pg_strdup(optarg);
|
|
||||||
break;
|
|
||||||
case 'D':
|
|
||||||
tablespace = pg_strdup(optarg);
|
|
||||||
break;
|
|
||||||
case 'T':
|
|
||||||
template = pg_strdup(optarg);
|
|
||||||
break;
|
|
||||||
case 'E':
|
|
||||||
encoding = pg_strdup(optarg);
|
|
||||||
break;
|
|
||||||
case 'S':
|
|
||||||
strategy = pg_strdup(optarg);
|
|
||||||
break;
|
|
||||||
case 1:
|
case 1:
|
||||||
lc_collate = pg_strdup(optarg);
|
lc_collate = pg_strdup(optarg);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
lc_ctype = pg_strdup(optarg);
|
lc_ctype = pg_strdup(optarg);
|
||||||
break;
|
break;
|
||||||
case 'l':
|
|
||||||
locale = pg_strdup(optarg);
|
|
||||||
break;
|
|
||||||
case 3:
|
case 3:
|
||||||
maintenance_db = pg_strdup(optarg);
|
maintenance_db = pg_strdup(optarg);
|
||||||
break;
|
break;
|
||||||
|
@ -65,13 +65,22 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
handle_help_version_opts(argc, argv, "dropdb", help);
|
handle_help_version_opts(argc, argv, "dropdb", help);
|
||||||
|
|
||||||
while ((c = getopt_long(argc, argv, "h:p:U:wWeif", long_options, &optindex)) != -1)
|
while ((c = getopt_long(argc, argv, "efh:ip:U:wW", long_options, &optindex)) != -1)
|
||||||
{
|
{
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
|
case 'e':
|
||||||
|
echo = true;
|
||||||
|
break;
|
||||||
|
case 'f':
|
||||||
|
force = true;
|
||||||
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
host = pg_strdup(optarg);
|
host = pg_strdup(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'i':
|
||||||
|
interactive = true;
|
||||||
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
port = pg_strdup(optarg);
|
port = pg_strdup(optarg);
|
||||||
break;
|
break;
|
||||||
@ -84,15 +93,6 @@ main(int argc, char *argv[])
|
|||||||
case 'W':
|
case 'W':
|
||||||
prompt_password = TRI_YES;
|
prompt_password = TRI_YES;
|
||||||
break;
|
break;
|
||||||
case 'e':
|
|
||||||
echo = true;
|
|
||||||
break;
|
|
||||||
case 'i':
|
|
||||||
interactive = true;
|
|
||||||
break;
|
|
||||||
case 'f':
|
|
||||||
force = true;
|
|
||||||
break;
|
|
||||||
case 0:
|
case 0:
|
||||||
/* this covers the long options */
|
/* this covers the long options */
|
||||||
break;
|
break;
|
||||||
|
@ -62,13 +62,19 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
handle_help_version_opts(argc, argv, "dropuser", help);
|
handle_help_version_opts(argc, argv, "dropuser", help);
|
||||||
|
|
||||||
while ((c = getopt_long(argc, argv, "h:p:U:wWei", long_options, &optindex)) != -1)
|
while ((c = getopt_long(argc, argv, "eh:ip:U:wW", long_options, &optindex)) != -1)
|
||||||
{
|
{
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
|
case 'e':
|
||||||
|
echo = true;
|
||||||
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
host = pg_strdup(optarg);
|
host = pg_strdup(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'i':
|
||||||
|
interactive = true;
|
||||||
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
port = pg_strdup(optarg);
|
port = pg_strdup(optarg);
|
||||||
break;
|
break;
|
||||||
@ -81,12 +87,6 @@ main(int argc, char *argv[])
|
|||||||
case 'W':
|
case 'W':
|
||||||
prompt_password = TRI_YES;
|
prompt_password = TRI_YES;
|
||||||
break;
|
break;
|
||||||
case 'e':
|
|
||||||
echo = true;
|
|
||||||
break;
|
|
||||||
case 'i':
|
|
||||||
interactive = true;
|
|
||||||
break;
|
|
||||||
case 0:
|
case 0:
|
||||||
/* this covers the long options */
|
/* this covers the long options */
|
||||||
break;
|
break;
|
||||||
|
@ -109,45 +109,21 @@ main(int argc, char *argv[])
|
|||||||
handle_help_version_opts(argc, argv, "reindexdb", help);
|
handle_help_version_opts(argc, argv, "reindexdb", help);
|
||||||
|
|
||||||
/* process command-line options */
|
/* process command-line options */
|
||||||
while ((c = getopt_long(argc, argv, "h:p:U:wWeqS:d:ast:i:j:v", long_options, &optindex)) != -1)
|
while ((c = getopt_long(argc, argv, "ad:eh:i:j:qp:sS:t:U:vwW", long_options, &optindex)) != -1)
|
||||||
{
|
{
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case 'h':
|
case 'a':
|
||||||
host = pg_strdup(optarg);
|
alldb = true;
|
||||||
break;
|
|
||||||
case 'p':
|
|
||||||
port = pg_strdup(optarg);
|
|
||||||
break;
|
|
||||||
case 'U':
|
|
||||||
username = pg_strdup(optarg);
|
|
||||||
break;
|
|
||||||
case 'w':
|
|
||||||
prompt_password = TRI_NO;
|
|
||||||
break;
|
|
||||||
case 'W':
|
|
||||||
prompt_password = TRI_YES;
|
|
||||||
break;
|
|
||||||
case 'e':
|
|
||||||
echo = true;
|
|
||||||
break;
|
|
||||||
case 'q':
|
|
||||||
quiet = true;
|
|
||||||
break;
|
|
||||||
case 'S':
|
|
||||||
simple_string_list_append(&schemas, optarg);
|
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
dbname = pg_strdup(optarg);
|
dbname = pg_strdup(optarg);
|
||||||
break;
|
break;
|
||||||
case 'a':
|
case 'e':
|
||||||
alldb = true;
|
echo = true;
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 'h':
|
||||||
syscatalog = true;
|
host = pg_strdup(optarg);
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
simple_string_list_append(&tables, optarg);
|
|
||||||
break;
|
break;
|
||||||
case 'i':
|
case 'i':
|
||||||
simple_string_list_append(&indexes, optarg);
|
simple_string_list_append(&indexes, optarg);
|
||||||
@ -157,9 +133,33 @@ main(int argc, char *argv[])
|
|||||||
&concurrentCons))
|
&concurrentCons))
|
||||||
exit(1);
|
exit(1);
|
||||||
break;
|
break;
|
||||||
|
case 'q':
|
||||||
|
quiet = true;
|
||||||
|
break;
|
||||||
|
case 'p':
|
||||||
|
port = pg_strdup(optarg);
|
||||||
|
break;
|
||||||
|
case 's':
|
||||||
|
syscatalog = true;
|
||||||
|
break;
|
||||||
|
case 'S':
|
||||||
|
simple_string_list_append(&schemas, optarg);
|
||||||
|
break;
|
||||||
|
case 't':
|
||||||
|
simple_string_list_append(&tables, optarg);
|
||||||
|
break;
|
||||||
|
case 'U':
|
||||||
|
username = pg_strdup(optarg);
|
||||||
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
verbose = true;
|
verbose = true;
|
||||||
break;
|
break;
|
||||||
|
case 'w':
|
||||||
|
prompt_password = TRI_NO;
|
||||||
|
break;
|
||||||
|
case 'W':
|
||||||
|
prompt_password = TRI_YES;
|
||||||
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
concurrently = true;
|
concurrently = true;
|
||||||
break;
|
break;
|
||||||
|
@ -155,82 +155,76 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
handle_help_version_opts(argc, argv, "vacuumdb", help);
|
handle_help_version_opts(argc, argv, "vacuumdb", help);
|
||||||
|
|
||||||
while ((c = getopt_long(argc, argv, "h:p:U:wWeqd:zZFat:fvj:P:n:N:", long_options, &optindex)) != -1)
|
while ((c = getopt_long(argc, argv, "ad:efFh:j:n:N:p:P:qt:U:vwWzZ", long_options, &optindex)) != -1)
|
||||||
{
|
{
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
|
case 'a':
|
||||||
|
objfilter |= OBJFILTER_ALL_DBS;
|
||||||
|
break;
|
||||||
|
case 'd':
|
||||||
|
objfilter |= OBJFILTER_DATABASE;
|
||||||
|
dbname = pg_strdup(optarg);
|
||||||
|
break;
|
||||||
|
case 'e':
|
||||||
|
echo = true;
|
||||||
|
break;
|
||||||
|
case 'f':
|
||||||
|
vacopts.full = true;
|
||||||
|
break;
|
||||||
|
case 'F':
|
||||||
|
vacopts.freeze = true;
|
||||||
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
host = pg_strdup(optarg);
|
host = pg_strdup(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'j':
|
||||||
|
if (!option_parse_int(optarg, "-j/--jobs", 1, INT_MAX,
|
||||||
|
&concurrentCons))
|
||||||
|
exit(1);
|
||||||
|
break;
|
||||||
|
case 'n':
|
||||||
|
objfilter |= OBJFILTER_SCHEMA;
|
||||||
|
simple_string_list_append(&objects, optarg);
|
||||||
|
break;
|
||||||
|
case 'N':
|
||||||
|
objfilter |= OBJFILTER_SCHEMA_EXCLUDE;
|
||||||
|
simple_string_list_append(&objects, optarg);
|
||||||
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
port = pg_strdup(optarg);
|
port = pg_strdup(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'P':
|
||||||
|
if (!option_parse_int(optarg, "-P/--parallel", 0, INT_MAX,
|
||||||
|
&vacopts.parallel_workers))
|
||||||
|
exit(1);
|
||||||
|
break;
|
||||||
|
case 'q':
|
||||||
|
quiet = true;
|
||||||
|
break;
|
||||||
|
case 't':
|
||||||
|
objfilter |= OBJFILTER_TABLE;
|
||||||
|
simple_string_list_append(&objects, optarg);
|
||||||
|
tbl_count++;
|
||||||
|
break;
|
||||||
case 'U':
|
case 'U':
|
||||||
username = pg_strdup(optarg);
|
username = pg_strdup(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'v':
|
||||||
|
vacopts.verbose = true;
|
||||||
|
break;
|
||||||
case 'w':
|
case 'w':
|
||||||
prompt_password = TRI_NO;
|
prompt_password = TRI_NO;
|
||||||
break;
|
break;
|
||||||
case 'W':
|
case 'W':
|
||||||
prompt_password = TRI_YES;
|
prompt_password = TRI_YES;
|
||||||
break;
|
break;
|
||||||
case 'e':
|
|
||||||
echo = true;
|
|
||||||
break;
|
|
||||||
case 'q':
|
|
||||||
quiet = true;
|
|
||||||
break;
|
|
||||||
case 'd':
|
|
||||||
objfilter |= OBJFILTER_DATABASE;
|
|
||||||
dbname = pg_strdup(optarg);
|
|
||||||
break;
|
|
||||||
case 'z':
|
case 'z':
|
||||||
vacopts.and_analyze = true;
|
vacopts.and_analyze = true;
|
||||||
break;
|
break;
|
||||||
case 'Z':
|
case 'Z':
|
||||||
vacopts.analyze_only = true;
|
vacopts.analyze_only = true;
|
||||||
break;
|
break;
|
||||||
case 'F':
|
|
||||||
vacopts.freeze = true;
|
|
||||||
break;
|
|
||||||
case 'a':
|
|
||||||
objfilter |= OBJFILTER_ALL_DBS;
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
{
|
|
||||||
objfilter |= OBJFILTER_TABLE;
|
|
||||||
simple_string_list_append(&objects, optarg);
|
|
||||||
tbl_count++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'f':
|
|
||||||
vacopts.full = true;
|
|
||||||
break;
|
|
||||||
case 'v':
|
|
||||||
vacopts.verbose = true;
|
|
||||||
break;
|
|
||||||
case 'j':
|
|
||||||
if (!option_parse_int(optarg, "-j/--jobs", 1, INT_MAX,
|
|
||||||
&concurrentCons))
|
|
||||||
exit(1);
|
|
||||||
break;
|
|
||||||
case 'P':
|
|
||||||
if (!option_parse_int(optarg, "-P/--parallel", 0, INT_MAX,
|
|
||||||
&vacopts.parallel_workers))
|
|
||||||
exit(1);
|
|
||||||
break;
|
|
||||||
case 'n':
|
|
||||||
{
|
|
||||||
objfilter |= OBJFILTER_SCHEMA;
|
|
||||||
simple_string_list_append(&objects, optarg);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'N':
|
|
||||||
{
|
|
||||||
objfilter |= OBJFILTER_SCHEMA_EXCLUDE;
|
|
||||||
simple_string_list_append(&objects, optarg);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 2:
|
case 2:
|
||||||
maintenance_db = pg_strdup(optarg);
|
maintenance_db = pg_strdup(optarg);
|
||||||
break;
|
break;
|
||||||
|
@ -157,48 +157,13 @@ main(int argc, char *const argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
output_filename = NULL;
|
output_filename = NULL;
|
||||||
while ((c = getopt_long(argc, argv, "vcio:I:tD:dC:r:h", ecpg_options, NULL)) != -1)
|
while ((c = getopt_long(argc, argv, "cC:dD:hiI:o:r:tv", ecpg_options, NULL)) != -1)
|
||||||
{
|
{
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case ECPG_GETOPT_LONG_REGRESSION:
|
|
||||||
regression_mode = true;
|
|
||||||
break;
|
|
||||||
case 'o':
|
|
||||||
output_filename = mm_strdup(optarg);
|
|
||||||
if (strcmp(output_filename, "-") == 0)
|
|
||||||
base_yyout = stdout;
|
|
||||||
else
|
|
||||||
base_yyout = fopen(output_filename, PG_BINARY_W);
|
|
||||||
|
|
||||||
if (base_yyout == NULL)
|
|
||||||
{
|
|
||||||
fprintf(stderr, _("%s: could not open file \"%s\": %s\n"),
|
|
||||||
progname, output_filename, strerror(errno));
|
|
||||||
output_filename = NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
out_option = 1;
|
|
||||||
break;
|
|
||||||
case 'I':
|
|
||||||
add_include_path(optarg);
|
|
||||||
break;
|
|
||||||
case 't':
|
|
||||||
autocommit = true;
|
|
||||||
break;
|
|
||||||
case 'v':
|
|
||||||
verbose = true;
|
|
||||||
break;
|
|
||||||
case 'h':
|
|
||||||
header_mode = true;
|
|
||||||
/* this must include "-c" to make sense, so fall through */
|
|
||||||
/* FALLTHROUGH */
|
|
||||||
case 'c':
|
case 'c':
|
||||||
auto_create_c = true;
|
auto_create_c = true;
|
||||||
break;
|
break;
|
||||||
case 'i':
|
|
||||||
system_includes = true;
|
|
||||||
break;
|
|
||||||
case 'C':
|
case 'C':
|
||||||
if (pg_strcasecmp(optarg, "INFORMIX") == 0 || pg_strcasecmp(optarg, "INFORMIX_SE") == 0)
|
if (pg_strcasecmp(optarg, "INFORMIX") == 0 || pg_strcasecmp(optarg, "INFORMIX_SE") == 0)
|
||||||
{
|
{
|
||||||
@ -220,6 +185,44 @@ main(int argc, char *const argv[])
|
|||||||
return ILLEGAL_OPTION;
|
return ILLEGAL_OPTION;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'd':
|
||||||
|
#ifdef YYDEBUG
|
||||||
|
base_yydebug = 1;
|
||||||
|
#else
|
||||||
|
fprintf(stderr, _("%s: parser debug support (-d) not available\n"),
|
||||||
|
progname);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
case 'D':
|
||||||
|
add_preprocessor_define(optarg);
|
||||||
|
break;
|
||||||
|
case 'h':
|
||||||
|
header_mode = true;
|
||||||
|
/* this must include "-c" to make sense: */
|
||||||
|
auto_create_c = true;
|
||||||
|
break;
|
||||||
|
case 'i':
|
||||||
|
system_includes = true;
|
||||||
|
break;
|
||||||
|
case 'I':
|
||||||
|
add_include_path(optarg);
|
||||||
|
break;
|
||||||
|
case 'o':
|
||||||
|
output_filename = mm_strdup(optarg);
|
||||||
|
if (strcmp(output_filename, "-") == 0)
|
||||||
|
base_yyout = stdout;
|
||||||
|
else
|
||||||
|
base_yyout = fopen(output_filename, PG_BINARY_W);
|
||||||
|
|
||||||
|
if (base_yyout == NULL)
|
||||||
|
{
|
||||||
|
fprintf(stderr, _("%s: could not open file \"%s\": %s\n"),
|
||||||
|
progname, output_filename, strerror(errno));
|
||||||
|
output_filename = NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
out_option = 1;
|
||||||
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
if (pg_strcasecmp(optarg, "no_indicator") == 0)
|
if (pg_strcasecmp(optarg, "no_indicator") == 0)
|
||||||
force_indicator = false;
|
force_indicator = false;
|
||||||
@ -233,16 +236,14 @@ main(int argc, char *const argv[])
|
|||||||
return ILLEGAL_OPTION;
|
return ILLEGAL_OPTION;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'D':
|
case 't':
|
||||||
add_preprocessor_define(optarg);
|
autocommit = true;
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'v':
|
||||||
#ifdef YYDEBUG
|
verbose = true;
|
||||||
base_yydebug = 1;
|
break;
|
||||||
#else
|
case ECPG_GETOPT_LONG_REGRESSION:
|
||||||
fprintf(stderr, _("%s: parser debug support (-d) not available\n"),
|
regression_mode = true;
|
||||||
progname);
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), argv[0]);
|
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), argv[0]);
|
||||||
|
@ -1705,13 +1705,10 @@ main(int argc, char **argv)
|
|||||||
PGresult *res;
|
PGresult *res;
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "t:r:")) != -1)
|
while ((c = getopt(argc, argv, "r:t:")) != -1)
|
||||||
{
|
{
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case 't': /* trace file */
|
|
||||||
tracefile = pg_strdup(optarg);
|
|
||||||
break;
|
|
||||||
case 'r': /* numrows */
|
case 'r': /* numrows */
|
||||||
errno = 0;
|
errno = 0;
|
||||||
numrows = strtol(optarg, NULL, 10);
|
numrows = strtol(optarg, NULL, 10);
|
||||||
@ -1722,6 +1719,9 @@ main(int argc, char **argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 't': /* trace file */
|
||||||
|
tracefile = pg_strdup(optarg);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user