]> granicus.if.org Git - postgis/commitdiff
Set all raster CASTs to be ASSIGNMENT not IMPLICIT. Related ticket is #490. Knowing...
authorBborie Park <bkpark at ucdavis.edu>
Fri, 24 Feb 2012 05:05:25 +0000 (05:05 +0000)
committerBborie Park <bkpark at ucdavis.edu>
Fri, 24 Feb 2012 05:05:25 +0000 (05:05 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@9282 b70326c6-7e19-0410-871a-916f4a2858ee

15 files changed:
raster/rt_pg/rtpostgis.sql.in.c
raster/rt_pg/rtpostgis_upgrade_cleanup.sql.in.c
raster/test/regress/rt_above.sql
raster/test/regress/rt_below.sql
raster/test/regress/rt_bytea.sql
raster/test/regress/rt_contain.sql
raster/test/regress/rt_contained.sql
raster/test/regress/rt_left.sql
raster/test/regress/rt_overabove.sql
raster/test/regress/rt_overbelow.sql
raster/test/regress/rt_overlap.sql
raster/test/regress/rt_overleft.sql
raster/test/regress/rt_overright.sql
raster/test/regress/rt_right.sql
raster/test/regress/rt_same.sql

index 4b3f7655fff9cec7b550f8c9baf3d75edbd3292a..02e5b5a59d7f4bf13855f653ed0e1fdec7267e19 100644 (file)
@@ -2781,13 +2781,13 @@ CREATE OR REPLACE FUNCTION bytea(raster)
 ------------------------------------------------------------------------------
 
 CREATE CAST (raster AS box3d)
-    WITH FUNCTION box3d(raster) AS IMPLICIT;
+    WITH FUNCTION box3d(raster) AS ASSIGNMENT;
 
 CREATE CAST (raster AS geometry)
-    WITH FUNCTION st_convexhull(raster) AS IMPLICIT;
+    WITH FUNCTION st_convexhull(raster) AS ASSIGNMENT;
 
 CREATE CAST (raster AS bytea)
-    WITH FUNCTION bytea(raster) AS IMPLICIT;
+    WITH FUNCTION bytea(raster) AS ASSIGNMENT;
 
 ------------------------------------------------------------------------------
 --  GiST index OPERATOR support functions
@@ -2995,13 +2995,13 @@ CREATE OR REPLACE FUNCTION _st_intersects(rast raster, geom geometry, nband inte
 
 CREATE OR REPLACE FUNCTION st_intersects(rast raster, geom geometry, nband integer DEFAULT NULL)
        RETURNS boolean
-       AS $$ SELECT $1 && $2 AND _st_intersects($1, $2, $3) $$
+       AS $$ SELECT $1::geometry && $2 AND _st_intersects($1, $2, $3) $$
        LANGUAGE 'SQL' IMMUTABLE
        COST 1000;
 
 CREATE OR REPLACE FUNCTION st_intersects(rast raster, nband integer, geom geometry)
        RETURNS boolean
-       AS $$ SELECT $1 && $3 AND _st_intersects($1, $3, $2) $$
+       AS $$ SELECT $1::geometry && $3 AND _st_intersects($1, $3, $2) $$
        LANGUAGE 'SQL' IMMUTABLE
        COST 1000;
 
@@ -3143,7 +3143,7 @@ CREATE OR REPLACE FUNCTION _st_intersects(geom geometry, rast raster, nband inte
 -- This function can not be STRICT
 CREATE OR REPLACE FUNCTION st_intersects(geom geometry, rast raster, nband integer DEFAULT NULL)
        RETURNS boolean AS
-       $$ SELECT $1 && $2 AND _st_intersects($1, $2, $3); $$
+       $$ SELECT $1 && $2::geometry AND _st_intersects($1, $2, $3); $$
        LANGUAGE 'SQL' IMMUTABLE
        COST 1000;
 
index 74c63596341bc6d5076ced1764c1aea4cb10f747..578febb6da152c840152655af4e289314adff6a8 100644 (file)
@@ -53,7 +53,7 @@ DROP OPERATOR IF EXISTS ~ (raster, raster);
 DROP FUNCTION IF EXISTS st_contain(raster, raster); **/
 
 -- drop st_bytea
-DROP CAST IF EXISTS (raster as bytea);
+DROP CAST IF EXISTS (raster AS bytea);
 DROP FUNCTION IF EXISTS st_bytea(raster);
 
 CREATE OR REPLACE FUNCTION bytea(raster)
@@ -61,40 +61,45 @@ CREATE OR REPLACE FUNCTION bytea(raster)
     AS 'MODULE_PATHNAME', 'RASTER_to_bytea'
     LANGUAGE 'C' IMMUTABLE STRICT;
 CREATE CAST (raster AS bytea)
-    WITH FUNCTION bytea(raster) AS IMPLICIT;
+    WITH FUNCTION bytea(raster) AS ASSIGNMENT;
 
 -- drop box2d
 DROP CAST IF EXISTS (raster AS box2d);
 DROP FUNCTION IF EXISTS box2d(raster);
 
--- create box3d cast if it does not exist --
+-- create box3d cast if it does not exist
+#if POSTGIS_PGSQL_VERSION >= 90
 -- If we are running 9.0+ we can use DO plpgsql to check
 -- and only create if not exists so no need to force a drop
 -- that way if people are using it, we will not mess them up
-#if POSTGIS_PGSQL_VERSION >= 90
 DO language 'plpgsql' $$DECLARE r record;
 BEGIN
-       IF NOT EXISTS(SELECT  cs.typname As source
+       IF NOT EXISTS(SELECT  cs.typname AS source
                FROM pg_cast AS ca 
                INNER JOIN pg_type AS cs ON ca.castsource = cs.oid
                INNER JOIN pg_type AS ct ON ca.casttarget = ct.oid
                WHERE cs.typname = 'raster' AND ct.typname = 'box3d') THEN
                CREATE OR REPLACE FUNCTION box3d(raster)
                RETURNS box3d
-               AS 'select box3d(st_convexhull($1))'
+               AS 'SELECT box3d(st_convexhull($1))'
                LANGUAGE 'SQL' IMMUTABLE STRICT;
                CREATE CAST (raster AS box3d)
-                       WITH FUNCTION box3d(raster) AS IMPLICIT;
+                       WITH FUNCTION box3d(raster) AS ASSIGNMENT;
     END IF;
 END$$; 
 #endif
--- if we are running 8.4 we need to use brute force
 #if POSTGIS_PGSQL_VERSION < 90
-DROP CAST IF EXISTS (raster as box3d);
+-- if we are running 8.4 we need to use brute force
+DROP CAST IF EXISTS (raster AS box3d);
 CREATE OR REPLACE FUNCTION box3d(raster)
     RETURNS box3d
-    AS 'select box3d(st_convexhull($1))'
+    AS 'SELECT box3d(st_convexhull($1))'
     LANGUAGE 'SQL' IMMUTABLE STRICT;
 CREATE CAST (raster AS box3d)
-    WITH FUNCTION box3d(raster) AS IMPLICIT;
+    WITH FUNCTION box3d(raster) AS ASSIGNMENT;
 #endif
+
+-- make geometry cast ASSIGNMENT
+DROP CAST IF EXISTS (raster AS geometry);
+CREATE CAST (raster AS geometry)
+       WITH FUNCTION st_convexhull(raster) AS ASSIGNMENT;
index 1fa83918cfbd36b601738fbf325c39db88e3e990..8c395fea206cde8d6b29155253e1f48a6db441b8 100644 (file)
@@ -16,7 +16,7 @@ SELECT 'raster_above(X, query(1,1))' as op,
         max(a.x) as xmax,
         min(a.y) as ymin,
         max(a.y) as ymax,
-        st_extent(a.tile)
+        st_extent(a.tile::geometry)
 FROM rt_gist_grid_test a, rt_gist_query_test b
 WHERE b.x = 1 and b.y = 1
     AND raster_above(a.tile, b.tile);
@@ -31,7 +31,7 @@ SELECT 'X |>> query(1,1)' as op,
         max(a.x) as xmax,
         min(a.y) as ymin,
         max(a.y) as ymax,
-        st_extent(a.tile)
+        st_extent(a.tile::geometry)
 FROM rt_gist_grid_test a, rt_gist_query_test b
 WHERE b.x = 1 and b.y = 1
     AND a.tile |>> b.tile;
index 375f2a44d1c87314e90b98161b301b938cf80984..46adc50142c7b36b577b58aed84965f4b58009d1 100644 (file)
@@ -17,7 +17,7 @@ SELECT 'raster_below(X, query(1,1))' as op,
         max(a.x) as xmax,
         min(a.y) as ymin,
         max(a.y) as ymax,
-        st_extent(a.tile)
+        st_extent(a.tile::geometry)
 FROM rt_gist_grid_test a, rt_gist_query_test b
 WHERE b.x = 1 and b.y = 1
     AND raster_below(a.tile, b.tile);
@@ -32,7 +32,7 @@ SELECT 'X <<| query(1,1)' as op,
         max(a.x) as xmax,
         min(a.y) as ymin,
         max(a.y) as ymax,
-        st_extent(a.tile)
+        st_extent(a.tile::geometry)
 FROM rt_gist_grid_test a, rt_gist_query_test b
 WHERE b.x = 1 and b.y = 1
     AND a.tile <<| b.tile;
index 85aebaa60cb493404bbd4531c58cf3310efb02c5..968c980376e6a97f647043d7662fe4fe318a8147 100644 (file)
@@ -139,8 +139,6 @@ SELECT
 FROM rt_bytea_test
 WHERE
     encode(bytea(rast), 'hex') != encode(rast::bytea, 'hex')
-    OR
-    encode(bytea(rast), 'hex') != encode(rast, 'hex')
     ;
 
 -----------------------------------------------------------------------
@@ -153,8 +151,6 @@ SELECT
 FROM rt_bytea_test
 WHERE
     encode(bytea(rast), 'base64') != encode(rast::bytea, 'base64')
-    OR
-    encode(bytea(rast), 'base64') != encode(rast, 'base64')
     ;
 
 -----------------------------------------------------------------------
@@ -167,8 +163,6 @@ SELECT
 FROM rt_bytea_test
 WHERE
     encode(st_asbinary(rast), 'base64') != encode(rast::bytea, 'base64')
-    OR
-    encode(st_asbinary(rast), 'base64') != encode(rast, 'base64')
     ;
 
 -- Cleanup
index f80ecd445cd099b4587c83289f9c7636df8b79db..d705492dc44913bc44ebd407b10c45988d755bcc 100644 (file)
@@ -17,7 +17,7 @@ SELECT 'raster_contain(query(1,1), X)' as op,
         max(a.x) as xmax,
         min(a.y) as ymin,
         max(a.y) as ymax,
-        st_extent(a.tile)
+        st_extent(a.tile::geometry)
 FROM rt_gist_grid_test a, rt_gist_query_test b
 WHERE b.x = 1 and b.y = 1
     AND raster_contain(b.tile, a.tile);
@@ -32,7 +32,7 @@ SELECT 'query(1,1) ~ X' as op,
         max(a.x) as xmax,
         min(a.y) as ymin,
         max(a.y) as ymax,
-        st_extent(a.tile)
+        st_extent(a.tile::geometry)
 FROM rt_gist_grid_test a, rt_gist_query_test b
 WHERE b.x = 1 and b.y = 1
     AND b.tile ~ a.tile;
index 6381831897b10afe1ede3c2ac97487acd86ee100..052947fba6f080b9f89ab8e41d9d129fb53acb93 100644 (file)
@@ -17,7 +17,7 @@ SELECT 'raster_contained(X, query(1,1))' as op,
         max(a.x) as xmax,
         min(a.y) as ymin,
         max(a.y) as ymax,
-        st_extent(a.tile)
+        st_extent(a.tile::geometry)
 FROM rt_gist_grid_test a, rt_gist_query_test b
 WHERE b.x = 1 and b.y = 1
     AND raster_contained(a.tile, b.tile);
@@ -32,7 +32,7 @@ SELECT 'X @ query(1,1)' as op,
         max(a.x) as xmax,
         min(a.y) as ymin,
         max(a.y) as ymax,
-        st_extent(a.tile)
+        st_extent(a.tile::geometry)
 FROM rt_gist_grid_test a, rt_gist_query_test b
 WHERE b.x = 1 and b.y = 1
     AND a.tile @ b.tile;
index 823eae6e2acf401a075168a84ddb9c8901733e04..7db658e427f9c8f242e9f9eafc964ea0bb94c21c 100644 (file)
@@ -17,7 +17,7 @@ SELECT 'raster_left(X, query(1,1))' as op,
         max(a.x) as xmax,
         min(a.y) as ymin,
         max(a.y) as ymax,
-        st_extent(a.tile)
+        st_extent(a.tile::geometry)
 FROM rt_gist_grid_test a, rt_gist_query_test b
 WHERE b.x = 1 and b.y = 1
     AND raster_left(a.tile, b.tile);
@@ -32,7 +32,7 @@ SELECT 'X << query(1,1)' as op,
         max(a.x) as xmax,
         min(a.y) as ymin,
         max(a.y) as ymax,
-        st_extent(a.tile)
+        st_extent(a.tile::geometry)
 FROM rt_gist_grid_test a, rt_gist_query_test b
 WHERE b.x = 1 and b.y = 1
     AND a.tile << b.tile;
index c4cdd7f21f9f49e7b5c230edb8d4b2bb5ab47f24..9b2284236aa073c0f1ef9d79e6f3f42495926685 100644 (file)
@@ -17,7 +17,7 @@ SELECT 'raster_overabove(X, query(1,1))' as op,
         max(a.x) as xmax,
         min(a.y) as ymin,
         max(a.y) as ymax,
-        st_extent(a.tile)
+        st_extent(a.tile::geometry)
 FROM rt_gist_grid_test a, rt_gist_query_test b
 WHERE b.x = 1 and b.y = 1
     AND raster_overabove(a.tile, b.tile);
@@ -32,7 +32,7 @@ SELECT 'X |&> query(1,1)' as op,
         max(a.x) as xmax,
         min(a.y) as ymin,
         max(a.y) as ymax,
-        st_extent(a.tile)
+        st_extent(a.tile::geometry)
 FROM rt_gist_grid_test a, rt_gist_query_test b
 WHERE b.x = 1 and b.y = 1
     AND a.tile |&> b.tile;
index 7cb6a32be4b5834af6f2b3978c0a9a3b2c10cda7..6b9a19e7604b97686017eaa9cc1e7bef9f6ecfcc 100644 (file)
@@ -17,7 +17,7 @@ SELECT 'raster_overbelow(X, query(1,1))' as op,
         max(a.x) as xmax,
         min(a.y) as ymin,
         max(a.y) as ymax,
-        st_extent(a.tile)
+        st_extent(a.tile::geometry)
 FROM rt_gist_grid_test a, rt_gist_query_test b
 WHERE b.x = 1 and b.y = 1
     AND raster_overbelow(a.tile, b.tile);
@@ -32,7 +32,7 @@ SELECT 'X &<| query(1,1)' as op,
         max(a.x) as xmax,
         min(a.y) as ymin,
         max(a.y) as ymax,
-        st_extent(a.tile)
+        st_extent(a.tile::geometry)
 FROM rt_gist_grid_test a, rt_gist_query_test b
 WHERE b.x = 1 and b.y = 1
     AND a.tile &<| b.tile;
index 57ad1de1d2e2cf1e5c7082e06bf2665ae68ae3c1..52cc5602d1ddd768a6a301820f278118ea4130a8 100644 (file)
@@ -17,7 +17,7 @@ SELECT 'raster_overlap(X, query(1,1))' as op,
         max(a.x) as xmax,
         min(a.y) as ymin,
         max(a.y) as ymax,
-        st_extent(a.tile)
+        st_extent(a.tile::geometry)
 FROM rt_gist_grid_test a, rt_gist_query_test b
 WHERE b.x = 1 and b.y = 1
     AND raster_overlap(a.tile, b.tile);
@@ -32,7 +32,7 @@ SELECT 'X && query(1,1)' as op,
         max(a.x) as xmax,
         min(a.y) as ymin,
         max(a.y) as ymax,
-        st_extent(a.tile)
+        st_extent(a.tile::geometry)
 FROM rt_gist_grid_test a, rt_gist_query_test b
 WHERE b.x = 1 and b.y = 1
     AND a.tile && b.tile;
index 2282d1a94a54b869bbefa8ba2ff324ea71820321..f864e979ea5c1c1da82efc660a74cb1624172a00 100644 (file)
@@ -17,7 +17,7 @@ SELECT 'raster_overleft(X, query(1,1))' as op,
         max(a.x) as xmax,
         min(a.y) as ymin,
         max(a.y) as ymax,
-        st_extent(a.tile)
+        st_extent(a.tile::geometry)
 FROM rt_gist_grid_test a, rt_gist_query_test b
 WHERE b.x = 1 and b.y = 1
     AND raster_overleft(a.tile, b.tile);
@@ -32,7 +32,7 @@ SELECT 'X &< query(1,1)' as op,
         max(a.x) as xmax,
         min(a.y) as ymin,
         max(a.y) as ymax,
-        st_extent(a.tile)
+        st_extent(a.tile::geometry)
 FROM rt_gist_grid_test a, rt_gist_query_test b
 WHERE b.x = 1 and b.y = 1
     AND a.tile &< b.tile;
index fe302d9d3cdabb6ae21c5825ddc26a7b2d8ceeb1..cc089573fd87307e170703e06ef71b1d1556377f 100644 (file)
@@ -16,7 +16,7 @@ SELECT 'raster_overright(X, query(1,1))' as op,
         max(a.x) as xmax,
         min(a.y) as ymin,
         max(a.y) as ymax,
-        st_extent(a.tile)
+        st_extent(a.tile::geometry)
 FROM rt_gist_grid_test a, rt_gist_query_test b
 WHERE b.x = 1 and b.y = 1
     AND raster_overright(a.tile, b.tile);
@@ -31,7 +31,7 @@ SELECT 'X &> query(1,1)' as op,
         max(a.x) as xmax,
         min(a.y) as ymin,
         max(a.y) as ymax,
-        st_extent(a.tile)
+        st_extent(a.tile::geometry)
 FROM rt_gist_grid_test a, rt_gist_query_test b
 WHERE b.x = 1 and b.y = 1
     AND a.tile &> b.tile;
index 80fb8710ad64aeceb6d6d96a1c9896f680b232ff..92166092c161366bef25242b8d2176e69388a377 100644 (file)
@@ -17,7 +17,7 @@ SELECT 'raster_right(X, query(1,1))' as op,
         max(a.x) as xmax,
         min(a.y) as ymin,
         max(a.y) as ymax,
-        st_extent(a.tile)
+        st_extent(a.tile::geometry)
 FROM rt_gist_grid_test a, rt_gist_query_test b
 WHERE b.x = 1 and b.y = 1
     AND raster_right(a.tile, b.tile);
@@ -32,7 +32,7 @@ SELECT 'X >> query(1,1)' as op,
         max(a.x) as xmax,
         min(a.y) as ymin,
         max(a.y) as ymax,
-        st_extent(a.tile)
+        st_extent(a.tile::geometry)
 FROM rt_gist_grid_test a, rt_gist_query_test b
 WHERE b.x = 1 and b.y = 1
     AND a.tile >> b.tile;
index 353927e7dd710be67379354a4c027c952cadfbaf..e9147982c5f2e8a6a94f143b1a812a31b3d767bb 100644 (file)
@@ -17,7 +17,7 @@ SELECT 'raster_same(X, query(1,1))' as op,
         max(a.x) as xmax,
         min(a.y) as ymin,
         max(a.y) as ymax,
-        st_extent(a.tile)
+        st_extent(a.tile::geometry)
 FROM rt_gist_grid_test a, rt_gist_query_test b
 WHERE b.x = 1 and b.y = 1
     AND raster_same(a.tile, b.tile);
@@ -28,7 +28,7 @@ SELECT 'raster_same(X, query(7,7))' as op,
         max(a.x) as xmax,
         min(a.y) as ymin,
         max(a.y) as ymax,
-        st_extent(a.tile)
+        st_extent(a.tile::geometry)
 FROM rt_gist_grid_test a, rt_gist_grid_test b
 WHERE b.x = 7 and b.y = 7
     AND raster_same(a.tile, b.tile);
@@ -43,7 +43,7 @@ SELECT 'X ~= query(1,1)' as op,
         max(a.x) as xmax,
         min(a.y) as ymin,
         max(a.y) as ymax,
-        st_extent(a.tile)
+        st_extent(a.tile::geometry)
 FROM rt_gist_grid_test a, rt_gist_query_test b
 WHERE b.x = 1 and b.y = 1
     AND a.tile ~= b.tile;
@@ -54,7 +54,7 @@ SELECT 'X ~= tile(7,7)' as op,
         max(a.x) as xmax,
         min(a.y) as ymin,
         max(a.y) as ymax,
-        st_extent(a.tile)
+        st_extent(a.tile::geometry)
 FROM rt_gist_grid_test a, rt_gist_grid_test b
 WHERE b.x = 7 and b.y = 7
     AND a.tile ~= b.tile;