Repository navigation
Description
Description
LIKE and REGEXP ignore the column's declared collation entirely. Even on a column explicitly created with COLLATE utf8mb4_unicode_ci — the collation that MO otherwise implements correctly for =, IN, and UNIQUE — pattern matching still compares case-sensitively. So on the same column, = is case-insensitive but LIKE is not.
This is distinct from the report that LIKE/REGEXP are case-sensitive under the default collation: here the collation is explicitly the one that otherwise works, and pattern matching still ignores it.
Environment
- MatrixOne dev build (local multi-CN,
main) - MySQL 8.0.45 control
Reproduction
CREATE TABLE uci2 (s VARCHAR(20) COLLATE utf8mb4_unicode_ci);
INSERT INTO uci2 VALUES ('Alice'), ('BOB');
-- equality and IN honor the collation:
SELECT COUNT(*) FROM uci2 WHERE s = 'alice'; -- MO: 1 ✓ (correct)
SELECT COUNT(*) FROM uci2 WHERE s IN ('alice'); -- MO: 1 ✓ (correct)
-- pattern matching does not:
SELECT COUNT(*) FROM uci2 WHERE s LIKE 'alice%'; -- MO: 0 ✗ (MySQL: 1)
SELECT COUNT(*) FROM uci2 WHERE s LIKE 'ALICE%'; -- MO: 0 ✗ (MySQL: 1)
SELECT COUNT(*) FROM uci2 WHERE s REGEXP '^alice'; -- MO: 0 ✗ (MySQL: 1)MySQL returns 1 for all five.
The same split exists at literal level:
SELECT 'Apple' = 'apple' COLLATE utf8mb4_unicode_ci; -- MO: 1 ✓
SELECT 'Apple' LIKE 'apple' COLLATE utf8mb4_unicode_ci; -- MO: 0 ✗Root cause (diagnostic)
MO contains a working case-folding collation implementation (utf8mb4_unicode_ci behaves exactly like MySQL, including ß→ss, œ→oe, æ≠ae, and correct sort weights). But LIKE/REGEXP evaluation appears to bypass the collation layer: they take the raw string bytes and run a byte-wise matcher (and a case-sensitive regex engine), never consulting the column's collation.
By contrast =/IN/UNIQUE do consult it — which is why the same column mixes correct and incorrect behavior.
Impact
WHERE name LIKE 'prefix%'returns fewer rows than MySQL on any_cicolumn, including columns where the user explicitly chose a working collation. There is currently no way to get case-insensitive pattern matching —COLLATEat the column level does not help, so the behavior cannot be worked around in SQL.- Application search breaks: autocomplete, admin filters, and
WHERE title LIKE '%term%'all become case-sensitive, diverging from MySQL behavior that applications were written against. - Self-contradictory predicates:
WHERE s = 'alice' OR s LIKE 'Ali%'mixes two case rules; a single row can satisfy one and not the other, which is essentially impossible to reason about. - Index range scans diverge:
LIKE 'prefix%'can be pushed into an index range, so the same query may return different rows depending on whether the index or a scan answers it.
Expected behavior
LIKE and REGEXP must honor the operand's collation, exactly as = and IN already do:
CREATE TABLE uci2 (s VARCHAR(20) COLLATE utf8mb4_unicode_ci);
INSERT INTO uci2 VALUES ('Alice');
SELECT COUNT(*) FROM uci2 WHERE s LIKE 'alice%'; -- 1
SELECT COUNT(*) FROM uci2 WHERE s REGEXP '^alice'; -- 1Since utf8mb4_unicode_ci already routes correctly through the comparator for =, the fix is to route the LIKE/REGEXP matchers through the same collation-aware comparison instead of a byte-wise matcher. (_bin collations should of course keep the current byte-wise behavior.)
Activity
XuPeng-SH commentedon Oct 26, 2026
Tracking consolidated into #31175. The canonical issue retains this report’s full reproduction/discussion and independent acceptance requirements. This is administrative consolidation, not a claim that the defect is fixed. Original evidence remains preserved here.
fix(sql): honor effective collation in pattern-matching operators (ma…
fix(sql): honor effective collation in pattern-matching operators (ma…
fix(sql): honor effective collation in pattern-matching operators (ma…
fix: honor the effective collation in LIKE, REGEXP and FIND_IN_SET (#…