From: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Stephen Frost <sfrost@snowman.net>
Cc: Merlin Moncure <mmoncure@gmail.com>
Cc: Regina Obe <lr@pcorp.us>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: Re: PostgreSQL 9.6 behavior change with set returning (funct).*
Date: Thu, 24 Mar 2016 10:31:57 -0400
Message-ID: <23451.1458829917@sss.pgh.pa.us> (raw)
In-Reply-To: <CA+TgmobfwwJHDpoKdi6cLv1-eu5zgtnd3E719-McmuaeDeEt4w@mail.gmail.com>
References: <001201d18524$f84c4580$e8e4d080$@pcorp.us>
<9987.1458754648@sss.pgh.pa.us>
<CAHyXU0zeaHigirhGXk5Go-=riu+ZSuiSa_kyLpgEaorSM8iAFg@mail.gmail.com>
<20160323201856.GR3127@tamriel.snowman.net>
<25750.1458767514@sss.pgh.pa.us>
<30200.1458772448@sss.pgh.pa.us>
<CA+TgmobfwwJHDpoKdi6cLv1-eu5zgtnd3E719-McmuaeDeEt4w@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>
Robert Haas <robertmhaas@gmail.com> writes:
> On Wed, Mar 23, 2016 at 6:34 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> A possibly larger problem is that it causes the SRFs to be evaluated
>> before sorting/ordering/limiting.
> I'm not sure I understand quite what the problem is here.
If you have "SELECT srf(x), y FROM ... ORDER BY y LIMIT n", we go
to some lengths as of 9118d03a8 to ensure that the ordering happens
before the SRF is expanded, meaning in particular that the SRF is
expanded only far enough to satisfy the limit. That is not the case
for SRF-in-FROM, and can't be if for instance there's a GROUP BY
involved. As-is, the proposed transformation obviously breaks the
semantics if grouping/aggregation/windowing is involved, and my point
is that that's true for ORDER BY/LIMIT as well. We'd need to fix
things so that the apparent order of performing those steps stays
the same.
I think that's probably doable in most cases by making a sub-select,
but I'm not sure if that works for every case --- in particular, what
do we do with a SRF referenced in ORDER BY or GROUP BY?
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, robertmhaas@gmail.com, sfrost@snowman.net, mmoncure@gmail.com, lr@pcorp.us
Subject: Re: PostgreSQL 9.6 behavior change with set returning (funct).*
In-Reply-To: <23451.1458829917@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox