postgresql/src/backend/optimizer/util
Tom Lane a4c35ea1c2 Improve parser's and planner's handling of set-returning functions.
Teach the parser to reject misplaced set-returning functions during parse
analysis using p_expr_kind, in much the same way as we do for aggregates
and window functions (cf commit eaccfded9).  While this isn't complete
(it misses nesting-based restrictions), it's much better than the previous
error reporting for such cases, and it allows elimination of assorted
ad-hoc expression_returns_set() error checks.  We could add nesting checks
later if it seems important to catch all cases at parse time.

There is one case the parser will now throw error for although previous
versions allowed it, which is SRFs in the tlist of an UPDATE.  That never
behaved sensibly (since it's ill-defined which generated row should be
used to perform the update) and it's hard to see why it should not be
treated as an error.  It's a release-note-worthy change though.

Also, add a new Query field hasTargetSRFs reporting whether there are
any 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_set
searches.  (There will be more such checks soon.)  In some places, this
allows decontorting the logic since it's no longer expensive to check for
SRFs in the tlist --- so I made the checks parallel to the handling of
hasAggs/hasWindowFuncs wherever it seemed appropriate.

catversion bump because adding a Query field changes stored rules.

Andres Freund and Tom Lane

Discussion: <24639.1473782855@sss.pgh.pa.us>
2016-09-13 13:54:24 -04:00
..
Makefile Extract restriction OR clauses whether or not they are indexable. 2013-12-30 12:24:37 -05:00
clauses.c Improve parser's and planner's handling of set-returning functions. 2016-09-13 13:54:24 -04:00
joininfo.c Update copyright for 2016 2016-01-02 13:33:40 -05:00
orclauses.c Adjust spellings of forms of "cancel" 2016-07-14 22:48:26 -04:00
pathnode.c Speed up planner's scanning for parallel-query hazards. 2016-08-19 14:03:13 -04:00
placeholder.c Remove reltarget_has_non_vars flag. 2016-06-10 16:20:03 -04:00
plancat.c Fix assorted fallout from IS [NOT] NULL patch. 2016-07-28 16:09:15 -04:00
predtest.c Refactor to reduce code duplication for function property checking. 2016-06-10 16:03:46 -04:00
relnode.c Speed up planner's scanning for parallel-query hazards. 2016-08-19 14:03:13 -04:00
restrictinfo.c Update copyright for 2016 2016-01-02 13:33:40 -05:00
tlist.c Simplify planner's final setup of Aggrefs for partial aggregation. 2016-06-26 12:08:12 -04:00
var.c Give pull_var_clause() reject/recurse/return behavior for WindowFuncs too. 2016-03-10 16:23:52 -05:00