When setting group_concat_max_len to exactly one GB (1073741824) or more and using GROUP_CONCAT() in a subquery the result gets truncated as if the actual group concat limit had been set to the given value modulo 1073741824.
How to reproduce:
(this originally occurred in combination with JSON functions, but this is the most simple case I could strip it down to while still getting the same truncated results)
USE test;
DROPTABLEIF EXISTS t1;
CREATETABLE t1(val VARCHAR(100) PRIMARYKEY);
INSERTINTO t1 VALUES('bar');
INSERTINTO t1 VALUES('foo');
SET group_concat_max_len = 1073741823; -- 1GB minus one
SHOW VARIABLES LIKE'group_concat_max_len';
SELECT GROUP_CONCAT(val) AS simple FROM t1;
SELECT * FROM ( SELECT GROUP_CONCAT(val) AS nested FROM t1) As tmp;
SET group_concat_max_len = 1073741824; -- exactly 1GB
SHOW VARIABLES LIKE'group_concat_max_len';
SELECT GROUP_CONCAT(val) AS simple FROM t1;
SELECT * FROM ( SELECT GROUP_CONCAT(val) AS nested FROM t1) As tmp;
SET group_concat_max_len = 1073741825; -- 1GB plus one
SHOW VARIABLES LIKE'group_concat_max_len';
SELECT GROUP_CONCAT(val) AS simple FROM t1;
SELECT * FROM ( SELECT GROUP_CONCAT(val) AS nested FROM t1) As tmp;
SET group_concat_max_len = 1073741826; -- 1GB plus two
SHOW VARIABLES LIKE'group_concat_max_len';
SELECT GROUP_CONCAT(val) AS simple FROM t1;
SELECT * FROM ( SELECT GROUP_CONCAT(val) AS nested FROM t1) As tmp;
SET group_concat_max_len = 2147483649; -- 2GB plus one
SHOW VARIABLES LIKE'group_concat_max_len';
SELECT GROUP_CONCAT(val) AS simple FROM t1;
SELECT * FROM ( SELECT GROUP_CONCAT(val) AS nested FROM t1) As tmp;
Hartmut Holzgraefe
added a comment - from looking at 10.5.4 changelog the most likely candidates for having introduced this seem to be:
https://github.com/MariaDB/server/commit/6c573a9146
https://github.com/MariaDB/server/commit/81a08c5462
https://github.com/MariaDB/server/commit/a006e88cac
When setting {{group_concat_max_len}} to exactly one GB (1073741824) or more and using {{GROUP_CONCAT()}} in a subquery the result gets truncated as if the actual group concat limit had been set to the given value modulo 1073741824.
How to reproduce:
(this originally occurred in combination with JSON functions, but this is the most simple case I could strip it down to while still getting the same truncated results)
{code:sql}
USE test;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(val VARCHAR(100) PRIMARY KEY);
INSERT INTO t1 VALUES('bar');
INSERT INTO t1 VALUES('foo');
SET group_concat_max_len = 1073741823; -- 1GB minus one
SHOW VARIABLES LIKE 'group_concat_max_len';
SELECT GROUP_CONCAT(val) AS simple FROM t1;
SELECT * FROM ( SELECT GROUP_CONCAT(val) AS nested FROM t1) As tmp;
SET group_concat_max_len = 1073741824; -- exactly 1GB
SHOW VARIABLES LIKE 'group_concat_max_len';
SELECT GROUP_CONCAT(val) AS simple FROM t1;
SELECT * FROM ( SELECT GROUP_CONCAT(val) AS nested FROM t1) As tmp;
SET group_concat_max_len = 1073741825; -- 1GB plus one
SHOW VARIABLES LIKE 'group_concat_max_len';
SELECT GROUP_CONCAT(val) AS simple FROM t1;
SELECT * FROM ( SELECT GROUP_CONCAT(val) AS nested FROM t1) As tmp;
SET group_concat_max_len = 1073741826; -- 1GB plus two
SHOW VARIABLES LIKE 'group_concat_max_len';
SELECT GROUP_CONCAT(val) AS simple FROM t1;
SELECT * FROM ( SELECT GROUP_CONCAT(val) AS nested FROM t1) As tmp;
SET group_concat_max_len = 2147483649; -- 2GB plus one
SHOW VARIABLES LIKE 'group_concat_max_len';
SELECT GROUP_CONCAT(val) AS simple FROM t1;
SELECT * FROM ( SELECT GROUP_CONCAT(val) AS nested FROM t1) As tmp;
{code:sql}
{noformat}
Variable_name Value
group_concat_max_len 1073741823
simple
bar,foo
nested
bar,foo
Variable_name Value
group_concat_max_len 1073741824
simple
bar,foo
nested
Variable_name Value
group_concat_max_len 1073741825
simple
bar,foo
nested
b
Variable_name Value
group_concat_max_len 1073741826
simple
bar,foo
nested
ba
group_concat_max_len 2147483649
simple
bar,foo
nested
b
{noformat}
When setting {{group_concat_max_len}} to exactly one GB (1073741824) or more and using {{GROUP_CONCAT()}} in a subquery the result gets truncated as if the actual group concat limit had been set to the given value modulo 1073741824.
How to reproduce:
(this originally occurred in combination with JSON functions, but this is the most simple case I could strip it down to while still getting the same truncated results)
{code:sql}
USE test;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(val VARCHAR(100) PRIMARY KEY);
INSERT INTO t1 VALUES('bar');
INSERT INTO t1 VALUES('foo');
SET group_concat_max_len = 1073741823; -- 1GB minus one
SHOW VARIABLES LIKE 'group_concat_max_len';
SELECT GROUP_CONCAT(val) AS simple FROM t1;
SELECT * FROM ( SELECT GROUP_CONCAT(val) AS nested FROM t1) As tmp;
SET group_concat_max_len = 1073741824; -- exactly 1GB
SHOW VARIABLES LIKE 'group_concat_max_len';
SELECT GROUP_CONCAT(val) AS simple FROM t1;
SELECT * FROM ( SELECT GROUP_CONCAT(val) AS nested FROM t1) As tmp;
SET group_concat_max_len = 1073741825; -- 1GB plus one
SHOW VARIABLES LIKE 'group_concat_max_len';
SELECT GROUP_CONCAT(val) AS simple FROM t1;
SELECT * FROM ( SELECT GROUP_CONCAT(val) AS nested FROM t1) As tmp;
SET group_concat_max_len = 1073741826; -- 1GB plus two
SHOW VARIABLES LIKE 'group_concat_max_len';
SELECT GROUP_CONCAT(val) AS simple FROM t1;
SELECT * FROM ( SELECT GROUP_CONCAT(val) AS nested FROM t1) As tmp;
SET group_concat_max_len = 2147483649; -- 2GB plus one
SHOW VARIABLES LIKE 'group_concat_max_len';
SELECT GROUP_CONCAT(val) AS simple FROM t1;
SELECT * FROM ( SELECT GROUP_CONCAT(val) AS nested FROM t1) As tmp;
{code}
{noformat}
Variable_name Value
group_concat_max_len 1073741823
simple
bar,foo
nested
bar,foo
Variable_name Value
group_concat_max_len 1073741824
simple
bar,foo
nested
Variable_name Value
group_concat_max_len 1073741825
simple
bar,foo
nested
b
Variable_name Value
group_concat_max_len 1073741826
simple
bar,foo
nested
ba
group_concat_max_len 2147483649
simple
bar,foo
nested
b
{noformat}
10.4 and earlier are not affected, this only started with 10.5