Repository navigation
Description
Bug or Feature Request
Bug
Description
The server claims utf8mb4_general_ci and utf8mb4_0900_ai_ci everywhere in metadata, but never applies their case-insensitive semantics to comparisons. Result: same database, same table, same column — constraint checking and querying answer differently, and values the catalog calls "case-insensitive" compare case-sensitively.
Evidence matrix (all on v3.x @ b24d1b3, fresh instance):
A. Literal comparison ignores the collation it itself reports
SELECT collation('Apple'); --> utf8mb4_general_ci (metadata CI)
SELECT 'Apple' = 'apple'; --> 0 (should be 1 under CI)
SET collation_connection = utf8mb4_general_ci; -- accepted
SELECT @@collation_connection; --> utf8mb4_general_ci
SELECT 'Apple' = 'apple'; --> STILL 0B. utf8mb4_unicode_ci shows the intended behavior — proving the CI engine works, general_ci/0900_ai_ci are just not wired to it
CREATE TABLE ci2 (s VARCHAR(20) COLLATE utf8mb4_unicode_ci, UNIQUE KEY uk(s));
INSERT INTO ci2 VALUES ('Apple');
INSERT INTO ci2 VALUES ('apple'); --> ERROR 1062 Duplicate entry (correct CI unique!)
SELECT * FROM ci2 WHERE s='apple'; --> matches 'Apple' (correct CI compare)
JOIN on a.s=b.s with 'ApPlE' --> matches (correct CI join)
SHOW CREATE TABLE ci2; --> COLLATE utf8mb4_unicode_ci PRESERVEDBut the same matrix under general_ci all fails:
CREATE TABLE ci (s VARCHAR(20) COLLATE utf8mb4_general_ci);
INSERT INTO ci VALUES ('Apple'),('APPLE'),('apple');
SELECT count(*) FROM ci WHERE s='apple'; --> 1 (should be 3)
ALTER TABLE ci ADD UNIQUE KEY uk_s(s); -- accepts Apple/APPLE/apple concurrently (no 1062)
SHOW CREATE TABLE ci; -- COLLATE clause silently MISSING (unicode_ci keeps it)C. utf8mb4_0900_ai_ci — the MySQL 8 default and MO's own default_collation_for_utf8mb4 — same story
SELECT 'Apple' = 'apple' collate utf8mb4_0900_ai_ci; --> 0D. SET collation_connection = utf8mb4_unicode_ci is REJECTED
ERROR 20301: invalid input: unsupported collation 'utf8mb4_unicode_ci'
…so the only collation that actually implements CI semantics is also the one that cannot be selected as a session default. The default (default) plus general_ci (accepted) are both inert.
Why this is a correctness/integrity issue, not cosmetics
- Cross-engine seam:
utf8mb4_general_cicolumns accept case-duplicated unique keys silently. Data entered through such a key violates the (MySQL-standard) uniqueness the schema promises; the 1062 the user relies on never fires; tools migrating from MySQL with app-level expectations of CI uniqueness constraints get corrupted data. - Query/constraint disagreement: with unicode_ci columns the unique key says Apple==apple (rejects) while a hypothetical mixed-query pattern under general_ci says they differ — the same two strings compare differently depending on which code path (index maintenance vs expression evaluation) runs.
- dump/restore fidelity:
SHOW CREATE TABLE(and therefore mo-dump) drops theCOLLATE utf8mb4_general_ciattribute (keeps the same attribute for unicode_ci) — a backup of a schema with general_ci columns silently changes collation on restore. @@collation_connectiondefault displays baredefault, which is not a legal MySQL answer (should be a concrete collation name), compounding the ambiguity.
Source pointers (v3.x @ b24d1b3)
- CI engine exists and handles:
pkg/common/collation/general_ci.gohas the full TiDB-derived utf8mb4_general_ci weight table (uppercase folds: 'a'(0x61)→0x41 etc.) — the capability is present but unused by the comparison path. - Domains enumerated in
pkg/common/collation/key.go(UTF8MB4GeneralCIexists as a Domain), butpkg/container/types/types.goIsUnicodeCollation(line ~207) only recognizesCharsetUTF8MB4UnicodeCI/CharsetUTF8MB3UnicodeCI;applyTextCharsetToPlanType(pkg/sql/plan/build_util.go:583-593) only setsCollationVersion = CollationVersionV1for those two, so general_ci/0900_ai_ci columns getKeyFormatLegacy(no transliteration) — the divergence starts here. IsCaseInsensitiveCollation(types.go:203) — the very helper named for this property — also excludes general_ci, contradicting the catalog listingSHOW COLLATIONprovides (general_ci:Default YES,Compiled Yes).
Steps to Reproduce
SELECT collation('Apple'), 'Apple'='apple';→utf8mb4_general_ci | 0(in one row; self-contradictory pair)SET collation_connection=utf8mb4_general_ci; SELECT 'Apple'='apple';→ still 0CREATE TABLE t(s VARCHAR(20) COLLATE utf8mb4_general_ci, UNIQUE KEY(s));then insert Apple / apple → no 1062;SHOW CREATE TABLE t→ COLLATE clause vanished- Same with
utf8mb4_unicode_ci→ 1062 fires, COLLATE preserved (control) SET collation_connection=utf8mb4_unicode_ci;→ ERROR unsupported collation (the only working CI is unsettable)
Expected behavior
utf8mb4_general_ci/utf8mb4_0900_ai_cicomparisons and unique keys must be case-insensitive (they're in SHOW COLLATION as the default!). If they're intentionally not supported as column collations, then: CREATE TABLE with those COLLATE must be rejected, SHOW COLLATION must not list them as default/compiled,collation()must stop reporting them, andSET collation_connectionaccepting them must stop — every metadata surface today lies about the actual behavior.SHOW CREATE TABLEmust round-trip whatever collate the table actually has, for every supported collation.SET collation_connection = utf8mb4_unicode_cimust work (it's the only semantic CI engine actually implemented).
Versions
- MatrixOne commit
b24d1b3(2026-10-16), v3.x dev, macOS 14.5 arm64
Additional context
Related earlier observation in #25096 (CI claims vs reality on UNIQUE with Abc/ABC/aBc) — that issue covered the CI unique-key aspect seen from version-scan; this one adds the expression-comparison level, the SHOW COLLATION/collation() metadata lying, the SHOW-CREATE attribute loss (dump fidelity), and the unicode_ci SET rejection, with source-level domain-mapping root cause.
Activity
XuPeng-SH commentedon Oct 22, 2026
Consolidated into #25096. The current-main reproductions for general_ci/0900_ai_ci, SHOW CREATE, and collation_connection are retained there.
Ariznawlll commentedon Oct 22, 2026
Additional divergence dimension worth tracking under this issue: PAD SPACE semantics are also missing for the fake-CI collations, with correctness ties to MySQL's most-deployed defaults (utf8mb3_general_ci is PAD SPACE).
Setup identical on both servers (dev
3a1e42b430, MySQL 8.0.45):MatrixOne (default/
utf8mb4_general_cicolumn): returnsid=1only.MySQL 8.0.45 (utf8mb3_general_ci, PAD SPACE): returns
id=1, id=2.Full behavior matrix (MO | MySQL):
s = 'ab's = 'ab 's <=> 'ab's IN ('ab','zz')COUNT(DISTINCT s)GROUP BY ss LIKE 'ab'(no wildcard)s LIKE 'ab%'So the trailing-space-equality gap extends beyond case folding into the PAD SPACE compare/collapse family (equality, null-safe-equal, IN, DISTINCT, GROUP BY all affected).
Cross-check that the real-CI engine path already implements PAD correctly — this issue's "only unicode_ci is real" observation holds for PAD too:
i.e.
utf8mb4_unicode_cion MatrixOne gets PAD right;general_ci/0900_ai_ci/default do not apply either CI or PAD. Same root as this issue (collation version unassigned → binary compare), just documenting the additional PAD observable so the fix's regression matrix covers it. Noteutf8mb4_0900_ai_ciis NO PAD in MySQL 8 — if MO keeps 0900 as fake-CI the eventual fix must NOT give it PAD — whilegeneral_ci-family anddefaultmust gain PAD to close this dimension.