pgsql-bugs@postgresql.org writes:
> create aggregate aggint4sum (basetype = int4, sfunc = int4_sum, stype = int4);
This doesn't work because there's no int4_sum(int4, int4).
regression=# \df int4_sum
List of functions
Result data type | Name | Argument data types
------------------+----------+---------------------
bigint | int4_sum | bigint, integer
^^^^^^
(1 row)
You don't get any automatic conversion when defining an aggregate: the
datatypes have to match exactly.
Your other three examples work for me.
regards, tom lane