Skip to content

[Bug]: ENUM/SET comparisons are case-sensitive under ci collation #31364

Open

Description

@Ariznawlll

DRAFT ISSUE 20 (候选, 不要提交)

标题候选: [Bug]: ENUM and SET comparisons are case-sensitive under ci collation — WHERE e='RED' and s='A,B' return 0 where MySQL matches (4th distinct gap in the ci family)

标签: kind/bug, needs-triage

Relation to #30771 (OPEN)

#30771 tracks the opposite direction of ENUM case handling: under utf8mb4_bin, case-distinct members like ENUM('a','A') are wrongly folded (should differ, don't). This report covers the ci direction: under the default _ci collation, WHERE e='RED' fails to match stored 'Red' (should fold, doesn't). Both symptoms live in ENUM/SET label comparison but in opposite collation regimes — this issue complements rather than duplicates #30771.

Description

ENUM/SET values store an ordinal bitmask internally but comparisons must go through the column collation — with the default utf8mb4_general_ci, WHERE e='RED' matches a row stored as 'Red' in MySQL. MatrixOne's ENUM/SET comparison is exact-case, so no case variant matches.

This is the fourth distinct code path in the case-insensitivity family found so far (previous three: =/IN literals on VARCHAR, LIKE/REGEXP, UNIQUE/PK index). ENUM appears to use its own untouched comparator; SET has the same defect.

Query on enum('Red','GREEN') with rows ('Red'),('GREEN') MO (main, 2026-10-26) MySQL 8.0.45
WHERE e='RED' 0 1
WHERE e='red' 0 1
WHERE e='green' 0 1
WHERE e='Red' 1 ✓ 1
Query on set('a','b','c','d') rows ('a'),('a,b'),('b,c,d'),('d') MO MySQL
WHERE s='A,B' 0 1

The full matrix from a plain enum('red','green','blue') also confirmed: count(*) where e='RED' → MO 0, MySQL 1.

Reproduction

CREATE TABLE en2 (e ENUM('Red','GREEN'));
INSERT INTO en2 VALUES ('Red'), ('GREEN');
SELECT COUNT(*) FROM en2 WHERE e='RED';   -- MO: 0.  MySQL: 1

CREATE TABLE st1 (s SET('a','b','c','d'));
INSERT INTO st1 VALUES ('a'), ('a,b'), ('b,c,d'), ('d');
SELECT COUNT(*) FROM st1 WHERE s='A,B';   -- MO: 0.  MySQL: 1

Impact

  • Application filters miss rows: form values commonly arrive uppercased (strtouppered statuses, normalized state names like 'ACTIVE'/'INACTIVE' enums). Such filters work on MySQL and silently return nothing on MatrixOne.
  • Migrated code cannot rely on the documented MySQL behavior "ENUM comparisons use the column collation" — they get case-sensitive exact matches instead.
  • INSERT validation is case-insensitive in MySQL too (INSERT ... VALUES ('RED') is stored as 'Red'): worth re-verifying that direction as well when fixing (current MO INSERT e='RED' — note this direction wasn't separately probed here; the read side divergence is confirmed).

Expected behavior

Route ENUM =/IN/LIKE comparisons through the column's collation exactly the way VARCHAR comparisons are supposed to (and per fix of the other ci-family issues), so under _ci collations e='RED' matches stored 'Red'. Given the other three ci issues are separate code paths, this one needs its own fix at the ENUM comparison site.

Activity

  1. added
    kind/bug
    on Oct 27, 2026
  2. added this to the MO-202610 milestone on Oct 27, 2026
  3. added theissue type on Oct 27, 2026
  4. added
    severity/s0
    ai-easy
    and removed on Nov 16, 2026
  5. gouhongshen commented on Nov 17, 2026

    @gouhongshen
    Contributor

    PR #32874 is trying to fix this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

ai-easykind/bugseverity/s0

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions