Обсуждение: [NOVICE] pg_ctl command option anomalies

Поиск
Список
Период
Сортировка

[NOVICE] pg_ctl command option anomalies

От
Neha Khatri
Дата:
Hi,

Some of the pg_ctl modes do not require following options:
  -m, -w, -t, -c, -l, -o, -p

However when one of this option is provided with any of the unsupported pg_ctl mode, misleading message is displayed:
  $ pg_ctl status -D data -m
  pg_ctl: option requires an argument -- 'm'

I believe that above command execution should give following message:
  pg_ctl: invalid option -- 'm'
  
Also, when an argument is provided for that option, the command proceeds without any error.
 $ pg_ctl status -D data/ -m fast
 pg_ctl: server is running (PID: 28108)
 /home/host1/bin/postgres "-D" "data"
 
It seems like a known pg_ctl anomaly. Is there a thought in the direction of changing/correcting this behaviour?

Regards,
Neha

Re: [NOVICE] pg_ctl command option anomalies

От
Tom Lane
Дата:
Neha Khatri <nehakhatri5@gmail.com> writes:
> Some of the pg_ctl modes do not require following options:
>   -m, -w, -t, -c, -l, -o, -p

Um ... all of those except -c and -w require an argument AFAIK.  Where did
you read that they don't?

The pg_ctl man page does seem to need some work, for instance -t is shown
as requiring an argument in the syntax synopsis, and the textual
description implies that it has one, but

-t
--timeout

should look more like

-t seconds
--timeout=seconds

But on the whole I'd bet that discrepancies of this sort are documentation
bugs not code bugs.

            regards, tom lane


Re: [NOVICE] pg_ctl command option anomalies

От
Neha Khatri
Дата:
On Thu, Apr 20, 2017 at 3:53 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Neha Khatri <nehakhatri5@gmail.com> writes:
> Some of the pg_ctl modes do not require following options:
>   -m, -w, -t, -c, -l, -o, -p

Um ... all of those except -c and -w require an argument AFAIK.  Where did
you read that they don't?

I did not mean that they don't require an argument. What I was trying to refer is that "pg_ctl status" would not require a "-m fast", for instance. Would there be a functional difference if I execute following commands:
 
pg_ctl status -D data/ -m fast
pg_ctl status -D data/ -m smart
pg_ctl status -D data/ -m immediate

If no, then -m does not seem a valid option for "pg_ctl status".But I am allowed to execute all of the above.

Regards,
Neha

Re: [NOVICE] pg_ctl command option anomalies

От
Tom Lane
Дата:
Neha Khatri <nehakhatri5@gmail.com> writes:
> On Thu, Apr 20, 2017 at 3:53 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Um ... all of those except -c and -w require an argument AFAIK.  Where did
>> you read that they don't?

> I did not mean that they don't require an argument. What I was trying to
> refer is that "pg_ctl status" would not require a "-m fast", for instance.

Ah.  Yeah, pg_ctl doesn't bother to complain about options that are
irrelevant to the selected sub-command.  But they still have to be
syntactically valid.  For instance, "-m bogus" would be rejected whether
or not -m is relevant to the selected sub-command.

There's a pretty large amount of art and history behind the way that
Unix commands react to command-line options.  One thing that's gotten
worked out along the way is that failing because some option is irrelevant
to the specific current action is really not very helpful.  For example,
C compilers generally allow -I options even when the current action only
involves linking not compiling, or -L options in the reverse case, because
doing otherwise makes Makefile-writing a lot harder for little benefit.
There are C compilers that just issue a warning (not fail outright) for
"unused command line options" in such cases, but even that is widely
deemed to be unhelpful pedantry.

            regards, tom lane


Re: [NOVICE] pg_ctl command option anomalies

От
Neha Khatri
Дата:
On Thu, Apr 20, 2017 at 4:20 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Neha Khatri <nehakhatri5@gmail.com> writes:
> On Thu, Apr 20, 2017 at 3:53 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Um ... all of those except -c and -w require an argument AFAIK.  Where did
>> you read that they don't?

> I did not mean that they don't require an argument. What I was trying to
> refer is that "pg_ctl status" would not require a "-m fast", for instance.

Ah.  Yeah, pg_ctl doesn't bother to complain about options that are
irrelevant to the selected sub-command.  But they still have to be
syntactically valid.  For instance, "-m bogus" would be rejected whether
or not -m is relevant to the selected sub-command.

But this looks odd, when I am not trying to shutdown, I am just checking the status:
  $ pg_ctl status -D data/ -m abc
  pg_ctl: unrecognized shutdown mode "abc"
  Try "pg_ctl --help" for more information.
 
There's a pretty large amount of art and history behind the way that
Unix commands react to command-line options.  One thing that's gotten
worked out along the way is that failing because some option is irrelevant
to the specific current action is really not very helpful.  For example,
C compilers generally allow -I options even when the current action only
involves linking not compiling, or -L options in the reverse case, because
doing otherwise makes Makefile-writing a lot harder for little benefit.
There are C compilers that just issue a warning (not fail outright) for
"unused command line options" in such cases, but even that is widely
deemed to be unhelpful pedantry.

That's enlightening.

Regards,
Neha