You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Compatibility]: COPY ALTER cannot combine ADD COLUMN and ADD INDEX in one statement #28052
当前 main 0c3a04f390adaf6281fd592a49778ea5b1155e67 复核后限制仍存在。
使用 JSON STORED generated column 的同一条 DDL:
ALTERTABLE t
ADD COLUMN category VARCHAR(20) AS (JSON_UNQUOTE(JSON_EXTRACT(payload, '$.category'))) STORED,
ADD INDEX category_idx(category);
三次均返回 ERROR 20301: unsupported alter option in copy mode: add index category_idx (category)。拒绝后 SHOW COLUMNS 只有原始 id/payload/note,SHOW INDEX 只有 PRIMARY,原子性保持正确。
changed the title [-][Compatibility]: ALTER TABLE cannot add a stored generated column and its index in one statement[/-][+][Compatibility]: COPY ALTER cannot combine ADD COLUMN and ADD INDEX in one statement[/+]on Sep 15, 2026
影响范围已在当前 main 0c3a04f390adaf6281fd592a49778ea5b1155e67 扩大确认,不限于 generated column 或 JSON。
下列两种普通表组合各连续三次均返回同一 20301:
-- 索引引用本条 ALTER 新增的普通列ALTERTABLE ordinary ADD COLUMN c INT, ADD INDEX idx_c(c);
-- 索引只引用 ALTER 前已经存在的普通列ALTERTABLE existing_col ADD COLUMN c INT, ADD INDEX idx_b(b);
两者均返回:
unsupported alter option in copy mode: add index ...
ALTERTABLE ft_t
ADD COLUMN body TEXT,
ADD FULLTEXT INDEX ft_body(body);
ALTERTABLE h_t
ADD COLUMN v VECF32(3),
ADD INDEX h_v USING hnsw (v) OP_TYPE 'vector_l2_ops';
两条语句各连续三次均在 COPY 计划阶段返回:
unsupported alter option in copy mode: add fulltext ft_body (body)
unsupported alter option in copy mode: add index h_v using hnsw (v) ...
Activity
Ariznawlll commentedon Sep 3, 2026
补充受影响范围:
同一条
ALTER TABLE中新增 VIRTUAL generated column 并创建引用它的普通索引,也会被 MatrixOne 拒绝:[RFC] functional indexes on deterministic expressions (#28156)
Ariznawlll commentedon Sep 15, 2026
当前 main
0c3a04f390adaf6281fd592a49778ea5b1155e67复核后限制仍存在。使用 JSON STORED generated column 的同一条 DDL:
三次均返回
ERROR 20301: unsupported alter option in copy mode: add index category_idx (category)。拒绝后SHOW COLUMNS只有原始id/payload/note,SHOW INDEX只有 PRIMARY,原子性保持正确。MySQL 8.0.45 成功执行同一组合:既有 JSON 行回填
category,后续把 id=2 的 JSON 更新为category=c后可返回 id=2,且category_idx存在。[-][Compatibility]: ALTER TABLE cannot add a stored generated column and its index in one statement[/-][+][Compatibility]: COPY ALTER cannot combine ADD COLUMN and ADD INDEX in one statement[/+]Ariznawlll commentedon Sep 15, 2026
影响范围已在当前 main
0c3a04f390adaf6281fd592a49778ea5b1155e67扩大确认,不限于 generated column 或 JSON。下列两种普通表组合各连续三次均返回同一 20301:
两者均返回:
因此根因是 COPY-ALTER 不接受
ADD INDEX与列变更并存,而非 generated-column 依赖解析。请按通用组合 DDL 兼容性处理;generated STORED/VIRTUAL 是该通用限制的受影响子集。Ariznawlll commentedon Sep 15, 2026
在当前
main(0c3a04f390adaf6281fd592a49778ea5b1155e67)继续确认,#28052 的 COPY-ALTER 组合限制也覆盖特殊索引类型:两条语句各连续三次均在 COPY 计划阶段返回:
拒绝后新列和索引都不存在,没有留下部分 DDL。作为边界对照,先独立新增列、再独立创建索引后,
RENAME COLUMN可以正确更新 FULLTEXT/HNSW 索引列元数据;后续 INSERT、UPDATE、MATCH 和 HNSW Top-K 查询均继续使用索引并返回正确结果。因此本问题的修复范围应包括普通、FULLTEXT 和向量索引插件,而不仅是最初的 generated-column 普通索引场景。
[RFC] functional indexes on deterministic expressions (matrixorigin#2…
[RFC] functional indexes on deterministic expressions (matrixorigin#2…
[RFC] functional indexes on deterministic expressions (matrixorigin#2…
fix: support ADD INDEX in COPY ALTER TABLE (#29052)
daviszhen commentedon Sep 22, 2026
补充 Paicoding 应用证据(关联 #29221):
Paicoding pinned revision
6b85f5c327de47b8f704a18bf15e95e24e0cc052的 Liquibase migrationupdate_schema_260506.sql包含:原始迁移在 MatrixOne copy mode 中返回:
将
ADD COLUMN和ADD KEY拆成两条 ALTER,或删除索引子句后即可继续迁移。当前 Paicoding adapter 因此会规范化update_schema_*.sql,并预加载基线 Schema。这使得 Paicoding 适配后可以启动,但不是原始 MySQL Liquibase migration 已兼容的证明。建议修复后恢复原始迁移并增加 Paicoding 回归。
Ariznawlll commentedon Sep 22, 2026
测试版本
main3727c5c5436ca136d7b0312f75bc223a11692a85原问题验证
ALGORITHM=COPY已可在一条 ALTER 中同时增加列与索引,新增对象可正常查询。Happy Path 覆盖
覆盖普通索引、generated column、FULLTEXT、HNSW 与 IVFFLAT 索引组合,建表及查询均成功。
Unhappy Path 覆盖
组合 ALTER 中唯一索引构建遇到重复键时返回 1062 错误。
白盒验证
失败后检查 catalog:新增列数量为 0、索引数量为 0,验证 COPY ALTER 失败回滚的原子性。
回归测试
新增
suites/14_issue_regression/t/issue_28052_copy_alter_add_index.test,已提交至 motr#199。测试证据
定向用例连续执行 3 轮;本次新增 7 个 case 共执行 21 次,结果为
21/21通过。14_issue_regression整套执行时该用例也通过。MOTR 当前未为该分支上报远端 checks。测试结论
测试通过。