Re: Windowing Function Patch Review -> NTH_VALUE

Поиск
Список
Период
Сортировка
От Hitoshi Harada
Тема Re: Windowing Function Patch Review -> NTH_VALUE
Дата
Msg-id e08cc0400811110809o3fb66e4cu50350c70a3732b20@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Windowing Function Patch Review -> NTH_VALUE  ("Hitoshi Harada" <umi.tanuki@gmail.com>)
Ответы Re: Windowing Function Patch Review -> NTH_VALUE  ("Hitoshi Harada" <umi.tanuki@gmail.com>)
Список pgsql-hackers
2008/11/10 Hitoshi Harada <umi.tanuki@gmail.com>:
> 2008/11/9 David Rowley <dgrowley@gmail.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


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: pg_upgrade project status
Следующее
От: Zdenek Kotala
Дата:
Сообщение: Re: pg_upgrade project status