From: | "Hitoshi Harada" <umi(dot)tanuki(at)gmail(dot)com> |
---|---|
To: | "David Rowley" <dgrowley(at)gmail(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Windowing Function Patch Review -> NTH_VALUE |
Date: | 2008-11-11 16:09:02 |
Message-ID: | e08cc0400811110809o3fb66e4cu50350c70a3732b20@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
2008/11/10 Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>:
> 2008/11/9 David Rowley <dgrowley(at)gmail(dot)com>:
>> I'm having a little trouble understanding the standard for NTH_VALUE(). I
>> would have assumed that NTH_VALUE(name,1) would return the first name in the
>> window. The current patch is using 0 for the first.
>>
>
> Hmmm, good point... I haven't thought about it enough, just followed
> the internal design. The window_seek() in nodeWindow.c, which is an
> internal API, counts rows from 0 so the external behavior is simlar.
> Nothing more :-P
>
Reading the spec more closely, it says:
If <window function type> is <nth value function>, then:
i) Let RN be the value of <nth row>.
ii) Case:
1) If RN is the null value, then the result is the null value.
2) If RN is less than or equal to 0 (zero), then an exception
condition is raised: data exception ― invalid argument for NTH_VALUE
function.
So obviously nth_value(expr, 0) causes error and nth_value(expr, 1)
returns the first row. I will update my patch soon.
Regards,
--
Hitoshi Harada
From | Date | Subject | |
---|---|---|---|
Next Message | Zdenek Kotala | 2008-11-11 16:19:05 | Re: pg_upgrade project status |
Previous Message | Sergey Konoplev | 2008-11-11 16:07:17 | Re: Very slow queries w/ NOT IN preparation (seems like a bug, test case) |