Re: BUG #17502: View based on window functions returns wrong results when queried

David Rowley <dgrowleyml@gmail.com>

From: David Rowley <dgrowleyml@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Richard Guo <guofenglinux@gmail.com>, Daniel Farkaš <daniel.farkas@datoris.com>, Magnus Hagander <magnus@hagander.net>, PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Date: 2026-06-29T23:35:19Z
Lists: pgsql-bugs
On Tue, 31 Jan 2023 at 11:53, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> Richard Guo <guofenglinux@gmail.com> writes:
> > On Mon, May 30, 2022 at 9:12 AM David Rowley <dgrowleyml@gmail.com> wrote:
> >> The following is also pretty strange. Why should adding the SRF column
> >> to the ORDER BY change the number of output rows?
>
> > Is this a bug we should fix?
>
> This bug seems to have slipped off the radar screen, but it's still
> a bug.  I continue to believe that the best fix is to disallow SRFs
> in window definitions, and present the trivial patch to do so.
>
> As discussed, I'm comfortable with leaving this alone in the back
> branches.

There has been another report about this in bug #19535. Should we
consider going with disallowing SRFs in the WindowClause for v19?

David



Commits

  1. Disallow set-returning functions within window OVER clauses.