]> granicus.if.org Git - postgis/commitdiff
Values for [rast1.x], [rast1.y], [rast2.x] and [rast2.y] should be INT4 instead of...
authorBborie Park <bkpark at ucdavis.edu>
Wed, 8 Feb 2012 21:04:44 +0000 (21:04 +0000)
committerBborie Park <bkpark at ucdavis.edu>
Wed, 8 Feb 2012 21:04:44 +0000 (21:04 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@9115 b70326c6-7e19-0410-871a-916f4a2858ee

raster/rt_pg/rt_pg.c

index 0f76302a2c15b585428ee31526a28e74b19f9def..384c37a93ab5c4722b6f46ff69e63093d25f9b3d 100644 (file)
@@ -9093,25 +9093,43 @@ Datum RASTER_mapAlgebra2(PG_FUNCTION_ARGS)
 
                                                        PG_RETURN_NULL();
                                                }
-                                               for (j = 0; j < spi_argcount[i]; j++) argtype[j] = FLOAT8OID;
+
+                                               /* specify datatypes of parameters */
+                                               for (j = 0, k = 0; j < argkwcount; j++) {
+                                                       if (argpos[i][j] < 1) continue;
+
+                                                       /* positions are INT4 */
+                                                       if (
+                                                               (strstr(argkw[j], "[rast1.x]") != NULL) ||
+                                                               (strstr(argkw[j], "[rast1.y]") != NULL) ||
+                                                               (strstr(argkw[j], "[rast2.x]") != NULL) ||
+                                                               (strstr(argkw[j], "[rast2.y]") != NULL)
+                                                       ) {
+                                                               argtype[k] = INT4OID;
+                                                       }
+                                                       /* everything else is FLOAT8 */
+                                                       else {
+                                                               argtype[k] = FLOAT8OID;
+                                                       }
+
+                                                       k++;
+                                               }
 
                                                spi_plan[i] = SPI_prepare(sql, spi_argcount[i], argtype);
+                                               pfree(argtype);
+
                                                if (spi_plan[i] == NULL) {
                                                        elog(ERROR, "RASTER_mapAlgebra2: Unable to create prepared plan of expression parameter %d", spi_exprpos[i]);
 
                                                        pfree(sql);
-                                                       pfree(argtype);
                                                        for (k = 0; k < spi_count; k++) SPI_freeplan(spi_plan[k]);
                                                        SPI_finish();
 
                                                        for (k = 0; k < set_count; k++) rt_raster_destroy(_rast[k]);
                                                        rt_raster_destroy(raster);
 
-
                                                        PG_RETURN_NULL();
                                                }
-
-                                               pfree(argtype);
                                        }
                                        /* no args, just execute query */
                                        else {