[postgis-tickets] r17223 - PostgreSQL 12 compatibility
Raul
raul at rmr.ninja
Thu Jan 31 07:47:33 PST 2019
Author: algunenano
Date: 2019-01-31 07:47:33 -0800 (Thu, 31 Jan 2019)
New Revision: 17223
Modified:
trunk/NEWS
trunk/libpgcommon/lwgeom_cache.c
trunk/libpgcommon/lwgeom_cache.h
trunk/postgis/geography_measurement_trees.c
trunk/postgis/geography_measurement_trees.h
trunk/postgis/gserialized_estimate.c
trunk/postgis/lwgeom_accum.c
trunk/postgis/lwgeom_geos_prepared.c
trunk/postgis/lwgeom_geos_prepared.h
trunk/postgis/lwgeom_rectree.c
trunk/postgis/lwgeom_rtree.c
trunk/postgis/lwgeom_rtree.h
trunk/raster/rt_pg/rtpg_mapalgebra.c
Log:
PostgreSQL 12 compatibility
Initial patch by Laurenz Albe
References #4313
Modified: trunk/NEWS
===================================================================
--- trunk/NEWS 2019-01-30 19:36:30 UTC (rev 17222)
+++ trunk/NEWS 2019-01-31 15:47:33 UTC (rev 17223)
@@ -67,6 +67,7 @@
- #4296, Use `server_version_num` instead of parsing `version()` (Raúl Marín)
- #4272, Improve notice message when unable to compute stats (Raúl Marín)
- #4314, ST_ClipByBox2D: Do not throw when the geometry is invalid (Raúl Marín)
+ - #4313, #4307, PostgreSQL 12 compatibility (Laurenz Albe, Raúl Marín)
PostGIS 2.5.0
Modified: trunk/libpgcommon/lwgeom_cache.c
===================================================================
--- trunk/libpgcommon/lwgeom_cache.c 2019-01-30 19:36:30 UTC (rev 17222)
+++ trunk/libpgcommon/lwgeom_cache.c 2019-01-31 15:47:33 UTC (rev 17223)
@@ -52,7 +52,7 @@
* info data.
*/
static MemoryContext
-FIContext(FunctionCallInfoData* fcinfo)
+FIContext(FunctionCallInfo fcinfo)
{
return fcinfo->flinfo->fn_mcxt;
}
@@ -61,8 +61,8 @@
* Get the generic collection off the statement, allocate a
* new one if we don't have one already.
*/
-static GenericCacheCollection*
-GetGenericCacheCollection(FunctionCallInfoData* fcinfo)
+static GenericCacheCollection *
+GetGenericCacheCollection(FunctionCallInfo fcinfo)
{
GenericCacheCollection* cache = fcinfo->flinfo->fn_extra;
@@ -80,8 +80,8 @@
* Get the Proj4 entry from the generic cache if one exists.
* If it doesn't exist, make a new empty one and return it.
*/
-PROJ4PortalCache*
-GetPROJ4SRSCache(FunctionCallInfoData* fcinfo)
+PROJ4PortalCache *
+GetPROJ4SRSCache(FunctionCallInfo fcinfo)
{
GenericCacheCollection* generic_cache = GetGenericCacheCollection(fcinfo);
PROJ4PortalCache* cache = (PROJ4PortalCache*)(generic_cache->entry[PROJ_CACHE_ENTRY]);
@@ -120,8 +120,11 @@
* Returns a cache pointer if there is a cache hit and we have an
* index built and ready to use. Returns NULL otherwise.
*/
-GeomCache*
-GetGeomCache(FunctionCallInfoData* fcinfo, const GeomCacheMethods* cache_methods, const GSERIALIZED* g1, const GSERIALIZED* g2)
+GeomCache *
+GetGeomCache(FunctionCallInfo fcinfo,
+ const GeomCacheMethods *cache_methods,
+ const GSERIALIZED *g1,
+ const GSERIALIZED *g2)
{
GeomCache* cache;
int cache_hit = 0;
Modified: trunk/libpgcommon/lwgeom_cache.h
===================================================================
--- trunk/libpgcommon/lwgeom_cache.h 2019-01-30 19:36:30 UTC (rev 17222)
+++ trunk/libpgcommon/lwgeom_cache.h 2019-01-31 15:47:33 UTC (rev 17223)
@@ -103,7 +103,10 @@
/*
* Cache retrieval functions
*/
-PROJ4PortalCache* GetPROJ4SRSCache(FunctionCallInfoData *fcinfo);
-GeomCache* GetGeomCache(FunctionCallInfoData *fcinfo, const GeomCacheMethods* cache_methods, const GSERIALIZED* g1, const GSERIALIZED* g2);
+PROJ4PortalCache *GetPROJ4SRSCache(FunctionCallInfo fcinfo);
+GeomCache *GetGeomCache(FunctionCallInfo fcinfo,
+ const GeomCacheMethods *cache_methods,
+ const GSERIALIZED *g1,
+ const GSERIALIZED *g2);
#endif /* LWGEOM_CACHE_H_ */
Modified: trunk/postgis/geography_measurement_trees.c
===================================================================
--- trunk/postgis/geography_measurement_trees.c 2019-01-30 19:36:30 UTC (rev 17222)
+++ trunk/postgis/geography_measurement_trees.c 2019-01-31 15:47:33 UTC (rev 17223)
@@ -89,8 +89,8 @@
CircTreeAllocator
};
-static CircTreeGeomCache*
-GetCircTreeGeomCache(FunctionCallInfoData* fcinfo, const GSERIALIZED* g1, const GSERIALIZED* g2)
+static CircTreeGeomCache *
+GetCircTreeGeomCache(FunctionCallInfo fcinfo, const GSERIALIZED *g1, const GSERIALIZED *g2)
{
return (CircTreeGeomCache*)GetGeomCache(fcinfo, &CircTreeCacheMethods, g1, g2);
}
@@ -151,9 +151,13 @@
}
}
-
static int
-geography_distance_cache_tolerance(FunctionCallInfoData* fcinfo, const GSERIALIZED* g1, const GSERIALIZED* g2, const SPHEROID* s, double tolerance, double* distance)
+geography_distance_cache_tolerance(FunctionCallInfo fcinfo,
+ const GSERIALIZED *g1,
+ const GSERIALIZED *g2,
+ const SPHEROID *s,
+ double tolerance,
+ double *distance)
{
CircTreeGeomCache* tree_cache = NULL;
@@ -242,15 +246,23 @@
}
}
-
int
-geography_distance_cache(FunctionCallInfoData* fcinfo, const GSERIALIZED* g1, const GSERIALIZED* g2, const SPHEROID* s, double* distance)
+geography_distance_cache(FunctionCallInfo fcinfo,
+ const GSERIALIZED *g1,
+ const GSERIALIZED *g2,
+ const SPHEROID *s,
+ double *distance)
{
return geography_distance_cache_tolerance(fcinfo, g1, g2, s, FP_TOLERANCE, distance);
}
int
-geography_dwithin_cache(FunctionCallInfoData* fcinfo, const GSERIALIZED* g1, const GSERIALIZED* g2, const SPHEROID* s, double tolerance, int* dwithin)
+geography_dwithin_cache(FunctionCallInfo fcinfo,
+ const GSERIALIZED *g1,
+ const GSERIALIZED *g2,
+ const SPHEROID *s,
+ double tolerance,
+ int *dwithin)
{
double distance;
/* Ticket #2422, difference between sphere and spheroid distance can trip up the */
Modified: trunk/postgis/geography_measurement_trees.h
===================================================================
--- trunk/postgis/geography_measurement_trees.h 2019-01-30 19:36:30 UTC (rev 17222)
+++ trunk/postgis/geography_measurement_trees.h 2019-01-31 15:47:33 UTC (rev 17223)
@@ -26,6 +26,15 @@
#include "lwgeodetic_tree.h"
#include "lwgeom_cache.h"
-int geography_dwithin_cache(FunctionCallInfoData* fcinfo, const GSERIALIZED* g1, const GSERIALIZED* g2, const SPHEROID* s, double tolerance, int* dwithin);
-int geography_distance_cache(FunctionCallInfoData* fcinfo, const GSERIALIZED* g1, const GSERIALIZED* g2, const SPHEROID* s, double* distance);
+int geography_dwithin_cache(FunctionCallInfo fcinfo,
+ const GSERIALIZED *g1,
+ const GSERIALIZED *g2,
+ const SPHEROID *s,
+ double tolerance,
+ int *dwithin);
+int geography_distance_cache(FunctionCallInfo fcinfo,
+ const GSERIALIZED *g1,
+ const GSERIALIZED *g2,
+ const SPHEROID *s,
+ double *distance);
int geography_tree_distance(const GSERIALIZED* g1, const GSERIALIZED* g2, const SPHEROID* s, double tolerance, double* distance);
Modified: trunk/postgis/gserialized_estimate.c
===================================================================
--- trunk/postgis/gserialized_estimate.c 2019-01-30 19:36:30 UTC (rev 17222)
+++ trunk/postgis/gserialized_estimate.c 2019-01-31 15:47:33 UTC (rev 17223)
@@ -90,7 +90,11 @@
#include "executor/spi.h"
#include "fmgr.h"
#include "commands/vacuum.h"
+#if PG_VERSION_NUM < 120000
#include "nodes/relation.h"
+#else
+#include "nodes/pathnodes.h"
+#endif
#include "parser/parsetree.h"
#include "utils/array.h"
#include "utils/lsyscache.h"
Modified: trunk/postgis/lwgeom_accum.c
===================================================================
--- trunk/postgis/lwgeom_accum.c 2019-01-30 19:36:30 UTC (rev 17222)
+++ trunk/postgis/lwgeom_accum.c 2019-01-31 15:47:33 UTC (rev 17223)
@@ -359,6 +359,7 @@
Datum
PGISDirectFunctionCall1(PGFunction func, Datum arg1)
{
+#if POSTGIS_PGSQL_VERSION < 120
FunctionCallInfoData fcinfo;
Datum result;
@@ -376,6 +377,23 @@
return (Datum) 0;
return result;
+#else
+ LOCAL_FCINFO(fcinfo, 1);
+ Datum result;
+
+ InitFunctionCallInfoData(*fcinfo, NULL, 1, InvalidOid, NULL, NULL);
+
+ fcinfo->args[0].value = arg1;
+ fcinfo->args[0].isnull = false;
+
+ result = (*func)(fcinfo);
+
+ /* Check for null result, returning a "NULL" Datum if indicated */
+ if (fcinfo->isnull)
+ return (Datum)0;
+
+ return result;
+#endif /* POSTGIS_PGSQL_VERSION < 120 */
}
/**
@@ -385,17 +403,12 @@
Datum
PGISDirectFunctionCall2(PGFunction func, Datum arg1, Datum arg2)
{
+#if POSTGIS_PGSQL_VERSION < 120
FunctionCallInfoData fcinfo;
Datum result;
-#if POSTGIS_PGSQL_VERSION > 90
-
InitFunctionCallInfoData(fcinfo, NULL, 2, InvalidOid, NULL, NULL);
-#else
- InitFunctionCallInfoData(fcinfo, NULL, 2, NULL, NULL);
-#endif
-
fcinfo.arg[0] = arg1;
fcinfo.arg[1] = arg2;
fcinfo.argnull[0] = false;
@@ -408,4 +421,23 @@
return (Datum) 0;
return result;
+#else
+ LOCAL_FCINFO(fcinfo, 2);
+ Datum result;
+
+ InitFunctionCallInfoData(*fcinfo, NULL, 2, InvalidOid, NULL, NULL);
+
+ fcinfo->args[0].value = arg1;
+ fcinfo->args[1].value = arg2;
+ fcinfo->args[0].isnull = false;
+ fcinfo->args[1].isnull = false;
+
+ result = (*func)(fcinfo);
+
+ /* Check for null result, returning a "NULL" Datum if indicated */
+ if (fcinfo->isnull)
+ return (Datum)0;
+
+ return result;
+#endif /* POSTGIS_PGSQL_VERSION < 120 */
}
Modified: trunk/postgis/lwgeom_geos_prepared.c
===================================================================
--- trunk/postgis/lwgeom_geos_prepared.c 2019-01-30 19:36:30 UTC (rev 17222)
+++ trunk/postgis/lwgeom_geos_prepared.c 2019-01-31 15:47:33 UTC (rev 17223)
@@ -458,8 +458,8 @@
* and freeing the GEOS PreparedGeometry structures
* we need for this particular caching strategy.
*/
-PrepGeomCache*
-GetPrepGeomCache(FunctionCallInfoData* fcinfo, GSERIALIZED* g1, GSERIALIZED* g2)
+PrepGeomCache *
+GetPrepGeomCache(FunctionCallInfo fcinfo, GSERIALIZED *g1, GSERIALIZED *g2)
{
return (PrepGeomCache*)GetGeomCache(fcinfo, &PrepGeomCacheMethods, g1, g2);
}
Modified: trunk/postgis/lwgeom_geos_prepared.h
===================================================================
--- trunk/postgis/lwgeom_geos_prepared.h 2019-01-30 19:36:30 UTC (rev 17222)
+++ trunk/postgis/lwgeom_geos_prepared.h 2019-01-31 15:47:33 UTC (rev 17223)
@@ -70,6 +70,6 @@
** If you are only caching one argument (e.g., in contains) supply 0 as the
** value for pg_geom2.
*/
-PrepGeomCache *GetPrepGeomCache(FunctionCallInfoData *fcinfo, GSERIALIZED *pg_geom1, GSERIALIZED *pg_geom2);
+PrepGeomCache *GetPrepGeomCache(FunctionCallInfo fcinfo, GSERIALIZED *pg_geom1, GSERIALIZED *pg_geom2);
#endif /* LWGEOM_GEOS_PREPARED_H_ */
Modified: trunk/postgis/lwgeom_rectree.c
===================================================================
--- trunk/postgis/lwgeom_rectree.c 2019-01-30 19:36:30 UTC (rev 17222)
+++ trunk/postgis/lwgeom_rectree.c 2019-01-31 15:47:33 UTC (rev 17223)
@@ -106,7 +106,7 @@
};
static RectTreeGeomCache *
-GetRectTreeGeomCache(FunctionCallInfoData *fcinfo, const GSERIALIZED *g1, const GSERIALIZED *g2)
+GetRectTreeGeomCache(FunctionCallInfo fcinfo, const GSERIALIZED *g1, const GSERIALIZED *g2)
{
return (RectTreeGeomCache*)GetGeomCache(fcinfo, &RectTreeCacheMethods, g1, g2);
}
Modified: trunk/postgis/lwgeom_rtree.c
===================================================================
--- trunk/postgis/lwgeom_rtree.c 2019-01-30 19:36:30 UTC (rev 17222)
+++ trunk/postgis/lwgeom_rtree.c 2019-01-31 15:47:33 UTC (rev 17223)
@@ -428,8 +428,8 @@
RTreeAllocator
};
-RTREE_POLY_CACHE*
-GetRtreeCache(FunctionCallInfoData* fcinfo, GSERIALIZED* g1)
+RTREE_POLY_CACHE *
+GetRtreeCache(FunctionCallInfo fcinfo, GSERIALIZED *g1)
{
RTreeGeomCache* cache = (RTreeGeomCache*)GetGeomCache(fcinfo, &RTreeCacheMethods, g1, NULL);
RTREE_POLY_CACHE* index = NULL;
Modified: trunk/postgis/lwgeom_rtree.h
===================================================================
--- trunk/postgis/lwgeom_rtree.h 2019-01-30 19:36:30 UTC (rev 17222)
+++ trunk/postgis/lwgeom_rtree.h 2019-01-31 15:47:33 UTC (rev 17223)
@@ -80,7 +80,6 @@
* a pre-built index structure (RTREE_POLY_CACHE) if one exists. Otherwise
* builds a new one and returns that.
*/
-RTREE_POLY_CACHE* GetRtreeCache(FunctionCallInfoData* fcinfo, GSERIALIZED* g1);
+RTREE_POLY_CACHE *GetRtreeCache(FunctionCallInfo fcinfo, GSERIALIZED *g1);
-
#endif /* !defined _LWGEOM_RTREE_H */
Modified: trunk/raster/rt_pg/rtpg_mapalgebra.c
===================================================================
--- trunk/raster/rt_pg/rtpg_mapalgebra.c 2019-01-30 19:36:30 UTC (rev 17222)
+++ trunk/raster/rt_pg/rtpg_mapalgebra.c 2019-01-31 15:47:33 UTC (rev 17223)
@@ -81,7 +81,16 @@
Oid ufc_noid;
Oid ufc_rettype;
FmgrInfo ufl_info;
+#if POSTGIS_PGSQL_VERSION < 120
FunctionCallInfoData ufc_info;
+#else
+ /* copied from LOCAL_FCINFO in fmgr.h */
+ union {
+ FunctionCallInfoBaseData fcinfo;
+ char fcinfo_data[SizeForFunctionCallInfo(FUNC_MAX_ARGS)]; /* Could be optimized */
+ } ufc_info_data;
+ FunctionCallInfo ufc_info;
+#endif
} rtpg_nmapalgebra_callback_arg;
typedef struct rtpg_nmapalgebra_arg_t *rtpg_nmapalgebra_arg;
@@ -137,6 +146,9 @@
arg->cextent = NULL;
arg->mask = NULL;
+#if POSTGIS_PGSQL_VERSION >= 120
+ arg->callback.ufc_info = &(arg->callback.ufc_info_data.fcinfo);
+#endif
arg->callback.ufc_noid = InvalidOid;
arg->callback.ufc_rettype = InvalidOid;
@@ -470,16 +482,30 @@
pfree(_pos);
pfree(_null);
+#if POSTGIS_PGSQL_VERSION < 120
callback->ufc_info.arg[0] = PointerGetDatum(mdValues);
callback->ufc_info.arg[1] = PointerGetDatum(mdPos);
+#else
+ callback->ufc_info->args[0].value = PointerGetDatum(mdValues);
+ callback->ufc_info->args[1].value = PointerGetDatum(mdPos);
+#endif
/* call user callback function */
+#if POSTGIS_PGSQL_VERSION < 120
datum = FunctionCallInvoke(&(callback->ufc_info));
+#else
+ datum = FunctionCallInvoke(callback->ufc_info);
+#endif
pfree(mdValues);
pfree(mdPos);
/* result is not null*/
+#if POSTGIS_PGSQL_VERSION < 120
if (!callback->ufc_info.isnull) {
+#else
+ if (!callback->ufc_info->isnull)
+ {
+#endif
switch (callback->ufc_rettype) {
case FLOAT8OID:
*value = DatumGetFloat8(datum);
@@ -836,25 +862,52 @@
elog(NOTICE, "Function provided is VOLATILE. Unless required and for best performance, function should be IMMUTABLE or STABLE");
/* prep function call data */
+#if POSTGIS_PGSQL_VERSION < 120
InitFunctionCallInfoData(arg->callback.ufc_info, &(arg->callback.ufl_info), arg->callback.ufl_info.fn_nargs, InvalidOid, NULL, NULL);
memset(arg->callback.ufc_info.argnull, FALSE, sizeof(bool) * arg->callback.ufl_info.fn_nargs);
+#else
+ InitFunctionCallInfoData(*(arg->callback.ufc_info),
+ &(arg->callback.ufl_info),
+ arg->callback.ufl_info.fn_nargs,
+ InvalidOid,
+ NULL,
+ NULL);
+ arg->callback.ufc_info->args[0].isnull = FALSE;
+ arg->callback.ufc_info->args[1].isnull = FALSE;
+ arg->callback.ufc_info->args[2].isnull = FALSE;
+#endif
+
/* userargs (7) */
if (!PG_ARGISNULL(9))
+#if POSTGIS_PGSQL_VERSION < 120
arg->callback.ufc_info.arg[2] = PG_GETARG_DATUM(9);
+#else
+ arg->callback.ufc_info->args[2].value = PG_GETARG_DATUM(9);
+#endif
else {
if (arg->callback.ufl_info.fn_strict) {
/* build and assign an empty TEXT array */
/* TODO: manually free the empty array? */
+#if POSTGIS_PGSQL_VERSION < 120
arg->callback.ufc_info.arg[2] = PointerGetDatum(
construct_empty_array(TEXTOID)
);
arg->callback.ufc_info.argnull[2] = FALSE;
+#else
+ arg->callback.ufc_info->args[2].value = PointerGetDatum(construct_empty_array(TEXTOID));
+ arg->callback.ufc_info->args[2].isnull = FALSE;
+#endif
}
else {
+#if POSTGIS_PGSQL_VERSION < 120
arg->callback.ufc_info.arg[2] = (Datum) NULL;
arg->callback.ufc_info.argnull[2] = TRUE;
+#else
+ arg->callback.ufc_info->args[2].value = (Datum)NULL;
+ arg->callback.ufc_info->args[2].isnull = TRUE;
+#endif
}
}
}
@@ -5085,7 +5138,11 @@
int ret = -1;
Oid oid;
FmgrInfo cbinfo;
+#if POSTGIS_PGSQL_VERSION < 120
FunctionCallInfoData cbdata;
+#else
+ LOCAL_FCINFO(cbdata, FUNC_MAX_ARGS); /* Could be optimized */
+#endif
Datum tmpnewval;
char * strFromText = NULL;
int k = 0;
@@ -5325,10 +5382,20 @@
}
/* prep function call data */
+#if POSTGIS_PGSQL_VERSION < 120
InitFunctionCallInfoData(cbdata, &cbinfo, 2, InvalidOid, NULL, NULL);
- memset(cbdata.argnull, FALSE, sizeof(bool) * cbinfo.fn_nargs);
+ cbdata.argnull[0] = FALSE;
+ cbdata.argnull[1] = FALSE;
+ cbdata.argnull[2] = FALSE;
+#else
+ InitFunctionCallInfoData(*cbdata, &cbinfo, 2, InvalidOid, NULL, NULL);
+ cbdata->args[0].isnull = FALSE;
+ cbdata->args[1].isnull = FALSE;
+ cbdata->args[2].isnull = FALSE;
+#endif
+
/* check that the function isn't strict if the args are null. */
if (PG_ARGISNULL(4)) {
if (cbinfo.fn_strict) {
@@ -5341,11 +5408,20 @@
PG_RETURN_NULL();
}
- cbdata.arg[k] = (Datum)NULL;
+#if POSTGIS_PGSQL_VERSION < 120
+ cbdata.arg[k] = (Datum)NULL;
cbdata.argnull[k] = TRUE;
+#else
+ cbdata->args[k].value = (Datum)NULL;
+ cbdata->args[k].isnull = TRUE;
+#endif
}
else {
- cbdata.arg[k] = PG_GETARG_DATUM(4);
+#if POSTGIS_PGSQL_VERSION < 120
+ cbdata.arg[k] = PG_GETARG_DATUM(4);
+#else
+ cbdata->args[k].value = PG_GETARG_DATUM(4);
+#endif
}
/**
@@ -5422,13 +5498,23 @@
POSTGIS_RT_DEBUG(3, "RASTER_mapAlgebraFct: Strict callbacks cannot accept NULL arguments, skipping NODATA cell.");
continue;
}
- cbdata.argnull[0] = TRUE;
+#if POSTGIS_PGSQL_VERSION < 120
+ cbdata.argnull[0] = TRUE;
cbdata.arg[0] = (Datum)NULL;
- }
+#else
+ cbdata->args[0].isnull = TRUE;
+ cbdata->args[0].value = (Datum)NULL;
+#endif
+ }
else {
- cbdata.argnull[0] = FALSE;
- cbdata.arg[0] = Float8GetDatum(r);
- }
+#if POSTGIS_PGSQL_VERSION < 120
+ cbdata.argnull[0] = FALSE;
+ cbdata.arg[0] = Float8GetDatum(r);
+#else
+ cbdata->args[0].isnull = FALSE;
+ cbdata->args[0].value = Float8GetDatum(r);
+#endif
+ }
/* Add pixel positions if callback has proper # of args */
if (cbinfo.fn_nargs == 3) {
@@ -5440,19 +5526,33 @@
a = construct_array(d, 2, INT4OID, sizeof(int32), true, 'i');
- cbdata.argnull[1] = FALSE;
+#if POSTGIS_PGSQL_VERSION < 120
+ cbdata.argnull[1] = FALSE;
cbdata.arg[1] = PointerGetDatum(a);
- }
+#else
+ cbdata->args[1].isnull = FALSE;
+ cbdata->args[1].value = PointerGetDatum(a);
+#endif
+ }
POSTGIS_RT_DEBUGF(3, "RASTER_mapAlgebraFct: (%dx%d), r = %f",
x, y, r);
- tmpnewval = FunctionCallInvoke(&cbdata);
+#if POSTGIS_PGSQL_VERSION < 120
+ tmpnewval = FunctionCallInvoke(&cbdata);
if (cbdata.isnull) {
newval = newnodatavalue;
}
- else {
+#else
+ tmpnewval = FunctionCallInvoke(cbdata);
+
+ if (cbdata->isnull)
+ {
+ newval = newnodatavalue;
+ }
+#endif
+ else {
newval = DatumGetFloat8(tmpnewval);
}
@@ -5507,7 +5607,11 @@
int ret = -1;
Oid oid;
FmgrInfo cbinfo;
+#if POSTGIS_PGSQL_VERSION < 120
FunctionCallInfoData cbdata;
+#else
+ LOCAL_FCINFO(cbdata, FUNC_MAX_ARGS); /* Could be optimized */
+#endif
Datum tmpnewval;
ArrayType * neighborDatum;
char * strFromText = NULL;
@@ -5754,8 +5858,15 @@
}
/* prep function call data */
+#if POSTGIS_PGSQL_VERSION < 120
InitFunctionCallInfoData(cbdata, &cbinfo, 3, InvalidOid, NULL, NULL);
memset(cbdata.argnull, FALSE, sizeof(bool) * 3);
+#else
+ InitFunctionCallInfoData(*cbdata, &cbinfo, 3, InvalidOid, NULL, NULL);
+ cbdata->args[0].isnull = FALSE;
+ cbdata->args[1].isnull = FALSE;
+ cbdata->args[2].isnull = FALSE;
+#endif
/* check that the function isn't strict if the args are null. */
if (PG_ARGISNULL(7)) {
@@ -5769,11 +5880,20 @@
PG_RETURN_NULL();
}
- cbdata.arg[2] = (Datum)NULL;
+#if POSTGIS_PGSQL_VERSION < 120
+ cbdata.arg[2] = (Datum)NULL;
cbdata.argnull[2] = TRUE;
+#else
+ cbdata->args[2].value = (Datum)NULL;
+ cbdata->args[2].isnull = TRUE;
+#endif
}
else {
- cbdata.arg[2] = PG_GETARG_DATUM(7);
+#if POSTGIS_PGSQL_VERSION < 120
+ cbdata.arg[2] = PG_GETARG_DATUM(7);
+#else
+ cbdata->args[2].value = PG_GETARG_DATUM(7);
+#endif
}
/**
@@ -5893,7 +6013,11 @@
memcpy((void *)VARDATA(txtCallbackParam), (void *)VARDATA(txtNodataMode), VARSIZE(txtNodataMode) - VARHDRSZ);
/* pass the nodata mode into the user function */
+#if POSTGIS_PGSQL_VERSION < 120
cbdata.arg[1] = CStringGetDatum(txtCallbackParam);
+#else
+ cbdata->args[1].value = CStringGetDatum(txtCallbackParam);
+#endif
strFromText = text_to_cstring(txtNodataMode);
strFromText = rtpg_strtoupper(strFromText);
@@ -6012,7 +6136,8 @@
neighborDatum = construct_md_array((void *)neighborData, neighborNulls, 2, neighborDims, neighborLbs,
FLOAT8OID, typlen, typbyval, typalign);
- /* Assign the neighbor matrix as the first argument to the user function */
+#if POSTGIS_PGSQL_VERSION < 120
+ /* Assign the neighbor matrix as the first argument to the user function */
cbdata.arg[0] = PointerGetDatum(neighborDatum);
/* Invoke the user function */
@@ -6022,7 +6147,20 @@
if (cbdata.isnull) {
newval = newnodatavalue;
}
- else {
+#else
+ /* Assign the neighbor matrix as the first argument to the user function */
+ cbdata->args[0].value = PointerGetDatum(neighborDatum);
+
+ /* Invoke the user function */
+ tmpnewval = FunctionCallInvoke(cbdata);
+
+ /* Get the return value of the user function */
+ if (cbdata->isnull)
+ {
+ newval = newnodatavalue;
+ }
+#endif
+ else {
newval = DatumGetFloat8(tmpnewval);
}
@@ -6130,7 +6268,11 @@
Oid ufc_noid = InvalidOid;
FmgrInfo ufl_info;
+#if POSTGIS_PGSQL_VERSION < 120
FunctionCallInfoData ufc_info;
+#else
+ LOCAL_FCINFO(ufc_info, FUNC_MAX_ARGS); /* Could be optimized */
+#endif
int ufc_nullcount = 0;
int idx = 0;
@@ -6857,13 +6999,24 @@
}
/* prep function call data */
+#if POSTGIS_PGSQL_VERSION < 120
InitFunctionCallInfoData(ufc_info, &ufl_info, ufl_info.fn_nargs, InvalidOid, NULL, NULL);
memset(ufc_info.argnull, FALSE, sizeof(bool) * ufl_info.fn_nargs);
+#else
+ InitFunctionCallInfoData(
+ *ufc_info, &ufl_info, ufl_info.fn_nargs, InvalidOid, NULL, NULL);
+ ufc_info->args[0].isnull = FALSE;
+ ufc_info->args[1].isnull = FALSE;
+ ufc_info->args[2].isnull = FALSE;
+ if (ufl_info.fn_nargs == 4)
+ ufc_info->args[3].isnull = FALSE;
+#endif
if (ufl_info.fn_nargs != 4)
k = 2;
else
k = 3;
+#if POSTGIS_PGSQL_VERSION < 120
if (!PG_ARGISNULL(7)) {
ufc_info.arg[k] = PG_GETARG_DATUM(7);
}
@@ -6872,6 +7025,18 @@
ufc_info.argnull[k] = TRUE;
ufc_nullcount++;
}
+#else
+ if (!PG_ARGISNULL(7))
+ {
+ ufc_info->args[k].value = PG_GETARG_DATUM(7);
+ }
+ else
+ {
+ ufc_info->args[k].value = (Datum)NULL;
+ ufc_info->args[k].isnull = TRUE;
+ ufc_nullcount++;
+ }
+#endif
}
break;
}
@@ -7098,15 +7263,27 @@
/* build fcnarg */
for (i = 0; i < set_count; i++) {
+#if POSTGIS_PGSQL_VERSION < 120
ufc_info.arg[i] = Float8GetDatum(_pixel[i]);
+#else
+ ufc_info->args[i].value = Float8GetDatum(_pixel[i]);
+#endif
if (_haspixel[i]) {
+#if POSTGIS_PGSQL_VERSION < 120
ufc_info.argnull[i] = FALSE;
+#else
+ ufc_info->args[i].isnull = FALSE;
+#endif
ufc_nullcount--;
}
else {
+#if POSTGIS_PGSQL_VERSION < 120
ufc_info.argnull[i] = TRUE;
- ufc_nullcount++;
+#else
+ ufc_info->args[i].isnull = TRUE;
+#endif
+ ufc_nullcount++;
}
}
@@ -7131,10 +7308,16 @@
}
a = construct_array(d, 4, INT4OID, sizeof(int32), true, 'i');
+#if POSTGIS_PGSQL_VERSION < 120
ufc_info.arg[2] = PointerGetDatum(a);
ufc_info.argnull[2] = FALSE;
+#else
+ ufc_info->args[2].value = PointerGetDatum(a);
+ ufc_info->args[2].isnull = FALSE;
+#endif
}
+#if POSTGIS_PGSQL_VERSION < 120
datum = FunctionCallInvoke(&ufc_info);
/* result is not null*/
@@ -7142,6 +7325,16 @@
haspixel = 1;
pixel = DatumGetFloat8(datum);
}
+#else
+ datum = FunctionCallInvoke(ufc_info);
+
+ /* result is not null*/
+ if (!ufc_info->isnull)
+ {
+ haspixel = 1;
+ pixel = DatumGetFloat8(datum);
+ }
+#endif
} break;
}
More information about the postgis-tickets
mailing list