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

From: shihao zhong <zhong950419(at)gmail(dot)com>
To: ishii(at)postgresql(dot)org, masao(dot)fujii(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-07 23:55:04
Message-ID: CAGRkXqQEwe4aP-1eo3b8qJ_A2cxPQGd=n1U4-36z5CZx_niFxA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

> In my understanding to determine whether a
> row is in frame, we need to fetch the row first. We need to check the
> tuple content in some frame options.

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,
Shihao

Attachment Content-Type Size
v1-0001-Don-t-read-past-a-ROWS-frame-end-in-IGNORE-NULLS-.patch application/octet-stream 3.5 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message shihao zhong 2026-11-08 00:02:15 Re: BUG #19780: gtsvector_picksplit() reads uninitialized data when called with three entries
Previous Message Kevin Struckhoff 2026-11-07 19:33:52 Re: Errors in pgdg repo packages