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

Implicit index name generation rejects a maximal multibyte column name after a collision

    XMLWordPrintable

Details

    • Bug
    • Status: Confirmed (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 10.11, 11.4, 11.8, 12.3, 13.1, 12.3.3
    • 10.11, 11.4, 11.8, 12.3, 13.1
    • Character Sets
    • None
    • MariaDB 12.3.3 on Linux x86_64

    Description

      On MariaDB 12.3.3, I get ERROR 1280 when an implicit index name must be made unique for a 64-character, 190-byte utf8mb3 column name. A short control resolves the same kind of name collision by generating the suffix _2.

      This occurs at the identifier-length boundary when an implicit index name needs a collision suffix and its base ends with three-byte characters.

      The following SQL uses MyISAM for both the control and failing table. The long identifier is a followed by 63 instances of 中 and must be preserved exactly.

      CREATE DATABASE IF NOT EXISTS test;
      USE test;
      DROP TABLE IF EXISTS long_name_test;
      DROP TABLE IF EXISTS index_control;
       
      CREATE TABLE index_control (
        controlcol INT,
        KEY controlcol (controlcol),
        KEY (controlcol)
      ) ENGINE=MyISAM;
      SELECT GROUP_CONCAT(DISTINCT INDEX_NAME ORDER BY INDEX_NAME) AS control_names
      FROM information_schema.STATISTICS
      WHERE TABLE_SCHEMA=DATABASE()
        AND TABLE_NAME='index_control';
      DROP TABLE index_control;
       
      SET NAMES utf8mb3;
      CREATE TABLE long_name_test (
        `a中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中` INT,
        KEY `a中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中` (`a中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中`),
        KEY (`a中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中`)
      ) ENGINE=MyISAM;
      SELECT INDEX_NAME, CHAR_LENGTH(INDEX_NAME) AS chars,
             LENGTH(INDEX_NAME) AS bytes, HEX(INDEX_NAME) AS hex_name
      FROM information_schema.STATISTICS
      WHERE TABLE_SCHEMA=DATABASE()
        AND TABLE_NAME='long_name_test'
      GROUP BY INDEX_NAME
      ORDER BY INDEX_NAME;
      DROP TABLE long_name_test;

      The control succeeds and shows the expected collision suffix:

      control_names
      controlcol,controlcol_2

      The second CREATE TABLE fails instead:

      ERROR 1280 (42000): Incorrect index name 'a中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中中'

      The maximal collision should produce a well-formed implicit index name of at most 64 characters, just as the shorter control produces controlcol_2. The collision suffix is needed at a byte truncation boundary that falls inside the final three-byte character, so the generated candidate is rejected rather than becoming a valid suffixed identifier.

      If the client stops at the expected error, cleanup is:

      CREATE DATABASE IF NOT EXISTS test;
      DROP TABLE IF EXISTS test.long_name_test;
      DROP TABLE IF EXISTS test.index_control;

      Attachments

        Activity

          People

            raghunandan.bhat Raghunandan Bhat
            faner fan
            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.