Details
-
Bug
-
Status: Closed (View Workflow)
-
Critical
-
Resolution: Fixed
-
10.3(EOL)
-
None
-
10.3.6-1
Description
Note: The agg_sum function definition is taken as is from main.aggregate_functions test.
--delimiter |
|
create aggregate function agg_sum(x INT) returns INT |
begin
|
declare z int default 0; |
declare continue handler for not found return z; |
loop
|
fetch group next row; |
set z= z+x; |
end loop; |
end| |
--delimiter ;
|
|
create table t1 (i int); |
insert into t1 values (1),(2),(2),(3); |
select i, agg_sum(i) from t1 group by i with rollup; |
--echo #
|
--echo # Compare with
|
select i, sum(i) from t1 group by i with rollup; |
|
# Cleanup
|
drop function agg_sum; |
drop table t1; |
Actual result with agg_sum |
select i, agg_sum(i) from t1 group by i with rollup;
|
i agg_sum(i)
|
1 1
|
2 8
|
3 6
|
NULL 6
|
Expected result with agg_sum, actual result with sum |
select i, sum(i) from t1 group by i with rollup;
|
i sum(i)
|
1 1
|
2 4
|
3 3
|
NULL 8
|
Attachments
Issue Links
- relates to
-
MDEV-7773 Aggregate stored functions
-
- Closed
-
Currently the main reason for the incorrect results in case of use of rollup in custom aggregate functions that in the function JOIN::rollup_make_fields, it says that create copies of item_sum items for each sum level, currently copy_or_same() function is missing from custom aggregate functions. This function would basically create a copy of custom aggregate functions Item_sum_sp object when we do rollup