@ -122,8 +122,8 @@ ordered_set_startup(FunctionCallInfo fcinfo, bool use_tuples)
int numSortCols ;
/*
* Check we ' re called as aggregate , and get the Agg node ' s
* group - lifespan context
* Check we ' re called as aggregate ( and not a window function ) , and
* get the Agg node ' s g roup - lifespan context
*/
if ( AggCheckCallContext ( fcinfo , & gcontext ) ! = AGG_CONTEXT_AGGREGATE )
elog ( ERROR , " ordered-set aggregate called in non-aggregate context " ) ;
@ -356,12 +356,7 @@ ordered_set_transition(PG_FUNCTION_ARGS)
if ( PG_ARGISNULL ( 0 ) )
osastate = ordered_set_startup ( fcinfo , false ) ;
else
{
/* safety check */
if ( AggCheckCallContext ( fcinfo , NULL ) ! = AGG_CONTEXT_AGGREGATE )
elog ( ERROR , " ordered-set aggregate called in non-aggregate context " ) ;
osastate = ( OSAPerGroupState * ) PG_GETARG_POINTER ( 0 ) ;
}
/* Load the datum into the tuplesort object, but only if it's not null */
if ( ! PG_ARGISNULL ( 1 ) )
@ -389,12 +384,7 @@ ordered_set_transition_multi(PG_FUNCTION_ARGS)
if ( PG_ARGISNULL ( 0 ) )
osastate = ordered_set_startup ( fcinfo , true ) ;
else
{
/* safety check */
if ( AggCheckCallContext ( fcinfo , NULL ) ! = AGG_CONTEXT_AGGREGATE )
elog ( ERROR , " ordered-set aggregate called in non-aggregate context " ) ;
osastate = ( OSAPerGroupState * ) PG_GETARG_POINTER ( 0 ) ;
}
/* Form a tuple from all the other inputs besides the transition value */
slot = osastate - > qstate - > tupslot ;
@ -435,9 +425,7 @@ percentile_disc_final(PG_FUNCTION_ARGS)
bool isnull ;
int64 rownum ;
/* safety check */
if ( AggCheckCallContext ( fcinfo , NULL ) ! = AGG_CONTEXT_AGGREGATE )
elog ( ERROR , " ordered-set aggregate called in non-aggregate context " ) ;
Assert ( AggCheckCallContext ( fcinfo , NULL ) = = AGG_CONTEXT_AGGREGATE ) ;
/* Get and check the percentile argument */
if ( PG_ARGISNULL ( 1 ) )
@ -542,9 +530,7 @@ percentile_cont_final_common(FunctionCallInfo fcinfo,
double proportion ;
bool isnull ;
/* safety check */
if ( AggCheckCallContext ( fcinfo , NULL ) ! = AGG_CONTEXT_AGGREGATE )
elog ( ERROR , " ordered-set aggregate called in non-aggregate context " ) ;
Assert ( AggCheckCallContext ( fcinfo , NULL ) = = AGG_CONTEXT_AGGREGATE ) ;
/* Get and check the percentile argument */
if ( PG_ARGISNULL ( 1 ) )
@ -752,9 +738,7 @@ percentile_disc_multi_final(PG_FUNCTION_ARGS)
bool isnull = true ;
int i ;
/* safety check */
if ( AggCheckCallContext ( fcinfo , NULL ) ! = AGG_CONTEXT_AGGREGATE )
elog ( ERROR , " ordered-set aggregate called in non-aggregate context " ) ;
Assert ( AggCheckCallContext ( fcinfo , NULL ) = = AGG_CONTEXT_AGGREGATE ) ;
/* If there were no regular rows, the result is NULL */
if ( PG_ARGISNULL ( 0 ) )
@ -875,9 +859,7 @@ percentile_cont_multi_final_common(FunctionCallInfo fcinfo,
bool isnull ;
int i ;
/* safety check */
if ( AggCheckCallContext ( fcinfo , NULL ) ! = AGG_CONTEXT_AGGREGATE )
elog ( ERROR , " ordered-set aggregate called in non-aggregate context " ) ;
Assert ( AggCheckCallContext ( fcinfo , NULL ) = = AGG_CONTEXT_AGGREGATE ) ;
/* If there were no regular rows, the result is NULL */
if ( PG_ARGISNULL ( 0 ) )
@ -1045,9 +1027,7 @@ mode_final(PG_FUNCTION_ARGS)
FmgrInfo * equalfn ;
bool shouldfree ;
/* safety check */
if ( AggCheckCallContext ( fcinfo , NULL ) ! = AGG_CONTEXT_AGGREGATE )
elog ( ERROR , " ordered-set aggregate called in non-aggregate context " ) ;
Assert ( AggCheckCallContext ( fcinfo , NULL ) = = AGG_CONTEXT_AGGREGATE ) ;
/* If there were no regular rows, the result is NULL */
if ( PG_ARGISNULL ( 0 ) )
@ -1173,9 +1153,7 @@ hypothetical_rank_common(FunctionCallInfo fcinfo, int flag,
TupleTableSlot * slot ;
int i ;
/* safety check */
if ( AggCheckCallContext ( fcinfo , NULL ) ! = AGG_CONTEXT_AGGREGATE )
elog ( ERROR , " ordered-set aggregate called in non-aggregate context " ) ;
Assert ( AggCheckCallContext ( fcinfo , NULL ) = = AGG_CONTEXT_AGGREGATE ) ;
/* If there were no regular rows, the rank is always 1 */
if ( PG_ARGISNULL ( 0 ) )
@ -1305,9 +1283,7 @@ hypothetical_dense_rank_final(PG_FUNCTION_ARGS)
MemoryContext tmpcontext ;
int i ;
/* safety check */
if ( AggCheckCallContext ( fcinfo , NULL ) ! = AGG_CONTEXT_AGGREGATE )
elog ( ERROR , " ordered-set aggregate called in non-aggregate context " ) ;
Assert ( AggCheckCallContext ( fcinfo , NULL ) = = AGG_CONTEXT_AGGREGATE ) ;
/* If there were no regular rows, the rank is always 1 */
if ( PG_ARGISNULL ( 0 ) )