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

From: Ilya Anfimov <ilan(at)tzirechnoy(dot)com>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #17502: View based on window functions returns wrong results when queried
Date: 2022-05-30 10:27:53
Message-ID: 20220530102753.GA2725032@azor.tzirechnoy.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Sun, May 29, 2022 at 10:18:59PM -0400, Tom Lane wrote:
> David Rowley <dgrowleyml(at)gmail(dot)com> writes:
> > The problem seems to be down to the fact that
> > remove_unused_subquery_outputs() does not check if the to-be-removed
> > target entry references WindowClauses which contain set-returning
> > functions.
>
> I was sort of wondering why we allow SRFs in this context in the
> first place. The results don't seem terribly well-defined to me.
> In particular, a WindowFunc invocation is not supposed to change the
> number of rows in the query result, and yet this one is doing so.

I would like to note, that some SRFs may return only one row in
specific cases, like dblink() with the specific query.
It may used much more often, than real multirow SRFs in PARTITION BY.

While converting it to a LATERAL JOIN is not a lot of work --
breaking it in previous versions may affect a lot of people.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2022-05-30 11:21:35 BUG #17503: Package postgresql-jdbc-42.3.6-1.rhel8.noarch.rpm is not signed
Previous Message Richard Guo 2022-05-30 09:18:44 Re: BUG #17502: View based on window functions returns wrong results when queried