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
-
Activity
Description |
_Note: The {{agg_sum}} function definition is taken as is from main.aggregate_functions test
{code:sql} --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; {code} {noformat:title=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 {noformat} {noformat:title=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 {noformat} |
_Note: The {{agg_sum}} function definition is taken as is from main.aggregate_functions test._
{code:sql} --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; {code} {noformat:title=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 {noformat} {noformat:title=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 {noformat} |
Status | Open [ 1 ] | In Progress [ 3 ] |
Assignee | Varun Gupta [ varun ] | Vicentiu Ciorbaru [ cvicentiu ] |
Status | In Progress [ 3 ] | In Review [ 10002 ] |
Sprint | 10.3.6-0 [ 237 ] |
Priority | Major [ 3 ] | Critical [ 2 ] |
Affects Version/s | 10.3 [ 22126 ] | |
Affects Version/s | N/A [ 14700 ] |
Status | In Review [ 10002 ] | Stalled [ 10000 ] |
Assignee | Vicentiu Ciorbaru [ cvicentiu ] | Varun Gupta [ varun ] |
Fix Version/s | 10.3.7 [ 23005 ] | |
Fix Version/s | 10.3 [ 22126 ] | |
Resolution | Fixed [ 1 ] | |
Status | Stalled [ 10000 ] | Closed [ 6 ] |
Workflow | MariaDB v3 [ 84128 ] | MariaDB v4 [ 153256 ] |
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