Hello All,
I just thought about implementing some two-argument aggregate functions from
SQL 2003 (like CORR(x,y), REGR_SLOPE(x,y) etc...)
( http://www.wiscorp.com/SQL2003Features.pdf , page 10)
1) I looked into the architecture of how the aggregate functions are created
and used, and it seemed for me that the structure of the pg_aggregate and
pg_proc tables do not prevent the creating of the two-argument
aggregate functions -- Just for each two-arg. aggregate, the corresponding
three-arg. transition function and the two-arg. aggregate_dummy function
should be added to the pg_proc and a record should be added to the
pg_aggregate. Nothing else and nothing internal need not to be changed to
insert new two-arg. aggregate functions into the core.
Am I right in this ?
2) Also I thought about allowing the user to create the new two-arg.
aggregates. With that I only saw one thing which could/should be changed,
and this is the handling of the BASETYPE attribute of the CREATE AGGREGATE
command.
CREATE AGGREGATE name ( BASETYPE = input_data_type, SFUNC = sfunc, STYPE = state_data_type ... )
I am not very familiar with the parser/lexer details in postgres, but is it
possible to allow to do things like that :
CREATE AGGREGATE new_2arg_agg ( BASETYPE = (int,int) , .... )
to create the two-arg. aggregates ?
I'd like to hear any comments/advices/objections...
Regards,Sergey
*****************************************************
Sergey E. Koposov
Max Planck Institute for Astronomy/Sternberg Astronomical Institute
Web: http://lnfm1.sai.msu.ru/~math
E-mail: math@sai.msu.ru