Hi Oliver,
I have just pushed a change to WinGetFuncArgInPartition() in
nodeWindowAgg.c to fix Coverity issues. So please update your git
respository.
> The result looks wrong. So I've just tried removing the "&& relpos != 0"
> and I get:
>
> SELECT x, y, lead(x, 0) IGNORE NULLS OVER w FROM g
> WINDOW w AS (ORDER BY y);
> x | y | lead
> ---+---+------
> | 1 |
> | 2 |
> 1 | 3 |
> (3 rows)
>
> Nothing appears for lead at all. So it was doing something but doesn't look
> like it handles the lead(x, 0) case
I think we need to change this:
forward = relpos > 0 ? 1 : -1;
:
:
/*
* Get the next nonnull value in the partition, moving forward or backward
* until we find a value or reach the partition's end.
*/
do
{
int nn_info; /* NOT NULL info */
abs_pos += forward;
if (abs_pos < 0) /* apparently out of partition */
break;
In lead(0, x) case, abs_pos==0 and foward==-1. So it exits the loop
due to out of partition. Probably we need to change
forward = relpos > 0 ? 1 : -1;
to
forward = relpos >= 0 ? 1 : -1;
and change the do..while loop to a for loop?
Best regards,
--
Tatsuo Ishii
SRA OSS K.K.
English: http://www.sraoss.co.jp/index_en/
Japanese:http://www.sraoss.co.jp