[MDEV-28490] Strange result truncation with group_concat_max_len=1GB Created: 2022-05-06  Updated: 2022-08-18  Resolved: 2022-05-16

Status: Closed
Project: MariaDB Server
Component/s: Configuration
Affects Version/s: 10.5.15, 10.6.7, 10.7.3, 10.8.2
Fix Version/s: 10.5.16, 10.6.8, 10.7.4, 10.8.3

Type: Bug Priority: Critical
Reporter: Hartmut Holzgraefe Assignee: Alexey Botchkov
Resolution: Fixed Votes: 1
Labels: None


 Description   

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;
 
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;

Expected result:

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
bar,foo
Variable_name	Value
group_concat_max_len	1073741825
simple
bar,foo
nested
bar,foo
Variable_name	Value
group_concat_max_len	1073741826
simple
bar,foo
nested
bar,foo
group_concat_max_len	2147483649
simple
bar,foo
nested
bar,foo

Actual result:

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



 Comments   
Comment by Hartmut Holzgraefe [ 2022-05-06 ]

10.4 and earlier are not affected, this only started with 10.5

Comment by Hartmut Holzgraefe [ 2022-05-06 ]

Actually started between 10.5.3 and 10.5.4

Comment by Hartmut Holzgraefe [ 2022-05-06 ]

from looking at 10.5.4 changelog the most likely candidates for having introduced this seem to be:

Comment by Alexey Botchkov [ 2022-05-16 ]

fixing patch
https://github.com/MariaDB/server/commit/b03ab1270d24c1fe011aa50f9e6b495c6d508706

Generated at Thu Feb 08 10:01:09 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.