コード例 #1
0
ファイル: int_aggregate.c プロジェクト: sunyangkobe/cscd43
/* This is the final function used for the integer aggregator. It returns all
 * the integers collected as a one dimensional integer array
 */
Datum
int_agg_final_array(PG_FUNCTION_ARGS)
{
	PGARRAY    *state = (PGARRAY *) PG_GETARG_POINTER(0);
	PGARRAY    *pnew = ShrinkPGArray(GetPGArray(state, 0));

	if (pnew)
		PG_RETURN_POINTER(pnew);
	else
		PG_RETURN_NULL();
}
コード例 #2
0
/*
 * This is the final function used for the integer aggregator. It returns all
 * the integers collected as a one dimensional integer array
 */
Datum
int_agg_final_array(PG_FUNCTION_ARGS)
{
	PGARRAY    *state;
	PGARRAY    *p;
	PGARRAY    *pnew;

	/*
	 * As of PG 8.1 we can actually verify that we are being used as an
	 * aggregate function, and so it is safe to scribble on our left input.
	 */
	if (!(fcinfo->context && IsA(fcinfo->context, AggState)))
		elog(ERROR, "int_agg_final_array may only be used as an aggregate");

	if (PG_ARGISNULL(0))
		state = NULL;			/* zero items in aggregation */
	else
		state = (PGARRAY *) PG_GETARG_POINTER(0);
	p = GetPGArray(state, (AggState *) fcinfo->context, false);

	pnew = ShrinkPGArray(p);
	PG_RETURN_POINTER(pnew);
}