Better error message when --single is not the first arg to postgres executable

2024-06-05 Thread Greg Sabino Mullane
Please find attached a quick patch to prevent this particularly bad error message for running "postgres", when making the common mistake of forgetting to put the "--single" option first because you added an earlier arg (esp. datadir) Current behavior: $ ~/pg/bin/postgres -D ~/pg/data --single 202

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

2024-06-05 Thread Nathan Bossart
On Wed, Jun 05, 2024 at 02:51:05PM -0400, Greg Sabino Mullane wrote: > Please find attached a quick patch to prevent this particularly bad error > message for running "postgres", when making the common mistake of > forgetting to put the "--single" option first because you added an earlier > arg (es

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

2024-06-05 Thread Greg Sabino Mullane
On Wed, Jun 5, 2024 at 3:18 PM Nathan Bossart wrote: > Could we remove the requirement that --single must be first? I'm not > thrilled about adding a list of "must be first" options that needs to stay > updated, but given this list probably doesn't change too frequently, maybe > that's still bet

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

2024-06-17 Thread Nathan Bossart
On Wed, Jun 05, 2024 at 11:38:48PM -0400, Greg Sabino Mullane wrote: > On Wed, Jun 5, 2024 at 3:18 PM Nathan Bossart > wrote: >> Could we remove the requirement that --single must be first? I'm not >> thrilled about adding a list of "must be first" options that needs to stay >> updated, but given

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

2024-06-18 Thread Greg Sabino Mullane
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 What about just inlining --version and --help e.g. else if (strcmp(argv[i], "--versio

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

2024-06-19 Thread Nathan Bossart
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,

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

2024-06-19 Thread Peter Eisentraut
On 19.06.24 16:04, Nathan Bossart wrote: 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

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

2024-06-19 Thread Nathan Bossart
On Wed, Jun 19, 2024 at 05:34:52PM +0200, Peter Eisentraut wrote: > I'm not really sure all this here is worth solving. I think requiring > things like --single or --boot to be first seems ok, and the alternatives > just make things more complicated. Yeah, I'm fine with doing something more like

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

2024-08-21 Thread Nathan Bossart
On Wed, Jun 19, 2024 at 10:58:02AM -0500, Nathan Bossart wrote: > On Wed, Jun 19, 2024 at 05:34:52PM +0200, Peter Eisentraut wrote: >> I'm not really sure all this here is worth solving. I think requiring >> things like --single or --boot to be first seems ok, and the alternatives >> just make thi

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

2024-08-25 Thread Greg Sabino Mullane
I'm not opposed to this new method, as long as the error code improves. :) +typedef enum Subprogram +{ + SUBPROGRAM_CHECK, + SUBPROGRAM_BOOT, +#ifdef EXEC_BACKEND + SUBPROGRAM_FORKCHILD, +#endif I'm not happy about making this and the const char[] change their structure based on the ifdefs - coul

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

2024-08-26 Thread Nathan Bossart
On Sun, Aug 25, 2024 at 01:14:36PM -0400, Greg Sabino Mullane wrote: > I'm not happy about making this and the const char[] change their structure > based on the ifdefs - could we not just leave forkchild in? Their usage is > already protected by the ifdefs in the calling code. Here's an attempt a

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

2024-08-27 Thread Greg Sabino Mullane
On Mon, Aug 26, 2024 at 11:43 AM Nathan Bossart wrote: > On Sun, Aug 25, 2024 at 01:14:36PM -0400, Greg Sabino Mullane wrote: > > I'm not happy about making this and the const char[] change their > structure > > based on the ifdefs - could we not just leave forkchild in? Their usage > is > > alre