Details
-
Bug
-
Status: Confirmed (View Workflow)
-
Major
-
Resolution: Unresolved
-
10.5.8, 10.4(EOL), 10.5
-
Ubuntu 20.04 LTS
Description
/*
|
In MariaDB version 10.3.27 and possibly later versions, the below function worked.
|
But in version 10.5.8, calling the function gives error: "ERROR 1111 (HY000) at line 65: Invalid use of group function".
|
*/ |
|
DELIMITER $$
|
|
DROP TABLE IF EXISTS t1; |
DROP TABLE IF EXISTS t2; |
|
CREATE TABLE t1 (t1_id int primary key, t1_text varchar(100)); |
CREATE TABLE t2 (t2_id1 int, t2_id2 int, t2_text varchar(100), primary key(t2_id1, t2_id2) ); |
|
INSERT t1 VALUES (1, 'Text 1'), (2, 'Text 2'); |
INSERT t2 VALUES (1, 1, 'Text 11'), (1, 2, 'Text 12'), (2, 1, 'Text 21'), (2, 2, 'Text 22'); |
|
-- This query works:
|
|
SELECT GROUP_CONCAT( |
(
|
SELECT GROUP_CONCAT(t2_text) |
FROM t2 |
WHERE t2_id1 = t1_id |
)
|
) this_works
|
FROM t1; |
|
|
DROP FUNCTION IF EXISTS fn_test; |
$$
|
CREATE FUNCTION fn_test() RETURNS varchar(500) READS SQL DATA |
RETURN ( |
SELECT GROUP_CONCAT( |
(
|
SELECT GROUP_CONCAT(t2_text) |
FROM t2 |
WHERE t2_id1 = t1_id |
)
|
) x
|
FROM t1 |
);
|
$$
|
|
SELECT fn_test(); |
Attachments
Issue Links
- relates to
-
MDEV-11867 Invalid use of group function -
- Closed