[postgis-tickets] r17225 - PostgreSQL 12 compatibility
Raul
raul at rmr.ninja
Thu Jan 31 07:51:02 PST 2019
Author: algunenano
Date: 2019-01-31 07:51:02 -0800 (Thu, 31 Jan 2019)
New Revision: 17225
Modified:
branches/2.4/NEWS
branches/2.4/libpgcommon/lwgeom_cache.c
branches/2.4/libpgcommon/lwgeom_cache.h
branches/2.4/postgis/geography_measurement_trees.c
branches/2.4/postgis/geography_measurement_trees.h
branches/2.4/postgis/gserialized_estimate.c
branches/2.4/postgis/lwgeom_accum.c
branches/2.4/postgis/lwgeom_geos_prepared.c
branches/2.4/postgis/lwgeom_geos_prepared.h
branches/2.4/postgis/lwgeom_rtree.c
branches/2.4/postgis/lwgeom_rtree.h
branches/2.4/raster/rt_pg/rtpg_mapalgebra.c
Log:
PostgreSQL 12 compatibility
Initial patch by Laurenz Albe
Closes #4313
Closes https://github.com/postgis/postgis/pull/368/
Modified: branches/2.4/NEWS
===================================================================
--- branches/2.4/NEWS 2019-01-31 15:49:08 UTC (rev 17224)
+++ branches/2.4/NEWS 2019-01-31 15:51:02 UTC (rev 17225)
@@ -16,6 +16,7 @@
- #4296, Use `server_version_num` instead of parsing `version()` (Raúl Marín)
- #4298, Geodetic tolerance issue in 32-bit (Paul Ramsey)
- #4283, Avoid final point duplicates for circle stroking (Paul Ramsey)
+ - #4313, #4307, PostgreSQL 12 compatibility (Laurenz Albe, Raúl Marín)
PostGIS 2.4.6
Modified: branches/2.4/libpgcommon/lwgeom_cache.c
===================================================================
--- branches/2.4/libpgcommon/lwgeom_cache.c 2019-01-31 15:49:08 UTC (rev 17224)
+++ branches/2.4/libpgcommon/lwgeom_cache.c 2019-01-31 15:51:02 UTC (rev 17225)
@@ -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: branches/2.4/libpgcommon/lwgeom_cache.h
===================================================================
--- branches/2.4/libpgcommon/lwgeom_cache.h 2019-01-31 15:49:08 UTC (rev 17224)
+++ branches/2.4/libpgcommon/lwgeom_cache.h 2019-01-31 15:51:02 UTC (rev 17225)
@@ -101,7 +101,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: branches/2.4/postgis/geography_measurement_trees.c
===================================================================
--- branches/2.4/postgis/geography_measurement_trees.c 2019-01-31 15:49:08 UTC (rev 17224)
+++ branches/2.4/postgis/geography_measurement_trees.c 2019-01-31 15:51:02 UTC (rev 17225)
@@ -94,8 +94,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);
}
@@ -156,9 +156,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;
@@ -247,15 +251,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: branches/2.4/postgis/geography_measurement_trees.h
===================================================================
--- branches/2.4/postgis/geography_measurement_trees.h 2019-01-31 15:49:08 UTC (rev 17224)
+++ branches/2.4/postgis/geography_measurement_trees.h 2019-01-31 15:51:02 UTC (rev 17225)
@@ -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: branches/2.4/postgis/gserialized_estimate.c
===================================================================
--- branches/2.4/postgis/gserialized_estimate.c 2019-01-31 15:49:08 UTC (rev 17224)
+++ branches/2.4/postgis/gserialized_estimate.c 2019-01-31 15:51:02 UTC (rev 17225)
@@ -63,7 +63,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: branches/2.4/postgis/lwgeom_accum.c
===================================================================
--- branches/2.4/postgis/lwgeom_accum.c 2019-01-31 15:49:08 UTC (rev 17224)
+++ branches/2.4/postgis/lwgeom_accum.c 2019-01-31 15:51:02 UTC (rev 17225)
@@ -383,6 +383,7 @@
Datum
PGISDirectFunctionCall1(PGFunction func, Datum arg1)
{
+#if POSTGIS_PGSQL_VERSION < 120
FunctionCallInfoData fcinfo;
Datum result;
@@ -400,6 +401,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 */
}
/**
@@ -409,17 +427,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;
@@ -432,4 +445,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: branches/2.4/postgis/lwgeom_geos_prepared.c
===================================================================
--- branches/2.4/postgis/lwgeom_geos_prepared.c 2019-01-31 15:49:08 UTC (rev 17224)
+++ branches/2.4/postgis/lwgeom_geos_prepared.c 2019-01-31 15:51:02 UTC (rev 17225)
@@ -462,8 +462,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: branches/2.4/postgis/lwgeom_geos_prepared.h
===================================================================
--- branches/2.4/postgis/lwgeom_geos_prepared.h 2019-01-31 15:49:08 UTC (rev 17224)
+++ branches/2.4/postgis/lwgeom_geos_prepared.h 2019-01-31 15:51:02 UTC (rev 17225)
@@ -74,6 +74,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: branches/2.4/postgis/lwgeom_rtree.c
===================================================================
--- branches/2.4/postgis/lwgeom_rtree.c 2019-01-31 15:49:08 UTC (rev 17224)
+++ branches/2.4/postgis/lwgeom_rtree.c 2019-01-31 15:51:02 UTC (rev 17225)
@@ -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: branches/2.4/postgis/lwgeom_rtree.h
===================================================================
--- branches/2.4/postgis/lwgeom_rtree.h 2019-01-31 15:49:08 UTC (rev 17224)
+++ branches/2.4/postgis/lwgeom_rtree.h 2019-01-31 15:51:02 UTC (rev 17225)
@@ -86,7 +86,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: branches/2.4/raster/rt_pg/rtpg_mapalgebra.c
===================================================================
--- branches/2.4/raster/rt_pg/rtpg_mapalgebra.c 2019-01-31 15:49:08 UTC (rev 17224)
+++ branches/2.4/raster/rt_pg/rtpg_mapalgebra.c 2019-01-31 15:51:02 UTC (rev 17225)
@@ -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
}
}
}
@@ -873,7 +926,7 @@
case ET_SECOND:
if (arg->numraster > 1) {
i = 1;
- break;
+ break;
}
default:
i = 0;
@@ -1466,9 +1519,9 @@
PG_RETURN_NULL();
}
- strncpy(sql, "SELECT (", strlen("SELECT ("));
- strncpy(sql + strlen("SELECT ("), expr, strlen(expr));
- strncpy(sql + strlen("SELECT (") + strlen(expr), ")::double precision", strlen(")::double precision"));
+ memcpy(sql, "SELECT (", strlen("SELECT ("));
+ memcpy(sql + strlen("SELECT ("), expr, strlen(expr));
+ memcpy(sql + strlen("SELECT (") + strlen(expr), ")::double precision", strlen(")::double precision"));
sql[len] = '\0';
POSTGIS_RT_DEBUGF(3, "sql #%d: %s", exprpos[i], sql);
@@ -5087,7 +5140,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;
@@ -5327,10 +5384,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) {
@@ -5343,11 +5410,20 @@
PG_RETURN_NULL();
}
- cbdata.arg[k] = (Datum)NULL;
- cbdata.argnull[k] = TRUE;
+#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
}
/**
@@ -5424,13 +5500,23 @@
POSTGIS_RT_DEBUG(3, "RASTER_mapAlgebraFct: Strict callbacks cannot accept NULL arguments, skipping NODATA cell.");
continue;
}
- cbdata.argnull[0] = TRUE;
- cbdata.arg[0] = (Datum)NULL;
- }
+#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) {
@@ -5442,19 +5528,33 @@
a = construct_array(d, 2, INT4OID, sizeof(int32), true, 'i');
- cbdata.argnull[1] = FALSE;
- cbdata.arg[1] = PointerGetDatum(a);
- }
+#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);
}
@@ -5509,7 +5609,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;
@@ -5756,12 +5860,15 @@
}
/* prep function call data */
-#if POSTGIS_PGSQL_VERSION <= 90
- InitFunctionCallInfoData(cbdata, &cbinfo, 3, InvalidOid, NULL);
+#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);
+ InitFunctionCallInfoData(*cbdata, &cbinfo, 3, InvalidOid, NULL, NULL);
+ cbdata->args[0].isnull = FALSE;
+ cbdata->args[1].isnull = FALSE;
+ cbdata->args[2].isnull = FALSE;
#endif
- memset(cbdata.argnull, FALSE, sizeof(bool) * 3);
/* check that the function isn't strict if the args are null. */
if (PG_ARGISNULL(7)) {
@@ -5775,11 +5882,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
}
/**
@@ -5899,7 +6015,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);
@@ -6018,7 +6138,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 */
@@ -6028,7 +6149,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);
}
@@ -6136,7 +6270,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;
@@ -6372,6 +6510,7 @@
switch (extenttype) {
case ET_FIRST:
i = 0;
+ /* fall through */
case ET_SECOND:
if (i > 1)
i = 1;
@@ -6862,17 +7001,24 @@
}
/* prep function call data */
-#if POSTGIS_PGSQL_VERSION <= 90
- InitFunctionCallInfoData(ufc_info, &ufl_info, ufl_info.fn_nargs, InvalidOid, NULL);
+#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);
+ 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
- memset(ufc_info.argnull, FALSE, sizeof(bool) * ufl_info.fn_nargs);
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);
}
@@ -6881,6 +7027,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;
}
@@ -7107,15 +7265,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++;
}
}
@@ -7140,10 +7310,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*/
@@ -7151,6 +7327,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;
}
@@ -7205,4 +7391,4 @@
SET_VARSIZE(pgrtn, pgrtn->size);
PG_RETURN_POINTER(pgrtn);
-}
+}
\ No newline at end of file
More information about the postgis-tickets
mailing list