Re: Implement <null treatment> for window functions

From: David Fetter <david(at)fetter(dot)org>
To: Zhihong Yu <zyu(at)yugabyte(dot)com>
Cc: Krasiyan Andreev <krasiyan(at)gmail(dot)com>, Vik Fearing <vik(at)postgresfriends(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Implement <null treatment> for window functions
Date: 2021-01-03 19:04:16
Message-ID: 20210103190416.GT13234@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2021-01-03 19:41:17 Re: [HACKERS] [PATCH] Generic type subscripting
Previous Message Pavel Stehule 2021-01-03 18:16:43 Re: Rethinking plpgsql's assignment implementation