pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
select version() with internal number version?
4+ messages / 3 participants
[nested] [flat]

* select version() with internal number version?
@ 2018-08-09 07:00  Luca Ferrari <fluca1978@gmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Luca Ferrari @ 2018-08-09 07:00 UTC (permalink / raw)
  To: pgsql-general

HI all,
I see a lot of external tools that do a 'SELECT version()' and then
parse the output to get the version number (e.g., 10.4).
My opinion is that this is not a good approach, since the output of
version includes a lot of information and can mismatch a poorly
written regular expression. It would be better to use pg_config
--version, byt again there is the needing for mangling the data.
Is there any way to get directly the PostgreSQL version number?

Thanks,
Luca




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: select version() with internal number version?
@ 2018-08-09 07:10  Wèi Cōngruì <crvv.mail@gmail.com>
  parent: Luca Ferrari <fluca1978@gmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Wèi Cōngruì @ 2018-08-09 07:10 UTC (permalink / raw)
  To: fluca1978@gmail.com; +Cc: pgsql-general

SHOW server_version;
SHOW server_version_num;

I can fetch the version by these two statement.

On Thu, Aug 9, 2018 at 3:01 PM Luca Ferrari <fluca1978@gmail.com> wrote:

> HI all,
> I see a lot of external tools that do a 'SELECT version()' and then
> parse the output to get the version number (e.g., 10.4).
> My opinion is that this is not a good approach, since the output of
> version includes a lot of information and can mismatch a poorly
> written regular expression. It would be better to use pg_config
> --version, byt again there is the needing for mangling the data.
> Is there any way to get directly the PostgreSQL version number?
>
> Thanks,
> Luca
>
>

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: select version() with internal number version?
@ 2018-08-09 13:51  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Wèi Cōngruì <crvv.mail@gmail.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Tom Lane @ 2018-08-09 13:51 UTC (permalink / raw)
  To: Wèi Cōngruì <crvv.mail@gmail.com>; +Cc: fluca1978@gmail.com; pgsql-general

=?UTF-8?B?V8OoaSBDxY1uZ3J1w6w=?= <crvv.mail@gmail.com> writes:
> On Thu, Aug 9, 2018 at 3:01 PM Luca Ferrari <fluca1978@gmail.com> wrote:
>> Is there any way to get directly the PostgreSQL version number?

> SHOW server_version;
> SHOW server_version_num;

Also, if you're using libpq, see PQserverVersion() which
(a) avoids a round trip to the server, and (b) works further back
than server_version_num, though that issue is probably academic
to most folk at this point (server_version_num appeared in 8.2).

			regards, tom lane




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: select version() with internal number version?
@ 2018-08-10 11:35  Luca Ferrari <fluca1978@gmail.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Luca Ferrari @ 2018-08-10 11:35 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: crvv.mail@gmail.com; pgsql-general

On Thu, Aug 9, 2018 at 3:51 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Also, if you're using libpq, see PQserverVersion() which
> (a) avoids a round trip to the server, and (b) works further back
> than server_version_num, though that issue is probably academic
> to most folk at this point (server_version_num appeared in 8.2).

Thanks but server_version_num is what I was looking for, since I need
to get the version number from outside PostgreSQL in foreign languages
(python, perl, etc).
I don't believe going back than 8.2 is a metter in this case, since
this is for supporting tools that should not...ehm...support any more
EOL versions.

Luca




^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2018-08-10 11:35 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-08-09 07:00 select version() with internal number version? Luca Ferrari <fluca1978@gmail.com>
2018-08-09 07:10 ` Wèi Cōngruì <crvv.mail@gmail.com>
2018-08-09 13:51   ` Tom Lane <tgl@sss.pgh.pa.us>
2018-08-10 11:35     ` Luca Ferrari <fluca1978@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox