Bug #106506 mysql does report error for invalid binary literal
Submitted: 18 Feb 2022 10:15 Modified: 18 Feb 2022 10:58
Reporter: x j Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:8.0.27, 8.0.28 OS:Any
Assigned to: CPU Architecture:Any

[18 Feb 2022 10:15] x j
Description:
mysql does report error for invalid binary literal in some case

How to repeat:
CREATE TABLE `t` (
  `a` char(10) DEFAULT NULL,
  KEY `idx` (`a`)
)
insert into t values ('a');
mysql> select * from t ignore index (idx) where a = 0x80;
ERROR 3854 (HY000): Cannot convert string '\x80' from binary to utf8mb4
mysql> select * from t where a = 0x80;
Empty set, 1 warning (0.00 sec)

mysql> select * from t where a > 0x80;
ERROR 3854 (HY000): Cannot convert string '\x80' from binary to utf8mb4

You can see that, if the expression is `=` and use the index, it will not report the error like other case
[18 Feb 2022 10:58] MySQL Verification Team
Hello x j,

Thank you for the report and test case.

regards,
Umesh