/*********************************************************// 撤销对表的新行插入操作。新插入意味着在插入时,相同的聚簇索引唯一键没有任何记录,即使是删除标记。InnoDB在回滚时非常迅速:如果它发现索引记录在清理时将被删除,它将在回滚时将其删除。 @return DB_SUCCESS或DB_OUT_OF_FILE_SPACE*/ UNIV_INTERN ulint row_undo_ins( /=========/ undo_node_t* node) /*!< in: 行撤销节点 */ { ut_ad(node); ut_ad(node->state == UNDO_NODE_INSERT);

row_undo_ins_parse_undo_rec(node);

if (!node->table || !row_undo_search_clust_to_pcur(node)) {
	trx_undo_rec_release(node->trx, node->undo_no);

	return(DB_SUCCESS);
}

/* 遍历所有索引并撤销插入操作。*/

/* 跳过聚簇索引(第一个索引)*/
node->index = dict_table_get_next_index(
	dict_table_get_first_index(node->table));

while (node->index != NULL) {
	dtuple_t*	entry;
	ulint		err;

	entry = row_build_index_entry(node->row, node->ext,
				      node->index, node->heap);
	if (UNIV_UNLIKELY(!entry)) {
		/* 在插入聚簇索引记录后,但在写入该记录的所有外部存储列之前,数据库可能已崩溃。由于二级索引条目是在聚簇索引记录之后插入的,因此我们可以假定二级索引记录不存在。但是,这种情况只可能在回滚不完整的事务时发生。*/
		ut_a(trx_is_recv(node->trx));
	} else {
		log_free_check();
		err = row_undo_ins_remove_sec(node->index, entry);

		if (err != DB_SUCCESS) {

			return(err);
		}
	}

	node->index = dict_table_get_next_index(node->index);
}

log_free_check();
return(row_undo_ins_remove_clust_rec(node));
Undoes a fresh insert of a row to a table A fresh insert means thatthe same clustered index unique key did not have any record even deletemarked at the time of the insert InnoDB is eager in a rollbac

原文地址: http://www.cveoy.top/t/topic/fsXS 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录