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: pgsql-hackers@postgresql.org
Date: 2016-09-13T16:07:35Z
Lists: pgsql-hackers
Attachments
- add-Query.hasTargetSRFs-field.patch (text/x-diff) patch
Andres Freund <andres@anarazel.de> writes: > Attached is a significantly updated patch series (see the mail one up > for details about what this is, I don't want to quote it in its > entirety). I've reviewed the portions of 0005 that have to do with making the parser mark queries with hasTargetSRF. The code as you had it was wrong because it would set the flag as a consequence of SRFs in function RTEs, which we don't want. It seemed to me that the best way to fix that was to rely on the parser's p_expr_kind mechanism to tell which part of the query we're in, whereupon we might as well make the parser act more like it does for aggregates and window functions and give a suitable error at parse time for misplaced SRFs. The attached isn't perfect, in that it doesn't know about nesting restrictions (ie that SRFs must be at top level of a function RTE), but we could improve that later if we wanted, and anyway it's definitely a good bit nicer than before. This also incorporates the part of 0002 that I agree with, namely disallowing SRFs in UPDATE, since check_srf_call_placement() naturally would do that. I also renamed the flag to hasTargetSRFs, which is more parallel to hasAggs and hasWindowFuncs, and made some effort to use it in place of expression_returns_set() searches. I'd like to go ahead and push this, since it's a necessary prerequisite for either approach we might adopt for the rest of the patch series, and the improved error reporting and avoidance of expensive expression_returns_set searches make it a win IMO even if we were not planning to do anything more with SRFs. 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