From: Darafei Praliaskouski Date: Sun, 21 Apr 2019 15:52:00 +0000 (+0000) Subject: Call POSTGIS2GEOS in aggregate context. X-Git-Tag: 3.0.0alpha1~37 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8ec8231004013f4a9fc200b71a3b55037000f182;p=postgis Call POSTGIS2GEOS in aggregate context. References #4382 git-svn-id: http://svn.osgeo.org/postgis/trunk@17405 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/postgis/lwgeom_geos.c b/postgis/lwgeom_geos.c index 0e265c424..8071b58ae 100644 --- a/postgis/lwgeom_geos.c +++ b/postgis/lwgeom_geos.c @@ -572,6 +572,7 @@ Datum pgis_geometry_union_transfn(PG_FUNCTION_ARGS) if (!gserialized_is_empty(gser_in)) { + MemoryContext old = MemoryContextSwitchTo(aggcontext); if (state->ngeoms == 0) { state->srid = gserialized_get_srid(gser_in); @@ -592,13 +593,12 @@ Datum pgis_geometry_union_transfn(PG_FUNCTION_ARGS) if (state->ngeoms > state->alen) { - MemoryContext old = MemoryContextSwitchTo(aggcontext); state->alen *= 2; state->geoms = repalloc(state->geoms, state->alen); - MemoryContextSwitchTo(old); } state->geoms[curgeom] = g; + MemoryContextSwitchTo(old); } else {