]> granicus.if.org Git - postgis/commitdiff
Forced casting of output from 1-raster ST_MapAlgebraExpr. Ticket is #1639.
authorBborie Park <bkpark at ucdavis.edu>
Thu, 1 Mar 2012 15:59:39 +0000 (15:59 +0000)
committerBborie Park <bkpark at ucdavis.edu>
Thu, 1 Mar 2012 15:59:39 +0000 (15:59 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@9371 b70326c6-7e19-0410-871a-916f4a2858ee

raster/rt_pg/rt_pg.c

index 0577cb45632ab9bf5cfbaaa590453420d784d0dd..c5691c4cbf468a2211127ce7d3fffd8c8957903e 100644 (file)
@@ -2795,11 +2795,12 @@ Datum RASTER_mapAlgebraExpr(PG_FUNCTION_ARGS)
     /* Construct expression for raster values */
     if (!PG_ARGISNULL(3)) {
         expression = text_to_cstring(PG_GETARG_TEXT_P(3));
-        len = strlen("SELECT ") + strlen(expression);
+        len = strlen("SELECT (") + strlen(expression) + strlen(")::double precision");
         initexpr = (char *)palloc(len + 1);
 
-        strncpy(initexpr, "SELECT ", strlen("SELECT "));
-        strncpy(initexpr + strlen("SELECT "), expression, strlen(expression));
+        strncpy(initexpr, "SELECT (", strlen("SELECT ("));
+        strncpy(initexpr + strlen("SELECT ("), expression, strlen(expression));
+                               strncpy(initexpr + strlen("SELECT (") + strlen(expression), ")::double precision", strlen(")::double precision"));
         initexpr[len] = '\0';
 
         POSTGIS_RT_DEBUGF(3, "RASTER_mapAlgebraExpr: Expression is %s", initexpr);