Re: Variable substitution in psql backtick expansion

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Corey Huinker <corey(dot)huinker(at)gmail(dot)com>, Daniel Verite <daniel(at)manitou-mail(dot)org>, PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Variable substitution in psql backtick expansion
Date: 2017-08-26 06:08:50
Message-ID: alpine.DEB.2.20.1708260747110.3627@lancre
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Hello Tom,

>>> ... I'm still not sure that there's any use case for the
>>> string versions ("9.6.4" etc).
>
>> If somebody's doing comparisons, they probably want the numeric
>> version, but somebody might want to print the string version in an
>> error message e.g. \if <test involving VERSION_NUM> \echo this thing
>> doesn't work on :VERSION_NAME \quit \endif
>
> OK, but if human-friendly display is the use-case then it ought to
> duplicate what psql itself would print in, eg, the startup message about
> server version mismatch. The v4 patch does not, in particular it neglects
> PQparameterStatus(pset.db, "server_version"). This would result in
> printing, eg, "11.0" when the user would likely rather see "11devel".

I understand that you would prefer VERSION_NAME to show something like

"11devel, server 9.6.4"

Instead of the current "11devel" when there is a client/server mismatch? I
do not like it much. Note that the server version is already available as
:SERVER_NAME/NUM.

Moreover I would like to point out that pre-existing :VERSION does not do
such a thing. I was just extending it to have something more convenient
and simple, hence the names.

Now they can be named :CLIENT_VERSION_NAME/NUM instead, as suggested by
Robert, but that would be a little bit inconsistent with the existing
VERSION...

Or maybe we could rename it CLIENT_VERSION as well, and make the ambiguous
VERSION be the "11devel, server 9.6.4" thing?

In summary, my prefered option is to have:
CLIENT_VERSION "PostgreSQL 11devel on ..."
CLIENT_VERSION_NAME "11devel"
CLIENT_VERSION_NUM 110000
SERVER_VERSION_NAME "9.6.4"
SERVER_VERSION_NUM 090604
maybe SERVER_VERSION for the long string?
and VERSION as "11devel server 9.6.4" is no match, or just the short
string if match, so that it is nearly upward compatible?

As always, the committer decides.

--
Fabien.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fabien COELHO 2017-08-26 06:54:24 psql - add ability to test whether a variable exists
Previous Message yangjie@highgo.com 2017-08-26 04:40:39 hash partitioning based on v10Beta2