From: Bborie Park Date: Fri, 24 Feb 2012 05:05:25 +0000 (+0000) Subject: Set all raster CASTs to be ASSIGNMENT not IMPLICIT. Related ticket is #490. Knowing... X-Git-Tag: 2.0.0beta1~74 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c91f947cf472d81971dbc3c9b8c266489f61bdaa;p=postgis Set all raster CASTs to be ASSIGNMENT not IMPLICIT. Related ticket is #490. Knowing my luck, I'll be reverting this due to some showstopper. git-svn-id: http://svn.osgeo.org/postgis/trunk@9282 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/raster/rt_pg/rtpostgis.sql.in.c b/raster/rt_pg/rtpostgis.sql.in.c index 4b3f7655f..02e5b5a59 100644 --- a/raster/rt_pg/rtpostgis.sql.in.c +++ b/raster/rt_pg/rtpostgis.sql.in.c @@ -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; diff --git a/raster/rt_pg/rtpostgis_upgrade_cleanup.sql.in.c b/raster/rt_pg/rtpostgis_upgrade_cleanup.sql.in.c index 74c635963..578febb6d 100644 --- a/raster/rt_pg/rtpostgis_upgrade_cleanup.sql.in.c +++ b/raster/rt_pg/rtpostgis_upgrade_cleanup.sql.in.c @@ -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; diff --git a/raster/test/regress/rt_above.sql b/raster/test/regress/rt_above.sql index 1fa83918c..8c395fea2 100644 --- a/raster/test/regress/rt_above.sql +++ b/raster/test/regress/rt_above.sql @@ -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; diff --git a/raster/test/regress/rt_below.sql b/raster/test/regress/rt_below.sql index 375f2a44d..46adc5014 100644 --- a/raster/test/regress/rt_below.sql +++ b/raster/test/regress/rt_below.sql @@ -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; diff --git a/raster/test/regress/rt_bytea.sql b/raster/test/regress/rt_bytea.sql index 85aebaa60..968c98037 100644 --- a/raster/test/regress/rt_bytea.sql +++ b/raster/test/regress/rt_bytea.sql @@ -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 diff --git a/raster/test/regress/rt_contain.sql b/raster/test/regress/rt_contain.sql index f80ecd445..d705492dc 100644 --- a/raster/test/regress/rt_contain.sql +++ b/raster/test/regress/rt_contain.sql @@ -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; diff --git a/raster/test/regress/rt_contained.sql b/raster/test/regress/rt_contained.sql index 638183189..052947fba 100644 --- a/raster/test/regress/rt_contained.sql +++ b/raster/test/regress/rt_contained.sql @@ -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; diff --git a/raster/test/regress/rt_left.sql b/raster/test/regress/rt_left.sql index 823eae6e2..7db658e42 100644 --- a/raster/test/regress/rt_left.sql +++ b/raster/test/regress/rt_left.sql @@ -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; diff --git a/raster/test/regress/rt_overabove.sql b/raster/test/regress/rt_overabove.sql index c4cdd7f21..9b2284236 100644 --- a/raster/test/regress/rt_overabove.sql +++ b/raster/test/regress/rt_overabove.sql @@ -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; diff --git a/raster/test/regress/rt_overbelow.sql b/raster/test/regress/rt_overbelow.sql index 7cb6a32be..6b9a19e76 100644 --- a/raster/test/regress/rt_overbelow.sql +++ b/raster/test/regress/rt_overbelow.sql @@ -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; diff --git a/raster/test/regress/rt_overlap.sql b/raster/test/regress/rt_overlap.sql index 57ad1de1d..52cc5602d 100644 --- a/raster/test/regress/rt_overlap.sql +++ b/raster/test/regress/rt_overlap.sql @@ -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; diff --git a/raster/test/regress/rt_overleft.sql b/raster/test/regress/rt_overleft.sql index 2282d1a94..f864e979e 100644 --- a/raster/test/regress/rt_overleft.sql +++ b/raster/test/regress/rt_overleft.sql @@ -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; diff --git a/raster/test/regress/rt_overright.sql b/raster/test/regress/rt_overright.sql index fe302d9d3..cc089573f 100644 --- a/raster/test/regress/rt_overright.sql +++ b/raster/test/regress/rt_overright.sql @@ -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; diff --git a/raster/test/regress/rt_right.sql b/raster/test/regress/rt_right.sql index 80fb8710a..92166092c 100644 --- a/raster/test/regress/rt_right.sql +++ b/raster/test/regress/rt_right.sql @@ -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; diff --git a/raster/test/regress/rt_same.sql b/raster/test/regress/rt_same.sql index 353927e7d..e9147982c 100644 --- a/raster/test/regress/rt_same.sql +++ b/raster/test/regress/rt_same.sql @@ -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;