[postgis-tickets] r14371 - _raster_constraint_info_scale gives invalid input syntax

Regina Obe lr at pcorp.us
Sat Nov 7 02:10:17 PST 2015


Author: robe
Date: 2015-11-07 02:10:17 -0800 (Sat, 07 Nov 2015)
New Revision: 14371

Modified:
   trunk/raster/rt_pg/rtpostgis.sql.in
Log:
_raster_constraint_info_scale gives invalid input syntax

references #3360 fix for PostGIS 2.3 (trunk)

Modified: trunk/raster/rt_pg/rtpostgis.sql.in
===================================================================
--- trunk/raster/rt_pg/rtpostgis.sql.in	2015-11-07 10:05:25 UTC (rev 14370)
+++ trunk/raster/rt_pg/rtpostgis.sql.in	2015-11-07 10:10:17 UTC (rev 14371)
@@ -6947,7 +6947,7 @@
 
 CREATE OR REPLACE FUNCTION _raster_constraint_info_scale(rastschema name, rasttable name, rastcolumn name, axis char)
 	RETURNS double precision AS $$
-	SELECT
+	WITH c AS (SELECT
 		regexp_replace(
 			replace(
 				split_part(
@@ -6957,7 +6957,7 @@
 				'round(', ''
 			),
 			'[ ''''\(\)]', '', 'g'
-		)::double precision
+		)::text AS val
 	FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
 	WHERE n.nspname = $1
 		AND c.relname = $2
@@ -6966,7 +6966,12 @@
 		AND s.connamespace = n.oid
 		AND s.conrelid = c.oid
 		AND a.attnum = ANY (s.conkey)
-		AND s.consrc LIKE '%st_scale' || $4 || '(% = %';
+		AND s.consrc LIKE '%st_scale' || $4 || '(% = %') 
+-- if it is a comma separated list of two numbers then need to use round
+   SELECT CASE WHEN split_part(c.val,',', 2) > '' 
+        THEN round( split_part(c.val, ',',1)::numeric, split_part(c.val,',',2)::integer )::float8 
+        ELSE c.val::float8 END
+        FROM c;
 	$$ LANGUAGE sql STABLE STRICT
   COST 100;
 



More information about the postgis-tickets mailing list