[Bug]: ENUM composite index lookup fails after ALTER TABLE index backfill

Open
#33,311 0 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@jiangxinmeng1 is already working on this.

Since Nov 26, 2026.

Assessment

This issue has not been assessed yet.

Description

Summary

A composite secondary index on an ENUM column works when created with the table, but after dropping and rebuilding that index with ALTER TABLE ... ADD KEY, a forced indexed lookup can fail with an internal type mismatch.

Reproduction

CREATE DATABASE enum_index_backfill_repro;
USE enum_index_backfill_repro;
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,'k','y'),(3,'k2','x'),(4,'k',NULL);

-- Passes before rebuilding the index and returns 1,2.
SELECT GROUP_CONCAT(id ORDER BY id)
FROM t FORCE INDEX(ix)
WHERE tag='k' AND e IN ('x','y');

ALTER TABLE t DROP INDEX ix;
ALTER TABLE t ADD KEY ix(tag,e);

-- Fails on current main with ERROR 20101:
-- internal error: provided type did not match the expected type
SELECT GROUP_CONCAT(id ORDER BY id)
FROM t FORCE INDEX(ix)
WHERE tag='k' AND e IN ('x','y');

On main commit ba80b48f4a182ae2d6c4f70c93aaa5d4affd6070, an isolated service reproduced this consistently. The same query without the index (USE INDEX()) passes; the same backfill/query sequence for a YEAR key passes. Inline ENUM index equality, IN, and <=> NULL queries pass before the ALTER rebuild.

This is a SELECT/read-path issue after index backfill. It is related in area to #33080/#29188's ENUM secondary-index key representation work, but those reports cover DELETE/index maintenance; this reproduction fails on SELECT after ALTER TABLE ... ADD KEY.

Dominant language
Go
Stars
1.9k
Forks
312
Avg merge
22h 59m
Merged PRs (30d)
736

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from matrixorigin/matrixone

All issues in matrixorigin/matrixone

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.