pgbench: improve --help and --version parsing

Поиск
Список
Период
Сортировка
От Andrei Korigodski
Тема pgbench: improve --help and --version parsing
Дата
Msg-id c50e18df-8f53-0b3e-8bb4-27be8598c954@gmail.com
обсуждение исходный текст
Ответы Re: pgbench: improve --help and --version parsing  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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


Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Remove psql's -W option
Следующее
От: Davy Machado
Дата:
Сообщение: Re: pg_ugprade test failure on data set with column with default valuewith type bit/varbit