Re: Implement targetlist SRFs using ROWS FROM() (was Changed SRF in targetlist handling)
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@anarazel.de>
Cc: Kevin Grittner <kgrittn@gmail.com>, Robert Haas <robertmhaas@gmail.com>,
"pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>
Date: 2016-09-02T14:34:54Z
Lists: pgsql-hackers
Andres Freund <andres@anarazel.de> writes: > On 2016-09-02 10:20:42 -0400, Tom Lane wrote: >> ... ISTM all we >> need is that the SRF be on the inside of the join, which is automatic >> if it's LATERAL. > Right. But there's nothing to force a lateral reference to be there > intrinsically. I've added a "fake" lateral reference to the ROWS FROM > RTE to the subquery, when there's none otherwise, but that's not > entirely pretty. Hm, do you get cases like this right: select generate_series(1, t1.a) from t1, t2; That would result in a lateral ref from the SRF RTE to t1, but you really need to treat it as laterally dependent on the join of t1/t2 in order to preserve the old semantics. That is, you need to be laterally dependent on the whole FROM clause regardless of which variable references appear. regards, tom lane
Commits
-
Remove obsoleted code relating to targetlist SRF evaluation.
- ea15e18677fc 10.0 landed
-
Doc: improve documentation of new SRF-in-tlist behavior.
- f13a1277aa2d 10.0 landed
-
Move targetlist SRF handling from expression evaluation to new executor node.
- 69f4b9c85f16 10.0 landed
-
Don't split up SRFs when choosing to postpone SELECT output expressions.
- d543170f2fdd 9.6.0 cited