1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-27 18:02:13 +03:00

MDEV-14520: Custom aggregate functions work incorrectly with WITH ROLLUP clause

Queries involving rollup need all aggregate function to have copy_or_same function where we create a copy
of item_sum items for each sum level.
Implemented copy_or_same function for the custom aggregate function class (Item_sum_sp)
This commit is contained in:
Varun Gupta
2018-05-17 17:19:33 +05:30
parent 7bf4a006b3
commit 89b1c2712a
6 changed files with 84 additions and 0 deletions

View File

@ -939,3 +939,29 @@ SHOW CREATE TABLE t1;
DROP TABLE t1;
DROP FUNCTION f1;
--echo #
--echo # MDEV-14520: Custom aggregate functions work incorrectly with WITH ROLLUP clause
--echo #
--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;