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

From: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
To: Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: add more frame types in window functions (ROWS)
Date: 2009-11-15 07:33:47
Message-ID: 87eio0mezy.fsf@news-spur.riddles.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>>>>> "Hitoshi" == Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com> writes:

>>> (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?)

>> Seems like you might as well allow any expression not containing
>> local Vars.  Compare the handling of LIMIT.

Hitoshi> Hmm, I've read it wrong, was assuming a constant for <unsigned value
Hitoshi> specification> which actually includes any expression. But it's a
Hitoshi> fixed value during execution, right? Otherwise, we cannot predicate
Hitoshi> frame boundary.

The spec doesn't allow arbitrary expressions there, only literals and
parameters. Allowing more than that would be going beyond the spec, but
as with LIMIT, could be useful nonetheless.

For it to be a fixed value during execution, the same rules apply as
for LIMIT; it can't contain Vars of the current query level.

My thinking is that the executor definitely shouldn't be relying on it
being a specific node type, but should just ExecEvalExpr it on the
first call and store the result; then you don't have to know whether
it's a Const or Param node or a more complex expression.

--
Andrew.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Hitoshi Harada 2009-11-15 07:43:41 Re: add more frame types in window functions (ROWS)
Previous Message Hitoshi Harada 2009-11-15 07:27:49 NULL input for array_agg()?