Details
Description
upstream: http://bugs.mysql.com/bug.php?id=38297
CREATE AGGREGATE FUNCTION avgcost
RETURNS REAL SONAME "udf_example.so";
create table t1(sum int, price float(24), g int);
insert into t1 values(100, 50.00, 1), (100, 100.00, 1);
insert into t1 values(10, 2.00, 2), (100, 100.00, 2);
MariaDB [test]> select avgcost(sum, price) from t1 where g=1;
+---------------------+
| avgcost(sum, price) |
+---------------------+
| 75.0000 |
+---------------------+
1 row in set (0.06 sec)
MariaDB [test]> select avgcost(sum, price) from t1 where g=2;
+---------------------+
| avgcost(sum, price) |
+---------------------+
| 91.0909 |
+---------------------+
1 row in set (0.00 sec)
MariaDB [test]> select avgcost(sum, price) from t1;
+---------------------+
| avgcost(sum, price) |
+---------------------+
| 80.7097 |
+---------------------+
1 row in set (0.00 sec)
MariaDB [test]> select avgcost(sum, price) from t1 group by g;
+---------------------+
| avgcost(sum, price) |
+---------------------+
| 75.0000 |
| 91.0909 |
+---------------------+
MariaDB [test]> select avgcost(sum, price) from t1 group by g with rollup;
+---------------------+
| avgcost(sum, price) |
+---------------------+
| 83.3333 |
| 91.0909 |
| 91.0909 |
+---------------------+
The ROLLUP structure is copied however the UDF init function isn't called meaning the initid->ptr is use for an aggregation and the rollup calculation at the same time.
Patch based on upstream submission. Added test case but its not got the correct result yet.
Gliffy Diagrams
Attachments
Issue Links
Activity
- All
- Comments
- Work Log
- History
- Activity
- Transitions