Re: BUG #19533: Wrong results from WindowAgg run-condition pushdown on count() with EXCLUDE CURRENT ROW

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: John Naylor <johncnaylorls(at)gmail(dot)com>
Cc: Richard Guo <guofenglinux(at)gmail(dot)com>, Chengpeng Yan <chengpeng_yan(at)outlook(dot)com>, "imchifan(at)163(dot)com" <imchifan(at)163(dot)com>, "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #19533: Wrong results from WindowAgg run-condition pushdown on count() with EXCLUDE CURRENT ROW
Date: 2026-07-03 23:57:23
Message-ID: CAApHDvrN-HL=dSBez=pme5RQKCiH7SrsMEFV-eQRJN3Vs94ZEQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Fri, 3 Jul 2026 at 21:10, John Naylor <johncnaylorls(at)gmail(dot)com> wrote:
> If it was from tooling, it must have stopped with the first case it
> found, as is often the case. I just tried myself and found three more
> apparent bugs with EXCLUDE both with and without the v1 patch. Do you
> want to see the reproducers, or rethink the risk/reward ratio of
> what's handled? I'm also not sure how common that clause is.

Please share what you discovered. It would be good to understand if
it's just a simple missing check that can be added to handle all
three, or if there's just more complexity in this than making this
work correctly is worth.

> Separately, I also I believe I found a counterexample to the part
> starting with /* No ORDER BY clause then all rows are peers */ :

Thanks for finding that. Looks like I failed to consider ROWs mode for
that, where the function is only monotonically increasing. The
attached includes a fix for that.

David

Attachment Content-Type Size
v2-0001-Fix-COUNT-s-logic-for-window-run-condition-suppor.patch application/octet-stream 35.4 KB

In response to

Browse pgsql-bugs by date

  From Date Subject
Previous Message Baji Shaik 2026-07-03 23:54:16 Re: uuidv7 improperly accepts dates before 1970-01-01