Re: BUG #19732: first_value/last_value/nth_value return NULL with EXCLUDE TIES when the current row is outside its f

From: shihao zhong <zhong950419(at)gmail(dot)com>
To: Andrey Rachitskiy <pl0h0yp1(at)gmail(dot)com>
Cc: theshallow27(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19732: first_value/last_value/nth_value return NULL with EXCLUDE TIES when the current row is outside its f
Date: 2026-10-05 02:39:02
Message-ID: CAGRkXqRqnmCutng5GryjDeppa1ysn7WhSU9d4Jj027=QRf5KSA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi Andrey,

v2 looks good, I checked first_value, last_value and nth_value
against array_agg for every frame shape, and they all match now.

Maybe one more test

SELECT k, first_value(k) OVER w
FROM (VALUES (0), (1), (1), (1), (2)) t(k)
WINDOW w AS (ORDER BY k ROWS BETWEEN 2 FOLLOWING AND UNBOUNDED FOLLOWING
EXCLUDE TIES);

On Master it report ERROR: cannot fetch row before WindowObject's mark
position

This patch also covers 19731

Thanks,
Shihao

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Ayush Tiwari 2026-10-05 03:37:02 Re: BUG #19720: pg_trgm GiST index corruption from gtrgm_union() dropping SIGNKEY
Previous Message shihao zhong 2026-10-05 02:35:49 Re: BUG #19731: `first_value` returns an excluded peer for a nonempty `EXCLUDE TIES` frame