29 #include "access/tupmacs.h" 30 #include "utils/datum.h" 31 #include "utils/array.h" 32 #include "utils/lsyscache.h" 34 #include "../postgis_config.h" 38 #include "lwgeom_pg.h" 39 #include "lwgeom_transform.h" 100 ereport(ERROR,(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
101 errmsg(
"function %s not implemented", __func__)));
102 PG_RETURN_POINTER(NULL);
108 ereport(ERROR,(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
109 errmsg(
"function %s not implemented", __func__)));
110 PG_RETURN_POINTER(NULL);
122 Oid arg1_typeid = get_fn_expr_argtype(fcinfo->flinfo, 1);
123 MemoryContext aggcontext;
124 ArrayBuildState *state;
128 if (arg1_typeid == InvalidOid)
130 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
131 errmsg(
"could not determine input data type")));
133 if ( ! AggCheckCallContext(fcinfo, &aggcontext) )
136 elog(ERROR,
"%s called in non-aggregate context", __func__);
140 if ( PG_ARGISNULL(0) )
144 p->
data = (Datum) NULL;
148 Datum argument = PG_GETARG_DATUM(2);
149 Oid dataOid = get_fn_expr_argtype(fcinfo->flinfo, 2);
150 MemoryContext old = MemoryContextSwitchTo(aggcontext);
152 p->
data = datumCopy(argument, get_typbyval(dataOid), get_typlen(dataOid));
154 MemoryContextSwitchTo(old);
159 p = (
pgis_abs*) PG_GETARG_POINTER(0);
162 elem = PG_ARGISNULL(1) ? (Datum) 0 : PG_GETARG_DATUM(1);
163 state = accumArrayResult(state,
170 PG_RETURN_POINTER(p);
186 ArrayBuildState *state;
190 Assert(fcinfo->context &&
191 (IsA(fcinfo->context, AggState) ||
192 IsA(fcinfo->context, WindowAggState))
196 dims[0] = state->nelems;
198 result = makeMdArrayResult(state, 1, dims, lbs, mctx,
false);
215 p = (
pgis_abs*) PG_GETARG_POINTER(0);
219 PG_RETURN_DATUM(result);
233 Datum geometry_array = 0;
238 p = (
pgis_abs*) PG_GETARG_POINTER(0);
245 PG_RETURN_DATUM(result);
258 Datum geometry_array = 0;
263 p = (
pgis_abs*) PG_GETARG_POINTER(0);
270 PG_RETURN_DATUM(result);
284 Datum geometry_array = 0;
289 p = (
pgis_abs*) PG_GETARG_POINTER(0);
296 PG_RETURN_DATUM(result);
309 Datum geometry_array = 0;
314 p = (
pgis_abs*) PG_GETARG_POINTER(0);
321 PG_RETURN_DATUM(result);
334 Datum geometry_array = 0;
339 p = (
pgis_abs*) PG_GETARG_POINTER(0);
345 PG_RETURN_DATUM(result);
358 Datum geometry_array = 0;
363 p = (
pgis_abs*) PG_GETARG_POINTER(0);
367 elog(ERROR,
"Tolerance not defined");
376 PG_RETURN_DATUM(result);
386 #if POSTGIS_PGSQL_VERSION < 120 387 FunctionCallInfoData fcinfo;
391 InitFunctionCallInfoData(fcinfo, NULL, 1, InvalidOid, NULL, NULL);
394 fcinfo.arg[0] = arg1;
395 fcinfo.argnull[0] =
false;
397 result = (*func) (&fcinfo);
405 LOCAL_FCINFO(fcinfo, 1);
408 InitFunctionCallInfoData(*fcinfo, NULL, 1, InvalidOid, NULL, NULL);
410 fcinfo->args[0].value = arg1;
411 fcinfo->args[0].isnull =
false;
413 result = (*func)(fcinfo);
430 #if POSTGIS_PGSQL_VERSION < 120 431 FunctionCallInfoData fcinfo;
434 InitFunctionCallInfoData(fcinfo, NULL, 2, InvalidOid, NULL, NULL);
436 fcinfo.arg[0] = arg1;
437 fcinfo.arg[1] = arg2;
438 fcinfo.argnull[0] =
false;
439 fcinfo.argnull[1] =
false;
441 result = (*func) (&fcinfo);
449 LOCAL_FCINFO(fcinfo, 2);
452 InitFunctionCallInfoData(*fcinfo, NULL, 2, InvalidOid, NULL, NULL);
454 fcinfo->args[0].value = arg1;
455 fcinfo->args[1].value = arg2;
456 fcinfo->args[0].isnull =
false;
457 fcinfo->args[1].isnull =
false;
459 result = (*func)(fcinfo);
Datum pgis_accum_finalfn(pgis_abs *p, MemoryContext mctx, FunctionCallInfo fcinfo)
The final function rescues the built array from the side memory context using the PostgreSQL built-in...
Datum pgis_union_geometry_array(PG_FUNCTION_ARGS)
Datum pgis_geometry_accum_transfn(PG_FUNCTION_ARGS)
Datum pgis_geometry_polygonize_finalfn(PG_FUNCTION_ARGS)
Datum pgis_abs_in(PG_FUNCTION_ARGS)
Datum pgis_geometry_clusterintersecting_finalfn(PG_FUNCTION_ARGS)
Datum pgis_geometry_union_finalfn(PG_FUNCTION_ARGS)
Datum LWGEOM_collect_garray(PG_FUNCTION_ARGS)
Datum pgis_geometry_collect_finalfn(PG_FUNCTION_ARGS)
Datum LWGEOM_makeline_garray(PG_FUNCTION_ARGS)
Datum pgis_geometry_makeline_finalfn(PG_FUNCTION_ARGS)
Datum pgis_abs_out(PG_FUNCTION_ARGS)
Datum pgis_geometry_clusterwithin_finalfn(PG_FUNCTION_ARGS)
Datum cluster_within_distance_garray(PG_FUNCTION_ARGS)
Datum PGISDirectFunctionCall1(PGFunction func, Datum arg1)
A modified version of PostgreSQL's DirectFunctionCall1 which allows NULL results; this is required fo...
Datum PGISDirectFunctionCall2(PGFunction func, Datum arg1, Datum arg2)
A modified version of PostgreSQL's DirectFunctionCall2 which allows NULL results; this is required fo...
Datum pgis_geometry_accum_finalfn(PG_FUNCTION_ARGS)
Datum clusterintersecting_garray(PG_FUNCTION_ARGS)
PG_FUNCTION_INFO_V1(pgis_abs_in)
We're never going to use this type externally so the in/out functions are dummies.
To pass the internal ArrayBuildState pointer between the transfn and finalfn we need to wrap it into ...
This library is the generic geometry handling section of PostGIS.
Datum polygonize_garray(PG_FUNCTION_ARGS)