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

JSON_OBJECTAGG skips the length limit of group_concat_max_len

    XMLWordPrintable

Details

    Description

      Hi,

      I found that the JSON_OBJECTAGG function is not limited by group_concat_max_len. This is an example:

      SET SESSION group_concat_max_len=32;
       
      CREATE TABLE t(k VARCHAR(8), v VARCHAR(64));
      INSERT INTO t VALUES
        ('a', REPEAT('x', 20)),
        ('b', REPEAT('y', 20));
       
      SELECT JSON_ARRAYAGG(v) FROM t; -- ["xxxxxxxxxxxxxxxxxxxx","yyyyyyy"]
      SHOW WARNINGS; -- Warning	1260	Row 2 was cut by json_arrayagg()
       
      SELECT
        JSON_OBJECTAGG(k, v),
        OCTET_LENGTH(JSON_OBJECTAGG(k, v)),
        OCTET_LENGTH(JSON_OBJECTAGG(k, v)) > @@group_concat_max_len
      FROM t; -- {"a":"xxxxxxxxxxxxxxxxxxxx", "b":"yyyyyyyyyyyyyyyyyyyy"}	56	1
      SHOW WARNINGS; -- empty
      

      Attachments

        Activity

          People

            rucha174 Rucha Deodhar
            ChiZhang Chi Zhang
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

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