Skip to content

[Bug]: composite ENUM secondary-index lookups fail with unsupported type on 4.2-dev #33258

Done

Description

@XuPeng-SH

Environment

  • Branch: 4.2-dev
  • Commit: 6c05e42f9f660a207077b050b8ec285ccf3f8103 (release candidate)
  • Also reproduced on PR [4.2-dev] fix: align ENUM/SET secondary-index key encoding #33152 head 16fd99fadd48f0912732b81681acf7b66b93c4a8, confirming this is not introduced by that PR
  • Deployment: local single-CN / single-TN / single-Log mo-service, built from source
  • Hardware / OS: Apple Silicon (arm64), macOS
  • Client: MySQL text protocol

Actual Behavior

An equality lookup through a composite secondary index containing an ENUM part fails with:

ERROR 20101 (HY000): internal error: not supported type ENUM

EXPLAIN selects the secondary index and produces a filter using cast_index_to_value over serial_extract(..., ENUM):

Project
  -> Index Table Scan on t.ix
       Filter Cond: prefix_eq(__mo_index_idx_col),
                    (serial_extract(__mo_index_idx_col, 0, VARCHAR)) = 'k'),
                    (cast_index_to_value('x,y', serial_extract(__mo_index_idx_col, 1, ENUM))) = 'x')

The same query shape and error occur on both the release candidate and PR #33152 head. A single-column ENUM secondary-index lookup works, so this report is specifically about the composite-index extraction path.

Expected Behavior

The query should return the matching row (id = 1) without an internal error.

Steps to Reproduce

create database enum_composite_lookup_42;
use enum_composite_lookup_42;

create table t (
  id int primary key,
  tag varchar(8),
  e enum('x','y'),
  key ix(tag,e)
);

insert into t values (1,'k','x'),(2,'k2','x');

explain select id from t where tag='k' and e='x';
select id from t where tag='k' and e='x';

The final statement returns 20101 internal error: not supported type ENUM instead of 1.

Additional Information

Activity

  1. added
    kind/bug
    on Nov 25, 2026
  2. XuPeng-SH commented on Nov 25, 2026

    @XuPeng-SH
    ContributorAuthor

    Main control result

    Built and tested origin/main at 0b641a61f42ebfc53fd415ab68898cfc77682a2a with the same local single-CN setup and MySQL text protocol.

    The exact composite-index reproduction is not affected on main:

    • where tag='k' and e='x' returned id = 1.
    • where tag='k' and e in ('x','y') returned id = 1, 3.
    • force index(ix) returned id = 1.
    • use index() and single-column ENUM index controls also returned the expected rows.

    EXPLAIN still uses the same cast_index_to_value(... serial_extract(..., ENUM)) plan shape, but execution succeeds. This scopes #33258 to 4.2-dev for the tested path. PR #26943 is therefore a backport candidate; a 4.2 cherry-pick plus this reproduction should confirm whether it is sufficient before closing.

  3. XuPeng-SH commented on Nov 25, 2026

    @XuPeng-SH
    ContributorAuthor

    转 QA:#33260 已合入 4.2-dev,merge SHA 4d846052dc4d78f3942a53da5f05668be9deb37b。补齐 serial_extract 的 ENUM/YEAR 类型分派,沿用现有编码与解码;回填后的 ENUM 索引依赖已合入的 #33152。

    最终 head 20b7c18b 的 CI Required、x86 UT、悲观多 CN BVT 均通过;独立复审通过,沿用只有测试行差异的先前 head 的 28 项嵌入式 SQL 和函数包证据。没有覆盖发布升级或在最终合并版的独立 MySQL 复试,本轮未本地重跑。请在上述合并版本验证原复合索引 SELECT,补 YEAR、INSERT 时建索引及 ALTER 回填、普通及 binary-prepared 等值/IN、NULL、FORCE INDEX 与无索引对照;对发布版本已有索引按实际升级路径核对。原 #33080 DELETE/UPDATE 不混入本单。

  4. Ariznawlll commented on Nov 26, 2026

    @Ariznawlll
    Collaborator

    已完成 4.2-dev 固定版本验收,结论:复合索引包含 ENUM 时查询返回 not supported type ENUM 的问题已修复,可关闭本 Issue。

    版本与原始复现

    • 修复 PR:[4.2-dev] fix: support ENUM and YEAR in serial_extract #33260,merge 4d846052dc4d78f3942a53da5f05668be9deb37b。
    • 固定验收实例:8a273a0f81eda0290d431e54f7a0befe3bb752ec(同时包含 [4.2-dev] fix: align ENUM/SET secondary-index key encoding #33152);真实连接的 git_version() 已核实。
    • 修复前对照:c56af3c5f04cb6047769696917b428c2658566a3。
    • 复现步骤:创建 t(id,tag,e ENUM,KEY ix(tag,e)),插入三行后执行 SELECT id FROM t WHERE tag='k' AND e='x'。
    • 实际输出:连续三轮均复现 ERROR 20101: not supported type ENUM;同轮无索引查询返回 (1),单列 ENUM 索引健康对照正常。
    • 预期结果:复合索引可正常用于查找并返回 id=1,不得因 ENUM 列报内部不支持错误。

    修复后实测

    MOTR CI 状态

    • 回归已提交至 matrixorigin/motr PR Fix bug of merge empty batch #353,head 3d085c8fb810453989044720dcb120e0f9bc46cc。
    • 截至评论时,其余 11 项检查已成功,latest-42-dual-cn 仍在运行;未将双 CN CI 计为通过,也未等待其全绿后关闭。

    范围说明

    • 已通过:上述修复前复现、固定版文本/binary 协议、相关白盒普通/race 及本地 MOTR。
    • 产品复测未通过项:无。
    • 未验收:MOTR 双 CN 最终状态、main/其他 release、生产发布、历史 ENUM 主键数据、停机重建、PITR、备份恢复及升级路径。本地协议连接不是跨 CN。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugneeds-triage

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions