mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
Recognize GROUPING() as a aggregate expression.
Previously GROUPING() was not recognized as a aggregate expression, erroneously allowing the planner to move it from HAVING to WHERE. Author: Jeevan Chalke Reviewed-By: Andrew Gierth Discussion: CAM2+6=WG9omG5rFOMAYBweJxmpTaapvVp5pCeMrE6BfpCwr4Og@mail.gmail.com Backpatch: 9.5, where grouping sets were introduced
This commit is contained in:
@@ -390,7 +390,7 @@ make_ands_implicit(Expr *clause)
|
||||
|
||||
/*
|
||||
* contain_agg_clause
|
||||
* Recursively search for Aggref nodes within a clause.
|
||||
* Recursively search for Aggref/GroupingFunc nodes within a clause.
|
||||
*
|
||||
* Returns true if any aggregate found.
|
||||
*
|
||||
@@ -417,6 +417,11 @@ contain_agg_clause_walker(Node *node, void *context)
|
||||
Assert(((Aggref *) node)->agglevelsup == 0);
|
||||
return true; /* abort the tree traversal and return true */
|
||||
}
|
||||
if (IsA(node, GroupingFunc))
|
||||
{
|
||||
Assert(((GroupingFunc *) node)->agglevelsup == 0);
|
||||
return true; /* abort the tree traversal and return true */
|
||||
}
|
||||
Assert(!IsA(node, SubLink));
|
||||
return expression_tree_walker(node, contain_agg_clause_walker, context);
|
||||
}
|
||||
|
Reference in New Issue
Block a user