PostGIS  2.1.10dev-r@@SVN_REVISION@@
Datum pgis_geometry_accum_transfn ( PG_FUNCTION_ARGS  )

Definition at line 95 of file lwgeom_accum.c.

References pgis_abs::a.

96 {
97  Oid arg1_typeid = get_fn_expr_argtype(fcinfo->flinfo, 1);
98  MemoryContext aggcontext;
99  ArrayBuildState *state;
100  pgis_abs *p;
101  Datum elem;
102 
103  if (arg1_typeid == InvalidOid)
104  ereport(ERROR,
105  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
106  errmsg("could not determine input data type")));
107 
108  if ( ! AggCheckCallContext(fcinfo, &aggcontext) )
109  {
110  /* cannot be called directly because of dummy-type argument */
111  elog(ERROR, "%s called in non-aggregate context", __func__);
112  aggcontext = NULL; /* keep compiler quiet */
113  }
114 
115  if ( PG_ARGISNULL(0) )
116  {
117  p = (pgis_abs*) palloc(sizeof(pgis_abs));
118  p->a = NULL;
119  }
120  else
121  {
122  p = (pgis_abs*) PG_GETARG_POINTER(0);
123  }
124  state = p->a;
125  elem = PG_ARGISNULL(1) ? (Datum) 0 : PG_GETARG_DATUM(1);
126  state = accumArrayResult(state,
127  elem,
128  PG_ARGISNULL(1),
129  arg1_typeid,
130  aggcontext);
131  p->a = state;
132 
133  PG_RETURN_POINTER(p);
134 }
ArrayBuildState * a
Definition: lwgeom_accum.c:63
To pass the internal ArrayBuildState pointer between the transfn and finalfn we need to wrap it into ...
Definition: lwgeom_accum.c:61