PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ pgis_geometry_accum_transfn()

Datum pgis_geometry_accum_transfn ( PG_FUNCTION_ARGS  )

Definition at line 106 of file lwgeom_accum.c.

References pgis_abs::a, pgis_abs::data, and pgis_accum_finalfn().

Referenced by pgis_abs_out().

107 {
108  Oid arg1_typeid = get_fn_expr_argtype(fcinfo->flinfo, 1);
109  MemoryContext aggcontext;
110  ArrayBuildState *state;
111  pgis_abs *p;
112  Datum elem;
113 
114  if (arg1_typeid == InvalidOid)
115  ereport(ERROR,
116  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
117  errmsg("could not determine input data type")));
118 
119  if ( ! AggCheckCallContext(fcinfo, &aggcontext) )
120  {
121  /* cannot be called directly because of dummy-type argument */
122  elog(ERROR, "%s called in non-aggregate context", __func__);
123  aggcontext = NULL; /* keep compiler quiet */
124  }
125 
126  if ( PG_ARGISNULL(0) )
127  {
128  p = (pgis_abs*) palloc(sizeof(pgis_abs));
129  p->a = NULL;
130  p->data = (Datum) NULL;
131 
132  if (PG_NARGS() == 3)
133  {
134  Datum argument = PG_GETARG_DATUM(2);
135  Oid dataOid = get_fn_expr_argtype(fcinfo->flinfo, 2);
136  MemoryContext old = MemoryContextSwitchTo(aggcontext);
137 
138  p->data = datumCopy(argument, get_typbyval(dataOid), get_typlen(dataOid));
139 
140  MemoryContextSwitchTo(old);
141  }
142  }
143  else
144  {
145  p = (pgis_abs*) PG_GETARG_POINTER(0);
146  }
147  state = p->a;
148  elem = PG_ARGISNULL(1) ? (Datum) 0 : PG_GETARG_DATUM(1);
149  state = accumArrayResult(state,
150  elem,
151  PG_ARGISNULL(1),
152  arg1_typeid,
153  aggcontext);
154  p->a = state;
155 
156  PG_RETURN_POINTER(p);
157 }
ArrayBuildState * a
Definition: lwgeom_accum.c:71
Datum data
Definition: lwgeom_accum.c:72
To pass the internal ArrayBuildState pointer between the transfn and finalfn we need to wrap it into ...
Definition: lwgeom_accum.c:69
Here is the call graph for this function:
Here is the caller graph for this function: