Re: Implement for window functions - Mailing list pgsql-hackers

From David Fetter
Subject Re: Implement for window functions
Date
Msg-id 20210103190416.GT13234@fetter.org
Whole thread Raw
In response to Re: Implement for window functions  (Zhihong Yu <zyu@yugabyte.com>)
List pgsql-hackers
On Fri, Jan 01, 2021 at 01:21:10PM -0800, Zhihong Yu wrote:
> Krasiyan:
> Happy New Year.
> 
> For WinGetFuncArgInPartition():
> 
> +           if (target > 0)
> +               step = 1;
> +           else if (target < 0)
> +               step = -1;
> +           else
> +               step = 0;
> 
> When would the last else statement execute ? Since the above code is
> for WINDOW_SEEK_CURRENT, I wonder why step should be 0.

If it does actually need step to be one of those three choices, it
might be shorter (well, less branchy) to write as

    step = (target > 0) - (target < 0);

Best,
David.
-- 
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate



pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: Rethinking plpgsql's assignment implementation
Next
From: Pavel Stehule
Date:
Subject: Re: [HACKERS] [PATCH] Generic type subscripting