Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.3(EOL), 10.4(EOL)
-
None
Description
CREATE SCHEMA IF NOT EXISTS common_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 ;
|
MariaDB [test]> USE common_schema;
|
Database changed
|
MariaDB [common_schema]> SELECT common_schema.sum_ints(seq)
|
-> FROM (SELECT 1 seq UNION ALL SELECT 2) t;
|
+-----------------------------+
|
| common_schema.sum_ints(seq) |
|
+-----------------------------+
|
| 3 |
|
+-----------------------------+
|
1 row in set (0.009 sec)
|
MariaDB [test]> USE another_schema;
|
Database changed
|
MariaDB [another_schema]> SELECT common_schema.sum_ints(seq) FROM (SELECT 1 seq UNION ALL SELECT 2) t;
|
+-----------------------------+
|
| common_schema.sum_ints(seq) |
|
+-----------------------------+
|
| NULL |
|
+-----------------------------+
|
1 row in set (0.028 sec)
|
On changing the schema the custom aggregate function returns NULL , which is incorrect
Attachments
Issue Links
- duplicates
-
MDEV-21763 Stored Aggregate Functions return NULL cross database.
- Closed