patch implementing the multi-argument aggregates (SOC project)

From: "Sergey E(dot) Koposov" <math(at)sai(dot)msu(dot)ru>
To: pgsql-patches(at)postgresql(dot)org
Subject: patch implementing the multi-argument aggregates (SOC project)
Date: 2006-07-24 09:59:47
Message-ID: Pine.LNX.4.64.0607241340090.19158@lnfm1.sai.msu.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Hello All,

Since the feature freeze is in a few days, I'm sending the first iteration
of my patch implementing the multi-argument aggregates (PolyArgAgg) (SOC
project)

I currently fully enabled the creation and usage of PolyArgAggs, like this

CREATE OR REPLACE FUNCTION sum2_trans (anyelement, anyelement,anyelement)
RETURNS anyelement
AS 'SELECT $1+$2+$3;'
LANGUAGE SQL;

CREATE AGGREGATE sum2( anyelement,anyelement)
(SFUNC=sum2_trans,
STYPE=anyelement,
INITCOND=0);

postgres=# select * from xx;
a | b | c
---+---+-----
1 | 2 | 1.2
2 | 3 | 2.3
3 | 4 | 3.4
4 | 5 | 3.4
(4 rows)

postgres=# select sum2(a,b) from xx;
sum2
------
24
(1 row)

postgres=# select sum2(a,b) from xx group by c;
sum2
------
3
16
5
(3 rows)

Also I implemented the full set of PolyArgAggs from SQL 2003

REGR_SXX(), REGR_SYY(), REGR_SXY(), REGR_AVGX(), REGR_AVGY(), REGR_R2(),
CORR(), COVAR_POP(),COVAR_SAMP(), REGR_SLOPE(), REGR_INTERCEPT(),
REGR_COUNT()

Example:
template1=# select regr_r2(pronamespace::int::numeric,prolang::int::numeric) from pg_proc;
regr_r2
------------------------
0.14226915125082682802
(1 row)

template1=# select regr_r2(pronamespace::int,prolang::int) from pg_proc;
regr_r2
-------------------
0.142269151250827
(1 row)

template1=# select regr_count(pronamespace::int,prolang::int) from pg_proc;
regr_count
------------
1956
(1 row)

The existing regression tests are working.

What is still missing:
1) The additional regression tests testing the PolyArgAggs.
2) There is a couple of moments in the PG core related part of patch,
where I'm not completely sure that I'm doing the right thing...
(they are commented in the special way in the patch (if somebody can
clarify them for me, I would be happy))

Any comments are very welcome.

Regards,
Sergey

*******************************************************************
Sergey E. Koposov
Max Planck Institute for Astronomy/Sternberg Astronomical Institute
Tel: +49-6221-528-349
Web: http://lnfm1.sai.msu.ru/~math
E-mail: math(at)sai(dot)msu(dot)ru

Attachment Content-Type Size
PolyArgAggs.diff text/plain 137.9 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Joerg Hessdoerfer 2006-07-24 10:04:10 Re: Transaction Speed and real time database
Previous Message Markus Schiltknecht 2006-07-24 09:32:03 Re: Documenting Replication Solutions

Browse pgsql-patches by date

  From Date Subject
Next Message Zdenek Kotala 2006-07-24 10:25:29 Re: Mark change-on-restart-only values in postgresql.conf
Previous Message Peter Eisentraut 2006-07-24 09:52:12 Re: Mark change-on-restart-only values in postgresql.conf