[postgis-tickets] [SCM] PostGIS branch stable-3.1 updated. 3.1.1-29-g15713db

git at osgeo.org git at osgeo.org
Thu Mar 11 14:29:13 PST 2021


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "PostGIS".

The branch, stable-3.1 has been updated
       via  15713db62a3cbacec5e2c28446e6c9b73e51c28f (commit)
      from  d2b6e27d15f0b931b5759384b7935afaa5648420 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 15713db62a3cbacec5e2c28446e6c9b73e51c28f
Author: Regina Obe <lr at pcorp.us>
Date:   Thu Mar 11 13:43:46 2021 -0500

    Change raster to use returns table instead of out for multi row returns
    Changes to raster regress to use lateral instead of select and other
    fixes to regress on PostgreSQL 14.  Paul Ramsey, Regina Obe
    Closes #4876 for PostGIS 3.1.2
    Closes https://git.osgeo.org/gitea/postgis/postgis/pulls/53

diff --git a/NEWS b/NEWS
index b6ad35b..2172241 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,8 @@ PostGIS 3.1.2
   - #4840, Improper conversion of negative geographic azimuth to positive (Paul Ramsey)
   - #4853, DBSCAN cluster not formed when recordset length equal to minPoints (Dan Baston)
   - #4863, Update bboxes after scale/affine coordinate changes (Paul Ramsey)
+  - #4876, Fix raster issues related to PostgreSQL 14 tablefunc changes
+           (Paul Ramsey, Regina Obe)
   - #4877, mingw64 PostGIS / PostgreSQL 14 compile (Regina Obe, Tom Lane)
 
 
diff --git a/raster/rt_pg/rtpg_band_properties.c b/raster/rt_pg/rtpg_band_properties.c
index c5188f2..8ec500a 100644
--- a/raster/rt_pg/rtpg_band_properties.c
+++ b/raster/rt_pg/rtpg_band_properties.c
@@ -485,8 +485,9 @@ Datum RASTER_bandmetadata(PG_FUNCTION_ARGS)
 		bool isoutdb;
 		char *bandpath;
 		uint8_t extbandnum;
-                uint64_t filesize;
-                uint64_t timestamp;
+		uint64_t filesize;
+		uint64_t timestamp;
+		bool isnullband;
 	};
 	struct bandmetadata *bmd = NULL;
 	struct bandmetadata *bmd2 = NULL;
@@ -527,10 +528,29 @@ Datum RASTER_bandmetadata(PG_FUNCTION_ARGS)
 		/* switch to memory context appropriate for multiple function calls */
 		oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
 
+		/* Build a tuple descriptor for our result type */
+		if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE) {
+			MemoryContextSwitchTo(oldcontext);
+			ereport(ERROR, (
+				errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+				errmsg(
+					"function returning record called in context "
+					"that cannot accept type record"
+				)
+			));
+		}
+
+		BlessTupleDesc(tupdesc);
+		funcctx->tuple_desc = tupdesc;
+
 		/* pgraster is null, return null */
 		if (PG_ARGISNULL(0)) {
+			bmd = (struct bandmetadata *) palloc(sizeof(struct bandmetadata));
+			bmd->isnullband = TRUE;
+			funcctx->user_fctx = bmd;
+			funcctx->max_calls = 1;
 			MemoryContextSwitchTo(oldcontext);
-			SRF_RETURN_DONE(funcctx);
+			goto PER_CALL;
 		}
 		pgraster = (rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
 
@@ -549,8 +569,12 @@ Datum RASTER_bandmetadata(PG_FUNCTION_ARGS)
 			elog(NOTICE, "Raster provided has no bands");
 			rt_raster_destroy(raster);
 			PG_FREE_IF_COPY(pgraster, 0);
+			bmd = (struct bandmetadata *) palloc(sizeof(struct bandmetadata));
+			bmd->isnullband = TRUE;
+			funcctx->user_fctx = bmd;
+			funcctx->max_calls = 1;
 			MemoryContextSwitchTo(oldcontext);
-			SRF_RETURN_DONE(funcctx);
+			goto PER_CALL;
 		}
 
 		/* band index */
@@ -593,8 +617,12 @@ Datum RASTER_bandmetadata(PG_FUNCTION_ARGS)
 				pfree(bandNums);
 				rt_raster_destroy(raster);
 				PG_FREE_IF_COPY(pgraster, 0);
+				bmd = (struct bandmetadata *) palloc(sizeof(struct bandmetadata));
+				bmd->isnullband = TRUE;
+				funcctx->user_fctx = bmd;
+				funcctx->max_calls = 1;
 				MemoryContextSwitchTo(oldcontext);
-				SRF_RETURN_DONE(funcctx);
+				goto PER_CALL;
 			}
 
 			bandNums[j] = idx;
@@ -611,7 +639,7 @@ Datum RASTER_bandmetadata(PG_FUNCTION_ARGS)
 		else if (j < n)
 			bandNums = repalloc(bandNums, sizeof(uint32_t) * j);
 
-		bmd = (struct bandmetadata *) palloc(sizeof(struct bandmetadata) * j);
+		bmd = (struct bandmetadata *) palloc0(sizeof(struct bandmetadata) * j);
 
 		for (i = 0; i < j; i++) {
 			band = rt_raster_get_band(raster, bandNums[i] - 1);
@@ -619,8 +647,11 @@ Datum RASTER_bandmetadata(PG_FUNCTION_ARGS)
 				elog(NOTICE, "Could not get raster band at index %d", bandNums[i]);
 				rt_raster_destroy(raster);
 				PG_FREE_IF_COPY(pgraster, 0);
+				bmd[0].isnullband = TRUE;
+				funcctx->user_fctx = bmd;
+				funcctx->max_calls = 1;
 				MemoryContextSwitchTo(oldcontext);
-				SRF_RETURN_DONE(funcctx);
+				goto PER_CALL;
 			}
 
 			/* bandnum */
@@ -685,24 +716,11 @@ Datum RASTER_bandmetadata(PG_FUNCTION_ARGS)
 		/* total number of tuples to be returned */
 		funcctx->max_calls = j;
 
-		/* Build a tuple descriptor for our result type */
-		if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE) {
-			MemoryContextSwitchTo(oldcontext);
-			ereport(ERROR, (
-				errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-				errmsg(
-					"function returning record called in context "
-					"that cannot accept type record"
-				)
-			));
-		}
-
-		BlessTupleDesc(tupdesc);
-		funcctx->tuple_desc = tupdesc;
-
 		MemoryContextSwitchTo(oldcontext);
 	}
 
+	PER_CALL:
+
 	/* stuff done on every call of the function */
 	funcctx = SRF_PERCALL_SETUP();
 
@@ -716,6 +734,14 @@ Datum RASTER_bandmetadata(PG_FUNCTION_ARGS)
 		Datum values[VALUES_LENGTH];
 		bool nulls[VALUES_LENGTH];
 
+		if (bmd2[0].isnullband) {
+			int i;
+			for (i = 0; i < VALUES_LENGTH; i++)
+				nulls[i] = TRUE;
+			result = HeapTupleGetDatum(heap_form_tuple(tupdesc, values, nulls));
+			SRF_RETURN_NEXT(funcctx, result);
+		}
+
 		memset(nulls, FALSE, sizeof(bool) * VALUES_LENGTH);
 
 		values[0] = UInt32GetDatum(bmd2[call_cntr].bandnum);
diff --git a/raster/rt_pg/rtpostgis.sql.in b/raster/rt_pg/rtpostgis.sql.in
index e7e491f..9adeb61 100644
--- a/raster/rt_pg/rtpostgis.sql.in
+++ b/raster/rt_pg/rtpostgis.sql.in
@@ -4527,32 +4527,36 @@ CREATE OR REPLACE FUNCTION ST_BandPixelType(rast raster, band integer DEFAULT 1)
     AS 'MODULE_PATHNAME','RASTER_getBandPixelTypeName'
     LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE;
 
+-- Changed: 3.1.2
 CREATE OR REPLACE FUNCTION ST_BandMetaData(
 	rast raster,
-	band int[],
-	OUT bandnum int,
-	OUT pixeltype text,
-	OUT nodatavalue double precision,
-	OUT isoutdb boolean,
-	OUT path text,
-	OUT outdbbandnum integer,
-	OUT filesize bigint,
-	OUT filetimestamp bigint
-)
+	band int[])
+	RETURNS TABLE(
+		bandnum int,
+		pixeltype text,
+		nodatavalue double precision,
+		isoutdb boolean,
+		path text,
+		outdbbandnum integer,
+		filesize bigint,
+		filetimestamp bigint
+	)
 	AS 'MODULE_PATHNAME','RASTER_bandmetadata'
 	LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE;
 
+-- Changed: 3.1.2
 CREATE OR REPLACE FUNCTION ST_BandMetaData(
 	rast raster,
-	band int DEFAULT 1,
-	OUT pixeltype text,
-	OUT nodatavalue double precision,
-	OUT isoutdb boolean,
-	OUT path text,
-	OUT outdbbandnum integer,
-	OUT filesize bigint,
-	OUT filetimestamp bigint
-)
+	band int DEFAULT 1)
+	RETURNS TABLE (
+		pixeltype text,
+		nodatavalue double precision,
+		isoutdb boolean,
+		path text,
+		outdbbandnum integer,
+		filesize bigint,
+		filetimestamp bigint
+	)
 	AS $$ SELECT pixeltype, nodatavalue, isoutdb, path, outdbbandnum, filesize, filetimestamp FROM @extschema at .ST_BandMetaData($1, ARRAY[$2]::int[]) LIMIT 1 $$
 	LANGUAGE 'sql' IMMUTABLE STRICT PARALLEL SAFE;
 
@@ -4625,47 +4629,55 @@ CREATE OR REPLACE FUNCTION st_pixelofvalue(
 	rast raster,
 	nband integer,
 	search double precision[],
-	exclude_nodata_value boolean DEFAULT TRUE,
-	OUT val double precision,
-	OUT x integer,
-	OUT y integer
-)
-	RETURNS SETOF record
+	exclude_nodata_value boolean DEFAULT TRUE
+	)
+	RETURNS
+	TABLE(
+		val double precision,
+		x integer,
+		y integer
+	)
 	AS 'MODULE_PATHNAME', 'RASTER_pixelOfValue'
 	LANGUAGE 'c' IMMUTABLE STRICT PARALLEL SAFE;
 
+-- Changed: 3.1.2
 CREATE OR REPLACE FUNCTION ST_PixelofValue(
 	rast raster,
 	search double precision[],
-	exclude_nodata_value boolean DEFAULT TRUE,
-	OUT val double precision,
-	OUT x integer,
-	OUT y integer
-)
-	RETURNS SETOF record
+	exclude_nodata_value boolean DEFAULT TRUE
+	)
+	RETURNS TABLE (
+		val double precision,
+		x integer,
+		y integer
+	)
 	AS $$ SELECT val, x, y FROM @extschema at .ST_PixelOfValue($1, 1, $2, $3) $$
 	LANGUAGE 'sql' IMMUTABLE STRICT PARALLEL SAFE;
 
+-- Changed: 3.1.2
 CREATE OR REPLACE FUNCTION st_pixelofvalue(
 	rast raster,
 	nband integer,
 	search double precision,
-	exclude_nodata_value boolean DEFAULT TRUE,
-	OUT x integer,
-	OUT y integer
-)
-	RETURNS SETOF record
+	exclude_nodata_value boolean DEFAULT TRUE
+	)
+	RETURNS TABLE (
+		x integer,
+		y integer
+	)
 	AS $$ SELECT x, y FROM @extschema at .ST_PixelofValue($1, $2, ARRAY[$3], $4) $$
 	LANGUAGE 'sql' IMMUTABLE STRICT PARALLEL SAFE;
 
+-- Changed: 3.1.2
 CREATE OR REPLACE FUNCTION st_pixelofvalue(
 	rast raster,
 	search double precision,
-	exclude_nodata_value boolean DEFAULT TRUE,
-	OUT x integer,
-	OUT y integer
-)
-	RETURNS SETOF record
+	exclude_nodata_value boolean DEFAULT TRUE
+	)
+	RETURNS TABLE (
+		x integer,
+		y integer
+	)
 	AS $$ SELECT x, y FROM @extschema at .ST_PixelOfValue($1, 1, ARRAY[$2], $3) $$
 	LANGUAGE 'sql' IMMUTABLE STRICT PARALLEL SAFE;
 
@@ -5041,11 +5053,11 @@ CREATE OR REPLACE FUNCTION st_dumpaspolygons(rast raster, band integer DEFAULT 1
 -----------------------------------------------------------------------
 -- ST_DumpValues
 -----------------------------------------------------------------------
+-- Changed: 3.1.2
 CREATE OR REPLACE FUNCTION st_dumpvalues(
-	rast raster, nband integer[] DEFAULT NULL, exclude_nodata_value boolean DEFAULT TRUE,
-	OUT nband integer, OUT valarray double precision[][]
-)
-	RETURNS SETOF record
+	rast raster, nband integer[] DEFAULT NULL, exclude_nodata_value boolean DEFAULT TRUE
+	)
+	RETURNS TABLE(nband integer, valarray double precision[][])
 	AS 'MODULE_PATHNAME','RASTER_dumpValues'
 	LANGUAGE 'c' IMMUTABLE PARALLEL SAFE;
 
@@ -5068,31 +5080,35 @@ CREATE OR REPLACE FUNCTION st_polygon(rast raster, band integer DEFAULT 1)
 -- Should be called like this:
 -- SELECT (gv).geom, (gv).val FROM (SELECT ST_PixelAsPolygons(rast) gv FROM mytable) foo
 -----------------------------------------------------------------------
+-- Changed: 3.1.2
 CREATE OR REPLACE FUNCTION _st_pixelaspolygons(
 	rast raster,
 	band integer DEFAULT 1,
 	columnx integer DEFAULT NULL,
 	rowy integer DEFAULT NULL,
-	exclude_nodata_value boolean DEFAULT TRUE,
-	OUT geom geometry,
-	OUT val double precision,
-	OUT x integer,
-	OUT y integer
-)
-	RETURNS SETOF record
+	exclude_nodata_value boolean DEFAULT TRUE
+	)
+	RETURNS TABLE(
+		geom geometry,
+		val double precision,
+		x integer,
+		y integer
+	)
 	AS 'MODULE_PATHNAME', 'RASTER_getPixelPolygons'
 	LANGUAGE 'c' IMMUTABLE PARALLEL SAFE;
 
+-- Changed: 3.1.2
 CREATE OR REPLACE FUNCTION st_pixelaspolygons(
 	rast raster,
 	band integer DEFAULT 1,
-	exclude_nodata_value boolean DEFAULT TRUE,
-	OUT geom geometry,
-	OUT val double precision,
-	OUT x int,
-	OUT y int
-)
-	RETURNS SETOF record
+	exclude_nodata_value boolean DEFAULT TRUE
+	)
+	RETURNS TABLE (
+		geom geometry,
+		val double precision,
+		x int,
+		y int
+	)
 	AS $$ SELECT geom, val, x, y FROM @extschema at ._ST_pixelaspolygons($1, $2, NULL, NULL, $3) $$
 	LANGUAGE 'sql' IMMUTABLE STRICT PARALLEL SAFE;
 
@@ -5108,17 +5124,18 @@ CREATE OR REPLACE FUNCTION st_pixelaspolygon(rast raster, x integer, y integer)
 -----------------------------------------------------------------------
 -- ST_PixelAsPoints
 -----------------------------------------------------------------------
-
+-- Changed: 3.1.2
 CREATE OR REPLACE FUNCTION st_pixelaspoints(
 	rast raster,
 	band integer DEFAULT 1,
-	exclude_nodata_value boolean DEFAULT TRUE,
-	OUT geom geometry,
-	OUT val double precision,
-	OUT x int,
-	OUT y int
-)
-	RETURNS SETOF record
+	exclude_nodata_value boolean DEFAULT TRUE
+	)
+	RETURNS TABLE (
+		geom geometry,
+		val double precision,
+		x int,
+		y int
+	)
 	AS $$ SELECT @extschema at .ST_PointN(  @extschema at .ST_ExteriorRing(geom), 1), val, x, y FROM @extschema at ._ST_pixelaspolygons($1, $2, NULL, NULL, $3) $$
 	LANGUAGE 'sql' IMMUTABLE STRICT PARALLEL SAFE;
 
@@ -5134,17 +5151,17 @@ CREATE OR REPLACE FUNCTION st_pixelaspoint(rast raster, x integer, y integer)
 -----------------------------------------------------------------------
 -- ST_PixelAsCentroids
 -----------------------------------------------------------------------
-
+-- Changed: 3.1.2
 CREATE OR REPLACE FUNCTION st_pixelascentroids(
 	rast raster,
 	band integer DEFAULT 1,
-	exclude_nodata_value boolean DEFAULT TRUE,
-	OUT geom geometry,
-	OUT val double precision,
-	OUT x int,
-	OUT y int
-)
-	RETURNS SETOF record
+	exclude_nodata_value boolean DEFAULT TRUE)
+	RETURNS TABLE (
+		geom geometry,
+		val double precision,
+		x int,
+		y int
+	)
 	AS $$ SELECT @extschema at .ST_Centroid(geom), val, x, y FROM @extschema at ._ST_pixelaspolygons($1, $2, NULL, NULL, $3) $$
 	LANGUAGE 'sql' IMMUTABLE STRICT PARALLEL SAFE;
 
@@ -5169,8 +5186,8 @@ CREATE OR REPLACE FUNCTION _st_worldtorastercoord(
 	rast raster,
 	longitude double precision DEFAULT NULL, latitude double precision DEFAULT NULL,
 	OUT columnx integer,
-	OUT rowy integer
-)
+	OUT rowy integer)
+	RETURNS record
 	AS 'MODULE_PATHNAME', 'RASTER_worldToRasterCoord'
 	LANGUAGE 'c' IMMUTABLE PARALLEL SAFE;
 
@@ -5184,8 +5201,8 @@ CREATE OR REPLACE FUNCTION st_worldtorastercoord(
 	rast raster,
 	longitude double precision, latitude double precision,
 	OUT columnx integer,
-	OUT rowy integer
-)
+	OUT rowy integer)
+	RETURNS record
 	AS $$ SELECT columnx, rowy FROM @extschema at ._ST_worldtorastercoord($1, $2, $3) $$
 	LANGUAGE 'sql' IMMUTABLE STRICT PARALLEL SAFE;
 
@@ -5197,9 +5214,8 @@ CREATE OR REPLACE FUNCTION st_worldtorastercoord(
 CREATE OR REPLACE FUNCTION st_worldtorastercoord(
 	rast raster, pt geometry,
 	OUT columnx integer,
-	OUT rowy integer
-)
-	AS
+	OUT rowy integer)
+	RETURNS record AS
 	$$
 	DECLARE
 		rx integer;
@@ -5315,13 +5331,12 @@ CREATE OR REPLACE FUNCTION st_worldtorastercoordy(rast raster, pt geometry)
 ---------------------------------------------------------------------------------
 -- ST_RasterToWorldCoord
 ---------------------------------------------------------------------------------
-
 CREATE OR REPLACE FUNCTION _st_rastertoworldcoord(
 	rast raster,
 	columnx integer DEFAULT NULL, rowy integer DEFAULT NULL,
 	OUT longitude double precision,
 	OUT latitude double precision
-)
+	) RETURNS record
 	AS 'MODULE_PATHNAME', 'RASTER_rasterToWorldCoord'
 	LANGUAGE 'c' IMMUTABLE PARALLEL SAFE;
 
@@ -5332,12 +5347,13 @@ CREATE OR REPLACE FUNCTION _st_rastertoworldcoord(
 -- This function works even if the provided raster column and row are beyond or
 -- below the raster width and height.
 ---------------------------------------------------------------------------------
+-- Changed: 3.1.2
 CREATE OR REPLACE FUNCTION st_rastertoworldcoord(
 	rast raster,
 	columnx integer, rowy integer,
-	OUT longitude double precision,
+	OUT	longitude double precision,
 	OUT latitude double precision
-)
+	) RETURNS record
 	AS $$ SELECT longitude, latitude FROM @extschema at ._ST_rastertoworldcoord($1, $2, $3) $$
 	LANGUAGE 'sql' IMMUTABLE STRICT PARALLEL SAFE;
 
@@ -8203,10 +8219,14 @@ CREATE OR REPLACE FUNCTION _overview_constraint(ov raster, factor integer, refsc
 	LANGUAGE 'sql' STABLE
 	COST 100;
 
+-- Changed: 3.1.2
 CREATE OR REPLACE FUNCTION _overview_constraint_info(
 	ovschema name, ovtable name, ovcolumn name,
-	OUT refschema name, OUT reftable name, OUT refcolumn name, OUT factor integer
-)
+		OUT refschema name,
+		OUT reftable name,
+		OUT refcolumn name,
+		OUT factor integer
+	)
 	AS $$
 	SELECT
 		split_part(split_part(s.consrc, '''::name', 1), '''', 2)::name,
@@ -8223,7 +8243,7 @@ CREATE OR REPLACE FUNCTION _overview_constraint_info(
 		AND s.connamespace = n.oid
 		AND s.conrelid = c.oid
 		AND a.attnum = ANY (s.conkey)
-		AND s.consrc LIKE '%_overview_constraint(%'
+		AND s.consrc LIKE '%_overview_constraint(%' LIMIT 1
 	$$ LANGUAGE sql STABLE STRICT
   COST 100;
 
diff --git a/raster/test/regress/rt_asraster.sql b/raster/test/regress/rt_asraster.sql
index 548cc97..88c58f0 100644
--- a/raster/test/regress/rt_asraster.sql
+++ b/raster/test/regress/rt_asraster.sql
@@ -483,15 +483,18 @@ SELECT
 FROM (
 	SELECT
 		d.rid,
-		(ST_MetaData(d.rast)).*,
-		(ST_SummaryStats(d.rast)).*,
-		(ST_BandMetaData(d.rast)).*,
+		mda.*,
+		ssum.*,
+		bmd.*,
 		CASE
 			WHEN d.rid LIKE '4.%'
 				THEN ST_SameAlignment(ST_Transform(d.rast, 992163), r.rast)
 			ELSE NULL
 		END AS same_alignment
 	FROM raster_asraster_dst d
+		LEFT JOIN LATERAL ST_MetaData(d.rast) AS mda ON true
+		LEFT JOIN LATERAL ST_SummaryStats(d.rast) AS ssum ON true
+		LEFT JOIN LATERAL ST_BandMetaData(d.rast) AS bmd ON true
 	CROSS JOIN raster_asraster_rast r
 	ORDER BY d.rid
 ) foo;
diff --git a/raster/test/regress/rt_bandmetadata.sql b/raster/test/regress/rt_bandmetadata.sql
index ed9b852..3070ace 100644
--- a/raster/test/regress/rt_bandmetadata.sql
+++ b/raster/test/regress/rt_bandmetadata.sql
@@ -98,7 +98,7 @@ FROM ST_BandMetaData(
 );
 
 SELECT
-	bandnum
+	bandnum,
 	pixeltype,
 	round(nodatavalue::numeric, 3),
 	isoutdb,
@@ -110,7 +110,7 @@ FROM ST_BandMetaData(
 );
 
 SELECT
-	bandnum
+	bandnum,
 	pixeltype,
 	round(nodatavalue::numeric, 3),
 	isoutdb,
diff --git a/raster/test/regress/rt_bandmetadata_expected b/raster/test/regress/rt_bandmetadata_expected
index 8458aac..2047367 100644
--- a/raster/test/regress/rt_bandmetadata_expected
+++ b/raster/test/regress/rt_bandmetadata_expected
@@ -5,11 +5,11 @@
 8BUI|4.000|f||
 NOTICE:  Invalid band index: 6. Indices must be 1-based. Returning NULL
 ||||
-1|1.000|f||
-2|2.000|f||
-5|5.000|f||
-1|1.000|f||
-2|2.000|f||
-3|3.000|f||
-4|4.000|f||
-5|5.000|f||
+1|8BUI|1.000|f||
+2|8BUI|2.000|f||
+5|8BUI|5.000|f||
+1|8BUI|1.000|f||
+2|8BUI|2.000|f||
+3|8BUI|3.000|f||
+4|8BUI|4.000|f||
+5|8BUI|5.000|f||
diff --git a/raster/test/regress/rt_clip.sql b/raster/test/regress/rt_clip.sql
index d50eb31..bae2cb3 100644
--- a/raster/test/regress/rt_clip.sql
+++ b/raster/test/regress/rt_clip.sql
@@ -116,9 +116,11 @@ FROM (
 	SELECT  tid,
 	        rid,
 		gid,
-		(ST_Metadata(rast)).*,
-		(ST_BandMetadata(rast, 1)).*
+		md.*,
+		bmd.*
 	FROM raster_clip_out
+		LEFT JOIN LATERAL ST_Metadata(rast) AS md ON true
+		LEFT JOIN LATERAL ST_BandMetadata(rast, 1) AS bmd ON true
 ) AS r;
 
 -- Display the pixels and the values of the resulting rasters (raster 1)
@@ -130,8 +132,8 @@ SELECT
 	(gvxy).y,
 	(gvxy).val,
 	ST_AsText((gvxy).geom) geom
-FROM (SELECT tid, rid, gid, ST_PixelAsPolygons(rast) gvxy
-      FROM raster_clip_out
+FROM (SELECT tid, rid, gid, gvxy
+      FROM raster_clip_out, ST_PixelAsPolygons(rast) AS gvxy
       WHERE rid = 1
 ) foo
 ORDER BY 1, 2, 3, 4, 5, 7;
@@ -146,8 +148,9 @@ SELECT
 	(gvxy).y,
 	(gvxy).val,
 	ST_AsText((gvxy).geom) geom
-FROM (SELECT tid, rid, gid, band, ST_PixelAsPolygons(rast, band) gvxy
-      FROM raster_clip_out, generate_series(1, 3) band
+FROM (SELECT tid, rid, gid, band, gvxy
+      FROM raster_clip_out, generate_series(1, 3) band,
+				ST_PixelAsPolygons(rast, band) AS gvxy
       WHERE rid = 2
 ) foo
 ORDER BY 1, 2, 3, 4, 5, 6, 8;
diff --git a/raster/test/regress/rt_intersection.sql b/raster/test/regress/rt_intersection.sql
index 1dd9a48..8d86d0b 100644
--- a/raster/test/regress/rt_intersection.sql
+++ b/raster/test/regress/rt_intersection.sql
@@ -134,11 +134,13 @@ FROM (
 	SELECT
 		rid1,
 		rid2,
-		(ST_Metadata(rast)).*,
-		(ST_BandMetadata(rast, 1)).*,
+		md.*,
+		bmd.*,
 		ST_Value(rast, 1, 1, 1) AS firstvalue,
 		ST_Value(rast, 1, ST_Width(rast), ST_Height(rast)) AS lastvalue
 	FROM raster_intersection_out
+		LEFT JOIN LATERAL ST_Metadata(rast) AS md ON true
+		LEFT JOIN LATERAL ST_BandMetadata(rast,1) AS bmd ON true
 ) AS r;
 
 -- Display the pixels and the values of the resulting rasters
@@ -155,9 +157,10 @@ FROM (
 		rid1,
 		rid2,
 		band,
-		ST_PixelAsPolygons(rast, band) gvxy
+	 	gvxy
 	FROM raster_intersection_out
-	CROSS JOIN generate_series(1, 2) band
+	CROSS JOIN generate_series(1, 2) AS band
+	CROSS JOIN ST_PixelAsPolygons(rast, band) AS gvxy
 ) foo
 ORDER BY 1, 2, 3, 4, 5, 6, 7;
 
diff --git a/raster/test/regress/rt_mapalgebra_expected b/raster/test/regress/rt_mapalgebra_expected
index d669125..a7753a7 100644
--- a/raster/test/regress/rt_mapalgebra_expected
+++ b/raster/test/regress/rt_mapalgebra_expected
@@ -72,6 +72,7 @@ NOTICE:  userargs = {3.14}
 NOTICE:  All input rasters do not have bands at indicated indexes. Returning empty raster
 NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
+NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  value = {{{NULL,NULL,NULL},{NULL,200,200},{NULL,200,200}}}
 NOTICE:  pos = [0:1][1:2]={{1,1},{1,1}}
 NOTICE:  userargs = <NULL>
diff --git a/raster/test/regress/rt_mapalgebra_expr.sql b/raster/test/regress/rt_mapalgebra_expr.sql
index 419e917..240deb8 100644
--- a/raster/test/regress/rt_mapalgebra_expr.sql
+++ b/raster/test/regress/rt_mapalgebra_expr.sql
@@ -425,11 +425,13 @@ FROM (
 		rid1,
 		rid2,
 		extent,
-		(ST_Metadata(rast)).*,
-		(ST_BandMetadata(rast, 1)).*,
+		md.*,
+		bmd.*,
 		ST_Value(rast, 1, 1, 1) AS firstvalue,
 		ST_Value(rast, 1, ST_Width(rast), ST_Height(rast)) AS lastvalue
 	FROM raster_mapalgebra_out
+		LEFT JOIN LATERAL ST_Metadata(rast) AS md ON true
+		LEFT JOIN LATERAL ST_BandMetadata(rast, 1) AS bmd ON true
 ) AS r;
 
 DROP TABLE IF EXISTS raster_mapalgebra;
diff --git a/raster/test/regress/rt_mapalgebraexpr_2raster.sql b/raster/test/regress/rt_mapalgebraexpr_2raster.sql
index 3f0c416..58adc26 100644
--- a/raster/test/regress/rt_mapalgebraexpr_2raster.sql
+++ b/raster/test/regress/rt_mapalgebraexpr_2raster.sql
@@ -260,11 +260,13 @@ FROM (
 		rid1,
 		rid2,
 		extent,
-		(ST_Metadata(rast)).*,
-		(ST_BandMetadata(rast, 1)).*,
+		mda.*,
+		bmd.*,
 		ST_Value(rast, 1, 1, 1) AS firstvalue,
 		ST_Value(rast, 1, ST_Width(rast), ST_Height(rast)) AS lastvalue
 	FROM raster_mapalgebra_out
+		LEFT JOIN LATERAL ST_Metadata(rast) AS mda ON true
+		LEFT JOIN LATERAL ST_BandMetadata(rast, 1) AS bmd ON true
 ) AS r;
 
 DROP TABLE IF EXISTS raster_mapalgebra;
diff --git a/raster/test/regress/rt_mapalgebraexpr_2raster_expected b/raster/test/regress/rt_mapalgebraexpr_2raster_expected
index 3e3e6b4..5665de3 100644
--- a/raster/test/regress/rt_mapalgebraexpr_2raster_expected
+++ b/raster/test/regress/rt_mapalgebraexpr_2raster_expected
@@ -47,91 +47,69 @@ NOTICE:  The SECOND raster is NULL.  Returning NULL
 NOTICE:  The SECOND raster is NULL.  Returning NULL
 NOTICE:  The two rasters provided are NULL.  Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 0|1|INTERSECTION|0.000|0.000|2|2|1.000|1.000|0.000|0.000|0|1|32BF|0.000|1.000|1.000
diff --git a/raster/test/regress/rt_mapalgebrafct_2raster.sql b/raster/test/regress/rt_mapalgebrafct_2raster.sql
index 7e5fb97..1febc7b 100644
--- a/raster/test/regress/rt_mapalgebrafct_2raster.sql
+++ b/raster/test/regress/rt_mapalgebrafct_2raster.sql
@@ -328,11 +328,13 @@ FROM (
 		rid1,
 		rid2,
 		extent,
-		(ST_Metadata(rast)).*,
-		(ST_BandMetadata(rast, 1)).*,
+		mda.*,
+		bmd.*,
 		ST_Value(rast, 1, 1, 1) AS firstvalue,
 		ST_Value(rast, 1, ST_Width(rast), ST_Height(rast)) AS lastvalue
 	FROM raster_mapalgebra_out
+		LEFT JOIN LATERAL ST_Metadata(rast) AS mda ON true
+		LEFT JOIN LATERAL ST_BandMetadata(rast,1) AS bmd ON true
 ) AS r;
 
 DROP FUNCTION IF EXISTS raster_mapalgebra_intersection(double precision, double precision, int[], VARIADIC text[]);
diff --git a/raster/test/regress/rt_mapalgebrafct_2raster_expected b/raster/test/regress/rt_mapalgebrafct_2raster_expected
index a658252..b819327 100644
--- a/raster/test/regress/rt_mapalgebrafct_2raster_expected
+++ b/raster/test/regress/rt_mapalgebrafct_2raster_expected
@@ -65,91 +65,69 @@ NOTICE:  The SECOND raster is NULL.  Returning NULL
 NOTICE:  The SECOND raster is NULL.  Returning NULL
 NOTICE:  The two rasters provided are NULL.  Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Raster provided has no bands
-NOTICE:  Raster provided has no bands
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 NOTICE:  Could not find raster band of index 1 when getting pixel value. Returning NULL
 0|1|INTERSECTION|0.000|0.000|2|2|1.000|1.000|0.000|0.000|0|1|32BF|0.000|1.000|1.000

-----------------------------------------------------------------------

Summary of changes:
 NEWS                                               |   2 +
 raster/rt_pg/rtpg_band_properties.c                |  70 +++++---
 raster/rt_pg/rtpostgis.sql.in                      | 198 ++++++++++++---------
 raster/test/regress/rt_asraster.sql                |   9 +-
 raster/test/regress/rt_bandmetadata.sql            |   4 +-
 raster/test/regress/rt_bandmetadata_expected       |  16 +-
 raster/test/regress/rt_clip.sql                    |  15 +-
 raster/test/regress/rt_intersection.sql            |  11 +-
 raster/test/regress/rt_mapalgebra_expected         |   1 +
 raster/test/regress/rt_mapalgebra_expr.sql         |   6 +-
 raster/test/regress/rt_mapalgebraexpr_2raster.sql  |   6 +-
 .../regress/rt_mapalgebraexpr_2raster_expected     |  22 ---
 raster/test/regress/rt_mapalgebrafct_2raster.sql   |   6 +-
 .../test/regress/rt_mapalgebrafct_2raster_expected |  22 ---
 14 files changed, 204 insertions(+), 184 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list