Skip to content

[Bug]: ENUM/SET character length is missing and SET is misreported as numeric in information_schema.COLUMNS #30936

Closed

Description

@Ariznawlll

Proposed consolidated tracking scope: 声明的列与索引元数据无损呈现

These are independent reproductions grouped under one acceptance contract; a common immediate root cause is not assumed. Administrative consolidation does not claim that any defect is fixed. Original report bodies and discussions remain available at the links below.

Included reports

  • #30935 — [Bug]: prefix-index length is missing from STATISTICS.SUB_PART and SHOW INDEX metadata
  • #30937 — [Bug]: information_schema truncates valid generated-column expressions at 500 characters

Acceptance checklist

  • Keep ENUM/SET character-length and numeric-classification cases, including multibyte labels.
  • Report prefix lengths as numeric SUB_PART/Sub_part and preserve actual SQL NULL for non-prefix indexes.
  • Return full generated expressions beyond 500 characters; compare with SHOW CREATE and evaluated values, independently of prefix-index and ENUM/SET paths.

Problem

information_schema.COLUMNS misclassifies supported ENUM and SET columns: both have CHARACTER_MAXIMUM_LENGTH and CHARACTER_OCTET_LENGTH as SQL NULL, while SET also has NUMERIC_PRECISION=20 and NUMERIC_SCALE=0. MySQL reports their maximum rendered label length as character metadata and leaves numeric metadata NULL. Schema introspection/migration tools can treat SET as numeric or omit length constraints.

Environment and reproduction

  • MatrixOne official main d4c37f4d8722dd91b80f5f5547940004bf1b293f, isolated locally built two-CN cluster, SQL ports 6431/6432.
  • MySQL 8.3.0 reference on a private Unix socket.
  • Three independent fresh MO table definitions, read from both CNs; result 3/3. Temporary database/user/role cleaned by the runner.
CREATE TABLE t(
  id INT PRIMARY KEY,
  e ENUM('a','bb'),
  s SET('a','bb')
);
SELECT column_name, data_type,
       character_maximum_length, character_octet_length,
       numeric_precision, numeric_scale
FROM information_schema.columns
WHERE table_schema=DATABASE() AND table_name='t'
ORDER BY ordinal_position;

For e, MatrixOne returns NULL, NULL, NULL, NULL in the four metadata fields; for s, it returns NULL, NULL, 20, 0. On MySQL 8.3 with default utf8mb4, e is 2, 8, NULL, NULL and s is 4, 16, NULL, NULL. The id INT precision/scale control agrees (10,0). The same defect persists with ENUM('z','a')/SET('z','a') and UTF-8 labels ENUM('中','长长')/SET('中','长长'); MySQL respectively reports character lengths 1/3 and 2/4, whereas MO continues returning NULL and SET numeric precision 20.

Stored ENUM/SET values and SHOW CREATE TABLE labels were correct. Duplicate-primary-key insertion was rejected, leaving exactly one source row; both CN connections remained healthy. This is a catalog metadata defect, not proof that value storage is wrong.

White-box and duplicate check

pkg/util/sysview/predefined.go:570-590 builds the COLUMNS view using internal_char_length(mc.atttyp) and internal_numeric_precision(mc.atttyp) without using mc.attr_enum to derive the declared ENUM/SET label lengths. pkg/sql/plan/function/func_builtin.go:855-883 only returns character length for ordinary MySQL string type OIDs. This explains ENUM's missing length; SET's numeric precision appears to follow its internal numeric storage representation. This is a starting point for a fix, not a claimed fully traced patch.

Searched open and closed issues and mysql-compatibility-contract. Closed #25103 fixed missing general varchar/decimal metadata and ORM introspection but did not cover ENUM/SET lengths or SET's false numeric classification. #30931 tracks ENUM/SET boolean value semantics, a separate execution path.

Evidence: EnumSetMetadata.java, /private/tmp/mo-explore-run-20261023/prepared_123922 (three passing source/error/metadata checks), and direct MySQL 8.3 queries for all three label definitions.

Activity

  1. added this to the MO-202610 milestone on Oct 23, 2026
  2. added theissue type on Oct 23, 2026
  3. added
    severity/s0
    ai-easy
    and removed on Oct 25, 2026
  4. gouhongshen commented on Oct 27, 2026

    @gouhongshen
    Contributor

    PR #31489 is trying to fix this issue.

  5. gouhongshen commented on Oct 30, 2026

    @gouhongshen
    Contributor

    PR #31489 has merged and is awaiting manual validation. The issue remains open.

  6. XuPeng-SH commented on Oct 30, 2026

    @XuPeng-SH
    Contributor

    转 QA 验证:#31489 已合入 main,合并提交 8197e28bc67c504a689ce8f38e1de56b5aac4982。

    COLUMNS 使用声明 ENUM/SET 标签计算字符/字节长度并使数值元数据为 NULL,经已有升级路径发布;当前 issue 完整评论只有合入待人工验证,无未完成开发 follow-up。

    本轮证据为 issue 全文/完整评论与合并源码、测试内容静态核对,未运行本地 MatrixOne 实例或回归;PR 作者自述的运行结果不算本轮独立测试。当前未找到适用于新修复的已验证反例或仍未完成的开发 follow-up,按转测口径交给 Ariznawlll;这不是验收通过。

    请 QA 继续覆盖:已有/新建租户、升级失败重试、ENUM/SET 多字节/空标签/重排与整数对照;PR 披露的逗号标签旧编码限制仍保留,不把它或跨版本分布式验证声称已解决。

  7. Ariznawlll commented on Oct 31, 2026

    @Ariznawlll
    CollaboratorAuthor

    结论

    测试通过。合并 issue 所要求的 ENUM/SET 字符元数据、索引前缀长度及长生成表达式,在所测新建与已有租户场景中符合预期。

    关键证据

    • 版本:官方 main@fe3b5591edac949af74ced9e0f3d61433826c582;修复 fix(sysview): publish declared COLUMNS metadata, numeric SUB_PART and full generated expressions #31489 的合并提交 8197e28bc67c504a689ce8f38e1de56b5aac4982 在祖先链。源码内隔离 embedded 升级夹具以该 SHA 的干净受版本控制源码构建,额外添加仅用于本轮验证的测试文件。
    • 在升级前已有的系统租户和普通租户中创建多字节、重排的 ENUM/SET 表及前缀索引;4.0.6/5 目录到 4.0.7/41 的正常完成和先失败后重试两条路径各 3/3。升级后及重启后,原始值保持正确,ENUM 的字符/字节长度为 2/8、SET 为 4/16,数值精度与 scale 为 SQL NULL,索引 SUB_PART 为 3;升级后新建租户同样通过。
    • 含 200 个加法项的生成列表达式完整内容与 SHOW CREATE TABLE 一致,长度超过 500,计算结果为 207;上述升级路径及新租户均检查。项目 TestIssue30936 定向测试在该源码上重复 3 次成功,覆盖空标签、标签重排、整数对照及多字节元数据。
    • 已有 MOTR 公共 SQL 回归 验证索引前缀、元数据与长表达式;本轮的独立升级夹具及运行说明已保存到 MOTR #298。MOTR 公共 SQL 回归上轮在 main@6e5f2ce0fa52b834e39fb4ada00984fa57c02c14 双 CN 各运行 3/3。

    待解决点

    • 升级夹具使用当前源码引擎暂存旧版目录定义,并非真实旧二进制到新二进制的分布式滚动升级;本轮未覆盖后者。研发已披露的旧编码中逗号标签歧义限制不在本次修复声明内,本次不声称已解决。升级夹具是独立验证资料,不是 MOTR 日常 CI 自动运行项。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

ai-easyarea/compatibilitykind/bugseverity/s0

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions