| From: | BHUVAN CHILUKUTI <c(dot)bhuvan(at)iitg(dot)ac(dot)in> |
|---|---|
| To: | shihao zhong <zhong950419(at)gmail(dot)com>, Tatsuo Ishii <ishii(at)postgresql(dot)org> |
| Cc: | "pgsql-bugs(at)lists(dot)postgresql(dot)org" <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-10-25 19:55:54 |
| Message-ID: | PN0P287MB090337113E44F5EE55D69A09A7622@PN0P287MB0903.INDP287.PROD.OUTLOOK.COM |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
Hi Shihao,
Thanks for reproducing the issue and for the helpful suggestion.
I've added the last_value(x) IGNORE NULLS regression case with EXCLUDE TIES and no ORDER BY. This covers the backward-scan path you mentioned: with no window ORDER BY, all rows are peers, so EXCLUDE TIES leaves only the current row in the frame, and the expected results are 1, 2, and 3.
The updated patch passes make check on both master and REL_19_STABLE (239/239 on each), and it applies cleanly to both branches. The production C fix is unchanged.
I've attached the updated patch for your review.
Best regards,
Bhuvan Chilukuti
________________________________
From: shihao zhong <zhong950419(at)gmail(dot)com>
Sent: Sunday, October 25, 2026 9:34 PM
To: Tatsuo Ishii <ishii(at)postgresql(dot)org>
Cc: BHUVAN CHILUKUTI <c(dot)bhuvan(at)iitg(dot)ac(dot)in>; pgsql-bugs(at)lists(dot)postgresql(dot)org <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)
You don't often get email from zhong950419(at)gmail(dot)com(dot) Learn why this is important<https://aka.ms/LearnAboutSenderIdentification>
Hi Bhuvan,
Thanks for the report and the patch. I can reproduce all five queries
on master and on 19rc1.
This came in with 25a30bbd423. I think it belongs on the 19 open items.
https://wiki.postgresql.org/wiki/PostgreSQL_19_Open_Items
With your patch all five return at once and the regression tests
pass. I also compared the three functions against array_agg(x) FILTER
(WHERE x IS NOT NULL) over about 11k frame combinations. That included
spill to disk and volatile arguments. No differences.
One suggestion for the test. Could you add last_value IGNORE NULLS
with EXCLUDE TIES and no ORDER BY? It scans backward, so it would
catch a later fix in row_is_in_frame that returns -1 for every
position after the current row.
Thanks,
Shihao
| Attachment | Content-Type | Size |
|---|---|---|
| AUDIT-F2_REGRESSION_TEST.patch | application/octet-stream | 8.4 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2026-10-25 21:16:45 | Re: BUG #19784: "no relation entry for relid 1" when costing = ANY (<array expr over max(col)>) in a MinMaxAggPath |
| Previous Message | shihao zhong | 2026-10-25 18:31:11 | Re: BUG #19792: BUG: Deadlock between WaitIO and read-stream look-ahead under io_method=io_uring (18.6) |