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

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


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

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

References #4296


Modified: branches/2.4/NEWS
===================================================================
--- branches/2.4/NEWS	2019-01-18 17:24:12 UTC (rev 17178)
+++ branches/2.4/NEWS	2019-01-18 17:24:32 UTC (rev 17179)
@@ -13,6 +13,7 @@
   - #4292, ST_AsMVT: parse JSON numeric values with decimals as doubles (Raúl Marín)
   - #4289, ST_AsMVTGeom: Transform coordinates space before clipping (Raúl Marín)
   - #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.4.6

Modified: branches/2.4/extensions/postgis_extension_helper.sql
===================================================================
--- branches/2.4/extensions/postgis_extension_helper.sql	2019-01-18 17:24:12 UTC (rev 17178)
+++ branches/2.4/extensions/postgis_extension_helper.sql	2019-01-18 17:24:32 UTC (rev 17179)
@@ -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.4/postgis/postgis.sql.in
===================================================================
--- branches/2.4/postgis/postgis.sql.in	2019-01-18 17:24:12 UTC (rev 17178)
+++ branches/2.4/postgis/postgis.sql.in	2019-01-18 17:24:32 UTC (rev 17179)
@@ -2778,8 +2778,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;
 
 CREATE OR REPLACE FUNCTION postgis_full_version() RETURNS text



More information about the postgis-tickets mailing list