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

Bad value can be inserted into an ENUM field when character set conversion

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 5.5.39, 10.0.13
    • Fix Version/s: 10.0
    • Component/s: None
    • Labels:
      None

      Description

      This SQL script:

      SET NAMES utf8;
      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a ENUM('a','b','?','.') CHARACTER SET latin1);
      INSERT INTO t1 VALUES ('ÿ'),('я');
      SHOW WARNINGS;
      SELECT * FROM t1;
      

      produces the following output:

      MariaDB [test]> SET NAMES utf8;
      Query OK, 0 rows affected (0.00 sec)
      
      MariaDB [test]> DROP TABLE IF EXISTS t1;
      Query OK, 0 rows affected (0.12 sec)
      
      MariaDB [test]> CREATE TABLE t1 (a ENUM('a','b','?','.') CHARACTER SET latin1);
      Query OK, 0 rows affected (0.32 sec)
      
      MariaDB [test]> INSERT INTO t1 VALUES ('ÿ'),('я');
      Query OK, 2 rows affected, 1 warning (0.03 sec)
      Records: 2  Duplicates: 0  Warnings: 1
      
      MariaDB [test]> SHOW WARNINGS;
      +---------+------+----------------------------------------+
      | Level   | Code | Message                                |
      +---------+------+----------------------------------------+
      | Warning | 1265 | Data truncated for column 'a' at row 1 |
      +---------+------+----------------------------------------+
      1 row in set (0.00 sec)
      
      MariaDB [test]> SELECT * FROM t1;
      +------+
      | a    |
      +------+
      |      |
      | ?    |
      +------+
      2 rows in set (0.00 sec)
      

      Notice:

      • the Latin letter 'ÿ' was correctly replaced to empty value with a warning.
      • the Cyrillic letter 'я' was erroneously misinterpreted as the question
        mark value silently.

      It should be fixed to work in the same way for both values.

        Gliffy Diagrams

          Attachments

            Activity

            There are no comments yet on this issue.

              People

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

                Dates

                • Created:
                  Updated: