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

    XMLWordPrintable

Details

    • Bug
    • Status: Confirmed (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 5.5.39, 10.0.13, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10
    • 10.4, 10.5, 10.6
    • None
    • 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.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.