[postgis-tickets] r17315 - Schema qualify all geometry casts in raster code, otherwise materialized views do not resture

Regina Obe lr at pcorp.us
Sat Mar 9 10:43:27 PST 2019


Author: robe
Date: 2019-03-09 10:43:26 -0800 (Sat, 09 Mar 2019)
New Revision: 17315

Modified:
   branches/2.4/NEWS
   branches/2.4/raster/rt_pg/rtpostgis.sql.in
Log:
Schema qualify all geometry casts in raster code, otherwise materialized views do not resture
Closes #4291 for PostGIS 2.4.7

Modified: branches/2.4/NEWS
===================================================================
--- branches/2.4/NEWS	2019-03-09 18:37:56 UTC (rev 17314)
+++ branches/2.4/NEWS	2019-03-09 18:43:26 UTC (rev 17315)
@@ -17,8 +17,8 @@
   - #4298, Geodetic tolerance issue in 32-bit (Paul Ramsey)
   - #4283, Avoid final point duplicates for circle stroking (Paul Ramsey)
   - #4313, #4307, PostgreSQL 12 compatibility (Laurenz Albe, Raúl Marín)
+  - #4290, Schema qualify geometry casts in raster functions (Regina Obe)
 
-
 PostGIS 2.4.6
 2018/11/24
 

Modified: branches/2.4/raster/rt_pg/rtpostgis.sql.in
===================================================================
--- branches/2.4/raster/rt_pg/rtpostgis.sql.in	2019-03-09 18:37:56 UTC (rev 17314)
+++ branches/2.4/raster/rt_pg/rtpostgis.sql.in	2019-03-09 18:43:26 UTC (rev 17315)
@@ -243,7 +243,7 @@
 		msg text;
 		msgset text[];
 	BEGIN
-		extent := @extschema at .ST_Extent(rast::geometry);
+		extent := @extschema at .ST_Extent(rast::@extschema at .geometry);
 		metadata := @extschema at .ST_Metadata(rast);
 
 		msg := 'Raster of ' || metadata.width || 'x' || metadata.height || ' pixels has ' || metadata.numbands || ' ';
@@ -302,7 +302,7 @@
 
 CREATE OR REPLACE FUNCTION st_makeemptyraster(width int, height int, upperleftx float8, upperlefty float8, pixelsize float8)
     RETURNS raster
-    AS $$ SELECT  @extschema at .ST_makeemptyraster($1, $2, $3, $4, $5, -($5), 0, 0, @extschema at .ST_SRID('POINT(0 0)'::geometry)) $$
+    AS $$ SELECT  @extschema at .ST_makeemptyraster($1, $2, $3, $4, $5, -($5), 0, 0, @extschema at .ST_SRID('POINT(0 0)'::@extschema at .geometry)) $$
     LANGUAGE 'sql' IMMUTABLE STRICT _PARALLEL;
 
 CREATE OR REPLACE FUNCTION st_makeemptyraster(rast raster)
@@ -5706,52 +5706,52 @@
 
 CREATE OR REPLACE FUNCTION raster_left(raster, raster)
     RETURNS bool
-    AS 'select $1::geometry << $2::geometry'
+    AS 'select $1::@extschema at .geometry << $2::@extschema at .geometry'
     LANGUAGE 'sql' IMMUTABLE STRICT _PARALLEL;
 
 CREATE OR REPLACE FUNCTION raster_right(raster, raster)
     RETURNS bool
-    AS 'select $1::geometry >> $2::geometry'
+    AS 'select $1::@extschema at .geometry >> $2::@extschema at .geometry'
     LANGUAGE 'sql' IMMUTABLE STRICT _PARALLEL;
 
 CREATE OR REPLACE FUNCTION raster_overabove(raster, raster)
     RETURNS bool
-    AS 'select $1::geometry |&> $2::geometry'
+    AS 'select $1::@extschema at .geometry |&> $2::@extschema at .geometry'
     LANGUAGE 'sql' IMMUTABLE STRICT _PARALLEL;
 
 CREATE OR REPLACE FUNCTION raster_overbelow(raster, raster)
     RETURNS bool
-    AS 'select $1::geometry &<| $2::geometry'
+    AS 'select $1::@extschema at .geometry &<| $2::@extschema at .geometry'
     LANGUAGE 'sql' IMMUTABLE STRICT _PARALLEL;
 
 CREATE OR REPLACE FUNCTION raster_above(raster, raster)
     RETURNS bool
-    AS 'select $1::geometry |>> $2::geometry'
+    AS 'select $1::@extschema at .geometry |>> $2::@extschema at .geometry'
     LANGUAGE 'sql' IMMUTABLE STRICT _PARALLEL;
 
 CREATE OR REPLACE FUNCTION raster_below(raster, raster)
     RETURNS bool
-    AS 'select $1::geometry <<| $2::geometry'
+    AS 'select $1::@extschema at .geometry <<| $2::@extschema at .geometry'
     LANGUAGE 'sql' IMMUTABLE STRICT _PARALLEL;
 
 CREATE OR REPLACE FUNCTION raster_same(raster, raster)
     RETURNS bool
-    AS 'select $1::geometry ~= $2::geometry'
+    AS 'select $1::@extschema at .geometry ~= $2::@extschema at .geometry'
     LANGUAGE 'sql' IMMUTABLE STRICT _PARALLEL;
 
 CREATE OR REPLACE FUNCTION raster_contained(raster, raster)
     RETURNS bool
-    AS 'select $1::geometry OPERATOR(@extschema at .@) $2::geometry'
+    AS 'select $1::@extschema at .geometry OPERATOR(@extschema at .@) $2::@extschema at .geometry'
     LANGUAGE 'sql' IMMUTABLE STRICT _PARALLEL;
 
 CREATE OR REPLACE FUNCTION raster_contain(raster, raster)
     RETURNS bool
-    AS 'select $1::geometry ~ $2::geometry'
+    AS 'select $1::@extschema at .geometry ~ $2::@extschema at .geometry'
     LANGUAGE 'sql' IMMUTABLE STRICT _PARALLEL;
 
 CREATE OR REPLACE FUNCTION raster_overlap(raster, raster)
     RETURNS bool
-    AS 'select $1::geometry OPERATOR(@extschema at .&&) $2::geometry'
+    AS 'select $1::@extschema at .geometry OPERATOR(@extschema at .&&) $2::@extschema at .geometry'
     LANGUAGE 'sql' IMMUTABLE STRICT _PARALLEL;
 
 -- raster/geometry functions
@@ -5759,19 +5759,19 @@
 -- Availability: 2.0.0
 CREATE OR REPLACE FUNCTION raster_geometry_contain(raster, geometry)
     RETURNS bool
-    AS 'select $1::geometry ~ $2'
+    AS 'select $1::@extschema at .geometry ~ $2'
     LANGUAGE 'sql' IMMUTABLE STRICT _PARALLEL;
 
 -- Availability: 2.0.5
 CREATE OR REPLACE FUNCTION raster_contained_by_geometry(raster, geometry)
     RETURNS bool
-    AS 'select $1::geometry OPERATOR(@extschema at .@) $2'
+    AS 'select $1::@extschema at .geometry OPERATOR(@extschema at .@) $2'
     LANGUAGE 'sql' IMMUTABLE STRICT _PARALLEL;
 
 -- Availability: 2.0.0
 CREATE OR REPLACE FUNCTION raster_geometry_overlap(raster, geometry)
     RETURNS bool
-    AS 'select $1::geometry OPERATOR(@extschema at .&&) $2'
+    AS 'select $1::@extschema at .geometry OPERATOR(@extschema at .&&) $2'
     LANGUAGE 'sql' IMMUTABLE STRICT _PARALLEL;
 
 -- geometry/raster functions
@@ -5779,19 +5779,19 @@
 -- Availability: 2.0.0
 CREATE OR REPLACE FUNCTION geometry_raster_contain(geometry, raster)
     RETURNS bool
-    AS 'select $1 OPERATOR(@extschema at .~) $2::geometry'
+    AS 'select $1 OPERATOR(@extschema at .~) $2::@extschema at .geometry'
     LANGUAGE 'sql' IMMUTABLE STRICT _PARALLEL;
 
 -- Availability: 2.0.5
 CREATE OR REPLACE FUNCTION geometry_contained_by_raster(geometry, raster)
     RETURNS bool
-    AS 'select $1 OPERATOR(@extschema at .@) $2::geometry'
+    AS 'select $1 OPERATOR(@extschema at .@) $2::@extschema at .geometry'
     LANGUAGE 'sql' IMMUTABLE STRICT _PARALLEL;
 
 -- Availability: 2.0.0
 CREATE OR REPLACE FUNCTION geometry_raster_overlap(geometry, raster)
     RETURNS bool
-    AS 'select $1 OPERATOR(@extschema at .&&) $2::geometry'
+    AS 'select $1 OPERATOR(@extschema at .&&) $2::@extschema at .geometry'
     LANGUAGE 'sql' IMMUTABLE STRICT _PARALLEL;
 
 ------------------------------------------------------------------------------
@@ -6182,7 +6182,7 @@
 -- 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 OPERATOR(@extschema at .&&) $2::geometry AND @extschema at ._st_intersects($1, $2, $3); $$
+	$$ SELECT $1 OPERATOR(@extschema at .&&) $2::@extschema at .geometry AND @extschema at ._st_intersects($1, $2, $3); $$
 	LANGUAGE 'sql' IMMUTABLE _PARALLEL
 	COST 1000;
 
@@ -6192,13 +6192,13 @@
 
 CREATE OR REPLACE FUNCTION st_intersects(rast raster, geom geometry, nband integer DEFAULT NULL)
 	RETURNS boolean
-	AS $$ SELECT $1::geometry OPERATOR(@extschema at .&&) $2 AND @extschema at ._st_intersects($2, $1, $3) $$
+	AS $$ SELECT $1::@extschema at .geometry OPERATOR(@extschema at .&&) $2 AND @extschema at ._st_intersects($2, $1, $3) $$
 	LANGUAGE 'sql' IMMUTABLE _PARALLEL
 	COST 1000;
 
 CREATE OR REPLACE FUNCTION st_intersects(rast raster, nband integer, geom geometry)
 	RETURNS boolean
-	AS $$ SELECT $1::geometry OPERATOR(@extschema at .&&) $3 AND @extschema at ._st_intersects($3, $1, $2) $$
+	AS $$ SELECT $1::@extschema at .geometry OPERATOR(@extschema at .&&) $3 AND @extschema at ._st_intersects($3, $1, $2) $$
 	LANGUAGE 'sql' IMMUTABLE _PARALLEL
 	COST 1000;
 
@@ -6368,7 +6368,7 @@
 
 CREATE OR REPLACE FUNCTION ST_DWithin(rast1 raster, nband1 integer, rast2 raster, nband2 integer, distance double precision)
 	RETURNS boolean
-	AS $$ SELECT $1::geometry OPERATOR(@extschema at .&&) ST_Expand(ST_ConvexHull($3), $5) AND $3::geometry OPERATOR(@extschema at .&&) ST_Expand(ST_ConvexHull($1), $5) AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN @extschema at ._ST_dwithin(st_convexhull($1), st_convexhull($3), $5) ELSE @extschema at ._ST_dwithin($1, $2, $3, $4, $5) END $$
+	AS $$ SELECT $1::@extschema at .geometry OPERATOR(@extschema at .&&) ST_Expand(ST_ConvexHull($3), $5) AND $3::@extschema at .geometry OPERATOR(@extschema at .&&) ST_Expand(ST_ConvexHull($1), $5) AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN @extschema at ._ST_dwithin(st_convexhull($1), st_convexhull($3), $5) ELSE @extschema at ._ST_dwithin($1, $2, $3, $4, $5) END $$
 	LANGUAGE 'sql' IMMUTABLE _PARALLEL
 	COST 1000;
 
@@ -6390,7 +6390,7 @@
 
 CREATE OR REPLACE FUNCTION ST_DFullyWithin(rast1 raster, nband1 integer, rast2 raster, nband2 integer, distance double precision)
 	RETURNS boolean
-	AS $$ SELECT $1::geometry OPERATOR(@extschema at .&&) @extschema at .ST_Expand(@extschema at .ST_ConvexHull($3), $5) AND $3::geometry OPERATOR(@extschema at .&&) @extschema at .ST_Expand(@extschema at .ST_ConvexHull($1), $5) AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN @extschema at ._ST_DFullyWithin(@extschema at .ST_ConvexHull($1), @extschema at .ST_Convexhull($3), $5) ELSE @extschema at ._ST_DFullyWithin($1, $2, $3, $4, $5) END $$
+	AS $$ SELECT $1::@extschema at .geometry OPERATOR(@extschema at .&&) @extschema at .ST_Expand(@extschema at .ST_ConvexHull($3), $5) AND $3::@extschema at .geometry OPERATOR(@extschema at .&&) @extschema at .ST_Expand(@extschema at .ST_ConvexHull($1), $5) AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN @extschema at ._ST_DFullyWithin(@extschema at .ST_ConvexHull($1), @extschema at .ST_Convexhull($3), $5) ELSE @extschema at ._ST_DFullyWithin($1, $2, $3, $4, $5) END $$
 	LANGUAGE 'sql' IMMUTABLE _PARALLEL
 	COST 1000;
 
@@ -7166,7 +7166,7 @@
 CREATE OR REPLACE FUNCTION _raster_constraint_info_extent(rastschema name, rasttable name, rastcolumn name)
 	RETURNS geometry AS $$
 	SELECT
-		trim(both '''' from split_part(trim(split_part(s.consrc, ' @ ', 2)), '::', 1))::geometry
+		trim(both '''' from split_part(trim(split_part(s.consrc, ' @ ', 2)), '::', 1))::@extschema at .geometry
 	FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
 	WHERE n.nspname = $1
 		AND c.relname = $2
@@ -7213,7 +7213,7 @@
 			|| ' ADD CONSTRAINT ' || quote_ident(cn)
 			|| ' CHECK ( @extschema at .st_envelope('
 			|| quote_ident($3)
-			|| ') @ ''' || attr || '''::geometry) NOT VALID';
+			|| ') @ ''' || attr || '''::@extschema at .geometry) NOT VALID';
 		RETURN  @extschema at ._add_raster_constraint(cn, sql);
 	END;
 	$$ LANGUAGE 'plpgsql' VOLATILE STRICT
@@ -7296,7 +7296,7 @@
 		AND s.contype = 'x'
 		AND 0::smallint = ANY (s.conkey)
 		AND idx.indexrelid = s.conindid
-		AND pg_get_indexdef(idx.indexrelid, 1, true) LIKE '(' || quote_ident($3) || '::geometry)'
+		AND pg_get_indexdef(idx.indexrelid, 1, true) LIKE '(' || quote_ident($3) || '::@extschema at .geometry)'
 		AND s.conexclop[1] = op.oid
 		AND op.oprname = '=';
 	$$ LANGUAGE sql STABLE STRICT
@@ -7321,7 +7321,7 @@
 
 		sql := 'ALTER TABLE ' || fqtn ||
 			' ADD CONSTRAINT ' || quote_ident(cn) ||
-			' EXCLUDE ((' || quote_ident($3) || '::geometry) WITH =)';
+			' EXCLUDE ((' || quote_ident($3) || '::@extschema at .geometry) WITH =)';
 		RETURN  @extschema at ._add_raster_constraint(cn, sql);
 	END;
 	$$ LANGUAGE 'plpgsql' VOLATILE STRICT
@@ -7344,7 +7344,7 @@
 			AND s.contype = 'x'
 			AND 0::smallint = ANY (s.conkey)
 			AND idx.indexrelid = s.conindid
-			AND pg_get_indexdef(idx.indexrelid, 1, true) LIKE '(' || quote_ident($3) || '::geometry)'
+			AND pg_get_indexdef(idx.indexrelid, 1, true) LIKE '(' || quote_ident($3) || '::@extschema at .geometry)'
 			AND s.conexclop[1] = op.oid
 			AND op.oprname = '=';
 
@@ -8303,7 +8303,7 @@
 		n.nspname AS r_table_schema,
 		c.relname AS r_table_name,
 		a.attname AS r_raster_column,
-		COALESCE(_raster_constraint_info_srid(n.nspname, c.relname, a.attname), (SELECT ST_SRID('POINT(0 0)'::geometry))) AS srid,
+		COALESCE(_raster_constraint_info_srid(n.nspname, c.relname, a.attname), (SELECT ST_SRID('POINT(0 0)'::@extschema at .geometry))) AS srid,
 		_raster_constraint_info_scale(n.nspname, c.relname, a.attname, 'x') AS scale_x,
 		_raster_constraint_info_scale(n.nspname, c.relname, a.attname, 'y') AS scale_y,
 		_raster_constraint_info_blocksize(n.nspname, c.relname, a.attname, 'width') AS blocksize_x,



More information about the postgis-tickets mailing list