]> granicus.if.org Git - postgis/commitdiff
Revert MemoryContext refactor
authorBjörn Harrtell <bjorn@wololo.org>
Wed, 26 Apr 2017 20:43:28 +0000 (20:43 +0000)
committerBjörn Harrtell <bjorn@wololo.org>
Wed, 26 Apr 2017 20:43:28 +0000 (20:43 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@15374 b70326c6-7e19-0410-871a-916f4a2858ee

postgis/lwgeom_out_geobuf.c
postgis/lwgeom_out_mvt.c

index 5d1cdcba170dd8f1ecda16a727259f8a7f4e52c4..30aaf5ee757dd36f86f525f279eb7a9ca3ab77e8 100644 (file)
@@ -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
 }
index 562fe424e0fe0b4d6c3f4b2157ce78355580deb8..b797773c83f466f3e02bbeda480b02be94585a61 100644 (file)
@@ -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
 }