Skip to content

[Bug]: Default ALTER TABLE ADD INDEX fails for table names containing an embedded backtick #31080

Done

Description

@XuPeng-SH

Description

The ordinary (no explicit ALGORITHM) ALTER TABLE ... ADD INDEX path fails with an internal SQL syntax error for a valid table name containing an embedded backtick. Plain, space-containing, and reserved-word table-name controls succeed. The same operation succeeds with explicit ALGORITHM=COPY, which isolates the failure to the default alter path. This report records behavior on current main; it does not claim that PR #30646 introduced it.

Environment

  • MatrixOne source SHA: aeaa273daf588a9988ba423915d3ae6b8c82124a
  • Isolated single-process local service, MySQL port 61320
  • Service binary SHA-256: 450363d5ec5e693bdd7ded44565b3b0ab1addcb807d3f9569c5d5eedeb1486e4

Reproduction

CREATE DATABASE qa_round2_30646_inplace;
USE qa_round2_30646_inplace;
CREATE TABLE plain(id INT PRIMARY KEY, v INT);
INSERT INTO plain VALUES(1,10);
ALTER TABLE plain ADD INDEX idx_v(v); -- succeeds

CREATE TABLE `has space`(id INT PRIMARY KEY, v INT);
INSERT INTO `has space` VALUES(2,20);
ALTER TABLE `has space` ADD INDEX idx_v(v); -- succeeds

CREATE TABLE `select`(id INT PRIMARY KEY, v INT);
INSERT INTO `select` VALUES(3,30);
ALTER TABLE `select` ADD INDEX idx_v(v); -- succeeds

CREATE TABLE `tick``table`(id INT PRIMARY KEY, v INT);
INSERT INTO `tick``table` VALUES(4,40);
ALTER TABLE `tick``table` ADD INDEX idx_v(v);
-- Error 1105 (HY000), internal syntax error near "table`;"

The exact failure reproduced in two fresh executions. After each failure the original row and two-column schema remained, and SHOW INDEX showed only the primary key. On the same retained table, ALTER TABLE tick``table ALGORITHM=COPY, ADD INDEX idx_copy(v) succeeded and `FORCE INDEX(idx_copy)` returned `(4,40)`; the disposable database was then dropped.

Expected behavior

The unhinted ADD INDEX should accept the same valid quoted table identifier as the explicit COPY path and normal-name control, preserve the row, and expose the new index.

Duplicate search

Searches for backtick/embedded backtick with ADD INDEX and ALTER found #30550 (COPY-based ADD COLUMN internal DROP failure), which is a different operation/path and now passes its original reproduction. Also checked nearby quoted-identifier issues #30545 and #30549, whose SHOW metadata code paths differ. No duplicate for the default ADD INDEX failure was found.

Evidence

  • Fixture: round2-30646-alter-inplace-quoted-name-repro.sql
  • Failure log: round2-aeaa273-30646-alter-inplace-quoted-name-repro-attempt1.log and ...attempt2.log (identical SHA-256 c465b4f3179e2f89c355a1a8c1e0c8d07829ae753a0917f393ce19d9bad2fefb)
  • Post-error recovery/control log: round2-aeaa273-30646-alter-inplace-quoted-name-recovery-attempt2.log

No customer data or credentials are involved. This is a local single-CN reproduction; multi-CN and restart behavior are not tested.

Activity

  1. assigned and unassigned on Oct 27, 2026
  2. assigned and unassigned on Oct 28, 2026
  3. Ariznawlll commented on Nov 30, 2026

    @Ariznawlll
    Collaborator

    QA 验收通过(最新 main)

    版本与方法

    • 被测及开测时官方 main:c255da6778fac39bc53b5b9defaab3b6f945e4d6;关闭前再次解析仍为该 SHA。
    • 独立双 CN,真实 MySQL 协议;两个 listener 均以 SELECT git_version() 核对完整 SHA。
    • 每轮使用独立数据库,连续 3/3 PASS。

    逐轮覆盖

    1. 普通表名、含空格表名、保留字 select 均执行默认 ALTER TABLE ... ADD INDEX,作为健康对照。
    2. 原始 tick`table 表名通过转义标识符执行默认 ADD INDEX,随后以 FORCE INDEX(idx_v) 精确读回 (4,40)。
    3. 同一表执行显式 ALGORITHM=COPY, ADD INDEX idx_copy(v);两个 CN 的 information_schema.statistics 均精确包含 PRIMARY、idx_v、idx_copy。
    4. 重复创建 idx_v 按预期拒绝;拒绝后索引元数据不变,两个成功索引均可读回正确行,覆盖失败原子性。

    三轮日志 SHA256:

    • f0e7701b5affb7bfe8bdceb4f2908246a8c0782980147100f493ecf2fa463810
    • eb4965b8373269e7a7b13a60aec43a65a8dd9afe30a6924a8e476cc436bfaef3
    • 1e2efdd2cdb727ca62e2012c2c1f3596b4b73db54feff2e719b153a46a2ce97c

    MOTR 回归

    已推送到 matrixorigin/motr PR 374,head d7715c5907ac73f967096343b1e394ec8486504f,用例为 issue_31080_alter_backtick.py。评论时新 head 的 CI 均为 pending(queued),daily-42 为 SKIPPED;本单关闭依据是上述当前 SHA 的真实服务结果,不把 pending 当作通过。

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions