From 5f37e1f0a5c1a6ccf30304e8579ed297a7314cc1 Mon Sep 17 00:00:00 2001 From: Bborie Park Date: Sun, 6 Jul 2014 18:33:41 +0000 Subject: [PATCH] escape delimiter of ST_Band(). Ticket #2812 git-svn-id: http://svn.osgeo.org/postgis/trunk@12741 b70326c6-7e19-0410-871a-916f4a2858ee --- raster/rt_pg/rtpostgis.sql.in | 2 +- raster/test/regress/rt_band.sql | 32 ++++++++++++++++++++++++++++ raster/test/regress/rt_band_expected | 2 ++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/raster/rt_pg/rtpostgis.sql.in b/raster/rt_pg/rtpostgis.sql.in index c47947258..725d0f7c5 100644 --- a/raster/rt_pg/rtpostgis.sql.in +++ b/raster/rt_pg/rtpostgis.sql.in @@ -411,7 +411,7 @@ CREATE OR REPLACE FUNCTION st_band(rast raster, nband int) CREATE OR REPLACE FUNCTION st_band(rast raster, nbands text, delimiter char DEFAULT ',') RETURNS RASTER - AS $$ SELECT st_band($1, regexp_split_to_array(regexp_replace($2, '[[:space:]]', '', 'g'), $3)::int[]) $$ + AS $$ SELECT st_band($1, regexp_split_to_array(regexp_replace($2, '[[:space:]]', '', 'g'), '\' || array_to_string(regexp_split_to_array($3, ''), '\'))::int[]) $$ LANGUAGE 'sql' IMMUTABLE STRICT; ----------------------------------------------------------------------- diff --git a/raster/test/regress/rt_band.sql b/raster/test/regress/rt_band.sql index 748a907ef..fbe123502 100644 --- a/raster/test/regress/rt_band.sql +++ b/raster/test/regress/rt_band.sql @@ -316,3 +316,35 @@ SELECT ST_NumBands( ) , ARRAY[999]) ); + +-- Ticket #2812 +SELECT ST_Value( + ST_Band( + ST_AddBand( + ST_AddBand( + ST_AddBand( + ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0,0) + , 1, '64BF', 1234.5678, NULL + ) + , '64BF', 987.654321, NULL + ) + , '64BF', 9876.54321, NULL + ), + '1|1', '|' + ), +2, 3, 3); +SELECT ST_Value( + ST_Band( + ST_AddBand( + ST_AddBand( + ST_AddBand( + ST_MakeEmptyRaster(200, 200, 10, 10, 2, 2, 0, 0,0) + , 1, '64BF', 1234.5678, NULL + ) + , '64BF', 987.654321, NULL + ) + , '64BF', 9876.54321, NULL + ), + '1.*.2', '.*.' + ), +2, 3, 3); diff --git a/raster/test/regress/rt_band_expected b/raster/test/regress/rt_band_expected index b56a9ca15..aedb7c7f8 100644 --- a/raster/test/regress/rt_band_expected +++ b/raster/test/regress/rt_band_expected @@ -25,3 +25,5 @@ NOTICE: Invalid band index (must use 1-based). Returning original raster 3 NOTICE: Invalid band index (must use 1-based). Returning original raster 3 +1234.5678 +987.654321 -- 2.40.0