该函数用于释放记录中存储的外部存储字段。它遍历记录中的每个字段,如果发现该字段是外部存储字段,则通过调用 btr_free_externally_stored_field() 函数来释放该字段。

该函数的参数解释如下:

  • index:数据所在的索引,必须是 X-latch 状态;
  • rec:记录;
  • offsets:通过 rec_get_offsets() 函数获取的记录中每个字段的偏移量数组;
  • page_zip:压缩页面,或 NULL;
  • rb_ctx:回滚上下文;
  • mtr:mini-transaction handle,其中包含对记录页面和索引树的 X-latch。

该函数首先验证了传入的参数是否正确,然后遍历记录中的每个字段。对于每个字段,它检查是否是外部存储字段,如果是,则调用 btr_free_externally_stored_field() 函数来释放该字段。最后,它返回。

/* 释放记录中存储的外部存储字段。 */
static
void
btr_rec_free_externally_stored_fields(
/*==================================*/
	dict_index_t*	index,	/*!< in: index of the data, the index
			tree MUST be X-latched */
	rec_t*		rec,	/*!< in/out: record */
	const ulint*	offsets,/*!< in: rec_get_offsets(rec, index) */
	page_zip_des_t*	page_zip,/*!< in: compressed page whose uncompressed
			part will be updated, or NULL */
	enum trx_rb_ctx	rb_ctx,	/*!< in: rollback context */
	mtr_t*		mtr)	/*!< in: mini-transaction handle which contains
			an X-latch to record page and to the index
			tree */
{
	ulint	n_fields;
	ulint	i;

	ut_ad(rec_offs_validate(rec, index, offsets));
	ut_ad(mtr_memo_contains_page(mtr, rec, MTR_MEMO_PAGE_X_FIX));
	/* Free possible externally stored fields in the record */

	ut_ad(dict_table_is_comp(index->table) == !!rec_offs_comp(offsets));
	n_fields = rec_offs_n_fields(offsets);

	for (i = 0; i < n_fields; i++) {
		if (rec_offs_nth_extern(offsets, i)) {
			btr_free_externally_stored_field(
				index, btr_rec_get_field_ref(rec, offsets, i),
				rec, offsets, page_zip, i, rb_ctx, mtr);
		}
	}
}
释放记录中外部存储字段的函数

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

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