Created
February 26, 2021 13:01
-
-
Save zhangysh1995/415a522d1108a12afe0d1989d9546f6a to your computer and use it in GitHub Desktop.
mvcc_mysql_exmaple
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---- create table | |
drop table if exists t0; | |
create table t0 ( | |
pk int primary key, | |
col0 int, | |
col1 int | |
); | |
insert into t0 values (0,1,2), (1,2,3); | |
---- T1 | |
drop table if exists t0; | |
create table t0 ( | |
pk int primary key, | |
col0 int, | |
col1 int | |
); | |
insert into t0 values (0,1,2), (1,2,3); | |
---- T1 | |
start transaction; | |
select pk from t0; | |
insert into t0 value (2,3,5); | |
commit; | |
---- T2 | |
start transaction; | |
select pk from t0; | |
insert into t0 value (2,3,5); | |
select pk from t0; | |
update t0 set col0 = 1 where pk > 0; | |
select pk from t0; ---- different? | |
commit; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- T1 -- -- T2 -- | |
start transaction; | |
start transaction; | |
select pk from t0; | |
insert into t0 value (2,3,5); | |
select pk from t0; ---- first read | |
commit; | |
select pk from t0; ---- second read (same) | |
update t0 set col0 = 1 where pk > 0; ---- also updated (2,3,5) to (2,1,5) | |
select pk from t0; ---- third read (different!??) | |
commit; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment