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

Fabien COELHO <coelho@cri.ensmp.fr>

From: Fabien COELHO <coelho@cri.ensmp.fr>
To: Corey Huinker <corey.huinker@gmail.com>
Cc: Robert Haas <robertmhaas@gmail.com>, Erik Rijkers <er@xs4all.nl>, Tom Lane <tgl@sss.pgh.pa.us>, Daniel Verite <daniel@manitou-mail.org>, Jim Nasby <Jim.Nasby@bluetreble.com>, PostgreSQL <pgsql-hackers@postgresql.org>, pgsql-hackers-owner@postgresql.org
Date: 2017-02-14T07:40:47Z
Lists: pgsql-hackers
Hello Corey,

>> 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?

Hmmm... This is too much of an Americanism, IMHO.

> I'm here all week, try the veal.

Sorry, syntax error, you have lost me. Some googling suggests a reference 
to post WW2 "lounge entertainers", probably in the USA. I also do not 
understand why this would mean "yes".

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

I'm not sure that this valid technical point should be a good reason for 
guiding what feedback should be provided to the user, but it makes it 
simpler to choose two states:-)

For three states with more culturally neutral mnemonics, I thought of:
   ? for f (waiting for a true answer...)
   . for z (waiting for the end of the sentence, i.e. endif)
   & for t (no real mnemonic)

For two states:
   * for being executed (beware, it is ***important***)
   / for not (under the hood, and it is opposed to *)

Otherwise I still like "?[tfz]", but it is two characters long.

-- 
Fabien.


Commits

  1. Support \if ... \elif ... \else ... \endif in psql scripting.

  2. Add a "void *" passthrough pointer for psqlscan.l's callback functions.