aboutsummaryrefslogtreecommitdiff
path: root/src/backend/nodes/nodeFuncs.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2022-03-21 17:44:29 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2022-03-21 17:44:29 -0400
commit2591ee8ec44d8cbc8e1226550337a64c684746e4 (patch)
treeaa7f3e4bf70d4302203de6a993dcd1acf5506fd7 /src/backend/nodes/nodeFuncs.c
parent13619598f1080d7923454634a2570ca1bc0f2fec (diff)
downloadpostgresql-2591ee8ec44d8cbc8e1226550337a64c684746e4.tar.gz
postgresql-2591ee8ec44d8cbc8e1226550337a64c684746e4.zip
Fix assorted missing logic for GroupingFunc nodes.
The planner needs to treat GroupingFunc like Aggref for many purposes, in particular with respect to processing of the argument expressions, which are not to be evaluated at runtime. A few places hadn't gotten that memo, notably including subselect.c's processing of outer-level aggregates. This resulted in assertion failures or wrong plans for cases in which a GROUPING() construct references an outer aggregation level. Also fix missing special cases for GroupingFunc in cost_qual_eval (resulting in wrong cost estimates for GROUPING(), although it's not clear that that would affect plan shapes in practice) and in ruleutils.c (resulting in excess parentheses in pretty-print mode). Per bug #17088 from Yaoguang Chen. Back-patch to all supported branches. Richard Guo, Tom Lane Discussion: https://postgr.es/m/17088-e33882b387de7f5c@postgresql.org
Diffstat (limited to 'src/backend/nodes/nodeFuncs.c')
-rw-r--r--src/backend/nodes/nodeFuncs.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/backend/nodes/nodeFuncs.c b/src/backend/nodes/nodeFuncs.c
index 47d0564fa29..ec25aae6e38 100644
--- a/src/backend/nodes/nodeFuncs.c
+++ b/src/backend/nodes/nodeFuncs.c
@@ -736,6 +736,8 @@ expression_returns_set_walker(Node *node, void *context)
/* Avoid recursion for some cases that parser checks not to return a set */
if (IsA(node, Aggref))
return false;
+ if (IsA(node, GroupingFunc))
+ return false;
if (IsA(node, WindowFunc))
return false;