Re: Variable substitution in psql backtick expansion
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: "Daniel Verite" <daniel@manitou-mail.org>
Cc: "Fabien COELHO" <coelho@cri.ensmp.fr>,
"PostgreSQL Developers" <pgsql-hackers@postgresql.org>
Date: 2017-04-03T14:16:18Z
Lists: pgsql-hackers
"Daniel Verite" <daniel@manitou-mail.org> writes:
> Let's imagine that psql would support a syntax like this:
> \if [select current_setting('server_version_num')::int < 110000]
> or
> \if [select 1 from pg_catalog.pg_extension where extname='pgcrypto']
I really dislike this syntax proposal. It would get us into having
to count nested brackets, and distinguish quoted from unquoted brackets,
and so on ... and for what? It's not really better than
\if sql select 1 from pg_catalog.pg_extension where extname='pgcrypto'
(ie, "\if sql ...text to send to server...").
If you're worried about shaving keystrokes, make the "select" be implicit.
That would be particularly convenient for the common case where you're
just trying to evaluate a boolean expression with no table reference.
regards, tom lane
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