Re: Variable substitution in psql backtick expansion

Fabien COELHO <coelho@cri.ensmp.fr>

From: Fabien COELHO <coelho@cri.ensmp.fr>
To: Michael Paquier <michael.paquier@gmail.com>, Tom Lane <tgl@sss.pgh.pa.us>
Cc: Pavel Stehule <pavel.stehule@gmail.com>, Robert Haas <robertmhaas@gmail.com>, Corey Huinker <corey.huinker@gmail.com>, Daniel Verite <daniel@manitou-mail.org>, PostgreSQL Developers <pgsql-hackers@postgresql.org>
Date: 2017-11-13T06:13:57Z
Lists: pgsql-hackers
Hello Tom & Michaël,

>> I think this patch should be rejected.
> +1 for rejection [...]

The noes have it!

Note that the motivation was really symmetric completion:

  fabien=# \echo :VERSION_NAME
  11devel
  fabien=# \echo :VERSION_NUM
  110000
  fabien=# \echo :VERSION
  PostgreSQL 11devel on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609, 64-bit
  fabien=# \echo :SERVER_VERSION_NAME
  10.1
  fabien=# \echo :SERVER_VERSION_NUM
  100001

But

  fabien=# \echo :SERVER_VERSION
  :SERVER_VERSION

To get it into a variable the work around is really:

  fabien=# SELECT version() AS "SERVER_VERSION" \gset
  fabien=# \echo :SERVER_VERSION
  PostgreSQL 10.1 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609, 64-bit

-- 
Fabien

Commits

  1. Add psql variables showing server version and psql version.

  2. Reformat psql's --help=variables output.

  3. Remove reinvention of stringify macro.

  4. Allow psql variable substitution to occur in backtick command strings.