From 058db9fb060d532ccfadee14de64d134a4b0610f Mon Sep 17 00:00:00 2001 From: Bborie Park Date: Wed, 8 Feb 2012 21:04:44 +0000 Subject: [PATCH] Values for [rast1.x], [rast1.y], [rast2.x] and [rast2.y] should be INT4 instead of FLOAT8. Ticket is #1557 git-svn-id: http://svn.osgeo.org/postgis/trunk@9115 b70326c6-7e19-0410-871a-916f4a2858ee --- raster/rt_pg/rt_pg.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/raster/rt_pg/rt_pg.c b/raster/rt_pg/rt_pg.c index 0f76302a2..384c37a93 100644 --- a/raster/rt_pg/rt_pg.c +++ b/raster/rt_pg/rt_pg.c @@ -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 { -- 2.50.1