📄 btr0cur.h
字号:
stays valid: it points to successor of deleted record on function exit */ ibool in_rollback,/* in: TRUE if called in rollback */ mtr_t* mtr); /* in: mtr *//***************************************************************Parses a redo log record of updating a record in-place. */byte*btr_cur_parse_update_in_place(/*==========================*/ /* out: end of log record or NULL */ byte* ptr, /* in: buffer */ byte* end_ptr,/* in: buffer end */ page_t* page, /* in: page or NULL */ dict_index_t* index); /* in: index corresponding to page *//********************************************************************Parses the redo log record for delete marking or unmarking of a clusteredindex record. */byte*btr_cur_parse_del_mark_set_clust_rec(/*=================================*/ /* out: end of log record or NULL */ byte* ptr, /* in: buffer */ byte* end_ptr,/* in: buffer end */ dict_index_t* index, /* in: index corresponding to page */ page_t* page); /* in: page or NULL *//********************************************************************Parses the redo log record for delete marking or unmarking of a secondaryindex record. */byte*btr_cur_parse_del_mark_set_sec_rec(/*===============================*/ /* out: end of log record or NULL */ byte* ptr, /* in: buffer */ byte* end_ptr,/* in: buffer end */ page_t* page); /* in: page or NULL *//***********************************************************************Estimates the number of rows in a given index range. */ib_longlongbtr_estimate_n_rows_in_range(/*=========================*/ /* out: estimated number of rows */ dict_index_t* index, /* in: index */ dtuple_t* tuple1, /* in: range start, may also be empty tuple */ ulint mode1, /* in: search mode for range start */ dtuple_t* tuple2, /* in: range end, may also be empty tuple */ ulint mode2); /* in: search mode for range end *//***********************************************************************Estimates the number of different key values in a given index, foreach n-column prefix of the index where n <= dict_index_get_n_unique(index).The estimates are stored in the array index->stat_n_diff_key_vals. */voidbtr_estimate_number_of_different_key_vals(/*======================================*/ dict_index_t* index); /* in: index *//***********************************************************************Marks not updated extern fields as not-owned by this record. The ownershipis transferred to the updated record which is inserted elsewhere in theindex tree. In purge only the owner of externally stored field is allowedto free the field. */voidbtr_cur_mark_extern_inherited_fields(/*=================================*/ rec_t* rec, /* in: record in a clustered index */ const ulint* offsets,/* in: array returned by rec_get_offsets() */ upd_t* update, /* in: update vector */ mtr_t* mtr); /* in: mtr *//***********************************************************************The complement of the previous function: in an update entry may inheritsome externally stored fields from a record. We must mark them as inheritedin entry, so that they are not freed in a rollback. */voidbtr_cur_mark_dtuple_inherited_extern(/*=================================*/ dtuple_t* entry, /* in: updated entry to be inserted to clustered index */ ulint* ext_vec, /* in: array of extern fields in the original record */ ulint n_ext_vec, /* in: number of elements in ext_vec */ upd_t* update); /* in: update vector *//***********************************************************************Marks all extern fields in a dtuple as owned by the record. */voidbtr_cur_unmark_dtuple_extern_fields(/*================================*/ dtuple_t* entry, /* in: clustered index entry */ ulint* ext_vec, /* in: array of numbers of fields which have been stored externally */ ulint n_ext_vec); /* in: number of elements in ext_vec *//***********************************************************************Stores the fields in big_rec_vec to the tablespace and puts pointers tothem in rec. The fields are stored on pages allocated from leaf nodefile segment of the index tree. */ulintbtr_store_big_rec_extern_fields(/*============================*/ /* out: DB_SUCCESS or error */ dict_index_t* index, /* in: index of rec; the index tree MUST be X-latched */ rec_t* rec, /* in: record */ const ulint* offsets, /* in: rec_get_offsets(rec, index); the "external storage" flags in offsets will not correspond to rec when this function returns */ big_rec_t* big_rec_vec, /* in: vector containing fields to be stored externally */ mtr_t* local_mtr); /* in: mtr containing the latch to rec and to the tree *//***********************************************************************Frees the space in an externally stored field to the file spacemanagement if the field in data is owned the externally stored field,in a rollback we may have the additional condition that the field mustnot be inherited. */voidbtr_free_externally_stored_field(/*=============================*/ dict_index_t* index, /* in: index of the data, the index tree MUST be X-latched; if the tree height is 1, then also the root page must be X-latched! (this is relevant in the case this function is called from purge where 'data' is located on an undo log page, not an index page) */ byte* data, /* in: internally stored data + reference to the externally stored part */ ulint local_len, /* in: length of data */ ibool do_not_free_inherited,/* in: TRUE if called in a rollback and we do not want to free inherited fields */ mtr_t* local_mtr); /* in: mtr containing the latch to data an an X-latch to the index tree *//***************************************************************Frees the externally stored fields for a record. */voidbtr_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: record */ const ulint* offsets,/* in: rec_get_offsets(rec, index) */ ibool do_not_free_inherited,/* in: TRUE if called in a rollback and we do not want to free inherited fields */ mtr_t* mtr); /* in: mini-transaction handle which contains an X-latch to record page and to the index tree *//***********************************************************************Copies an externally stored field of a record to mem heap. */byte*btr_rec_copy_externally_stored_field(/*=================================*/ /* out: the field copied to heap */ rec_t* rec, /* in: record */ const ulint* offsets,/* in: array returned by rec_get_offsets() */ ulint no, /* in: field number */ ulint* len, /* out: length of the field */ mem_heap_t* heap); /* in: mem heap *//***********************************************************************Copies an externally stored field of a record to mem heap. Parameterdata contains a pointer to 'internally' stored part of the field:possibly some data, and the reference to the externally stored part inthe last 20 bytes of data. */byte*btr_copy_externally_stored_field(/*=============================*/ /* out: the whole field copied to heap */ ulint* len, /* out: length of the whole field */ byte* data, /* in: 'internally' stored part of the field containing also the reference to the external part */ ulint local_len,/* in: length of data */ mem_heap_t* heap); /* in: mem heap *//***********************************************************************Stores the positions of the fields marked as extern storage in the updatevector, and also those fields who are marked as extern storage in recand not mentioned in updated fields. We use this function to rememberwhich fields we must mark as extern storage in a record inserted for anupdate. */ulintbtr_push_update_extern_fields(/*==========================*/ /* out: number of values stored in ext_vect */ ulint* ext_vect,/* in: array of ulints, must be preallocated to have space for all fields in rec */ const ulint* offsets,/* in: array returned by rec_get_offsets() */ upd_t* update);/* in: update vector or NULL */ /*######################################################################*//* In the pessimistic delete, if the page data size drops below thislimit, merging it to a neighbor is tried */#define BTR_CUR_PAGE_COMPRESS_LIMIT (UNIV_PAGE_SIZE / 2)/* A slot in the path array. We store here info on a search path down thetree. Each slot contains data on a single level of the tree. */typedef struct btr_path_struct btr_path_t;struct btr_path_struct{ ulint nth_rec; /* index of the record where the page cursor stopped on this level (index in alphabetical order); value ULINT_UNDEFINED denotes array end */ ulint n_recs; /* number of records on the page */};#define BTR_PATH_ARRAY_N_SLOTS 250 /* size of path array (in slots) *//* The tree cursor: the definition appears here only for the compilerto know struct size! */struct btr_cur_struct { dict_index_t* index; /* index where positioned */ page_cur_t page_cur; /* page cursor */ page_t* left_page; /* this field is used to store a pointer to the left neighbor page, in the cases BTR_SEARCH_PREV and BTR_MODIFY_PREV */ /*------------------------------*/ que_thr_t* thr; /* this field is only used when btr_cur_search_... is called for an index entry insertion: the calling query thread is passed here to be used in the insert buffer */ /*------------------------------*/ /* The following fields are used in btr_cur_search... to pass information: */ ulint flag; /* BTR_CUR_HASH, BTR_CUR_HASH_FAIL, BTR_CUR_BINARY, or BTR_CUR_INSERT_TO_IBUF */ ulint tree_height; /* Tree height if the search is done for a pessimistic insert or update operation */ ulint up_match; /* If the search mode was PAGE_CUR_LE, the number of matched fields to the the first user record to the right of the cursor record after btr_cur_search_...; for the mode PAGE_CUR_GE, the matched fields to the first user record AT THE CURSOR or to the right of it; NOTE that the up_match and low_match values may exceed the correct values for comparison to the adjacent user record if that record is on a different leaf page! (See the note in row_ins_duplicate_key.) */ ulint up_bytes; /* number of matched bytes to the right at the time cursor positioned; only used internally in searches: not defined after the search */ ulint low_match; /* if search mode was PAGE_CUR_LE, the number of matched fields to the first user record AT THE CURSOR or to the left of it after btr_cur_search_...; NOT defined for PAGE_CUR_GE or any other search modes; see also the NOTE in up_match! */ ulint low_bytes; /* number of matched bytes to the right at the time cursor positioned; only used internally in searches: not defined after the search */ ulint n_fields; /* prefix length used in a hash search if hash_node != NULL */ ulint n_bytes; /* hash prefix bytes if hash_node != NULL */ ulint fold; /* fold value used in the search if flag is BTR_CUR_HASH */ /*------------------------------*/ btr_path_t* path_arr; /* in estimating the number of rows in range, we store in this array information of the path through the tree */};/* Values for the flag documenting the used search method */#define BTR_CUR_HASH 1 /* successful shortcut using the hash index */#define BTR_CUR_HASH_FAIL 2 /* failure using hash, success using binary search: the misleading hash reference is stored in the field hash_node, and might be necessary to update */#define BTR_CUR_BINARY 3 /* success using the binary search */#define BTR_CUR_INSERT_TO_IBUF 4 /* performed the intended insert to the insert buffer *//* If pessimistic delete fails because of lack of file space,there is still a good change of success a little later: try this many times,and sleep this many microseconds in between */#define BTR_CUR_RETRY_DELETE_N_TIMES 100#define BTR_CUR_RETRY_SLEEP_TIME 50000/* The reference in a field for which data is stored on a different page.The reference is at the end of the 'locally' stored part of the field.'Locally' means storage in the index record.We store locally a long enough prefix of each column so that we can determinethe ordering parts of each index record without looking into the externallystored part. *//*--------------------------------------*/#define BTR_EXTERN_SPACE_ID 0 /* space id where stored */#define BTR_EXTERN_PAGE_NO 4 /* page no where stored */#define BTR_EXTERN_OFFSET 8 /* offset of BLOB header on that page */#define BTR_EXTERN_LEN 12 /* 8 bytes containing the length of the externally stored part of the BLOB. The 2 highest bits are reserved to the flags below. *//*--------------------------------------*/#define BTR_EXTERN_FIELD_REF_SIZE 20/* The highest bit of BTR_EXTERN_LEN (i.e., the highest bit of the byteat lowest address) is set to 1 if this field does not 'own' the externallystored field; only the owner field is allowed to free the field in purge!If the 2nd highest bit is 1 then it means that the externally stored fieldwas inherited from an earlier version of the row. In rollback we are notallowed to free an inherited external field. */#define BTR_EXTERN_OWNER_FLAG 128#define BTR_EXTERN_INHERITED_FLAG 64extern ulint btr_cur_n_non_sea;extern ulint btr_cur_n_sea;extern ulint btr_cur_n_non_sea_old;extern ulint btr_cur_n_sea_old;#ifndef UNIV_NONINL#include "btr0cur.ic"#endif #endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -