Corey Huinker wrote:
> Revised patch
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;
select :var ;
The 2nd reference to :var has a quoting hazard, but since it's within
an "\if false" branch, at a glance it seems like this script might work.
In fact it barfs with:
psql:script.sql:0: found EOF before closing \endif(s)
AFAICS what happens is that :var gets injected and starts a
runaway string, so that as far as the parser is concerned
the \else ..\endif block slips into the untaken branch, as a part of
that unfinished string.
This contrasts with line 2: -- select :var
where the reference to :var is inoffensive.
To avoid that kind of trouble, would it make sense not to expand
variables in untaken branches?
PostgreSQL-powered mailer: http://www.manitou-mail.org
Sent via pgsql-hackers mailing list (firstname.lastname@example.org)
To make changes to your subscription: