[postgis-tickets] r15633 - Add support for 4-digits PostgreSQL (10+) in _postgis_pgsql_version

Sandro Santilli strk at kbt.io
Tue Sep 5 14:11:58 PDT 2017


Author: strk
Date: 2017-09-05 14:11:57 -0700 (Tue, 05 Sep 2017)
New Revision: 15633

Modified:
   trunk/postgis/postgis.sql.in
Log:
Add support for 4-digits PostgreSQL (10+) in _postgis_pgsql_version

Modified: trunk/postgis/postgis.sql.in
===================================================================
--- trunk/postgis/postgis.sql.in	2017-09-05 20:50:46 UTC (rev 15632)
+++ trunk/postgis/postgis.sql.in	2017-09-05 21:11:57 UTC (rev 15633)
@@ -2778,7 +2778,15 @@
 
 CREATE OR REPLACE FUNCTION _postgis_pgsql_version() RETURNS text
 AS $$
-	SELECT CASE WHEN split_part(s,'.',1)::integer > 9 THEN split_part(s,'.',1) || '0' ELSE split_part(s,'.', 1) || split_part(s,'.', 2) END AS v
+	SELECT CASE
+		WHEN split_part(s,'.', 1)::integer > 9 THEN
+			split_part(s,'.', 1) || LPAD(
+				COALESCE(NULLIF(
+					split_part(s,'.', 2),
+				''), '0'), 2, '0')
+		ELSE
+			split_part(s,'.', 1) || split_part(s,'.', 2)
+	END AS v
 	FROM substring(version(), 'PostgreSQL ([0-9\.]+)') AS s;
 $$ LANGUAGE 'sql' STABLE;
 



More information about the postgis-tickets mailing list