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: Daniel Verite <daniel@manitou-mail.org>
Cc: Corey Huinker <corey.huinker@gmail.com>,
PostgreSQL <pgsql-hackers@postgresql.org>
Date: 2017-01-26T20:55:13Z
Lists: pgsql-hackers
Hello Daniel, > A comment about control flow and variables: in branches that are not > taken, variables are expanded nonetheless, in a way that can be > surprising. Case in point: > > \set var 'ab''cd' > -- select :var; > \if false > select :var ; > \else > select 1; > \endif > > To avoid that kind of trouble, would it make sense not to expand > variables in untaken branches? Hmmm. This case is somehow contrived (for a string, :'var' could be used, in which case escaping would avoid the hazard), but I think that what you suggest is a better behavior, if easy to implement. -- Fabien.
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