A modified version of PostgreSQL's DirectFunctionCall2 which allows NULL results; this is required for aggregates that return NULL.
374{
375#if POSTGIS_PGSQL_VERSION < 120
376 FunctionCallInfoData fcinfo;
377 Datum result;
378
379 InitFunctionCallInfoData(fcinfo, NULL, 2, InvalidOid, NULL, NULL);
380
381 fcinfo.arg[0] = arg1;
382 fcinfo.arg[1] = arg2;
383 fcinfo.argnull[0] = false;
384 fcinfo.argnull[1] = false;
385
386 result = (*func) (&fcinfo);
387
388
389 if (fcinfo.isnull)
390 return (Datum) 0;
391
392 return result;
393#else
394 LOCAL_FCINFO(fcinfo, 2);
395 Datum result;
396
397 InitFunctionCallInfoData(*fcinfo, NULL, 2, InvalidOid, NULL, NULL);
398
399 fcinfo->args[0].value = arg1;
400 fcinfo->args[1].value = arg2;
401 fcinfo->args[0].isnull = false;
402 fcinfo->args[1].isnull = false;
403
404 result = (*func)(fcinfo);
405
406
407 if (fcinfo->isnull)
408 return (Datum)0;
409
410 return result;
411#endif
412}