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

📄 row0row.c

📁 这是linux下运行的mysql软件包,可用于linux 下安装 php + mysql + apach 的网络配置
💻 C
📖 第 1 页 / 共 2 页
字号:
				at least s-latched and the latch held				as long as the row reference is used! */	mem_heap_t*	heap)	/* in: memory heap from which the memory				needed is allocated */{	dict_table_t*	table;	dict_index_t*	clust_index;	dfield_t*	dfield;	dtuple_t*	ref;	byte*		field;	ulint		len;	ulint		ref_len;	ulint		pos;	byte*		buf;	ulint		clust_col_prefix_len;	ulint		i;	mem_heap_t*	tmp_heap	= NULL;	ulint		offsets_[REC_OFFS_NORMAL_SIZE];	ulint*		offsets		= offsets_;	*offsets_ = (sizeof offsets_) / sizeof *offsets_;	ut_ad(index && rec && heap);	offsets = rec_get_offsets(rec, index, offsets,					ULINT_UNDEFINED, &tmp_heap);	if (type == ROW_COPY_DATA) {		/* Take a copy of rec to heap */		buf = mem_heap_alloc(heap, rec_offs_size(offsets));		rec = rec_copy(buf, rec, offsets);		/* Avoid a debug assertion in rec_offs_validate(). */		rec_offs_make_valid(rec, index, offsets);	}	table = index->table;		clust_index = dict_table_get_first_index(table);	ref_len = dict_index_get_n_unique(clust_index);	ref = dtuple_create(heap, ref_len);	dict_index_copy_types(ref, clust_index, ref_len);	for (i = 0; i < ref_len; i++) {		dfield = dtuple_get_nth_field(ref, i);		pos = dict_index_get_nth_field_pos(index, clust_index, i);		ut_a(pos != ULINT_UNDEFINED);			field = rec_get_nth_field(rec, offsets, pos, &len);		dfield_set_data(dfield, field, len);		/* If the primary key contains a column prefix, then the		secondary index may contain a longer prefix of the same		column, or the full column, and we must adjust the length		accordingly. */		clust_col_prefix_len =			dict_index_get_nth_field(clust_index, i)->prefix_len;		if (clust_col_prefix_len > 0) {		    	if (len != UNIV_SQL_NULL) {				dfield_set_len(dfield,				  dtype_get_at_most_n_mbchars(					dfield_get_type(dfield),					clust_col_prefix_len, len, (char*) field));			}		}	}	ut_ad(dtuple_check_typed(ref));	if (tmp_heap) {		mem_heap_free(tmp_heap);	}	return(ref);}/***********************************************************************Builds from a secondary index record a row reference with which we cansearch the clustered index record. */voidrow_build_row_ref_in_tuple(/*=======================*/	dtuple_t*	ref,	/* in/out: row reference built; see the				NOTE below! */	dict_index_t*	index,	/* in: index */	rec_t*		rec,	/* in: record in the index;				NOTE: the data fields in ref will point				directly into this record, therefore,				the buffer page of this record must be				at least s-latched and the latch held				as long as the row reference is used! */	trx_t*		trx)	/* in: transaction */{	dict_index_t*	clust_index;	dfield_t*	dfield;	byte*		field;	ulint		len;	ulint		ref_len;	ulint		pos;	ulint		clust_col_prefix_len;	ulint		i;	mem_heap_t*	heap		= NULL;	ulint		offsets_[REC_OFFS_NORMAL_SIZE];	ulint*		offsets		= offsets_;	*offsets_ = (sizeof offsets_) / sizeof *offsets_;	ut_a(ref && index && rec);		if (!index->table) {		fputs("InnoDB: table ", stderr);	notfound:		ut_print_name(stderr, trx, index->table_name);		fputs(" for index ", stderr);		ut_print_name(stderr, trx, index->name);		fputs(" not found\n", stderr);		ut_error;	}		clust_index = dict_table_get_first_index(index->table);		if (!clust_index) {		fputs("InnoDB: clust index for table ", stderr);		goto notfound;	}	offsets = rec_get_offsets(rec, index, offsets, ULINT_UNDEFINED, &heap);	ref_len = dict_index_get_n_unique(clust_index);	ut_ad(ref_len == dtuple_get_n_fields(ref));		dict_index_copy_types(ref, clust_index, ref_len);	for (i = 0; i < ref_len; i++) {		dfield = dtuple_get_nth_field(ref, i);		pos = dict_index_get_nth_field_pos(index, clust_index, i);		ut_a(pos != ULINT_UNDEFINED);		field = rec_get_nth_field(rec, offsets, pos, &len);		dfield_set_data(dfield, field, len);		/* If the primary key contains a column prefix, then the		secondary index may contain a longer prefix of the same		column, or the full column, and we must adjust the length		accordingly. */		clust_col_prefix_len =			dict_index_get_nth_field(clust_index, i)->prefix_len;		if (clust_col_prefix_len > 0) {		    	if (len != UNIV_SQL_NULL) {				dfield_set_len(dfield,				  dtype_get_at_most_n_mbchars(					dfield_get_type(dfield),					clust_col_prefix_len, len, (char*) field));			}		}	}	ut_ad(dtuple_check_typed(ref));	if (UNIV_LIKELY_NULL(heap)) {		mem_heap_free(heap);	}}/***********************************************************************From a row build a row reference with which we can search the clusteredindex record. */voidrow_build_row_ref_from_row(/*=======================*/	dtuple_t*	ref,	/* in/out: row reference built; see the				NOTE below! ref must have the right number				of fields! */	dict_table_t*	table,	/* in: table */	dtuple_t*	row)	/* in: row				NOTE: the data fields in ref will point				directly into data of this row */{	dict_index_t*	clust_index;	dict_field_t*	field;	dfield_t*	dfield;	dfield_t*	dfield2;	dict_col_t*	col;	ulint		ref_len;	ulint		i;	dtype_t*	cur_type;		ut_ad(ref && table && row);			clust_index = dict_table_get_first_index(table);	ref_len = dict_index_get_n_unique(clust_index);	ut_ad(ref_len == dtuple_get_n_fields(ref));		for (i = 0; i < ref_len; i++) {		dfield = dtuple_get_nth_field(ref, i);				field = dict_index_get_nth_field(clust_index, i);				col = dict_field_get_col(field);						dfield2 = dtuple_get_nth_field(row, dict_col_get_no(col));		dfield_copy(dfield, dfield2);		if (field->prefix_len > 0		    && dfield->len != UNIV_SQL_NULL) {			cur_type = dict_col_get_type(				dict_field_get_col(field));			dfield->len = dtype_get_at_most_n_mbchars(				cur_type,				field->prefix_len,				dfield->len, dfield->data);		}	}	ut_ad(dtuple_check_typed(ref));}/*******************************************************************Searches the clustered index record for a row, if we have the row reference. */iboolrow_search_on_row_ref(/*==================*/				/* out: TRUE if found */	btr_pcur_t*	pcur,	/* in/out: persistent cursor, which must				be closed by the caller */	ulint		mode,	/* in: BTR_MODIFY_LEAF, ... */	dict_table_t*	table,	/* in: table */	dtuple_t*	ref,	/* in: row reference */	mtr_t*		mtr)	/* in: mtr */{	ulint		low_match;		rec_t*		rec;	dict_index_t*	index;	ut_ad(dtuple_check_typed(ref));	index = dict_table_get_first_index(table);	ut_a(dtuple_get_n_fields(ref) == dict_index_get_n_unique(index));	btr_pcur_open(index, ref, PAGE_CUR_LE, mode, pcur, mtr);		low_match = btr_pcur_get_low_match(pcur);	rec = btr_pcur_get_rec(pcur);	if (page_rec_is_infimum(rec)) {		return(FALSE);	}	if (low_match != dtuple_get_n_fields(ref)) {		return(FALSE);	}	return(TRUE);}/*************************************************************************Fetches the clustered index record for a secondary index record. The latcheson the secondary index record are preserved. */rec_t*row_get_clust_rec(/*==============*/				/* out: record or NULL, if no record found */	ulint		mode,	/* in: BTR_MODIFY_LEAF, ... */	rec_t*		rec,	/* in: record in a secondary index */	dict_index_t*	index,	/* in: secondary index */	dict_index_t**	clust_index,/* out: clustered index */	mtr_t*		mtr)	/* in: mtr */{	mem_heap_t*	heap;	dtuple_t*	ref;	dict_table_t*	table;	btr_pcur_t	pcur;	ibool		found;	rec_t*		clust_rec;		ut_ad((index->type & DICT_CLUSTERED) == 0);	table = index->table;	heap = mem_heap_create(256);	ref = row_build_row_ref(ROW_COPY_POINTERS, index, rec, heap);	found = row_search_on_row_ref(&pcur, mode, table, ref, mtr);	clust_rec = found ? btr_pcur_get_rec(&pcur) : NULL;	mem_heap_free(heap);	btr_pcur_close(&pcur);	*clust_index = dict_table_get_first_index(table);	return(clust_rec);}/*******************************************************************Searches an index record. */iboolrow_search_index_entry(/*===================*/				/* out: TRUE if found */	dict_index_t*	index,	/* in: index */	dtuple_t*	entry,	/* in: index entry */	ulint		mode,	/* in: BTR_MODIFY_LEAF, ... */	btr_pcur_t*	pcur,	/* in/out: persistent cursor, which must				be closed by the caller */	mtr_t*		mtr)	/* in: mtr */{	ulint	n_fields;	ulint	low_match;	rec_t*	rec;	ut_ad(dtuple_check_typed(entry));		btr_pcur_open(index, entry, PAGE_CUR_LE, mode, pcur, mtr);	low_match = btr_pcur_get_low_match(pcur);	rec = btr_pcur_get_rec(pcur);	n_fields = dtuple_get_n_fields(entry);	if (page_rec_is_infimum(rec)) {		return(FALSE);	}	if (low_match != n_fields) {		/* Not found */		return(FALSE);	}	return(TRUE);}

⌨️ 快捷键说明

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