[postgis-tickets] [SCM] PostGIS branch master updated. 3.1.0alpha1-102-g10c405f
git at osgeo.org
git at osgeo.org
Mon May 4 09:19:36 PDT 2020
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "PostGIS".
The branch, master has been updated
via 10c405f3faa48485354be22dc648daafb5a0b3f4 (commit)
from 943cda089b3dd74b68c805cb935cb00f4a044e43 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 10c405f3faa48485354be22dc648daafb5a0b3f4
Author: Raúl Marín <git at rmr.ninja>
Date: Mon May 4 12:37:33 2020 +0200
Revert "Internal cache now persists until the end of the transaction"
This reverts commit 3ced96fc1a79831a26c33311a17d1f32e3c5c732.
References #4674
Closes https://github.com/postgis/postgis/pull/560
diff --git a/NEWS b/NEWS
index 5f62cb1..a7a0886 100644
--- a/NEWS
+++ b/NEWS
@@ -4,7 +4,7 @@ PostGIS 3.1.0XXXX
Only tickets not included in 3.1.0alpha1
* Breaking changes *
- - #4674, Internal cache now persists until the end of the transaction (Raúl Marín)
+ -
* New features *
- #4656, Cast a geojson_text::geometry for implicit GeoJSON ingestion (Raúl Marín)
diff --git a/libpgcommon/lwgeom_cache.c b/libpgcommon/lwgeom_cache.c
index d505021..6ca313b 100644
--- a/libpgcommon/lwgeom_cache.c
+++ b/libpgcommon/lwgeom_cache.c
@@ -62,23 +62,13 @@ typedef struct {
/**
* Utility function to read the upper memory context off a function call
* info data.
- * This used to return flinfo->fn_mcxt (the function memory context) but that has the issue
- * that is cleaned up once the function is finished, which on pure SQL functions (like ST_AsGML(geometry))
- * is an issue as the cache will die after every _ST_AsGML call (thus being worthless).
- * Instead we use CurTransactionContext which will live until the end of the transaction
*/
MemoryContext
PostgisCacheContext(FunctionCallInfo fcinfo)
{
- return CurTransactionContext;
-}
-
-static GenericCacheCollection *internal_cache = NULL;
-
-static void
-PostgisResetInternalCache(void *v)
-{
- internal_cache = NULL;
+ if (!fcinfo->flinfo)
+ elog(ERROR, "%s: Could not find upper context", __func__);
+ return fcinfo->flinfo->fn_mcxt;
}
/**
@@ -88,18 +78,17 @@ PostgisResetInternalCache(void *v)
static GenericCacheCollection *
GetGenericCacheCollection(FunctionCallInfo fcinfo)
{
+ GenericCacheCollection *internal_cache;
+ if (!fcinfo->flinfo)
+ elog(ERROR, "%s: Could not find upper context", __func__);
+
+ internal_cache = fcinfo->flinfo->fn_extra;
+
if (!internal_cache)
{
- internal_cache = MemoryContextAlloc(PostgisCacheContext(fcinfo), sizeof(GenericCacheCollection));
- memset(internal_cache, 0, sizeof(GenericCacheCollection));
-
- MemoryContextCallback *cb =
- MemoryContextAlloc(PostgisCacheContext(fcinfo), sizeof(MemoryContextCallback));
- cb->func = PostgisResetInternalCache;
- cb->arg = NULL;
- MemoryContextRegisterResetCallback(PostgisCacheContext(fcinfo), cb);
+ internal_cache = MemoryContextAllocZero(PostgisCacheContext(fcinfo), sizeof(GenericCacheCollection));
+ fcinfo->flinfo->fn_extra = internal_cache;
}
-
return internal_cache;
}
diff --git a/postgis/lwgeom_inout.c b/postgis/lwgeom_inout.c
index 0757de0..8ce752d 100644
--- a/postgis/lwgeom_inout.c
+++ b/postgis/lwgeom_inout.c
@@ -658,8 +658,10 @@ Datum parse_WKT_lwgeom(PG_FUNCTION_ARGS)
/* Unwrap the PgSQL text type into a cstring */
wkt = text_to_cstring(wkt_text);
- /* Now we call over to the geometry_in function */
- result = DirectFunctionCall1(LWGEOM_in, CStringGetDatum(wkt));
+ /* Now we call over to the geometry_in function
+ * We need to initialize the fcinfo since cache might be used
+ */
+ result = CallerFInfoFunctionCall1(LWGEOM_in, fcinfo->flinfo, InvalidOid, CStringGetDatum(wkt));
/* Return null on null */
if ( ! result )
-----------------------------------------------------------------------
Summary of changes:
NEWS | 2 +-
libpgcommon/lwgeom_cache.c | 33 +++++++++++----------------------
postgis/lwgeom_inout.c | 6 ++++--
3 files changed, 16 insertions(+), 25 deletions(-)
hooks/post-receive
--
PostGIS
More information about the postgis-tickets
mailing list