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

Wrong column collation on MODIFY + CONVERT

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 10.2, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9
    • Fix Version/s: 10.9.0
    • Component/s: Character Sets
    • Labels:
      None

      Description

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a CHAR);
      ALTER TABLE t1
        MODIFY a CHAR COLLATE DEFAULT,
        CONVERT TO CHARACTER SET utf8mb3 COLLATE utf8mb3_bin;
      SHOW CREATE TABLE t1;
      

      +-------+--------------------------------------------------------------------------------------------------------------------------------+
      | Table | Create Table                                                                                                                   |
      +-------+--------------------------------------------------------------------------------------------------------------------------------+
      | t1    | CREATE TABLE `t1` (
        `a` char(1) COLLATE utf8mb3_bin DEFAULT NULL
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin |
      +-------+--------------------------------------------------------------------------------------------------------------------------------+
      

      utf8mb3_bin for the column 'a' looks wrong. The ALTER statement asked to use COLLATE DEFAULT for the column "a", which is utf8mb3_general_ci. But COLLATE DEFAULT was erroneously ignored.

      Note, if I change the script slightly to ask for:

      • binary collation on the column level
      • default collation on the table level
        it returns the expected result:

        DROP TABLE IF EXISTS t1;
        CREATE TABLE t1 (a CHAR);
        ALTER TABLE t1
          MODIFY a CHAR BINARY,
          CONVERT TO CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci;
        SHOW CREATE TABLE t1;
        

        +-------+----------------------------------------------------------------------------------------------------------------------------------+
        | Table | Create Table                                                                                                                     |
        +-------+----------------------------------------------------------------------------------------------------------------------------------+
        | t1    | CREATE TABLE `t1` (
          `a` char(1) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin DEFAULT NULL
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 |
        +-------+----------------------------------------------------------------------------------------------------------------------------------+
        

      Notice, the BINARY on the column level was not ignored, which is correct.

      The first script should be fixed not to ingore COLLATE DEFAULT.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              bar Alexander Barkov
              Reporter:
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              1 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.