Re: creating a new aggregate function - Mailing list pgsql-sql

From Tom Lane
Subject Re: creating a new aggregate function
Date
Msg-id 20952.1393892275@sss.pgh.pa.us
Whole thread Raw
In response to Re: creating a new aggregate function  (Seb <spluque@gmail.com>)
List pgsql-sql
Seb <spluque@gmail.com> writes:
> Thanks for that suggestion.  It seemed as if array_agg would allow me to
> define a new aggregate for avg as follows:

> CREATE AGGREGATE avg (angle_vector)
> (
>   sfunc=array_agg,
>   stype=anyarray,
>   finalfunc=angle_vector_avg
> );

That's not going to work, for exactly this reason:

> ERROR:  cannot determine transition data type
> DETAIL:  An aggregate using a polymorphic transition type must have at least one polymorphic argument.

I see no reason to use a polymorphic type here anyway ... why not just
declare the transition data type as angle_vector[] ?
        regards, tom lane



pgsql-sql by date:

Previous
From: Seb
Date:
Subject: Re: creating a new aggregate function
Next
From: Sebastian P. Luque
Date:
Subject: Re: creating a new aggregate function