Re: \if, \elseif, \else, \endif (was Re: PSQL commands: \quit_if, \quit_unless)
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Fabien COELHO <coelho@cri.ensmp.fr>
Cc: Corey Huinker <corey.huinker@gmail.com>,
Daniel Verite <daniel@manitou-mail.org>,
"David G. Johnston" <david.g.johnston@gmail.com>,
Greg Stark <stark@mit.edu>, Erik Rijkers <er@xs4all.nl>,
Robert Haas <robertmhaas@gmail.com>,
Jim Nasby <Jim.Nasby@bluetreble.com>,
PostgreSQL <pgsql-hackers@postgresql.org>,
pgsql-hackers-owner@postgresql.org
Date: 2017-03-30T04:15:59Z
Lists: pgsql-hackers
Attachments
- psql-if-v30.patch (text/x-diff) patch v30
Fabien COELHO <coelho@cri.ensmp.fr> writes:
>> New Patch v29: Now with less coverage!
> Patch applies cleanly. Make check ok. Feature still works!
I've been hacking on this for about two full days now, and have gotten
it to a point where I think it's committable. Aside from cosmetic
changes, I've made it behave reasonably for cases where \if is used
on portions of a query, for instance
SELECT
\if :something
var1
\else
var2
\endif
FROM table;
which as I mentioned a long time ago is something that people will
certainly expect to work. I also cleaned up a lot of corner-case
discrepancies between how much text is consumed in active-branch and
inactive-branch cases (OT_FILEPIPE is a particularly nasty case in that
regard :-()
I plan to read this over again tomorrow and then push it, if there are
not objections/corrections.
regards, tom lane
Commits
-
Support \if ... \elif ... \else ... \endif in psql scripting.
- e984ef5861df 10.0 landed
-
Add a "void *" passthrough pointer for psqlscan.l's callback functions.
- 895e36bb3f36 10.0 landed