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

Wrong column collation on MODIFY + CONVERT

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 10.2(EOL), 10.3(EOL), 10.4(EOL), 10.5, 10.6, 10.7(EOL), 10.8(EOL), 10.9(EOL)
    • 10.9.0
    • Character Sets
    • 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

              bar Alexander Barkov
              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.