You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
Improve parser's and planner's handling of set-returning functions.
Teach the parser to reject misplaced set-returning functions during parseanalysis using p_expr_kind, in much the same way as we do for aggregatesand window functions (cf commiteaccfde). While this isn't complete(it misses nesting-based restrictions), it's much better than the previouserror reporting for such cases, and it allows elimination of assortedad-hoc expression_returns_set() error checks. We could add nesting checkslater if it seems important to catch all cases at parse time.There is one case the parser will now throw error for although previousversions allowed it, which is SRFs in the tlist of an UPDATE. That neverbehaved sensibly (since it's ill-defined which generated row should beused to perform the update) and it's hard to see why it should not betreated as an error. It's a release-note-worthy change though.Also, add a new Query field hasTargetSRFs reporting whether there areany SRFs in the targetlist (including GROUP BY/ORDER BY expressions).The parser can now set that basically for free during parse analysis,and we can use it in a number of places to avoid expression_returns_setsearches. (There will be more such checks soon.) In some places, thisallows decontorting the logic since it's no longer expensive to check forSRFs in the tlist --- so I made the checks parallel to the handling ofhasAggs/hasWindowFuncs wherever it seemed appropriate.catversion bump because adding a Query field changes stored rules.Andres Freund and Tom LaneDiscussion: <24639.1473782855@sss.pgh.pa.us>