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

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Richard Guo <guofenglinux@gmail.com>
Cc: David Rowley <dgrowleyml@gmail.com>, Daniel Farkaš <daniel.farkas@datoris.com>, Magnus Hagander <magnus@hagander.net>, PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Date: 2023-01-30T22:53:33Z
Lists: pgsql-bugs

Attachments

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.

			regards, tom lane

Commits

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