Re: \if, \elseif, \else, \endif (was Re: [HACKERS] PSQL commands:\quit_if, \quit_unless) - Mailing list pgsql-hackers

From Corey Huinker
Subject Re: \if, \elseif, \else, \endif (was Re: [HACKERS] PSQL commands:\quit_if, \quit_unless)
Date
Msg-id CADkLM=eopA+VrO9+OmST9p71F7+PJDYzNDyRs6w9t4mE2X-rpQ@mail.gmail.com
Whole thread Raw
In response to Re: \if, \elseif, \else, \endif (was Re: [HACKERS] PSQL commands:\quit_if, \quit_unless)  (Fabien COELHO <coelho@cri.ensmp.fr>)
Responses Re: \if, \elseif, \else, \endif (was Re: [HACKERS] PSQL commands:\quit_if, \quit_unless)  (Fabien COELHO <coelho@cri.ensmp.fr>)
List pgsql-hackers


On Mon, Feb 13, 2017 at 3:40 PM, Fabien COELHO <coelho@cri.ensmp.fr> wrote:

Hello Robert,

[...] I think we should try to make this REALLY simple.  We don't really want to have everybody have to change their PROMPT1 and PROMPT2 strings for this one feature.

Ok. I think that we agree that the stack was too much details.

How about just introducing a new value for %R?

Yes. That is indeed one of the idea being discussed.

[...] , or @ if commands are currently being ignored because of the result of an \if test.

,-or-@ has one advantage over t/f/z: we cannot infer the 'z' state purely from pset.active_state, and the if-stack itself is sequestered in scan_state, which is not visible to the get_prompt() function.

I suppose if somebody wanted it, a separate slash command that does a verbose printing of the current if-stack would be nice, but mostly just to explain to people how the if-stack works.
 
If I can find some simple mnemonic for "," vs "@" for being executed vs ignored, I could live with that, but nothing obvious comes to my mind.

@in't gonna execute it? 

I'm here all week, try the veal.

To sum up your points: just update %R (ok), keep it simple/short (ok... but how simple [2 vs 3 states] and short [1 or 2 chars]), and no real need to be too nice with the user beyond the vital (ok, that significantly simplifies things).

I'd be fine with either of these on aesthetic grounds. On technical grounds, 'z' is harder to show. 
 

pgsql-hackers by date:

Previous
From: Brad DeJong
Date:
Subject: Re: [HACKERS] Small improvement to parallel query docs
Next
From: Craig Ringer
Date:
Subject: Re: [HACKERS] COPY IN/BOTH vs. extended query mode