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

ST_COLLECT can exceed group_concat_max_len without warning

    XMLWordPrintable

Details

    • Bug
    • Status: Confirmed (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 12.3, 13.1, 12.3.3
    • 12.3, 13.1
    • GIS
    • Linux/amd64

    Description

      With group_concat_max_len set to 10 bytes, a one-point ST_COLLECT returns a non-NULL 34-byte result without a warning, while the two-point case returns NULL with warning 1260. This was reproduced on MariaDB 12.3.3 on Linux/amd64.

      Run the following statements in one session. No database objects are created, and the original session setting is restored at the end.

      SET @saved_concat_limit=@@session.group_concat_max_len;
      SET SESSION group_concat_max_len=10;
      SELECT OCTET_LENGTH(ST_COLLECT(ST_GEOMFROMTEXT('POINT(0 0)'))) AS one_point_len;
      SHOW WARNINGS;
      SELECT OCTET_LENGTH(ST_COLLECT(g)) AS two_point_len
        FROM (
          SELECT ST_GEOMFROMTEXT('POINT(0 0)') AS g
          UNION ALL
          SELECT ST_GEOMFROMTEXT('POINT(1 1)') AS g
        ) AS points;
      SHOW WARNINGS;
      SET SESSION group_concat_max_len=@saved_concat_limit;

      The recorded output is:

      34
      NULL
      Warning	1260	Row 1 was cut by st_collect()

      The one-point aggregate exceeds the configured limit without producing a warning. The two-point case reaches the existing rejection path only on the following iteration, after the accumulated content is already oversized.

      The source-supported explanation is that Item_func_collect::val_str() checks the accumulated content length before appending each geometry. Consequently, the first geometry—or the final geometry appended—can cross the limit without being rejected.

      ST_COLLECT must enforce group_concat_max_len when appending every input, including the first input and the input that crosses the boundary. It must not return a non-NULL 34-byte aggregate when the configured limit is 10 bytes.

      This occurs when ST_COLLECT aggregates a geometry whose encoded result exceeds group_concat_max_len, including when the first or final input crosses the limit.

      Attachments

        Issue Links

          Activity

            People

              rucha174 Rucha Deodhar
              noob liu
              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.