[postgis-tickets] [SCM] PostGIS branch master updated. 3.1.0alpha2-77-g678f526

git at osgeo.org git at osgeo.org
Mon Oct 5 02:28:14 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  678f526670b6b1805495431e62f12072bb9485cf (commit)
      from  76b524544ccbaab6831f672ef1c56dd23d925996 (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 678f526670b6b1805495431e62f12072bb9485cf
Author: Raúl Marín <git at rmr.ninja>
Date:   Fri Oct 2 16:09:45 2020 +0200

    Ensure all functions using postgis_oid initialize the internal cache
    
    References #4739
    Closes https://github.com/postgis/postgis/pull/581

diff --git a/NEWS b/NEWS
index cb49fbb..c5eec4e 100644
--- a/NEWS
+++ b/NEWS
@@ -43,6 +43,7 @@ Only tickets not included in 3.1.0alpha2
     malformed WKB. Remove memory leaks in malformed WKB cases. (Paul Ramsey)
   - #4740, Round values in geography_distance_tree
            as we do on geography_distance (Raúl Marín, Paul Ramsey, Regina Obe)
+  - #4739, Ensure all functions using postgis_oid initialize the internal cache (Raúl Marín)
 
 
 
diff --git a/postgis/gserialized_estimate.c b/postgis/gserialized_estimate.c
index 56d0ab6..b5202d7 100644
--- a/postgis/gserialized_estimate.c
+++ b/postgis/gserialized_estimate.c
@@ -2300,6 +2300,9 @@ Datum gserialized_estimated_extent(PG_FUNCTION_ARGS)
 	bool only_parent = false;
 	int key_type;
 
+	/* We need to initialize the internal cache to access it later via postgis_oid() */
+	postgis_initialize_cache(fcinfo);
+
 	if ( PG_NARGS() == 4 )
 	{
 		nsp = text_to_cstring(PG_GETARG_TEXT_P(0));
@@ -2562,8 +2565,12 @@ Datum _postgis_gserialized_index_extent(PG_FUNCTION_ARGS)
 	int key_type;
 	Oid tbl_oid = PG_GETARG_DATUM(0);
 	text *col = PG_GETARG_TEXT_P(1);
+	Oid idx_oid;
+
+	/* We need to initialize the internal cache to access it later via postgis_oid() */
+	postgis_initialize_cache(fcinfo);
 
-	Oid idx_oid = table_get_spatial_index(tbl_oid, col, &key_type);
+	idx_oid = table_get_spatial_index(tbl_oid, col, &key_type);
 	if (!idx_oid)
 		PG_RETURN_NULL();
 
diff --git a/postgis/gserialized_spgist_2d.c b/postgis/gserialized_spgist_2d.c
index fc60e18..3957075 100644
--- a/postgis/gserialized_spgist_2d.c
+++ b/postgis/gserialized_spgist_2d.c
@@ -291,6 +291,7 @@ PGDLLEXPORT Datum gserialized_spgist_config_2d(PG_FUNCTION_ARGS)
 {
 	spgConfigOut *cfg = (spgConfigOut *)PG_GETARG_POINTER(1);
 	Oid boxoid = InvalidOid;
+	/* We need to initialize the internal cache to access it later via postgis_oid() */
 	postgis_initialize_cache(fcinfo);
 	boxoid = postgis_oid(BOX2DFOID);
 
diff --git a/postgis/gserialized_spgist_3d.c b/postgis/gserialized_spgist_3d.c
index b417baa..61953fa 100644
--- a/postgis/gserialized_spgist_3d.c
+++ b/postgis/gserialized_spgist_3d.c
@@ -374,6 +374,7 @@ PGDLLEXPORT Datum gserialized_spgist_config_3d(PG_FUNCTION_ARGS)
 	spgConfigOut *cfg = (spgConfigOut *)PG_GETARG_POINTER(1);
 
 	Oid boxoid = InvalidOid;
+	/* We need to initialize the internal cache to access it later via postgis_oid() */
 	postgis_initialize_cache(fcinfo);
 	boxoid = postgis_oid(BOX3DOID);
 
diff --git a/postgis/gserialized_supportfn.c b/postgis/gserialized_supportfn.c
index d783337..ce53816 100644
--- a/postgis/gserialized_supportfn.c
+++ b/postgis/gserialized_supportfn.c
@@ -279,6 +279,12 @@ Datum postgis_index_supportfn(PG_FUNCTION_ARGS)
 	Node *rawreq = (Node *) PG_GETARG_POINTER(0);
 	Node *ret = NULL;
 
+	/* The support function need the cache to be populated to know what the type Oids are.
+	 * Otherwise it will need look them up dynamically, which only works in the schema where Postgis
+	 * is installed is part of the search path (Trac #4739)
+	 */
+	postgis_initialize_cache(fcinfo);
+
 	if (IsA(rawreq, SupportRequestSelectivity))
 	{
 		SupportRequestSelectivity *req = (SupportRequestSelectivity *) rawreq;
diff --git a/postgis/lwgeom_out_geobuf.c b/postgis/lwgeom_out_geobuf.c
index e70f7f4..b8bc61e 100644
--- a/postgis/lwgeom_out_geobuf.c
+++ b/postgis/lwgeom_out_geobuf.c
@@ -52,6 +52,9 @@ Datum pgis_asgeobuf_transfn(PG_FUNCTION_ARGS)
 	MemoryContext aggcontext;
 	struct geobuf_agg_context *ctx;
 
+	/* We need to initialize the internal cache to access it later via postgis_oid() */
+	postgis_initialize_cache(fcinfo);
+
 	if (!AggCheckCallContext(fcinfo, &aggcontext))
 		elog(ERROR, "pgis_asgeobuf_transfn: called in non-aggregate context");
 	MemoryContextSwitchTo(aggcontext);
diff --git a/postgis/lwgeom_out_geojson.c b/postgis/lwgeom_out_geojson.c
index 0c24319..b1e6948 100644
--- a/postgis/lwgeom_out_geojson.c
+++ b/postgis/lwgeom_out_geojson.c
@@ -93,6 +93,7 @@ ST_AsGeoJsonRow(PG_FUNCTION_ARGS)
 	Oid geom_oid = InvalidOid;
 	Oid geog_oid = InvalidOid;
 
+	/* We need to initialize the internal cache to access it later via postgis_oid() */
 	postgis_initialize_cache(fcinfo);
 	geom_oid = postgis_oid(GEOMETRYOID);
 	geog_oid = postgis_oid(GEOGRAPHYOID);
diff --git a/postgis/lwgeom_out_mvt.c b/postgis/lwgeom_out_mvt.c
index 27efd3e..e4e71e5 100644
--- a/postgis/lwgeom_out_mvt.c
+++ b/postgis/lwgeom_out_mvt.c
@@ -132,6 +132,9 @@ Datum pgis_asmvt_transfn(PG_FUNCTION_ARGS)
 	MemoryContext aggcontext, old_context;
 	mvt_agg_context *ctx;
 
+	/* We need to initialize the internal cache to access it later via postgis_oid() */
+	postgis_initialize_cache(fcinfo);
+
 	if (!AggCheckCallContext(fcinfo, &aggcontext))
 		elog(ERROR, "%s called in non-aggregate context", __func__);
 

-----------------------------------------------------------------------

Summary of changes:
 NEWS                            | 1 +
 postgis/gserialized_estimate.c  | 9 ++++++++-
 postgis/gserialized_spgist_2d.c | 1 +
 postgis/gserialized_spgist_3d.c | 1 +
 postgis/gserialized_supportfn.c | 6 ++++++
 postgis/lwgeom_out_geobuf.c     | 3 +++
 postgis/lwgeom_out_geojson.c    | 1 +
 postgis/lwgeom_out_mvt.c        | 3 +++
 8 files changed, 24 insertions(+), 1 deletion(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list