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;
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;
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);
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
}
}
}
case ET_SECOND:
if (arg->numraster > 1) {
i = 1;
- break;
+ break;
}
default:
i = 0;
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);
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;
}
/* 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)) {
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
}
/**
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) {
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);
}
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;
}
/* prep function call data */
-#if POSTGIS_PGSQL_VERSION <= 90
- InitFunctionCallInfoData(cbdata, &cbinfo, 3, InvalidOid, NULL);
-#else
+#if POSTGIS_PGSQL_VERSION < 120
InitFunctionCallInfoData(cbdata, &cbinfo, 3, InvalidOid, NULL, NULL);
-#endif
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)) {
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
}
/**
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);
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 */
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);
}
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;
switch (extenttype) {
case ET_FIRST:
i = 0;
+ /* fall through */
case ET_SECOND:
if (i > 1)
i = 1;
}
/* prep function call data */
-#if POSTGIS_PGSQL_VERSION <= 90
- InitFunctionCallInfoData(ufc_info, &ufl_info, ufl_info.fn_nargs, InvalidOid, NULL);
-#else
+#if POSTGIS_PGSQL_VERSION < 120
InitFunctionCallInfoData(ufc_info, &ufl_info, ufl_info.fn_nargs, InvalidOid, NULL, NULL);
-#endif
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);
}
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;
}
/* 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++;
}
}
}
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*/
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;
}
SET_VARSIZE(pgrtn, pgrtn->size);
PG_RETURN_POINTER(pgrtn);
-}
+}
\ No newline at end of file