Re: \if, \elseif, \else, \endif (was Re: PSQL commands: \quit_if, \quit_unless)

From: Corey Huinker <corey(dot)huinker(at)gmail(dot)com>
To: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Greg Stark <stark(at)mit(dot)edu>, Erik Rijkers <er(at)xs4all(dot)nl>, Robert Haas <robertmhaas(at)gmail(dot)com>, Daniel Verite <daniel(at)manitou-mail(dot)org>, Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com>, PostgreSQL <pgsql-hackers(at)postgresql(dot)org>, pgsql-hackers-owner(at)postgresql(dot)org
Subject: Re: \if, \elseif, \else, \endif (was Re: PSQL commands: \quit_if, \quit_unless)
Date: 2017-03-01 18:01:40
Message-ID: CADkLM=eeyM_5eFyty6S_VDK-rJXNaKPJmB5mELC04n1xfWZK=Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Mar 1, 2017 at 12:23 PM, Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr> wrote:

>
> Hello Corey,
>
> on elif
>> if misplaced elif
>> misplaced elif error
>> else
>> eval expression
>> => possible eval error
>> set new status if eval fine
>>
>
> Currently it is really:
>
> switch (state) {
> case NONE:
> case ELSE_TRUE:
> case ELSE_FALSE:
> success = false;
> show some error
> default:
> }
> if (success) {
> success = evaluate_expression(...);
> if (success) {
> switch (state) {
> case ...:
> default:
> }
> }
> }
>
> Which I do not find so neat. The previous one with nested switch-if-switch
> looked as bad.

That is accurate. The only positive it has is that the user only
experiences one error, and it's the first error that was encountered if
reading top-to-bottom, left to right. It is an issue of which we prioritize
- user experience or simpler code.

Now if you want to require committer opinion on this one, fine with me.

Rather than speculate on what a committer thinks of this edge case (and
making a patch for each possible theory), I'd rather just ask them what
their priorities are and which user experience they favor.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tels 2017-03-01 18:12:36 Re: PassDownLimitBound for ForeignScan/CustomScan [take-2]
Previous Message Alvaro Herrera 2017-03-01 17:58:06 Re: Patch: Optimize memory allocation in function 'bringetbitmap'