summaryrefslogtreecommitdiff
path: root/mysql-test/main/custom_aggregate_functions.test
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-05-16 06:27:55 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2020-05-16 06:27:55 +0300
commit4f29d776c756ac522ae49c481ea8975dee8787fe (patch)
treed152b05f3bca9b4022802654c129f0470ed92038 /mysql-test/main/custom_aggregate_functions.test
parenta4996f951d731322acc63033646d950ddbb0f60c (diff)
parent3eadb135fd7b7e2d40fd6b9a819ac3245043f781 (diff)
downloadmariadb-git-4f29d776c756ac522ae49c481ea8975dee8787fe.tar.gz
Merge 10.3 into 10.4
Diffstat (limited to 'mysql-test/main/custom_aggregate_functions.test')
-rw-r--r--mysql-test/main/custom_aggregate_functions.test36
1 files changed, 36 insertions, 0 deletions
diff --git a/mysql-test/main/custom_aggregate_functions.test b/mysql-test/main/custom_aggregate_functions.test
index a10ea44af60..12a09b07fc0 100644
--- a/mysql-test/main/custom_aggregate_functions.test
+++ b/mysql-test/main/custom_aggregate_functions.test
@@ -966,6 +966,40 @@ select i, sum(i) from t1 group by i with rollup;
drop function agg_sum;
drop table t1;
+--echo #
+--echo # User defined aggregate functions not working correctly when the schema is changed
+--echo #
+
+CREATE SCHEMA IF NOT EXISTS common_schema;
+CREATE SCHEMA IF NOT EXISTS another_schema;
+DELIMITER |;
+DROP FUNCTION IF EXISTS common_schema.add_ints |
+CREATE FUNCTION common_schema.add_ints(int_1 INT, int_2 INT) RETURNS INT NO SQL
+BEGIN
+ RETURN int_1 + int_2;
+END |
+DROP FUNCTION IF EXISTS common_schema.sum_ints |
+CREATE AGGREGATE FUNCTION common_schema.sum_ints(int_val INT) RETURNS INT
+BEGIN
+ DECLARE result INT DEFAULT 0;
+ DECLARE CONTINUE HANDLER FOR NOT FOUND RETURN result;
+ LOOP FETCH GROUP NEXT ROW;
+ SET result = common_schema.add_ints(result, int_val);
+ END LOOP;
+END |
+
+DELIMITER ;|
+
+use common_schema;
+SELECT common_schema.sum_ints(seq) FROM (SELECT 1 seq UNION ALL SELECT 2) t;
+
+USE another_schema;
+SELECT common_schema.sum_ints(seq) FROM (SELECT 1 seq UNION ALL SELECT 2) t;
+
+drop database common_schema;
+drop database another_schema;
+
+USE test;
--echo #
--echo # MDEV-18813 PROCEDURE and anonymous blocks silently ignore FETCH GROUP NEXT ROW
@@ -1016,3 +1050,5 @@ CREATE EVENT ev1
STARTS CURRENT_TIMESTAMP + INTERVAL 1 MONTH
ENDS CURRENT_TIMESTAMP + INTERVAL 1 MONTH + INTERVAL 1 WEEK
DO FETCH GROUP NEXT ROW;
+
+--echo # End of 10.4 tests