mirror of
https://github.com/postgres/postgres.git
synced 2025-11-09 06:21:09 +03:00
Give pull_var_clause() reject/recurse/return behavior for WindowFuncs too.
All along, this function should have treated WindowFuncs in a manner similar to Aggrefs, ie with an option whether or not to recurse into them. By not considering the case, it was always recursing, which is OK for most callers (although I suspect that the case in prepare_sort_from_pathkeys might represent a bug). But now we need return-without-recursing behavior as well. There are also more than a few callers that should never see a WindowFunc, and now we'll get some error checking on that.
This commit is contained in:
@@ -5307,7 +5307,8 @@ prepare_sort_from_pathkeys(Plan *lefttree, List *pathkeys,
|
||||
* that we treat Aggrefs as if they were variables; this is
|
||||
* necessary when attempting to sort the output from an Agg node
|
||||
* for use in a WindowFunc (since grouping_planner will have
|
||||
* treated the Aggrefs as variables, too).
|
||||
* treated the Aggrefs as variables, too). Likewise, if we find a
|
||||
* WindowFunc in a sort expression, treat it as a variable.
|
||||
*/
|
||||
Expr *sortexpr = NULL;
|
||||
|
||||
@@ -5336,6 +5337,7 @@ prepare_sort_from_pathkeys(Plan *lefttree, List *pathkeys,
|
||||
sortexpr = em->em_expr;
|
||||
exprvars = pull_var_clause((Node *) sortexpr,
|
||||
PVC_INCLUDE_AGGREGATES |
|
||||
PVC_INCLUDE_WINDOWFUNCS |
|
||||
PVC_INCLUDE_PLACEHOLDERS);
|
||||
foreach(k, exprvars)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user