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: 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-05 05:29:57
Message-ID: 20261105.142957.1216400569926986716.ishii@postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi Shihao,

> Hi Tatsuo,
>
> I think you are right here, sorry for my previous email confused you.

No problem at all.

> I misread Bhuvan's first mail. I thought row_is_in_frame also needed a fix,
> so that it would return -1 for rows after the current row when there is no
> ORDER BY.
>
> I rechecked the code and the fix already covered all the cases, I dont
> think we need to adjust the test anymore.

Ok.

Attached is the v1 patch, based on Bhuvan's second patch, minus the
last_value test case. The commit message is almost copied from his
patch, except comments about the test cases, which I feel too verbose
for a commit message. IMO attached patch is ready for commit, but
comments are welcome. If there's no objection, I will push it to
master and 19 branches soon.

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

Attachment Content-Type Size
v1-0001-Fix-infinite-loop-in-first_value-nth_value-with-I.patch application/octet-stream 6.2 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Bertrand Drouvot 2026-11-05 05:48:38 Re: VACUUM/ANALYZE double-count the backend's own pending table stats
Previous Message Michael Paquier 2026-11-05 04:18:30 Re: [Bug] Heap use-after-free in COPY FROM error context after ON_ERROR ignore skips a row