[MDEV-6570] Bad value can be inserted into an ENUM field when character set conversion Created: 2014-08-13  Updated: 2023-11-28

Status: Confirmed
Project: MariaDB Server
Component/s: None
Affects Version/s: 5.5.39, 10.0.13, 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10
Fix Version/s: 10.4, 10.5, 10.6

Type: Bug Priority: Minor
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Unresolved Votes: 0
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.


Generated at Thu Feb 08 07:12:55 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.