From: Björn Harrtell Date: Wed, 26 Apr 2017 20:43:28 +0000 (+0000) Subject: Revert MemoryContext refactor X-Git-Tag: 2.4.0alpha~118 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8a771874cc4c4511def0a66c2f9e4e7b602eaf5b;p=postgis Revert MemoryContext refactor git-svn-id: http://svn.osgeo.org/postgis/trunk@15374 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/postgis/lwgeom_out_geobuf.c b/postgis/lwgeom_out_geobuf.c index 5d1cdcba1..30aaf5ee7 100644 --- a/postgis/lwgeom_out_geobuf.c +++ b/postgis/lwgeom_out_geobuf.c @@ -49,11 +49,12 @@ Datum pgis_asgeobuf_transfn(PG_FUNCTION_ARGS) lwerror("Missing libprotobuf-c"); PG_RETURN_NULL(); #else - MemoryContext aggcontext, oldcxt = NULL; + MemoryContext aggcontext; struct geobuf_agg_context *ctx; if (!AggCheckCallContext(fcinfo, &aggcontext)) - aggcontext = CurrentMemoryContext; + lwerror("pgis_asmvt_transfn: called in non-aggregate context"); + MemoryContextSwitchTo(aggcontext); if (PG_ARGISNULL(0)) { ctx = palloc(sizeof(*ctx)); @@ -62,7 +63,6 @@ Datum pgis_asgeobuf_transfn(PG_FUNCTION_ARGS) ctx->geom_name = text_to_cstring(PG_GETARG_TEXT_P(1)); geobuf_agg_init_context(ctx); } else { - oldcxt = MemoryContextSwitchTo(aggcontext); ctx = (struct geobuf_agg_context *) PG_GETARG_POINTER(0); } @@ -71,10 +71,6 @@ Datum pgis_asgeobuf_transfn(PG_FUNCTION_ARGS) ctx->row = PG_GETARG_HEAPTUPLEHEADER(2); geobuf_agg_transfn(ctx); - - if (oldcxt) - MemoryContextSwitchTo(oldcxt); - PG_RETURN_POINTER(ctx); #endif } diff --git a/postgis/lwgeom_out_mvt.c b/postgis/lwgeom_out_mvt.c index 562fe424e..b797773c8 100644 --- a/postgis/lwgeom_out_mvt.c +++ b/postgis/lwgeom_out_mvt.c @@ -79,11 +79,12 @@ Datum pgis_asmvt_transfn(PG_FUNCTION_ARGS) lwerror("Missing libprotobuf-c"); PG_RETURN_NULL(); #else - MemoryContext aggcontext, oldcxt = NULL; + MemoryContext aggcontext; struct mvt_agg_context *ctx; if (!AggCheckCallContext(fcinfo, &aggcontext)) - aggcontext = CurrentMemoryContext; + lwerror("pgis_asmvt_transfn: called in non-aggregate context"); + MemoryContextSwitchTo(aggcontext); if (PG_ARGISNULL(0)) { ctx = palloc(sizeof(*ctx)); @@ -100,7 +101,6 @@ Datum pgis_asmvt_transfn(PG_FUNCTION_ARGS) PG_FREE_IF_COPY(geom_name, 3); mvt_agg_init_context(ctx); } else { - oldcxt = MemoryContextSwitchTo(aggcontext); ctx = (struct mvt_agg_context *) PG_GETARG_POINTER(0); } @@ -109,11 +109,7 @@ Datum pgis_asmvt_transfn(PG_FUNCTION_ARGS) ctx->row = PG_GETARG_HEAPTUPLEHEADER(4); mvt_agg_transfn(ctx); - PG_FREE_IF_COPY(ctx->row, 4); - if (oldcxt) - MemoryContextSwitchTo(oldcxt); - PG_RETURN_POINTER(ctx); #endif }