Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-28490

Strange result truncation with group_concat_max_len=1GB

    XMLWordPrintable

    Details

      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
      

        Attachments

          Activity

            People

            Assignee:
            holyfoot Alexey Botchkov
            Reporter:
            hholzgra Hartmut Holzgraefe
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.