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

Table with two UCS2 ENUM or SET fields is created wrongly

    XMLWordPrintable

    Details

      Description

      CREATE TABLE t1 (
          f1 ENUM ('a','b') CHARACTER SET ucs2,
          f2 ENUM ('a','b') CHARACTER SET ucs2
      );
      SHOW CREATE TABLE t1;
      

      The table is created seemingly without a problem, but the definition is wrong (note question marks):

      10.3 803d0521

      MariaDB [test]> CREATE TABLE t1 (
          ->     f1 ENUM ('a','b') CHARACTER SET ucs2,
          ->     f2 ENUM ('a','b') CHARACTER SET ucs2
          -> );
      Query OK, 0 rows affected (0.311 sec)
       
      MariaDB [test]> SHOW CREATE TABLE t1;
      +-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
      | Table | Create Table                                                                                                                                                          |
      +-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
      | t1    | CREATE TABLE `t1` (
        `f1` enum('?','?') CHARACTER SET ucs2 DEFAULT NULL,
        `f2` enum('?','?') CHARACTER SET ucs2 DEFAULT NULL
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
      +-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
      1 row in set (0.002 sec)
      

      And indeed, an attempt to insert a value causes a problem:

      MariaDB [test]> INSERT INTO t1 VALUES ('a','a');
      ERROR 1265 (01000): Data truncated for column 'f1' at row 1
      

      Same with SETs.
      When there is only one such field, it works all right (note that f2 is now utf8):

      MariaDB [test]> CREATE TABLE t1 (
          ->     f1 ENUM ('a','b') CHARACTER SET ucs2,
          ->     f2 ENUM ('a','b') CHARACTER SET utf8
          -> );
      Query OK, 0 rows affected (0.215 sec)
       
      MariaDB [test]> SHOW CREATE TABLE t1;
      +-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
      | Table | Create Table                                                                                                                                                          |
      +-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
      | t1    | CREATE TABLE `t1` (
        `f1` enum('a','b') CHARACTER SET ucs2 DEFAULT NULL,
        `f2` enum('a','b') CHARACTER SET utf8 DEFAULT NULL
      ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
      +-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
      1 row in set (0.002 sec)
      

      Reproducible on all MariaDB 5.5-10.5 and MySQL 5.6/5.7. Not reproducible on MySQL 8.0.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              bar Alexander Barkov
              Reporter:
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:

                  Git Integration