Re: [HACKERS] Aggregates with context - a question - Mailing list pgsql-hackers
From | wieck@debis.com (Jan Wieck) |
---|---|
Subject | Re: [HACKERS] Aggregates with context - a question |
Date | |
Msg-id | m10rhTh-0003kGC@orion.SAPserv.Hamburg.dsh.de Whole thread Raw |
In response to | Aggregates with context - a question (Philip Warner <pjw@rhyme.com.au>) |
List | pgsql-hackers |
Philip Warner wrote: > > Dear All, > > I have written a STDEV aggregate function which seems to work; the only problem is that I am not sure that the method Iam using was intended by the designers of aggregates. > > I am using the first parameter of sfunc1 to store a pointer to a context record, and sfunc1 creates and returns that pointerwhen it is first called (the DB definition specified initcond1 = '0'). In this way I can accumulate all the detailsI need. > > The problems is that the way I read the code, there is an expectation that the parameters of sfuncX and finalfunc matchthe basetype. This is clearly not the case, and I have declared them as int4, which will also presumable break on 64bit implementations... > > Anyway, the code is below. Any suggestions as to how I should handle complex context within aggregates would be appreciated. Here's another implementation of standard deviation and variance I've done some month's ago. It's based on it's own datatype holding 2 float64 values as aggregate state variable. So it doesn't need to pass pointers of context records around. I wanted to wait for some other statistical functions that could be added to the package before putting it into the contrib. Maybe you have some suggestions what would be nice to add it to? I'll add it anyway to the contrib for v6.6. Jan -- #======================================================================# # It's easier to get forgiveness for being wrong than for being right. # # Let's break this rule - forgive me. # #========================================= wieck@debis.com (Jan Wieck) # begin 644 statmath.tar.gz M'XL(`/U;7C<"`^U:>W/;R`WWO]Q/@3@//6)1HF3)&9^=.<567'?D1V5[>IW+ MC88B*9D-12I\R,DUU\]>8)=/DY;EJ^-F4F(2B5PN@`7P`Q9+V?-5?Z[ZU\V- M;T>PW=KI=F$#D#HM_JVTQ7=(+8!>;Z?7;G?Q`Y^V=EJ=#>AN/`$%GJ^Z`!N+ MF??)6C%/GZ@;/R!Y4?Q/U(_&U+2,;Z!#:;5ZV]MWQK_=ZFY3_)7M7K?;57;H MZ7:GMP&M,O[?G)XW'HO8<_8<(A1!>(\4#TT=%_QK`R+(P=S1`\N0:>+CK8*= M'QT>CV`?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