I happily announce that the first design of window function was finished and the patch against HEAD is released online. See http://umitanuki.net/pgsql/wfv03/design.html
The window functions such like row_number(), rank(), dense_rank(), percent_rank() are experimentally defined within the patch as * It is formed as an aggregate function, seen in pg_aggregate * It does or does not have trans function. * It has a final function that is declared as VOLATILE. * Its final function is called multiple times during returning values. And ranking system is a bit ugly. The problem was how you know the ranking boundary. Inside rank_final(), you see WindowState node is pulled out from fcinfo->context and TupleTableSlot is used. Actually I am not sure if this is appropriate but have tried it, which did work. So as the first release, I guess it is better that the window functions are formulated but not open as user-defined functions. Also, since current design of the window functions is by aggregate, some of the SQL spec functions such like lag()/lead() was dropped. These functions need to reach for random rows from current row. For this needs, we might have to provide something like Window Object mechanism that allows random access to the current frame. There's no additional docs and tests, as well as lack of comments in source code. The "make check" will fail because some of the window functions do not have trans function. Reviews and comments are welcome. I'm eager to refine it. Regards, -- Hitoshi Harada
window_function_v03_patch.tgz
Description: GNU Zip compressed data
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers