Re: [COMMITTERS] pgsql: Add psql variables showing server version and psql version.

From: Simon Riggs <simon(at)2ndquadrant(dot)com>
To: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [COMMITTERS] pgsql: Add psql variables showing server version and psql version.
Date: 2017-09-06 13:14:01
Message-ID: CANP8+jLauL-q4=jynt=y8NpL7JXM1hjtywqLn5ha-cxLEqgjNA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On 5 September 2017 at 11:58, Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr> wrote:
>
> Hello Simon,
>
>> Does raise the further question of how psql behaves when we connect to
>> a pre-10 server, so we have SERVER_VERSION_NUM but yet it is not set.
>> How does this
>> \if SERVER_VERSION_NUM < x
>
>
> The if does not have expressions (yet), it just handles TRUE/ON/1 and
> FALSE/0/OFF.
>
>> Do we need some macro or suggested special handling?
>
>
> If "SERVER_VERSION_NUM" is available in 10, then:
>
> -- exit if version < 10 (\if is ignored and \q is executed)
> \if false \echo "prior 10" \q \endif
>
> -- then test version through a server side expression, will work
> SELECT :SERVER_VERSION_NUM < 110000 AS prior_11 \gset
> \if :prior_11
> -- version 10
> \else
> -- version 11 or more
> \endif

Based upon input from Tom and Fabien, I propose this additional doc patch.

--
Simon Riggs http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachment Content-Type Size
clarify_psql_server_version.v1.patch application/octet-stream 1.5 KB

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2017-09-06 13:38:35 Re: [COMMITTERS] pgsql: Add psql variables showing server version and psql version.
Previous Message Peter Eisentraut 2017-09-06 01:47:18 pgsql: doc: Clarify pg_inherits description

Browse pgsql-hackers by date

  From Date Subject
Next Message Sokolov Yura 2017-09-06 13:31:53 Re: Fix performance of generic atomics
Previous Message Alexander Korotkov 2017-09-06 13:08:07 Fix bloom WAL tap test