1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

MDEV-5542: GROUP_CONCAT truncate output to 65.536 chars when using DISTINCT or ORDER BY

port of mysql fix WL#6098
This commit is contained in:
Oleksandr Byelkin
2016-03-01 21:10:59 +01:00
parent 66832b6195
commit 6c414fcf89
13 changed files with 312 additions and 101 deletions

View File

@ -1119,3 +1119,84 @@ GROUP_CONCAT(t1a.a ORDER BY 1, t1a.a=0)
1,1
2,2
DROP TABLE t1;
#
# WL#6098 Eliminate GROUP_CONCAT intermediate result limitation.
# Bug#13387020 GROUP_CONCAT WITH ORDER BY RESULTS ARE TRUNCATED.
#
SET group_concat_max_len= 9999999;
CREATE TABLE t1 (f1 LONGTEXT , f2 INTEGER);
INSERT INTO t1 VALUES (REPEAT('a', 500000), 0), (REPEAT('b', 500000), 1), (REPEAT('c', 500000), 2);
SELECT LENGTH(GROUP_CONCAT(f1 ORDER BY f2)) FROM t1;
LENGTH(GROUP_CONCAT(f1 ORDER BY f2))
1500002
SELECT LENGTH(GROUP_CONCAT(DISTINCT f1 ORDER BY f1 DESC)) FROM t1;
LENGTH(GROUP_CONCAT(DISTINCT f1 ORDER BY f1 DESC))
1500002
SELECT SUBSTRING(GROUP_CONCAT(DISTINCT f1 ORDER BY f1 DESC), 1, 5) FROM t1;
SUBSTRING(GROUP_CONCAT(DISTINCT f1 ORDER BY f1 DESC), 1, 5)
ccccc
SELECT LENGTH(GROUP_CONCAT(DISTINCT f1)) FROM t1;
LENGTH(GROUP_CONCAT(DISTINCT f1))
1500002
SELECT LENGTH(GROUP_CONCAT(UPPER(f1) ORDER BY f2)) FROM t1;
LENGTH(GROUP_CONCAT(UPPER(f1) ORDER BY f2))
1500002
SELECT LENGTH(GROUP_CONCAT(DISTINCT UPPER(f1) ORDER BY f1)) FROM t1;
LENGTH(GROUP_CONCAT(DISTINCT UPPER(f1) ORDER BY f1))
1500002
SELECT SUBSTRING(GROUP_CONCAT(DISTINCT UPPER(f1) ORDER BY f1), 1, 5) FROM t1;
SUBSTRING(GROUP_CONCAT(DISTINCT UPPER(f1) ORDER BY f1), 1, 5)
AAAAA
SELECT LENGTH(GROUP_CONCAT(DISTINCT UPPER(f1))) FROM t1;
LENGTH(GROUP_CONCAT(DISTINCT UPPER(f1)))
1500002
CREATE TABLE t2 SELECT GROUP_CONCAT(f1 order by f2) FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`GROUP_CONCAT(f1 order by f2)` mediumtext
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
CREATE TABLE t2 SELECT GROUP_CONCAT(UPPER(f1) ORDER BY f2) FROM t1;
SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`GROUP_CONCAT(UPPER(f1) ORDER BY f2)` mediumtext
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t2;
SET group_concat_max_len= DEFAULT;
SELECT LENGTH(GROUP_CONCAT(f1 ORDER BY f2)) FROM t1;
LENGTH(GROUP_CONCAT(f1 ORDER BY f2))
1024
Warnings:
Warning 1260 Row 2 was cut by GROUP_CONCAT()
SET group_concat_max_len= 499999;
SELECT LENGTH(GROUP_CONCAT(f1 ORDER BY f2)) FROM t1 WHERE f2 = 0;
LENGTH(GROUP_CONCAT(f1 ORDER BY f2))
499999
Warnings:
Warning 1260 Row 1 was cut by GROUP_CONCAT()
SELECT LENGTH(GROUP_CONCAT(f1 ORDER BY f2)) FROM t1 GROUP BY f2;
LENGTH(GROUP_CONCAT(f1 ORDER BY f2))
499999
499999
499999
Warnings:
Warning 1260 Row 1 was cut by GROUP_CONCAT()
Warning 1260 Row 2 was cut by GROUP_CONCAT()
Warning 1260 Row 3 was cut by GROUP_CONCAT()
INSERT INTO t1 VALUES (REPEAT('a', 499999), 3), (REPEAT('b', 500000), 4);
SELECT LENGTH(GROUP_CONCAT(f1 ORDER BY f2)) FROM t1 GROUP BY f2;
LENGTH(GROUP_CONCAT(f1 ORDER BY f2))
499999
499999
499999
499999
499999
Warnings:
Warning 1260 Row 1 was cut by GROUP_CONCAT()
Warning 1260 Row 2 was cut by GROUP_CONCAT()
Warning 1260 Row 3 was cut by GROUP_CONCAT()
Warning 1260 Row 5 was cut by GROUP_CONCAT()
DROP TABLE t1;
SET group_concat_max_len= DEFAULT;