]> granicus.if.org Git - postgis/commitdiff
_raster_constraint_info_scale gives invalid input syntax
authorRegina Obe <lr@pcorp.us>
Sat, 7 Nov 2015 10:10:17 +0000 (10:10 +0000)
committerRegina Obe <lr@pcorp.us>
Sat, 7 Nov 2015 10:10:17 +0000 (10:10 +0000)
references #3360 fix for PostGIS 2.3 (trunk)

git-svn-id: http://svn.osgeo.org/postgis/trunk@14371 b70326c6-7e19-0410-871a-916f4a2858ee

raster/rt_pg/rtpostgis.sql.in

index cff84c4eaf54dd97b83c5c7c35a37f959b03fd42..94c7adfa54b9b69aae95e4387f31ba17a7aaf77c 100644 (file)
@@ -6947,7 +6947,7 @@ CREATE OR REPLACE FUNCTION _drop_raster_constraint_srid(rastschema name, rasttab
 
 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 @@ CREATE OR REPLACE FUNCTION _raster_constraint_info_scale(rastschema name, rastta
                                '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 @@ CREATE OR REPLACE FUNCTION _raster_constraint_info_scale(rastschema name, rastta
                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;