PostGIS  2.5.7dev-r@@SVN_REVISION@@
lwgeom_accum.c File Reference

Versions of PostgreSQL < 8.4 perform array accumulation internally using pass by value, which is very slow working with large/many geometries. More...

#include "postgres.h"
#include "fmgr.h"
#include "funcapi.h"
#include "access/tupmacs.h"
#include "utils/datum.h"
#include "utils/array.h"
#include "utils/lsyscache.h"
#include "../postgis_config.h"
#include "liblwgeom.h"
#include "lwgeom_geos.h"
#include "lwgeom_pg.h"
#include "lwgeom_transform.h"
Include dependency graph for lwgeom_accum.c:

Go to the source code of this file.

Data Structures

struct  pgis_abs
 To pass the internal ArrayBuildState pointer between the transfn and finalfn we need to wrap it into a custom type first, the pgis_abs type in our case. More...
 

Functions

Datum PGISDirectFunctionCall1 (PGFunction func, Datum arg1)
 A modified version of PostgreSQL's DirectFunctionCall1 which allows NULL results; this is required for aggregates that return NULL. More...
 
Datum PGISDirectFunctionCall2 (PGFunction func, Datum arg1, Datum arg2)
 A modified version of PostgreSQL's DirectFunctionCall2 which allows NULL results; this is required for aggregates that return NULL. More...
 
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)
 
Datum pgis_geometry_makeline_finalfn (PG_FUNCTION_ARGS)
 
Datum pgis_geometry_clusterintersecting_finalfn (PG_FUNCTION_ARGS)
 
Datum pgis_geometry_clusterwithin_finalfn (PG_FUNCTION_ARGS)
 
Datum pgis_abs_in (PG_FUNCTION_ARGS)
 Putting pgis_abs back for ABI compatibility with 2.4 and below TODO: Drop when 3.0 rolls around. More...
 
Datum pgis_abs_out (PG_FUNCTION_ARGS)
 
 PG_FUNCTION_INFO_V1 (pgis_abs_in)
 Putting back pgis_* for ABI compatibility to smooth pg_upgrade TODO: Drop when 3.0 rolls around. More...
 
 PG_FUNCTION_INFO_V1 (pgis_abs_out)
 
Datum pgis_union_geometry_array (PG_FUNCTION_ARGS)
 
Datum LWGEOM_collect_garray (PG_FUNCTION_ARGS)
 
Datum polygonize_garray (PG_FUNCTION_ARGS)
 
Datum clusterintersecting_garray (PG_FUNCTION_ARGS)
 
Datum cluster_within_distance_garray (PG_FUNCTION_ARGS)
 
Datum LWGEOM_makeline_garray (PG_FUNCTION_ARGS)
 
 PG_FUNCTION_INFO_V1 (pgis_geometry_accum_transfn)
 The transfer function hooks into the PostgreSQL accumArrayResult() function (present since 8.0) to build an array in a side memory context. More...
 
Datum pgis_accum_finalfn (pgis_abs *p, MemoryContext mctx, FunctionCallInfo fcinfo)
 
Datum pgis_accum_finalfn (pgis_abs *p, MemoryContext mctx, __attribute__((__unused__)) FunctionCallInfo fcinfo)
 The final function rescues the built array from the side memory context using the PostgreSQL built-in function makeMdArrayResult. More...
 
 PG_FUNCTION_INFO_V1 (pgis_geometry_accum_finalfn)
 The "accum" final function just returns the geometry[]. More...
 
 PG_FUNCTION_INFO_V1 (pgis_geometry_union_finalfn)
 The "union" final function passes the geometry[] to a union conversion before returning the result. More...
 
 PG_FUNCTION_INFO_V1 (pgis_geometry_collect_finalfn)
 The "collect" final function passes the geometry[] to a geometrycollection conversion before returning the result. More...
 
 PG_FUNCTION_INFO_V1 (pgis_geometry_polygonize_finalfn)
 The "polygonize" final function passes the geometry[] to a polygonization before returning the result. More...
 
 PG_FUNCTION_INFO_V1 (pgis_geometry_makeline_finalfn)
 The "makeline" final function passes the geometry[] to a line builder before returning the result. More...
 
 PG_FUNCTION_INFO_V1 (pgis_geometry_clusterintersecting_finalfn)
 The "clusterintersecting" final function passes the geometry[] to a clustering function before returning the result. More...
 
 PG_FUNCTION_INFO_V1 (pgis_geometry_clusterwithin_finalfn)
 The "cluster_within_distance" final function passes the geometry[] to a clustering function before returning the result. More...
 

Detailed Description

Versions of PostgreSQL < 8.4 perform array accumulation internally using pass by value, which is very slow working with large/many geometries.

Hence PostGIS currently implements its own aggregate for building geometry arrays using pass by reference, which is significantly faster and similar to the method used in PostgreSQL 8.4.

Hence we can revert this to the original aggregate functions from 1.3 at whatever point PostgreSQL 8.4 becomes the minimum version we support :)

Definition in file lwgeom_accum.c.