Re: \if, \elseif, \else, \endif (was Re: PSQL commands: \quit_if, \quit_unless)
Daniel Verite <daniel@manitou-mail.org>
From: "Daniel Verite" <daniel@manitou-mail.org>
To: "Tom Lane" <tgl@sss.pgh.pa.us>
Cc: "Corey Huinker" <corey.huinker@gmail.com>,"David G. Johnston"
<david.g.johnston@gmail.com>,"Fabien COELHO" <coelho@cri.ensmp.fr>,"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-17T11:33:54Z
Lists: pgsql-hackers
Tom Lane wrote: > OT_WHOLE_LINE is not what you want because that results in verbatim > copying, without variable expansion or anything But if we want to implement "\if defined :foo" in the future isn't it just what we need? Also we could leave open the option to accept an SQL expression here. I expect people will need SQL as the evaluator in a lot of cases. So far we need to do that: SELECT sql_expr ... AS varname \gset \if :varname ... \endif Surely users will wonder right away why they can't write it like this instead: \if (sql_expr) ... \endif There's a precedent with \copy accepting a query inside parentheses, using OT_WHOLE_LINE. Best regards, -- Daniel Vérité PostgreSQL-powered mailer: http://www.manitou-mail.org Twitter: @DanielVerite
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