BUG #15291: Lateral join has different/suprising semantics (withimpure function) - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #15291: Lateral join has different/suprising semantics (withimpure function)
Date
Msg-id 153241622629.1395.7281368493830784815@wrigleys.postgresql.org
Whole thread Raw
Responses Re: BUG #15291: Lateral join has different/suprising semantics (with impure function)
List pgsql-bugs
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.


pgsql-bugs by date:

Previous
From: Moshe Jacobson
Date:
Subject: Re: pg_restore: All GRANTs on table fail when any one role is missing
Next
From: PG Bug reporting form
Date:
Subject: BUG #15292: Multiple Messages "2018-07-24 10:46:12.566 CEST [32029]LOG: invalid length of startup" in logfile