pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #15291: Lateral join has different/suprising semantics (with impure function)
2+ messages / 2 participants
[nested] [flat]
* BUG #15291: Lateral join has different/suprising semantics (with impure function)
@ 2018-07-24 07:10 PG Bug reporting form <noreply@postgresql.org>
0 siblings, 1 reply; 2+ messages in thread
From: PG Bug reporting form @ 2018-07-24 07:10 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org; +Cc: kadek.marek@gmail.com
The following bug has been logged on the website:
Bug reference: 15291
Logged by: Marek K.
Email address: kadek.marek@gmail.com
PostgreSQL version: 11beta2
Operating system: Ubuntu, OSX
Description:
Following SQL:
CREATE EXTENSION "uuid-ossp";
CREATE TABLE fruits (name VARCHAR);
INSERT INTO fruits VALUES ('banana'), ('apple');
-- 1:
-- banana | uuid1
-- apple | uuid1
SELECT f.name, t.uuid FROM fruits f
CROSS JOIN LATERAL (
SELECT uuid_generate_v4() AS uuid FROM (VALUES(1)) v
) t;
-- 2:
-- banana | uuid1
-- apple | uuid2
SELECT f.name, t.uuid FROM fruits f
CROSS JOIN LATERAL (
SELECT f.name, uuid_generate_v4() AS uuid FROM (VALUES(1)) v
) t
I can understand why it's happening what is happening, yet I still find it
to be problematic. In my opinion those two selects should yield same
results. Hence for impure functions lateral semantics should be preserved
and not optimized away.
I am not 100% sure it can be classified as a bug, but looking into what your
opinion is.
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: BUG #15291: Lateral join has different/suprising semantics (with impure function)
@ 2018-07-24 13:50 Tom Lane <tgl@sss.pgh.pa.us>
parent: PG Bug reporting form <noreply@postgresql.org>
0 siblings, 0 replies; 2+ messages in thread
From: Tom Lane @ 2018-07-24 13:50 UTC (permalink / raw)
To: kadek.marek@gmail.com; +Cc: pgsql-bugs@lists.postgresql.org
=?utf-8?q?PG_Bug_reporting_form?= <noreply@postgresql.org> writes:
> [ LATERAL is ignored when sub-select has no actual lateral references ]
> I can understand why it's happening what is happening, yet I still find it
> to be problematic. In my opinion those two selects should yield same
> results. Hence for impure functions lateral semantics should be preserved
> and not optimized away.
I believe this behavior is effectively required by the SQL spec.
In any case, removing it would pessimize many queries in which writing
an unnecessary LATERAL has no bad side-effects today, so I'm disinclined
to change a behavior that's stood for half a dozen releases now.
regards, tom lane
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2018-07-24 13:50 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-07-24 07:10 BUG #15291: Lateral join has different/suprising semantics (with impure function) PG Bug reporting form <noreply@postgresql.org>
2018-07-24 13:50 ` Tom Lane <tgl@sss.pgh.pa.us>
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