Re: [HACKERS] Sample of user-define window function and other things

2009-01-12 Thread Tom Lane
Gregory Stark writes: > Even if they can support it shouldn't they reject functions that aren't > actually window functions? What happens if you mark a perfectly normal > function as a window function, does it behave sanely? Yes, for small values of "sane". It will see all its arguments as NULL

Re: [HACKERS] Sample of user-define window function and other things

2009-01-12 Thread Gregory Stark
Peter Eisentraut writes: > Hitoshi Harada wrote: >> - CREATE FUNCTION command accepts WINDOW keyword for non-c language >> like plpgsql. Don't we need to throw error? > > The validator procedures of those languages should be made to reject that case > if they can't support it. Even if they can s

Re: [HACKERS] Sample of user-define window function and other things

2009-01-12 Thread Peter Eisentraut
Hitoshi Harada wrote: - CREATE FUNCTION command accepts WINDOW keyword for non-c language like plpgsql. Don't we need to throw error? The validator procedures of those languages should be made to reject that case if they can't support it. -- Sent via pgsql-hackers mailing list (pgsql-hackers

Re: [HACKERS] Sample of user-define window function and other things

2009-01-08 Thread Tom Lane
"Hitoshi Harada" writes: > 2009/1/8 Tom Lane : >> You mean set_mark? It's just to save an extra calculation of the >> absolute location of the fetched row. See leadlag_common for an >> example use: we can truncate the tuplestore if the offset is constant. > Yeah, I mean set_mark :P) I already c

Re: [HACKERS] Sample of user-define window function and other things

2009-01-08 Thread Hitoshi Harada
2009/1/8 Tom Lane : > "Hitoshi Harada" writes: >> - Is WinGetFuncArgInPartition()'s argument mark_pos required? For the >> newbies to window functions, it seems a bit confusing, but >> WinSetMarkPos() looks enough for the purpose AFAIK. > > You mean set_mark? It's just to save an extra calculatio

Re: [HACKERS] Sample of user-define window function and other things

2009-01-08 Thread Tom Lane
"Hitoshi Harada" writes: > - CREATE FUNCTION command accepts WINDOW keyword for non-c language > like plpgsql. Don't we need to throw error? No. CREATE FUNCTION has no business trying to keep track of which PLs implement what. That case won't do anything useful right now, but it might do someth

[HACKERS] Sample of user-define window function and other things

2009-01-08 Thread Hitoshi Harada
Attached is a simple user-define window function as a test, which calculates moving avg(). Writing this, I found that even with current specification (i.e. limited frame clauses), user-define function can emulate some kinds of moving frame for simple purpose. CREATE OR REPLACE FUNCTION movavg(floa