Bug #104534 | Pattern matching using LIKE not working with UFT8MB4_BIN collation | ||
---|---|---|---|
Submitted: | 4 Aug 2021 13:11 | Modified: | 5 Aug 2021 13:55 |
Reporter: | Christoph Mayr | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S2 (Serious) |
Version: | 8.0, 8.0.26 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | LIKE statement utf8mb4 index |
[4 Aug 2021 13:11]
Christoph Mayr
[5 Aug 2021 13:55]
MySQL Verification Team
Hello Christoph Mayr, Thank you for the report and test case. regards, Umesh
[12 Aug 2021 4:15]
Takuji Shimokawa
I've encountered a similar problem. In my case, you don't need multi-byte characters to reproduce the problem. ``` CREATE TABLE table1( id INT PRIMARY KEY AUTO_INCREMENT, text1 TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin ); CREATE INDEX idx_text1 ON table1 (text1(100)); INSERT INTO table1 (text1) VALUES ('a\tb'); INSERT INTO table1 (text1) VALUES ('ab'); SELECT * FROM table1 WHERE text1 LIKE 'a%'; ``` I expected that the both records will be found, but this results in: ``` +----+-------+ | id | text1 | +----+-------+ | 2 | ab | +----+-------+ 1 row in set (0.00 sec) ``` This happened for MySQL 8.0.26 and 5.6.40. By making any one of the changes below, the same SELECT query returned the both records: - Removing the index on the text1 column - Changing the collation to utf8mb4_generic_ci or utf8mb4_unicode_ci Only for the version 5.6.40, - Changing the column type to VARCHAR
[11 Oct 2023 6:49]
Tsubasa Tanaka
8.0.34 and 8.1.0 are affected too.