> The problem is, given that the parser is looking at: > > foo(p1,p2,...) within group (order by q1,q2,...) > > how do we best represent the possible matching functions in pg_proc > and pg_aggregate? Our partial solution so far does not allow > polymorphism to work properly, so we need a better way; I'm hoping for > some independent suggestions before I post my own ideas.
Yeah, you'd need to extend VARIADIC somehow. That is, I should be able to define a function as: percentile_state ( pctl float, ordercols VARIADIC ANY ) returns VARIADIC ANY ... so that it can handle the sorting. Another way to look at it would be: percentile_state ( pctl float, orderedset ANONYMOUS ROW ) returns ANONYMOUS ROW as ... ... because really, what you're handing the state function is an anonymous row type constructed of the order by phrase. Of course, then we have to have some way to manipulate the anonymous row from within the function; at the very least, an equality operator. -- Josh Berkus PostgreSQL Experts Inc. http://pgexperts.com -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers