[postgis-tickets] r17397 - Remove ST_Accum. Please use array_agg instead.

Darafei komzpa at gmail.com
Wed Apr 17 10:35:08 PDT 2019


Author: komzpa
Date: 2019-04-17 22:35:07 -0700 (Wed, 17 Apr 2019)
New Revision: 17397

Modified:
   trunk/NEWS
   trunk/doc/reference_accessor.xml
   trunk/doc/reference_constructor.xml
   trunk/doc/reference_processing.xml
   trunk/postgis/legacy.sql.in
   trunk/postgis/lwgeom_accum.c
   trunk/postgis/postgis.sql.in
   trunk/postgis/postgis_drop_after.sql
   trunk/postgis/postgis_legacy.c
   trunk/regress/core/cluster.sql
Log:
Remove ST_Accum. Please use array_agg instead.

Closes #4356
Closes https://github.com/postgis/postgis/pull/393


Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2019-04-17 06:31:04 UTC (rev 17396)
+++ trunk/NEWS	2019-04-18 05:35:07 UTC (rev 17397)
@@ -21,6 +21,7 @@
   - #4268, Bump minimum SFCGAL version to 1.3.1 (Darafei Praliaskouski)
   - #4331, ST_3DMakeBox now returns error instead of a miniscule box (Regina Obe)
   - #4342, Removed "versioned" variants of ST_AsGeoJSON and ST_AsKML (Paul Ramsey)
+  - #4356, ST_Accum removed. Use array_agg instead. (Darafei Praliaskouski)
 
 * New Features *
   - #2902, postgis_geos_noop (Sandro Santilli)

Modified: trunk/doc/reference_accessor.xml
===================================================================
--- trunk/doc/reference_accessor.xml	2019-04-17 06:31:04 UTC (rev 17396)
+++ trunk/doc/reference_accessor.xml	2019-04-18 05:35:07 UTC (rev 17397)
@@ -1588,7 +1588,7 @@
 --First 3 Rejects from a successful quintuplet experiment
 SELECT gid, ST_IsValidReason(the_geom) as validity_info
 FROM
-(SELECT ST_MakePolygon(ST_ExteriorRing(e.buff), ST_Accum(f.line)) As the_geom, gid
+(SELECT ST_MakePolygon(ST_ExteriorRing(e.buff), array_agg(f.line)) As the_geom, gid
 FROM (SELECT ST_Buffer(ST_MakePoint(x1*10,y1), z1) As buff, x1*10 + y1*100 + z1*1000 As gid
 	FROM generate_series(-4,6) x1
 	CROSS JOIN generate_series(2,5) y1
@@ -1676,7 +1676,7 @@
 --First 3 Rejects from a successful quintuplet experiment
 SELECT gid, reason(ST_IsValidDetail(the_geom)), ST_AsText(location(ST_IsValidDetail(the_geom))) as location
 FROM
-(SELECT ST_MakePolygon(ST_ExteriorRing(e.buff), ST_Accum(f.line)) As the_geom, gid
+(SELECT ST_MakePolygon(ST_ExteriorRing(e.buff), array_agg(f.line)) As the_geom, gid
 FROM (SELECT ST_Buffer(ST_MakePoint(x1*10,y1), z1) As buff, x1*10 + y1*100 + z1*1000 As gid
 	FROM generate_series(-4,6) x1
 	CROSS JOIN generate_series(2,5) y1

Modified: trunk/doc/reference_constructor.xml
===================================================================
--- trunk/doc/reference_constructor.xml	2019-04-17 06:31:04 UTC (rev 17396)
+++ trunk/doc/reference_constructor.xml	2019-04-18 05:35:07 UTC (rev 17397)
@@ -1551,7 +1551,7 @@
 				geometries must be closed LINESTRINGS. Comes in 2 variants.</para>
 			<para>Variant 1:  Takes one closed linestring.</para>
 			<para>Variant 2:  Creates a Polygon formed by the given shell and array of
-			holes. You can construct a geometry array using ST_Accum or the PostgreSQL ARRAY[] and
+			holes. You can construct a geometry array using the PostgreSQL array_agg, ARRAY[] and
 			ARRAY() constructs. Input geometries must be closed LINESTRINGS.</para>
 			<note>
 				<para>This function will not accept a MULTILINESTRING.  Use <xref linkend="ST_LineMerge" /> or <xref linkend="ST_Dump" /> to generate line strings.</para>
@@ -1604,7 +1604,6 @@
 		<para>Build province boundaries with holes
 		representing lakes in the province from a set of
 		province polygons/multipolygons and water linestrings.
-		This is an example of using PostGIS ST_Accum.
 		<note><para>The CASE construct is used because feeding a null array into
 		ST_MakePolygon results in NULL.</para></note>
 		<note><para>A left join is used to guarantee we get all provinces back even if they have no lakes.</para></note></para>
@@ -1611,8 +1610,8 @@
 		<programlisting>
 	SELECT p.gid, p.province_name,
 		CASE WHEN
-			ST_Accum(w.the_geom) IS NULL THEN p.the_geom
-		ELSE  ST_MakePolygon(ST_LineMerge(ST_Boundary(p.the_geom)), ST_Accum(w.the_geom)) END
+			array_agg(w.the_geom) IS NULL THEN p.the_geom
+		ELSE  ST_MakePolygon(ST_LineMerge(ST_Boundary(p.the_geom)), array_agg(w.the_geom)) END
 	FROM
 		provinces p LEFT JOIN waterlines w
 			ON (ST_Within(w.the_geom, p.the_geom) AND ST_IsClosed(w.the_geom))
@@ -1641,7 +1640,6 @@
 			<title>See Also</title>
 			<para>
 				<xref linkend="ST_Boundary" />,
-				<xref linkend="ST_Accum" />,
 				<xref linkend="ST_AddPoint" />,
 				<xref linkend="ST_GeometryType" />,
 				<xref linkend="ST_IsClosed" />,

Modified: trunk/doc/reference_processing.xml
===================================================================
--- trunk/doc/reference_processing.xml	2019-04-17 06:31:04 UTC (rev 17396)
+++ trunk/doc/reference_processing.xml	2019-04-18 05:35:07 UTC (rev 17397)
@@ -1,67 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 	<sect1 id="Geometry_Processing">
 		<title>Geometry Processing</title>
-
-	<refentry id="ST_Accum">
-	  <refnamediv>
-		<refname>ST_Accum</refname>
-
-		<refpurpose>An aggregate function to construct an array of geometries.</refpurpose>
-	  </refnamediv>
-
-	  <refsynopsisdiv>
-		<funcsynopsis>
-		  <funcprototype>
-			<funcdef>geometry[] <function>ST_Accum</function></funcdef>
-			<paramdef><type>geometry set</type> <parameter>geomfield</parameter></paramdef>
-		  </funcprototype>
-		</funcsynopsis>
-	  </refsynopsisdiv>
-
-	  <refsection>
-		<title>Description</title>
-
-		<para>An aggregate function to construct an array of geometries.</para>
-		<para>Enhanced: 2.0.0 support for Polyhedral surfaces, Triangles and TIN was introduced.</para>
-		<para>&Z_support;</para>
-		<para>&curve_support;</para>
-		<para>&P_support;</para>
-		<para>&T_support;</para>
-	  </refsection>
-
-
-	  <refsection>
-		<title>Examples</title>
-
-		<programlisting>SELECT (ST_Accum(the_geom)) As all_em, ST_AsText((ST_Accum(the_geom))[1]) As grabone,
-(ST_Accum(the_geom))[2:4] as grab_rest
-			FROM (SELECT ST_MakePoint(a*CAST(random()*10 As integer), a*CAST(random()*10 As integer), a*CAST(random()*10 As integer)) As the_geom
-				FROM generate_series(1,4) a) As foo;
-
-all_em|grabone   | grab_rest
-
--------------------------------------------------------------------------------+
-
- {0101000080000000000000144000000000000024400000000000001040:
- 0101000080000000000
-00018400000000000002C400000000000003040:
-0101000080000000000000354000000000000038400000000000001840:
-010100008000000000000040400000000000003C400000000000003040} |
- POINT(5 10) | {010100008000000000000018400000000000002C400000000000003040:
- 0101000080000000000000354000000000000038400000000000001840:
- 010100008000000000000040400000000000003C400000000000003040}
-(1 row)
-		</programlisting>
-	  </refsection>
-
-	  <!-- Optionally add a "See Also" section -->
-	  <refsection>
-		<title>See Also</title>
-
-		<para><xref linkend="ST_Collect" /></para>
-	  </refsection>
-	</refentry>
-
 		<refentry id="ST_Buffer">
 			<refnamediv>
 				<refname>ST_Buffer</refname>

Modified: trunk/postgis/legacy.sql.in
===================================================================
--- trunk/postgis/legacy.sql.in	2019-04-17 06:31:04 UTC (rev 17396)
+++ trunk/postgis/legacy.sql.in	2019-04-18 05:35:07 UTC (rev 17397)
@@ -2091,16 +2091,6 @@
 
 -- end Old underscored_names replaced by CamelCase names
 
-
---- Start Aggregates and supporting functions --
--- Deprecation in: 1.2.3
--- Changed: 2.5.0 use 'internal' stype
-CREATE AGGREGATE accum (
-	sfunc = pgis_geometry_accum_transfn,
-	basetype = geometry,
-	stype = internal,
-	finalfunc = pgis_geometry_accum_finalfn
-	);
 -- Deprecation in 1.2.3
 CREATE OR REPLACE FUNCTION collect(geometry, geometry)
 	RETURNS geometry

Modified: trunk/postgis/lwgeom_accum.c
===================================================================
--- trunk/postgis/lwgeom_accum.c	2019-04-17 06:31:04 UTC (rev 17396)
+++ trunk/postgis/lwgeom_accum.c	2019-04-18 05:35:07 UTC (rev 17397)
@@ -42,7 +42,6 @@
 Datum PGISDirectFunctionCall1(PGFunction func, Datum arg1);
 Datum PGISDirectFunctionCall2(PGFunction func, Datum arg1, Datum arg2);
 Datum pgis_geometry_accum_transfn(PG_FUNCTION_ARGS);
-Datum pgis_geometry_accum_finalfn(PG_FUNCTION_ARGS);
 Datum pgis_geometry_union_finalfn(PG_FUNCTION_ARGS);
 Datum pgis_geometry_collect_finalfn(PG_FUNCTION_ARGS);
 Datum pgis_geometry_polygonize_finalfn(PG_FUNCTION_ARGS);
@@ -176,27 +175,6 @@
 }
 
 /**
-** The "accum" final function just returns the geometry[]
-*/
-PG_FUNCTION_INFO_V1(pgis_geometry_accum_finalfn);
-Datum
-pgis_geometry_accum_finalfn(PG_FUNCTION_ARGS)
-{
-	pgis_abs *p;
-	Datum result = 0;
-
-	if (PG_ARGISNULL(0))
-		PG_RETURN_NULL();   /* returns null iff no input values */
-
-	p = (pgis_abs*) PG_GETARG_POINTER(0);
-
-	result = pgis_accum_finalfn(p, CurrentMemoryContext, fcinfo);
-
-	PG_RETURN_DATUM(result);
-
-}
-
-/**
 * The "union" final function passes the geometry[] to a union
 * conversion before returning the result.
 */

Modified: trunk/postgis/postgis.sql.in
===================================================================
--- trunk/postgis/postgis.sql.in	2019-04-17 06:31:04 UTC (rev 17396)
+++ trunk/postgis/postgis.sql.in	2019-04-18 05:35:07 UTC (rev 17397)
@@ -3822,13 +3822,6 @@
 
 -- Availability: 1.4.0
 -- Changed: 2.5.0 use 'internal' transfer type
-CREATE OR REPLACE FUNCTION pgis_geometry_accum_finalfn(internal)
-	RETURNS geometry[]
-	AS 'MODULE_PATHNAME'
-	LANGUAGE 'c' _PARALLEL;
-
--- Availability: 1.4.0
--- Changed: 2.5.0 use 'internal' transfer type
 CREATE OR REPLACE FUNCTION pgis_geometry_union_finalfn(internal)
 	RETURNS geometry
 	AS 'MODULE_PATHNAME'
@@ -3869,18 +3862,6 @@
 	AS 'MODULE_PATHNAME'
 	LANGUAGE 'c' _PARALLEL;
 
--- Availability: 1.2.2
--- Changed: 2.4.0 marked parallel safe
--- Changed: 2.5.0 use 'internal' stype
-CREATE AGGREGATE ST_Accum (geometry) (
-	sfunc = pgis_geometry_accum_transfn,
-	stype = internal,
-#if POSTGIS_PGSQL_VERSION >= 96
-	parallel = safe,
-#endif
-	finalfunc = pgis_geometry_accum_finalfn
-	);
-
 -- Availability: 1.4.0
 CREATE OR REPLACE FUNCTION ST_Union (geometry[])
 	RETURNS geometry

Modified: trunk/postgis/postgis_drop_after.sql
===================================================================
--- trunk/postgis/postgis_drop_after.sql	2019-04-17 06:31:04 UTC (rev 17396)
+++ trunk/postgis/postgis_drop_after.sql	2019-04-18 05:35:07 UTC (rev 17397)
@@ -27,6 +27,8 @@
 DROP AGGREGATE IF EXISTS st_geomunion(geometry);
 DROP AGGREGATE IF EXISTS accum_old(geometry);
 DROP AGGREGATE IF EXISTS st_accum_old(geometry);
+DROP AGGREGATE IF EXISTS st_accum(geometry); -- Dropped in 3.0.0
+DROP FUNCTION IF EXISTS pgis_geometry_accum_finalfn(internal);
 
 DROP AGGREGATE IF EXISTS st_astwkb_agg(geometry, integer); -- temporarely introduced before 2.2.0 final
 DROP AGGREGATE IF EXISTS st_astwkb_agg(geometry, integer, bigint); -- temporarely introduced before 2.2.0 final

Modified: trunk/postgis/postgis_legacy.c
===================================================================
--- trunk/postgis/postgis_legacy.c	2019-04-17 06:31:04 UTC (rev 17396)
+++ trunk/postgis/postgis_legacy.c	2019-04-18 05:35:07 UTC (rev 17397)
@@ -74,3 +74,4 @@
 POSTGIS_DEPRECATE("3.0.0", sfcgal_distance3d);
 POSTGIS_DEPRECATE("3.0.0", LWGEOM_mindistance3d);
 POSTGIS_DEPRECATE("3.0.0", intersects);
+POSTGIS_DEPRECATE("3.0.0", pgis_geometry_accum_finalfn);

Modified: trunk/regress/core/cluster.sql
===================================================================
--- trunk/regress/core/cluster.sql	2019-04-17 06:31:04 UTC (rev 17396)
+++ trunk/regress/core/cluster.sql	2019-04-18 05:35:07 UTC (rev 17397)
@@ -11,9 +11,9 @@
 (7, 'POLYGON ((0 0, 4 0, 4 4, 0 4, 0 0))');
 
 SELECT 't1', ST_AsText(unnest(ST_ClusterIntersecting(geom ORDER BY id))) FROM cluster_inputs;
-SELECT 't2', ST_AsText(unnest(ST_ClusterIntersecting(ST_Accum(geom ORDER BY id)))) FROM cluster_inputs;
+SELECT 't2', ST_AsText(unnest(ST_ClusterIntersecting(array_agg(geom ORDER BY id)))) FROM cluster_inputs;
 SELECT 't3', ST_AsText(unnest(ST_ClusterWithin(geom, 1.4 ORDER BY id))) FROM cluster_inputs;
-SELECT 't4', ST_AsText(unnest(ST_ClusterWithin(ST_Accum(geom ORDER BY id), 1.5))) FROM cluster_inputs;
+SELECT 't4', ST_AsText(unnest(ST_ClusterWithin(array_agg(geom ORDER BY id), 1.5))) FROM cluster_inputs;
 
 -- tests for ST_DBSCAN
 



More information about the postgis-tickets mailing list