pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Ron Johnson <ronljohnsonjr@gmail.com>
Cc: Nathan Bossart <nathan@postgresql.org>
Cc: David G. Johnston <david.g.johnston@gmail.com>
Cc: Pgsql-admin <pgsql-admin@lists.postgresql.org>
Subject: Re: pg_ctl only allows 12 parameters?
Date: Mon, 18 Dec 2023 14:28:05 -0500
Message-ID: <4005894.1702927685@sss.pgh.pa.us> (raw)
In-Reply-To: <CANzqJaCOJALngyw3Sk7-H=L7vuWBqK3et7x78Ghe8JrPnL+LMQ@mail.gmail.com>
References: <CANzqJaDCagH5wNkPQ42=Fx3mJPR-YnB3PWFdCAYAVdb9=Q+t-A@mail.gmail.com>
	<CAKFQuwbBvswquRFOZBeXSa5qvwBwmWvzNedPTP3JOBvzBo48TA@mail.gmail.com>
	<CANzqJaAL5OpkujQzDSgN5HWamWeOVcaL39cAgW_JoW+YKu5Ziw@mail.gmail.com>
	<CAKFQuwb=Qo49SpcA6obmA2xtjV3Nc8mxPkhsyoxKFJbTWA_ngg@mail.gmail.com>
	<CANzqJaCSpziN3onfthDgy02hGWF_mvLLcZCzNttw2_jmbp4++A@mail.gmail.com>
	<3960907.1702915763@sss.pgh.pa.us>
	<CANzqJaC=pY4fOLkNjVsGxm4w2C=h=KR7ndLRY4f9aEEKKuQiNA@mail.gmail.com>
	<3973210.1702918924@sss.pgh.pa.us>
	<CANzqJaCOJALngyw3Sk7-H=L7vuWBqK3et7x78Ghe8JrPnL+LMQ@mail.gmail.com>

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





view thread (11+ messages)

Message-ID: <4005894.1702927685@sss.pgh.pa.us>
Permalink:  ../4005894.1702927685@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/4005894.1702927685@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: tgl@sss.pgh.pa.us, ronljohnsonjr@gmail.com, nathan@postgresql.org, david.g.johnston@gmail.com, pgsql-admin@lists.postgresql.org
  Subject: Re: pg_ctl only allows 12 parameters?
  In-Reply-To: <4005894.1702927685@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox