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

Corey Huinker <corey.huinker@gmail.com>

From: Corey Huinker <corey.huinker@gmail.com>
To: Daniel Verite <daniel@manitou-mail.org>
Cc: Fabien COELHO <coelho@cri.ensmp.fr>, Erik Rijkers <er@xs4all.nl>, Tom Lane <tgl@sss.pgh.pa.us>, Jim Nasby <Jim.Nasby@bluetreble.com>, PostgreSQL <pgsql-hackers@postgresql.org>, pgsql-hackers-owner@postgresql.org
Date: 2017-02-03T20:03:23Z
Lists: pgsql-hackers
On Fri, Feb 3, 2017 at 12:20 PM, Daniel Verite <daniel@manitou-mail.org>
wrote:

> If we add the functionality that Ctrl+C also exits from branches,
> we could do it like the shell does Ctrl+D for logout, that is it
> logs out only if the input buffer is empty, otherwise it does
> the other functionality bound to this key (normally Delete).
> So if you're in the middle of an edit, the first Ctrl+C will
> cancel the edit and a second one will go back from the /if
>

That does seem to be the consensus desired behavior. I'm just not sure
where to handle that. The var "cancel_pressed" shows up in a lot of places.
Advice?

Commits

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

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