From: | Andrei Korigodski <akorigod(at)gmail(dot)com> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | pgbench: improve --help and --version parsing |
Date: | 2018-07-22 00:39:39 |
Message-ID: | c50e18df-8f53-0b3e-8bb4-27be8598c954@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
There is a small catch in the parsing of --help and --version args by pgbench:
they are processed correctly only as the first argument. If it's not the case,
strange error message occurs:
$ pgbench -q --help
pgbench: unrecognized option '--help'
Try "pgbench --help" for more information.
The reason for this behavior is how these two arguments are handled in
src/bin/pgbench/pgbench.c:
if (argc > 1)
{
if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0)
{
usage();
exit(0);
}
if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0)
{
puts("pgbench (PostgreSQL) " PG_VERSION);
exit(0);
}
}
All other arguments are processed with getopt_long. The proposed patch replaces
the existing way of parsing the --help and --version arguments with getopt_long,
expanding the existing switch statement.
--
Andrei Korigodski
Attachment | Content-Type | Size |
---|---|---|
pgbench-arg-parsing-v1.patch | text/x-patch | 2.0 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Davy Machado | 2018-07-22 02:21:28 | Re: pg_ugprade test failure on data set with column with default value with type bit/varbit |
Previous Message | Tom Lane | 2018-07-22 00:03:37 | Re: Remove psql's -W option |