mysql读未提交_InnoDB---读未提交隔离级别的实现

row_search_mvcc(...)//获取记录

{...

/* We are

ready to look at a possible new index entry in the result

set: the cursor is now placed on a user

record */

if (prebuilt->select_lock_type

!= LOCK_NONE) {//如果需要加锁,则加锁的语义来自上层

...

} else {//不需要加锁

/*

This is a non-locking consistent read: if necessary, fetch a previous version

of the record */

if

(trx->isolation_level == TRX_ISO_READ_UNCOMMITTED)

{ //如果是读未提交,则什么也不做

/* Do nothing: we let a non-locking SELECT read the latest version of

the record */

}

else if (index == clust_index) { //否则,才需要检查“rec”是否满足可见性,不满足则找出满足可见性要求的旧版本

//所以,读未提交什么也不做,就是在说当前的rec是符合的,能被读到的,根本不用到回滚段找出旧版本(所得即所“可见”)

/* Fetch a previous version of

the row if the current one is not visible in the snapshot;

if we have a very high force recovery level

set, we try to avoid crashes by skipping this lookup */

if (srv_force_recovery < 5

&& !lock_clust_rec_cons_read_sees(rec,

index, offsets, trx_get_read_view(trx))) {

rec_t*old_vers;

/* The following call returns ‘offsets‘ associated with ‘old_vers‘ */

err = row_sel_build_prev_vers_for_mysql(trx->read_view,

clust_index, prebuilt, rec, &offsets, &heap,

&old_vers,

need_vrow ? &vrow : NULL, &mtr);

if (err != DB_SUCCESS) {

goto lock_wait_or_error;

}

if (old_vers == NULL) {

/* The row did not exist yet in the read view */

goto next_rec;

}

rec = old_vers;

}

}

else {

/* We are looking into a non-clustered

index, and to get the right version of the record we

have to look also into the clustered index:

this is necessary, because we can only get the undo

information via the clustered index record.

*/

...

}

}

}

...}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值