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
[Feature Request]: support new data branching syntax #21979
create table t1(a varchar(10) primary key, b varchar(10));
create table t2 clone t1 {snapshot}
insert into t1 values("pk1", "a");
insert into t2 values("pk1", "b");
那么,data branch diff t2 against t1 的 结果就是:
mysql> data branch diff t2 against t1;
+--------------------+------+------+------+
| diff t2 against t1 | flag | a | b |
+--------------------+------+------+------+
| t2 | - | pk1 | a |
| t2 | + | pk1 | b |
+--------------------+------+------+------+
2 rows in set (0.01 sec)
Activity
gouhongshen commentedon Jul 15, 2025
doc: https://github.com/gouhongshen/docs/blob/clone_doc/tech-notes/cnservice/clone.md
gouhongshen commentedon Oct 29, 2025
data branch (data branch 功能需要 clone 功能支持) 描述:
data branch 能够让用户像使用 git 一样操纵 mo 的数据,提供了如下的功能:
创建 branch:
data branch create table/db/account x clone ...
(暂不支持, 目前是用 clone 创建 branch, 只要执行 clone, 即创建了一个 branch, 可以通过 mo_catalog.mo_branch_metadata 查看)
create table t2 clone t1 {snapshot}: 从 t1.snapshot 分支生成 t2.|
比较两个表的不同
data branch diff t1 against t2 output_option
data branch diff t1 against t2会返回所有的 diffdata branch diff t1 against t2 output limit x只返回 x 个 diffdata branch diff t1 against t2 output count只返回 diff 的数量两个表的 diff 是通过 pk 去比较的,如果 pk 相同就认为是同一行,如果剩余的列的值不同,就判定为 diff,如果没有 pk, 那么所有列的组合构成 pk. 例子:
那么,data branch diff t2 against t1 的 结果就是:
merge 两个表
将 diff t1 against t2 的结果 merge 进 t2. 根据 conflict 有下面三种情况:
data branch merge t1 into t2 when conflict fail. 默认,等同于省略 conflict_opt,遇到 conflict就报错返回。data branch merge t1 into t2 when conflict skip. 跳过 conflict 的行,保留 t2 对应的行data branch merge t1 into t2 when conflict accept.接受 conflict的行,用 t1 的行替代 t2 对应的行。同样是上面的例子:
更多的细节,可以参考 BVT cases: snapshot/branch
to 3.0: supporting data branch diff as file with stage. (#23189)
to 3.0: update data branch: data branch create table and database (#2…
to 3.0: fix non sys account cannot find the branch meta table. (#23220)
to 3.0: degrade version from 4.0.0 to 3.0.0 (#23241)