Re: Variable substitution in psql backtick expansion
Fabien COELHO <coelho@cri.ensmp.fr>
From: Fabien COELHO <coelho@cri.ensmp.fr>
To: Daniel Verite <daniel@manitou-mail.org>
Cc: Tom Lane <tgl@sss.pgh.pa.us>,
PostgreSQL Developers <pgsql-hackers@postgresql.org>
Date: 2017-04-03T19:30:09Z
Lists: pgsql-hackers
> [...] but OTOH "\if sql 1 from table where expr" looks awkward. Given an > implicit select, I would prefer "\if exists (select 1 from table where > expr)" but now it's not shorter. Possibly, but it is just an SQL expression, which looks good in the middle of an sql script. > An advantage of prepending the SELECT automatically, is that it > would prevent people from abusing this syntax by putting > update/insert/delete or even DDL in there, imagining that this would > be a success/failure test for these operations. > Having these fail to execute in the first place, when called by \if, > seems like a sane failure mode that we would gain incidentally. Yes, it should be avoided. -- Fabien.
Commits
-
Add psql variables showing server version and psql version.
- a6c678f018d3 10.0 landed
- 9ae9d8c1549c 11.0 landed
-
Reformat psql's --help=variables output.
- 3955c8c4eda2 11.0 landed
-
Remove reinvention of stringify macro.
- cd6baed78150 10.0 landed
-
Allow psql variable substitution to occur in backtick command strings.
- f833c847b8fa 10.0 landed