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

Collation "binary" is not accepted for databases, tables, columns

Details

    Description

      binary character set is accepted in in CREATE statements and such, but binary collation isn't, it requires backticks:

      MariaDB [test]> create table t (a char(1) collate binary);
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'binary)' at line 1
      

      MariaDB [test]> create table t (a char(1) collate `binary`);
      Query OK, 0 rows affected (0.033 sec)
      

      Maybe semantically binary collation doesn't make much sense, but not being able to parse it can cause a problem loading a dump from MySQL 8.0, as it can produce such structures:

      8.0.28

      MySQL [test]> create table t (a enum('a') character set binary, b char(8)) character set latin1;
      Query OK, 0 rows affected (0.194 sec)
       
      MySQL [test]> show create table t \G
      *************************** 1. row ***************************
             Table: t
      Create Table: CREATE TABLE `t` (
        `a` enum('a') CHARACTER SET binary COLLATE binary DEFAULT NULL,
        `b` char(8) DEFAULT NULL
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1
      1 row in set (0.001 sec)
      

      Attachments

        Activity

          Indeed, MySQL-8.0 accepts all these statements:

          create database db1 character set binary collate binary;
           
          create table db1.t1 (a char) character set binary collate binary;
           
          create table db1.t2 (a char character set binary collate binary);
          

          bar Alexander Barkov added a comment - Indeed, MySQL-8.0 accepts all these statements: create database db1 character set binary collate binary ;   create table db1.t1 (a char ) character set binary collate binary ;   create table db1.t2 (a char character set binary collate binary );

          People

            bar Alexander Barkov
            elenst Elena Stepanova
            Votes:
            0 Vote for this issue
            Watchers:
            4 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.