pg_server_version — Get the PostgreSQL server software version
pg_server_version conn
pg_server_version
returns the version of the
connected PostgreSQL server, as an integer.
This integer value can be used to check for a minimum server level, for
example, and is easier to work with compared to the version string in the
server_version
parameter.
For PostgreSQL releases through 9.x, there are two digits allocated to each
of the major, minor, and revision numbers.
For PostgreSQL releases starting with 10.x, there are two digits for the
major version, two digits are zero, and two digits are for the minor version.
See the example below.
This command does not contact the database server - it uses information supplied by the server at connection time.
This command uses or emulates the PostgreSQL
libpq
function PQserverVersion
.
This command was added in pgtclng-2.0.0 and in pgintcl-3.4.0.
PostgreSQL used 3-part version numbers before 10.0 and 2-part version numbers starting with 10.0.
The return value from pg_server_version
contains an
integer representation of the server_version
parameter. See
pg_parameter_status for more on parameters.
Consider the following:
set version_int [pg_server_version $conn] set version_str [pg_parameter_status $conn server_version]
If the PostgreSQL server is running version 9.6.5, the above will set version_int to 90605, and version_str to "9.6.5". If the PostgreSQL server is running version 10.1, the above will set version_int to 100001, and version_str to "10.1".
This version of the manual was produced for the
Pgtcl-ng Sourceforge project web service site, which requires the logo on each
page.
To download a logo-free copy of the manual, see the
Pgtcl-ng project
downloads area.