]> granicus.if.org Git - postgis/commitdiff
Added checks to make sure user-function is valid. Also added check for volatility...
authorBborie Park <bkpark at ucdavis.edu>
Sat, 12 Nov 2011 15:12:30 +0000 (15:12 +0000)
committerBborie Park <bkpark at ucdavis.edu>
Sat, 12 Nov 2011 15:12:30 +0000 (15:12 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@8147 b70326c6-7e19-0410-871a-916f4a2858ee

raster/rt_pg/rt_pg.c
raster/rt_pg/rtpostgis_drop.sql.in.c
raster/test/regress/rt_mapalgebrafct_2raster.sql
raster/test/regress/rt_mapalgebrafct_2raster_expected

index e0d57f6d3b878da93b96fe55362264c266b18949..151ed352b79b08d5d9f5b81c003adb46bf25003e 100644 (file)
@@ -8475,6 +8475,29 @@ Datum RASTER_mapAlgebra2(PG_FUNCTION_ARGS)
                                /* get function info */
                                fmgr_info(ufcnoid, &uflinfo);
 
+                               /* function cannot return set */
+                               err = 0;
+                               if (uflinfo.fn_retset) {
+                                       elog(ERROR, "RASTER_mapAlgebra2: Function provided must return double precision not resultset");
+                                       err = 1;
+                               }
+                               /* function should have correct # of args */
+                               else if (uflinfo.fn_nargs != 3) {
+                                       elog(ERROR, "RASTER_mapAlgebra2: Function does not have three input parameters");
+                                       err = 1;
+                               }
+
+                               if (err) {
+                                       for (k = 0; k < set_count; k++) rt_raster_destroy(_rast[k]);
+                                       rt_raster_destroy(raster);
+
+                                       PG_RETURN_NULL();
+                               }
+
+                               if (func_volatile(ufcnoid) == 'v') {
+                                       elog(NOTICE, "Function provided is VOLATILE. Unless required and for best performance, function should be IMMUTABLE or STABLE");
+                               }
+
                                /* prep function call data */
 #if POSTGIS_PGSQL_VERSION <= 90
                                InitFunctionCallInfoData(ufcinfo, &uflinfo, 3, InvalidOid, NULL);
index 4b06439c7f2042babdccefe98e35cab27446c6e0..1888715996b4b4a4356a19e32ce4e115e70e3b9d 100644 (file)
@@ -61,6 +61,9 @@ DROP FUNCTION IF EXISTS ST_MapAlgebra(raster, pixeltype text, expression text, n
 DROP FUNCTION IF EXISTS  ST_MapAlgebraExpr(raster, integer, text, text, text);
 DROP FUNCTION IF EXISTS  ST_MapAlgebraExpr(raster, text, text, text);
 
+--dropped functions
+DROP FUNCTION IF EXISTS  ST_MapAlgebraFct(raster, raster, regprocedure, VARIADIC text[]);
+
 --added extra parameter so these are obsolete --
 DROP FUNCTION IF EXISTS ST_AsRaster(geometry , integer , integer , double precision , double precision , text , double precision , double precision , double precision , double precision );
 DROP FUNCTION IF EXISTS ST_AsRaster(geometry , integer , integer , text[] , double precision[] , double precision[] , double precision , double precision , double precision , double precision );
index 00ee8d9cb669eccf88d59646c22f7c4fa3825a1b..135ab607c6860add94f218031500244f192fd8e5 100644 (file)
@@ -69,7 +69,7 @@ CREATE OR REPLACE FUNCTION raster_mapalgebra_intersection(
 
                RETURN NULL;
        END;
-       $$ LANGUAGE 'plpgsql';
+       $$ LANGUAGE 'plpgsql' IMMUTABLE;
 
 CREATE OR REPLACE FUNCTION raster_mapalgebra_union(
        rast1 double precision,
@@ -93,7 +93,7 @@ CREATE OR REPLACE FUNCTION raster_mapalgebra_union(
 
                RETURN NULL;
        END;
-       $$ LANGUAGE 'plpgsql';
+       $$ LANGUAGE 'plpgsql' IMMUTABLE;
 
 CREATE OR REPLACE FUNCTION raster_mapalgebra_first(
        rast1 double precision,
@@ -115,7 +115,7 @@ CREATE OR REPLACE FUNCTION raster_mapalgebra_first(
 
                RETURN NULL;
        END;
-       $$ LANGUAGE 'plpgsql';
+       $$ LANGUAGE 'plpgsql' IMMUTABLE;
 
 CREATE OR REPLACE FUNCTION raster_mapalgebra_second(
        rast1 double precision,
index 199f099706f2a11f45e6c9992aaf1c563d4f8364..5a0395c558f8e1d8b0a5e465096ce840bd981ca0 100644 (file)
@@ -35,6 +35,24 @@ NOTICE:  The FIRST raster is NULL.  Returning NULL
 NOTICE:  The FIRST raster is NULL.  Returning NULL
 NOTICE:  The FIRST raster is NULL.  Returning NULL
 NOTICE:  The two rasters provided are NULL.  Returning NULL
+NOTICE:  Function provided is VOLATILE. Unless required and for best performance, function should be IMMUTABLE or STABLE
+NOTICE:  Function provided is VOLATILE. Unless required and for best performance, function should be IMMUTABLE or STABLE
+NOTICE:  Function provided is VOLATILE. Unless required and for best performance, function should be IMMUTABLE or STABLE
+NOTICE:  Function provided is VOLATILE. Unless required and for best performance, function should be IMMUTABLE or STABLE
+NOTICE:  Function provided is VOLATILE. Unless required and for best performance, function should be IMMUTABLE or STABLE
+NOTICE:  Function provided is VOLATILE. Unless required and for best performance, function should be IMMUTABLE or STABLE
+NOTICE:  Function provided is VOLATILE. Unless required and for best performance, function should be IMMUTABLE or STABLE
+NOTICE:  Function provided is VOLATILE. Unless required and for best performance, function should be IMMUTABLE or STABLE
+NOTICE:  Function provided is VOLATILE. Unless required and for best performance, function should be IMMUTABLE or STABLE
+NOTICE:  Function provided is VOLATILE. Unless required and for best performance, function should be IMMUTABLE or STABLE
+NOTICE:  Function provided is VOLATILE. Unless required and for best performance, function should be IMMUTABLE or STABLE
+NOTICE:  Function provided is VOLATILE. Unless required and for best performance, function should be IMMUTABLE or STABLE
+NOTICE:  Function provided is VOLATILE. Unless required and for best performance, function should be IMMUTABLE or STABLE
+NOTICE:  Function provided is VOLATILE. Unless required and for best performance, function should be IMMUTABLE or STABLE
+NOTICE:  Function provided is VOLATILE. Unless required and for best performance, function should be IMMUTABLE or STABLE
+NOTICE:  Function provided is VOLATILE. Unless required and for best performance, function should be IMMUTABLE or STABLE
+NOTICE:  Function provided is VOLATILE. Unless required and for best performance, function should be IMMUTABLE or STABLE
+NOTICE:  Function provided is VOLATILE. Unless required and for best performance, function should be IMMUTABLE or STABLE
 NOTICE:  The SECOND raster is NULL.  Returning NULL
 NOTICE:  The SECOND raster is NULL.  Returning NULL
 NOTICE:  The SECOND raster is NULL.  Returning NULL