Bug #105916 create enum/set column with binary literal
Submitted: 16 Dec 2021 8:12 Modified: 16 Dec 2021 8:58
Reporter: x j Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:8.0.26, 8.0.27, 5.7 OS:Any
Assigned to: CPU Architecture:Any

[16 Dec 2021 8:12] x j
Description:
if we create an enum/set column table and fill the elements with binary literal, we will get unreadable results

How to repeat:
mysql> create table t(a enum(0x91) default 0x91);
Query OK, 0 rows affected, 1 warning (0.03 sec)

mysql> show warnings;
+---------+------+----------------------------------------+
| Level   | Code | Message                                |
+---------+------+----------------------------------------+
| Warning | 1300 | Invalid utf8mb4 character string: '91' |
+---------+------+----------------------------------------+
1 row in set (0.00 sec)

it will create success and then we get then unreadable results from t

mysql> insert into t values (0x91);
Query OK, 1 row affected (0.01 sec)
mysql> select hex(a), a from t;
+--------+------+
| hex(a) | a    |
+--------+------+
| 91     | �     |
+--------+------+
1 row in set (0.00 sec)

if we create a char(10) column with an invalid default value.

mysql> create table t(a char(10) default 0x91);
ERROR 1067 (42000): Invalid default value for 'a'

it reports an error, I think MySQL should make them have the same behavior
[16 Dec 2021 8:58] MySQL Verification Team
Hello x j,

Thank you for the report and test case.

regards,
Umesh