Created
September 16, 2019 06:40
-
-
Save sandcastle/8640f92c9c6367135a4d9c71e19ae460 to your computer and use it in GitHub Desktop.
Determine the version of postgres a statement is run on.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select version(); | |
-- PostgreSQL 9.6.12 on x86_64-pc-linux-musl, compiled by gcc (Alpine 8.2.0) 8.2.0, 64-bit | |
SHOW server_version; | |
-- 9.6.12 | |
SELECT current_setting('server_version_num'); | |
-- 90612 | |
select current_setting('server_version'); | |
-- 9.6.12 | |
-- major version | |
select (regexp_matches(current_setting('server_version'), '(\d+)\.(\d+)\.(\d+)'))[1]; | |
-- 9 | |
-- minor version | |
select (regexp_matches(current_setting('server_version'), '(\d+)\.(\d+)\.(\d+)'))[2]; | |
-- 6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment