Re: Better error message when --single is not the first arg to postgres executable - Mailing list pgsql-hackers

From Nathan Bossart
Subject Re: Better error message when --single is not the first arg to postgres executable
Date
Msg-id ZnLlfMQeV1src1ot@nathan
Whole thread Raw
In response to Re: Better error message when --single is not the first arg to postgres executable  (Greg Sabino Mullane <htamfids@gmail.com>)
Responses Re: Better error message when --single is not the first arg to postgres executable
List pgsql-hackers
On Tue, Jun 18, 2024 at 09:42:32PM -0400, Greg Sabino Mullane wrote:
> If I am reading your patch correctly, we have lost the behavior of least
> surprise in which the first "meta" argument overrides all others:
> 
> $ bin/postgres --version --boot --extrastuff
> postgres (PostgreSQL) 16.2

Right, with the patch we fail if there are multiple such options specified:

    $ postgres --version --help
    FATAL:  multiple server modes set
    DETAIL:  Only one of --check, --boot, --describe-config, --single, --help/-?, --version/-V, -C may be set.

> What about just inlining --version and --help e.g.
> 
> else if (strcmp(argv[i], "--version") == 0 || strcmp(argv[i], "-V") == 0)
> {
>      fputs(PG_BACKEND_VERSIONSTR, stdout);
>      exit(0);
> }
> 
> I'm fine with being more persnickety about the other options; they are much
> rarer and not unixy.

That seems like it should work.  I'm not sure I agree that's the least
surprising behavior (e.g., what exactly is the user trying to tell us with
commands like "postgres --version --help --describe-config"?), but I also
don't feel too strongly about it.

-- 
nathan



pgsql-hackers by date:

Previous
From: Ranier Vilela
Date:
Subject: Re: Add pg_get_acl() function get the ACL for a database object
Next
From: Bertrand Drouvot
Date:
Subject: Re: Avoid orphaned objects dependencies, take 3