Re: pg_ctl only allows 12 parameters?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ron Johnson <ronljohnsonjr@xxxxxxxxx> writes:
> On Mon, Dec 18, 2023 at 12:02 PM Tom Lane <tgl@xxxxxxxxxxxxx> 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





[Index of Archives]     [Postgresql Home]     [Postgresql General]     [Postgresql Performance]     [Postgresql PHP]     [Postgresql Jobs]     [PHP Users]     [PHP Databases]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Forum]

  Powered by Linux