[postgis-tickets] r17180 - Use `server_version_num` instead of parsing `version()`

Raul raul at rmr.ninja
Fri Jan 18 09:24:55 PST 2019


Author: algunenano
Date: 2019-01-18 09:24:55 -0800 (Fri, 18 Jan 2019)
New Revision: 17180

Modified:
   branches/2.5/NEWS
   branches/2.5/extensions/postgis_extension_helper.sql
   branches/2.5/postgis/postgis.sql.in
Log:
Use `server_version_num` instead of parsing `version()`

References #4296


Modified: branches/2.5/NEWS
===================================================================
--- branches/2.5/NEWS	2019-01-18 17:24:32 UTC (rev 17179)
+++ branches/2.5/NEWS	2019-01-18 17:24:55 UTC (rev 17180)
@@ -40,6 +40,8 @@
 
   - #4275, Avoid passing a NULL pointer to GEOSisEmpty (Raúl Marín)
 
+  - #4296, Use `server_version_num` instead of parsing `version()` (Raúl Marín)
+
 PostGIS 2.5.1
 2018/11/18
 

Modified: branches/2.5/extensions/postgis_extension_helper.sql
===================================================================
--- branches/2.5/extensions/postgis_extension_helper.sql	2019-01-18 17:24:32 UTC (rev 17179)
+++ branches/2.5/extensions/postgis_extension_helper.sql	2019-01-18 17:24:55 UTC (rev 17180)
@@ -28,8 +28,7 @@
 	var_class text := '';
 	var_is_aggregate boolean := false;
 	var_sql_list text := '';
-	var_pgsql_version integer := 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
-	FROM substring(version(), 'PostgreSQL ([0-9\.]+)') AS s;
+	var_pgsql_version integer := current_setting('server_version_num');
 BEGIN
 		var_class := CASE WHEN lower(param_type) = 'function' OR lower(param_type) = 'aggregate' THEN 'pg_proc' ELSE '' END;
 		var_is_aggregate := CASE WHEN lower(param_type) = 'aggregate' THEN true ELSE false END;

Modified: branches/2.5/postgis/postgis.sql.in
===================================================================
--- branches/2.5/postgis/postgis.sql.in	2019-01-18 17:24:32 UTC (rev 17179)
+++ branches/2.5/postgis/postgis.sql.in	2019-01-18 17:24:55 UTC (rev 17180)
@@ -2808,8 +2808,7 @@
 
 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
-	FROM substring(version(), 'PostgreSQL ([0-9\.]+)') AS s;
+	SELECT current_setting('server_version_num');
 $$ LANGUAGE 'sql' STABLE;
 
 -- Availability: 2.5.0



More information about the postgis-tickets mailing list