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
createdatabasegc_modify_repro;
use gc_modify_repro;
createtablet (
id intprimary key,
a int,
b int,
g bigint generated always as (a +5) stored
);
insert into t values (1, 10, 20, default);
altertable t modify column a bigint;
insert into t(id,a,b) values (2,4000000000,30);
select id,a,g from t order by id;
MatrixOne 行为
ALTER TABLE 返回:
Cannot modify column 'a': generated column 'g' depends on it
MySQL 8.3.0 行为
INT -> BIGINT 修改成功;已有行保持 g=15,新行可保存 a=4000000000 并生成 g=4000000005。
受影响的安全变更
在独立表上逐项验证,下列 MySQL 支持的修改均被 MatrixOne 以相同依赖错误拒绝:
altertable t modify column a bigint;
altertable t modify column a int unsigned;
altertable t modify column a intnot null;
altertable t modify column a int after b;
-- decimal 表altertable td modify column a decimal(20,4);
CREATETABLEgen(
id INTPRIMARY KEY,
d DECIMAL(38,0),
g DECIMAL(41,0) GENERATED ALWAYS AS (d+1) STORED
);
INSERT INTO gen(id,d) VALUES(1,1);
ALTERTABLE gen MODIFY COLUMN d DECIMAL(40,0);
MatrixOne 返回:
invalid input: Cannot modify column 'd': generated column 'g' depends on it
2026-09-12 — COPY ALTER support for generated-column dependencies
Status: PR fix: allow modify of generated column sources #28770 is open and mergeable at abd3972aefa8ff4e048b980fb5ec7a71654e2037; CodeQL and CI preflight have started. This issue remains open pending exact-head tests and merge.
Root cause: MODIFY COLUMN rejects any source referenced by a generated column, even when COPY ALTER can rebind the expression against the final schema and recompute its values. Index classification also needs to account for the transitive generated dependency closure; otherwise a stale generated-key index can be cloned.
Change: PR #28770 removes only the over-broad MODIFY guard, tracks original-column lineage, and rebuilds indexes affected directly or through chained generated columns while keeping unrelated indexes cloneable. When the closure reaches a real primary-key component, it rebuilds all secondary indexes because their entries carry the base row's PK. DROP/rename dependency rejection, type checks, and unique-key deduplication remain unchanged.
Evidence and review: planner tests cover lineage, chains, reordering, same-name CHANGE, unrelated index cloning, and ADD-then-MODIFY. BVT coverage includes type widening, UNSIGNED/NOT NULL, Decimal128→Decimal256, index refresh, and failed COPY rollback. GPT-6 Astra medium's final source review passed exact tracked diff c1c93775ca111cc08a8eff778d03ac7d68ac67dab63801a05bf5bddd34ee8eb3 plus the new planner test a2b68eca20888935177df44d7b70d3e3e1db7a472f60db96b85d6ff6ddd71ff5. During review, a weak ordinary-index test was replaced by a UNIQUE(payload) forced lookup selecting base columns and compared against IGNORE INDEX, making stale hidden PK payload observable.
Validation: gofmt, git diff --check, incremental molint vet (exit 0; only pre-existing findings in unchanged files), and incremental golangci-lint (0 issues) passed. The prescribed CGo test wrapper stopped before compilation because this isolated macOS worktree lacks provenance-validated cgo/libmo.dylib; local UT and BVT are not claimed as run. No unrelated MatrixOne services were touched.
Performance: dependency closure is computed once during planning; only affected indexes rebuild in the common case. All secondary indexes rebuild only when generated PK values may change. No added table-data pass.
Remaining risk / next: require exact-head CI to execute planner UT, shared tests, and generated-column BVT; resolve any relevant failure before considering the issue verified.
Activity
Ariznawlll commentedon Sep 10, 2026
在最新
main(fc621e3616d229c7a29d0c80e73ed8eb1997459c)补充确认:该限制也阻断DECIMAL从 Decimal128 到 Decimal256 的安全扩宽。MatrixOne 返回:
这里生成列
g DECIMAL(41,0)足以容纳扩宽后的d+1,表达式和列名均未改变。去掉生成列后,相同的DECIMAL(38,0) -> DECIMAL(40,0)可以执行,原值保持精确,并可继续写入 40 位值;存在 40 位值时再缩回DECIMAL(38,0)会拒绝且表结构、数据均保持不变。MySQL 8.0.46 对上述带生成列的安全扩宽可以执行。因此该场景仍属于 issue 描述的“无破坏性类型扩宽被生成列依赖统一阻断”,不另建重复 issue。
XuPeng-SH commentedon Sep 12, 2026
2026-09-12 — COPY ALTER support for generated-column dependencies
abd3972aefa8ff4e048b980fb5ec7a71654e2037; CodeQL and CI preflight have started. This issue remains open pending exact-head tests and merge.MODIFY COLUMNrejects any source referenced by a generated column, even when COPY ALTER can rebind the expression against the final schema and recompute its values. Index classification also needs to account for the transitive generated dependency closure; otherwise a stale generated-key index can be cloned.c1c93775ca111cc08a8eff778d03ac7d68ac67dab63801a05bf5bddd34ee8eb3plus the new planner testa2b68eca20888935177df44d7b70d3e3e1db7a472f60db96b85d6ff6ddd71ff5. During review, a weak ordinary-index test was replaced by aUNIQUE(payload)forced lookup selecting base columns and compared againstIGNORE INDEX, making stale hidden PK payload observable.gofmt,git diff --check, incremental molint vet (exit 0; only pre-existing findings in unchanged files), and incremental golangci-lint (0 issues) passed. The prescribed CGo test wrapper stopped before compilation because this isolated macOS worktree lacks provenance-validatedcgo/libmo.dylib; local UT and BVT are not claimed as run. No unrelated MatrixOne services were touched.fix: allow modify of generated column sources (#28770)
Ariznawlll commentedon Sep 14, 2026
测试版本
原问题验证
Happy Path 覆盖
Unhappy Path 覆盖
白盒验证
回归测试
./motr --repeat 3 14_issue_regression.issue_28187_28772_latest_main连续 3/3 通过(213/213 statements matched)。测试证据
测试结论
测试通过。
fix: allow modify of generated column sources (matrixorigin#28770)
fix: allow modify of generated column sources (matrixorigin#28770)
fix: allow modify of generated column sources (matrixorigin#28770)