⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 row0purge.c

📁 这是linux下运行的mysql软件包,可用于linux 下安装 php + mysql + apach 的网络配置
💻 C
📖 第 1 页 / 共 2 页
字号:
	heap = mem_heap_create(1024);	while (node->index != NULL) {		index = node->index;		/* Build the index entry */		entry = row_build_index_entry(node->row, index, heap);		row_purge_remove_sec_if_poss(node, index, entry);		node->index = dict_table_get_next_index(node->index);	}	mem_heap_free(heap);		row_purge_remove_clust_if_poss(node);}	/***************************************************************Purges an update of an existing record. Also purges an update of a deletemarked record if that record contained an externally stored field. */staticvoidrow_purge_upd_exist_or_extern(/*==========================*/	purge_node_t*	node)	/* in: row purge node */{	mem_heap_t*	heap;	dtuple_t*	entry;	dict_index_t*	index;	upd_field_t*	ufield;	ibool		is_insert;	ulint		rseg_id;	ulint		page_no;	ulint		offset;	ulint		internal_offset;	byte*		data_field;	ulint		data_field_len;	ulint		i;	mtr_t		mtr;		ut_ad(node);	if (node->rec_type == TRX_UNDO_UPD_DEL_REC) {		goto skip_secondaries;	}	heap = mem_heap_create(1024);	while (node->index != NULL) {		index = node->index;		if (row_upd_changes_ord_field_binary(NULL, node->index,							node->update)) {			/* Build the older version of the index entry */			entry = row_build_index_entry(node->row, index, heap);			row_purge_remove_sec_if_poss(node, index, entry);		}		node->index = dict_table_get_next_index(node->index);	}	mem_heap_free(heap);	skip_secondaries:	/* Free possible externally stored fields */	for (i = 0; i < upd_get_n_fields(node->update); i++) {		ufield = upd_get_nth_field(node->update, i);		if (ufield->extern_storage) {			/* We use the fact that new_val points to			node->undo_rec and get thus the offset of			dfield data inside the unod record. Then we			can calculate from node->roll_ptr the file			address of the new_val data */			internal_offset = ((byte*)ufield->new_val.data)						- node->undo_rec;									ut_a(internal_offset < UNIV_PAGE_SIZE);			trx_undo_decode_roll_ptr(node->roll_ptr,						&is_insert, &rseg_id,						&page_no, &offset);			mtr_start(&mtr);			/* We have to acquire an X-latch to the clustered			index tree */			index = dict_table_get_first_index(node->table);			mtr_x_lock(dict_tree_get_lock(index->tree), &mtr);			/* NOTE: we must also acquire an X-latch to the			root page of the tree. We will need it when we			free pages from the tree. If the tree is of height 1,			the tree X-latch does NOT protect the root page,			because it is also a leaf page. Since we will have a			latch on an undo log page, we would break the			latching order if we would only later latch the			root page of such a tree! */						btr_root_get(index->tree, &mtr);			/* We assume in purge of externally stored fields			that the space id of the undo log record is 0! */			data_field = buf_page_get(0, page_no, RW_X_LATCH, &mtr)				     + offset + internal_offset;#ifdef UNIV_SYNC_DEBUG			buf_page_dbg_add_level(buf_frame_align(data_field),						SYNC_TRX_UNDO_PAGE);#endif /* UNIV_SYNC_DEBUG */				     			data_field_len = ufield->new_val.len;			btr_free_externally_stored_field(index, data_field,						data_field_len, FALSE, &mtr);			mtr_commit(&mtr);		}	}}/***************************************************************Parses the row reference and other info in a modify undo log record. */staticiboolrow_purge_parse_undo_rec(/*=====================*/				/* out: TRUE if purge operation required:				NOTE that then the CALLER must unfreeze				data dictionary! */	purge_node_t*	node,	/* in: row undo node */	ibool*		updated_extern,				/* out: TRUE if an externally stored field				was updated */	que_thr_t*	thr)	/* in: query thread */{	dict_index_t*	clust_index;	byte*		ptr;	trx_t*		trx;	dulint		undo_no;	dulint		table_id;	dulint		trx_id;	dulint		roll_ptr;	ulint		info_bits;	ulint		type;	ulint		cmpl_info;		ut_ad(node && thr);	trx = thr_get_trx(thr);		ptr = trx_undo_rec_get_pars(node->undo_rec, &type, &cmpl_info,					updated_extern, &undo_no, &table_id);	node->rec_type = type;	if (type == TRX_UNDO_UPD_DEL_REC && !(*updated_extern)) {		return(FALSE);	}	    			ptr = trx_undo_update_rec_get_sys_cols(ptr, &trx_id, &roll_ptr,								&info_bits);	node->table = NULL;	if (type == TRX_UNDO_UPD_EXIST_REC	    && cmpl_info & UPD_NODE_NO_ORD_CHANGE && !(*updated_extern)) {	    	/* Purge requires no changes to indexes: we may return */	    	return(FALSE);	}		/* Prevent DROP TABLE etc. from running when we are doing the purge	for this row */	row_mysql_freeze_data_dictionary(trx);	mutex_enter(&(dict_sys->mutex));	node->table = dict_table_get_on_id_low(table_id, trx);		mutex_exit(&(dict_sys->mutex));	if (node->table == NULL) {		/* The table has been dropped: no need to do purge */		row_mysql_unfreeze_data_dictionary(trx);		return(FALSE);	}	if (node->table->ibd_file_missing) {		/* We skip purge of missing .ibd files */		node->table = NULL;		row_mysql_unfreeze_data_dictionary(trx);		return(FALSE);	}	clust_index = dict_table_get_first_index(node->table);	if (clust_index == NULL) {		/* The table was corrupt in the data dictionary */		row_mysql_unfreeze_data_dictionary(trx);		return(FALSE);	}	ptr = trx_undo_rec_get_row_ref(ptr, clust_index, &(node->ref),								node->heap);	ptr = trx_undo_update_rec_get_update(ptr, clust_index, type, trx_id,					roll_ptr, info_bits, trx,					node->heap, &(node->update));	/* Read to the partial row the fields that occur in indexes */	if (!cmpl_info & UPD_NODE_NO_ORD_CHANGE) {		ptr = trx_undo_rec_get_partial_row(ptr, clust_index,						&(node->row), node->heap);	}		return(TRUE);}/***************************************************************Fetches an undo log record and does the purge for the recorded operation.If none left, or the current purge completed, returns the control to theparent node, which is always a query thread node. */staticulintrow_purge(/*======*/				/* out: DB_SUCCESS if operation successfully				completed, else error code */	purge_node_t*	node,	/* in: row purge node */	que_thr_t*	thr)	/* in: query thread */{	dulint	roll_ptr;	ibool	purge_needed;	ibool	updated_extern;	trx_t*	trx;		ut_ad(node && thr);	trx = thr_get_trx(thr);		node->undo_rec = trx_purge_fetch_next_rec(&roll_ptr,						&(node->reservation),						node->heap);	if (!node->undo_rec) {		/* Purge completed for this query thread */		thr->run_node = que_node_get_parent(node);		return(DB_SUCCESS);	}	node->roll_ptr = roll_ptr;	if (node->undo_rec == &trx_purge_dummy_rec) {		purge_needed = FALSE;	} else {		purge_needed = row_purge_parse_undo_rec(node, &updated_extern,									thr);		/* If purge_needed == TRUE, we must also remember to unfreeze		data dictionary! */	}	if (purge_needed) {		node->found_clust = FALSE;			node->index = dict_table_get_next_index(				dict_table_get_first_index(node->table));		if (node->rec_type == TRX_UNDO_DEL_MARK_REC) {			row_purge_del_mark(node);		} else if (updated_extern			    || node->rec_type == TRX_UNDO_UPD_EXIST_REC) {			row_purge_upd_exist_or_extern(node);		}		if (node->found_clust) {			btr_pcur_close(&(node->pcur));		}		row_mysql_unfreeze_data_dictionary(trx);	}	/* Do some cleanup */	trx_purge_rec_release(node->reservation);	mem_heap_empty(node->heap);		thr->run_node = node;	return(DB_SUCCESS);}/***************************************************************Does the purge operation for a single undo log record. This is a high-levelfunction used in an SQL execution graph. */que_thr_t*row_purge_step(/*===========*/				/* out: query thread to run next or NULL */	que_thr_t*	thr)	/* in: query thread */{	purge_node_t*	node;	ulint		err;	ut_ad(thr);		node = thr->run_node;	ut_ad(que_node_get_type(node) == QUE_NODE_PURGE);	err = row_purge(node, thr);	ut_ad(err == DB_SUCCESS);	return(thr);} 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -