Re: add more frame types in window functions (ROWS)

From: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
To: umi(dot)tanuki(at)gmail(dot)com (Hitoshi Harada), pgsql-hackers(at)postgresql(dot)org
Subject: Re: add more frame types in window functions (ROWS)
Date: 2009-11-14 20:33:51
Message-ID: 87y6m8najw.fsf@news-spur.riddles.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi, I've started reviewing your patch.

I've already found some things that need work:

- missing _readWindowFrameDef function (all nodes that are output
from parse analysis must have both _read and _out functions,
otherwise views can't work)

- the A_Const nodes should probably be transformed to Const nodes in
parse analysis, since A_Const has no _read/_out functions, which
means changing the corresponding code in the executor.

(A question here: the spec allows (by my reading) the use of
parameters in the window frame clause, i.e. BETWEEN $1 PRECEDING AND
$2 FOLLOWING. Wouldn't it therefore make more sense to treat the
values as Exprs, albeit very limited ones, and eval them at startup
rather than assuming we know the node type and digging down into it
all over the place?)

You can see the problem here if you do this:

create view v as
select i,sum(i) over (order by i rows between 1 preceding and 1 following)
from generate_series(1,10) i;
select * from v;

(A regression test for this would probably be good, which reminds me that
I need to add one of those myself in the aggregate order by stuff.)

Also, you're going to need to do some work in ruleutils.c
(get_rule_windowspec) in order to be able to deparse your new frame
definitions.

I'll continue reviewing the stuff that does work, so I'm not marking this
as "waiting for author" yet.

--
Andrew (irc:RhodiumToad)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2009-11-14 20:43:50 Re: add more frame types in window functions (ROWS)
Previous Message Tom Lane 2009-11-14 20:31:05 Re: Inspection of row types in pl/pgsql and pl/sql