1、进入该函数的条件:
if (n_uniq&& (cursor.up_match >= n_uniq || cursor.low_match >= n_uniq))
同样是已经duplicate
2、主键索引加记录锁S
if (cursor->low_match >= n_unique) {//一般都走这个流程 rec= btr_cur_get_rec(cursor); if(trx->duplicates) { /*If the SQL-query will update or replace duplicate key we will take X-lock for duplicates ( REPLACE, LOAD DATAFILE REPLACE, INSERT ON DUPLICATE KEY UPDATE).*/ err= row_ins_set_exclusive_rec_lock( LOCK_REC_NOT_GAP,btr_cur_get_block(cursor),rec, cursor->index, offsets, thr); else{ err= row_ins_set_shared_rec_lock(LOCK_REC_NOT_GAP, btr_cur_get_block(cursor), rec,cursor->index,offsets, thr); } row_ins_dupl_error_with_rec err =DB_DUPLICATE_KEY; }if (cursor->up_match >= n_unique) {//这个流程什么时候走?
对next-record加锁
}