Re: pg_ctl only allows 12 parameters?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: pg_ctl only allows 12 parameters?
Дата
Msg-id 4005894.1702927685@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: pg_ctl only allows 12 parameters?  (Ron Johnson <ronljohnsonjr@gmail.com>)
Список pgsql-admin
Ron Johnson <ronljohnsonjr@gmail.com> writes:
> On Mon, Dec 18, 2023 at 12:02 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Looking at the v14 pg_ctl code, I see it has an extra level of
>> looping around getopt_long to try to cope with implementations
>> that don't permute the arguments.  So in theory it should work as
>> documented everywhere.  But I could see how things might get
>> confused, if the subroutine misidentifies what is a switch.

> There must be some PEBKAC involved that pg_ctl error handling didn't
> explain well, because _this_ unreformatted command works.

After studying the code some more, I think I can reproduce it:

$ pg_ctl restart foo -o "whatever"
pg_ctl: too many command-line arguments (first is "restart")
Try "pg_ctl --help" for more information.

It should be complaining about "foo", but the message mentions
"restart" instead.  I think you must have had something in your
non-working command that did not get interpreted as being a
switch or a switch argument, leading to the misleading report.

That's with v14.  HEAD gets this right:

$ pg_ctl restart foo -o "whatever"
pg_ctl: too many command-line arguments (first is "foo")
Try "pg_ctl --help" for more information.

The change in behavior is evidently due to commit 03d1080d8, which
got rid of the extra level of looping in pg_ctl's use of getopt_long.
I surmise that after we loop around and re-invoke getopt_long,
glibc's getopt_long resets "optind" to the first non-option argument,
rather than honoring the increment from the bottom of the loop.

This seems like a bug to me, but I'm not sure if I want to
propose back-patching 03d1080d8 (and 411b72034) to deal with
it.  That code hasn't made it into a stable branch yet, so
a back-patch would be a little bit risky.

            regards, tom lane



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

Предыдущее
От: Ron Johnson
Дата:
Сообщение: Re: pg_ctl only allows 12 parameters?
Следующее
От: GF
Дата:
Сообщение: Re: Guidance required to summarize the migration breaking changes between PG versions