Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: 实现update set多表时的回滚支持 #136

Merged
merged 2 commits into from
Dec 16, 2019

Conversation

hanchuanchuan
Copy link
Owner

@hanchuanchuan hanchuanchuan commented Dec 16, 2019

示例:

create table table1(id1 int primary key,c1 int,c2 int);
create table table2(id2 int primary key,c1 int,c2 int,c22 int);
insert into table1 values(1,1,1),(2,1,1);
insert into table2 values(1,1,1,null),(2,1,null,null);
-- 修改两表的字段
update table1 t1,table2 t2 set t2.c22=20,t1.c1=10 where t1.id1=t2.id2 and t2.c1=1;

回滚说明:

  • $_$inception_backup_information$_$ 备份记录表和之前版本一致,列tablename取值为set中第一个字段对应的表,示例中为table2
  • table2记录的回滚语句如下(不同enable_minimal_rollback选项会略有差异):
UPDATE `test_inc`.`table2` SET `id2`=1, `c1`=1, `c2`=1, `c22`=NULL WHERE `id2`=1;
UPDATE `test_inc`.`table2` SET `id2`=2, `c1`=1, `c2`=NULL, `c22`=NULL WHERE `id2`=2;
UPDATE `test_inc`.`table1` SET `id1`=1, `c1`=1, `c2`=1 WHERE `id1`=1;
UPDATE `test_inc`.`table1` SET `id1`=2, `c1`=1, `c2`=1 WHERE `id1`=2;

table2数据截图:
image

table1数据截图:
image

@codecov
Copy link

codecov bot commented Dec 16, 2019

Codecov Report

Merging #136 into master will decrease coverage by 0.0641%.
The diff coverage is 0%.

@@               Coverage Diff                @@
##             master       #136        +/-   ##
================================================
- Coverage   60.0704%   60.0062%   -0.0642%     
================================================
  Files           369        369                
  Lines         80096      80165        +69     
================================================
- Hits          48114      48104        -10     
- Misses        27882      27958        +76     
- Partials       4100       4103         +3

@hanchuanchuan hanchuanchuan merged commit e575b00 into master Dec 16, 2019
@hanchuanchuan hanchuanchuan deleted the patch-update-multi-tables branch December 16, 2019 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant