Re: first_value()/nth_value() with IGNORE NULLS loop forever (EXCLUDE GROUP/TIES, frame past partition end, no ORDER BY)

From: Tatsuo Ishii <ishii(at)postgresql(dot)org>
To: zhong950419(at)gmail(dot)com
Cc: masao(dot)fujii(at)gmail(dot)com, c(dot)bhuvan(at)iitg(dot)ac(dot)in, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: first_value()/nth_value() with IGNORE NULLS loop forever (EXCLUDE GROUP/TIES, frame past partition end, no ORDER BY)
Date: 2026-11-09 00:19:50
Message-ID: 20261109.091950.2016703765973000585.ishii@postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

> I agree about nth_value() with RESPECT NULLS. It has always worked
> this way.
>
> But for ROWS frames row_is_in_frame() can tell from the position
> alone that the row is out of frame. The attached patch moves that call
> back in front of the partition end check. Fujii-san's query returns
> NULL again, and the loop from the original report still ends.

Thanks for the patch. I had thought about a similar fix but still am
not convinced it's worth the trouble.

Let's continue the discussion on it after 19 GA is out.

Regards,
--
Tatsuo Ishii
SRA OSS K.K.
English: http://www.sraoss.co.jp/index_en/
Japanese:http://www.sraoss.co.jp

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tender Wang 2026-11-09 00:59:23 Re: BUG #19852: NOT IN -> anti-join conversion gives wrong results when the equality operator returns NULL for non-n
Previous Message David Rowley 2026-11-09 00:10:27 Re: BUG #19836: Backend crash with large hash partition modulus