insert流程加锁--辅助索引

    xiaoxiao2021-03-25  80

    row_ins_scan_sec_index_for_duplicate

    1、判断唯一索引是不是多列决定的,多列决定的话,一旦其中有一列为NULL,那么不做处理直接退出。

    n_unique =dict_index_get_n_unique(index); /*If the secondary index is unique, but one of the fields in the n_uniquefirst fields is NULL, a unique key violation cannot occur, sincewe define NULL != NULL in this case */ for(ulint i = 0; i < n_unique; i ) { if(UNIV_SQL_NULL == dfield_get_len(dtuple_get_nth_field(entry, i))) { return(DB_SUCCESS); } }

    2、循环扫描索引记录,检查是不是有重复值

       1、有重复值的话不管是哪个隔离级别,加的都是LOCK_ORDINARY即next-key锁。

       2、replace、loaddatafile replace、insert on duplicate key update。语句对当前记录加X类型next-key锁。

       3、其他类型insert,对当前插入的记录加S类型的next-key锁。

       4、加完锁后,才会判断是不是重复。如果重复,处理动作:

               1)匹配域数==n_unique

       

    转载请注明原文地址: https://ju.6miu.com/read-34507.html

    最新回复(0)