步驟
|
事務1
|
事務2
|
事務3
|
1
|
begin;
|
||
2
|
begin;
|
||
3
|
insert into test(score) select 101;
此時事務ID爲101
|
||
4
|
insert into test(score) select 102;
此時事務ID爲102
|
||
5
|
select * from test;
+----+-------+
| id | score |
+----+-------+
| 1 | 101 |
+----+-------+
此時就會建立read view:
up_limit_id = 101
low_limit_id = 103
trx_ids爲(101,102)
而101自身可見,102在活躍事務列表中不可見
|
||
6
|
insert into test(score) select 103;
此時事務ID爲103
|
||
7
|
insert into test(score) select 104;
此時事務ID爲104
|
||
8
|
nsert into test(score) select 105;
此時事務ID爲105
|
||
9
|
select * from test;
+----+-------+
| id | score |
+----+-------+
| 3 | 103 |
| 4 | 104 |
| 5 | 105 |
+----+-------+
此時的up_limit_id=101,
low_limit_id=106,
trx_ids爲(101, 102),
而101和102在trx_ds列表中不可見
|
||
10
|
select * from test;
+----+-------+
| id | score |
+----+-------+
| 2 | 102 |
| 3 | 103 |
| 4 | 104 |
| 5 | 105 |
+----+-------+
此時就會建立read view:
up_limit_id=101,
low_limit_id=106,
trx_ids爲(101, 102),
102自身可見,101在活躍事務列表中不可見
而10三、10四、105不在trx_ids列表中全部可見
|
||
11
|
select * from test;
+----+-------+
| id | score |
+----+-------+
| 1 | 101 |
| 3 | 103 |
| 4 | 104 |
| 5 | 105 |
+----+-------+
因爲事務內read view不變
(與RC的區別就在這),
此時的up_limit_id=101,low_limit_id=103,
trx_ids爲(101, 102),
101自身可見,102在活躍事務列表中不可見
而>=103的都不可見
|