修复聚合嵌套时的core问题

This commit is contained in:
wangfeihuo
2024-09-21 10:30:20 +08:00
parent 19eb68f08e
commit 7c6c2a1b55
3 changed files with 7 additions and 1 deletions

View File

@ -225,7 +225,8 @@ void transformAggregateCall(ParseState* pstate, Aggref* agg, List* args, List* a
* didn't find any local vars or aggs.
*/
if (min_varlevel == 0) {
if (pstate->p_hasAggs && checkExprHasAggs((Node*)agg->args)) {
if (pstate->p_hasAggs &&
(checkExprHasAggs((Node*)agg->args) || checkExprHasAggs((Node*)agg->aggdirectargs))) {
ereport(ERROR,
(errcode(ERRCODE_GROUPING_ERROR),
errmsg("aggregate function calls cannot be nested"),

View File

@ -579,6 +579,9 @@ GROUP BY c2,c3;
----+----+----+------------
(0 rows)
SELECT percentile_cont(sum(value)) WITHIN GROUP (ORDER BY value) FROM (VALUES ('2019-07-12 00:00:01'::timestamptz,'red',1),('2019-07-12 00:00:01'::timestamptz,'blue',2)) v(time,color,value);
ERROR: aggregate function calls cannot be nested
CONTEXT: referenced column: percentile_cont
reset current_schema;
drop schema if exists distribute_aggregates_part3 cascade;
NOTICE: drop cascades to 2 other objects

View File

@ -117,5 +117,7 @@ SELECT
FROM sales_transaction_line
GROUP BY c2,c3;
SELECT percentile_cont(sum(value)) WITHIN GROUP (ORDER BY value) FROM (VALUES ('2019-07-12 00:00:01'::timestamptz,'red',1),('2019-07-12 00:00:01'::timestamptz,'blue',2)) v(time,color,value);
reset current_schema;
drop schema if exists distribute_aggregates_part3 cascade;