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

From David Rowley
Subject Re: BUG #19533: Wrong results from WindowAgg run-condition pushdown on count() with EXCLUDE CURRENT ROW
Date
Msg-id CAApHDvrN-HL=dSBez=pme5RQKCiH7SrsMEFV-eQRJN3Vs94ZEQ@mail.gmail.com
Whole thread
In response to Re: BUG #19533: Wrong results from WindowAgg run-condition pushdown on count() with EXCLUDE CURRENT ROW  (John Naylor <johncnaylorls@gmail.com>)
Responses Re: BUG #19533: Wrong results from WindowAgg run-condition pushdown on count() with EXCLUDE CURRENT ROW
List pgsql-bugs
On Fri, 3 Jul 2026 at 21:10, John Naylor <johncnaylorls@gmail.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

pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #19543: ALTER RULE ... RENAME accepts reserved name "_RETURN" for a non-view rule; breaks a restored dump
Next
From: Tom Lane
Date:
Subject: Re: BUG #19543: ALTER RULE ... RENAME accepts reserved name "_RETURN" for a non-view rule; breaks a restored dump