]> granicus.if.org Git - postgis/commitdiff
Remove ST_Accum. Please use array_agg instead.
authorDarafei Praliaskouski <me@komzpa.net>
Thu, 18 Apr 2019 05:35:07 +0000 (05:35 +0000)
committerDarafei Praliaskouski <me@komzpa.net>
Thu, 18 Apr 2019 05:35:07 +0000 (05:35 +0000)
Closes #4356
Closes https://github.com/postgis/postgis/pull/393

git-svn-id: http://svn.osgeo.org/postgis/trunk@17397 b70326c6-7e19-0410-871a-916f4a2858ee

NEWS
doc/reference_accessor.xml
doc/reference_constructor.xml
doc/reference_processing.xml
postgis/legacy.sql.in
postgis/lwgeom_accum.c
postgis/postgis.sql.in
postgis/postgis_drop_after.sql
postgis/postgis_legacy.c
regress/core/cluster.sql

diff --git a/NEWS b/NEWS
index 13aba984b48ebb9cd4d642626006860ea170f18c..5e8daa9d2cd45daa9f70c422ac58601e0b982478 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -21,6 +21,7 @@ PostGIS 3.0.0
   - #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)
index 65a125fe482fb5f73854154136b60d72f948d928..9dccc6a93619ac8ab5267f786ef36923d3df9062 100644 (file)
@@ -1588,7 +1588,7 @@ Allowed <varname>flags</varname> are documented in <xref linkend="ST_IsValidDeta
 --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 @@ The 'flags' argument is a bitfield. It can have the following values:
 --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
index 210ef93fc1b7e7c09af9963868e21518386d515a..0dc6254475c524683fe82bfb0443eba5bca23d98 100644 (file)
@@ -1551,7 +1551,7 @@ POLYGON((10 10, 10 11, 11 11, 11 10, 10 10))
                                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,15 +1604,14 @@ FROM
                <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>
                <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 @@ FROM
                        <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" />,
index 7adddcb1aaa789552a14724b3d6cd461b8e56f93..8d5541aa07c4548fec3000d1efffca8b1c4fa31d 100644 (file)
@@ -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>
index 985f8217eff3320336aff9c743a8b3a4537ca38f..6a720dda03566a5f885bd53587dff3c25e98c729 100644 (file)
@@ -2091,16 +2091,6 @@ CREATE OR REPLACE FUNCTION ST_distance_sphere(geom1 geometry, geom2 geometry)
 
 -- 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
index db7ccd3fe772a0712d19f7885a494677adcbacef..ad28228f822033cb2396198934434c0b4a1329ac 100644 (file)
@@ -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);
@@ -175,27 +174,6 @@ pgis_accum_finalfn(pgis_abs *p, MemoryContext mctx, __attribute__((__unused__))
        return result;
 }
 
-/**
-** 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.
index 4133362c420f91408eb7d84f52e6467f50de90e8..586036999a84dc9c8cbd25568ae54502684bd6c6 100644 (file)
@@ -3820,13 +3820,6 @@ CREATE OR REPLACE FUNCTION pgis_geometry_accum_transfn(internal, geometry, float
        AS 'MODULE_PATHNAME'
        LANGUAGE 'c' _PARALLEL;
 
--- 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)
@@ -3869,18 +3862,6 @@ CREATE OR REPLACE FUNCTION pgis_geometry_makeline_finalfn(internal)
        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
index 90079f9eb0c564bce62332b5d0df828d917b89fb..b62dd2372651663aef8a41739e052a93e454dc2f 100644 (file)
@@ -27,6 +27,8 @@ DROP AGGREGATE IF EXISTS collect(geometry); -- Deprecated in 1.2.3, Dropped in 2
 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
index 429012de70ce5c5596f3c84a5d76ea8a0d4d4bc0..d5cc9ef567703e5b19651cfe4c9f13bec5745bac 100644 (file)
@@ -74,3 +74,4 @@ POSTGIS_DEPRECATE("3.0.0", distance3d);
 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);
index 006d59598b02819d7f7dba9520ec83a3549773da..d8ed0a89defaa16cc8d9957cfd9cb127f3ead290 100644 (file)
@@ -11,9 +11,9 @@ INSERT INTO cluster_inputs VALUES
 (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