Re: Request for Patch Feedback: Lag & Lead Window Functions Can Ignore Nulls

From: Nicholas White <n(dot)j(dot)white(at)gmail(dot)com>
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: Request for Patch Feedback: Lag & Lead Window Functions Can Ignore Nulls
Date: 2013-03-25 00:15:10
Message-ID: CA+=vxNYqLgXiNsa9sP-K4FLmKH+pyR-P=iA72prtuAMf9b_A9g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thanks for the feedback.

For the parsing changes, it seems I can either make RESPECT and IGNORE
reserved keywords, or add a lookahead to construct synthetic RESPECT NULLS
and IGNORE NULLS keywords. The grammar wouldn't compile if RESPECT and
IGNORE were just normal unreserved keywords due to ambiguities after a
function definition (e.g. select abs(1) respect; - which is currently a
valid statement).

I've redone the leadlag function changes to use datumCopy as you suggested.
However, I've had to remove the NOT_USED #ifdef around datumFree so I can
use it to avoid building up large numbers of copies of Datums in the memory
context while a query is executing. I've attached the revised patch...

Thanks -

Nick

On 24 March 2013 03:43, Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com> wrote:

>
>
> On Sat, Mar 23, 2013 at 3:25 PM, Nicholas White <n(dot)j(dot)white(at)gmail(dot)com>wrote:
>
>> Thanks - I've added it here:
>> https://commitfest.postgresql.org/action/patch_view?id=1096 .
>>
>> I've also attached a revised version that makes IGNORE and RESPECT
>> UNRESERVED keywords (following the pattern of NULLS_FIRST and NULLS_LAST).
>>
>
> Hm, you made another lookahead in base_yylex to make them unreserved --
> looks ok, but not sure if there was no way to do it.
>
> You might want to try byref types such as text. It seems you need to copy
> the datum to save the value in appropriate memory context. Also, try to
> create a view on those expressions. I don't think it correctly preserves
> it.
>
> Thanks,
> --
> Hitoshi Harada

Attachment Content-Type Size
lead-lag-ignore-nulls.patch application/octet-stream 19.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Josh Berkus 2013-03-25 02:02:55 Re: [PATCH] Exorcise "zero-dimensional" arrays (Was: Re: Should array_length() Return NULL)
Previous Message Tom Lane 2013-03-24 22:38:47 Re: WIP: index support for regexp search