MySQL 9.1.0
Source Code Documentation
|
The index tree cursor. More...
#include <stddef.h>
#include <sys/types.h>
#include "btr0types.h"
#include "dict0dict.h"
#include "gis0type.h"
#include "page0cur.h"
#include "univ.i"
#include "ha0ha.h"
#include "que0types.h"
#include "row0types.h"
#include "btr0cur.ic"
Go to the source code of this file.
Classes | |
struct | btr_latch_leaves_t |
struct | btr_path_t |
A slot in the path array. More... | |
struct | btr_cur_t |
The tree cursor: the definition appears here only for the compiler to know struct size! More... | |
Macros | |
#define | BTR_CUR_PAGE_COMPRESS_LIMIT(index) ((UNIV_PAGE_SIZE * (ulint)((index)->merge_threshold)) / 100) |
In the pessimistic delete, if the page data size drops below this limit, merging it to a neighbor is tried. More... | |
Enumerations | |
enum | { BTR_NO_UNDO_LOG_FLAG = 1 , BTR_NO_LOCKING_FLAG = 2 , BTR_KEEP_SYS_FLAG = 4 , BTR_KEEP_POS_FLAG = 8 , BTR_CREATE_FLAG = 16 , BTR_KEEP_IBUF_BITMAP = 32 } |
Mode flags for btr_cur operations; these can be ORed. More... | |
enum | btr_cur_method { BTR_CUR_UNSET = 0 , BTR_CUR_HASH = 1 , BTR_CUR_HASH_NOT_ATTEMPTED , BTR_CUR_HASH_FAIL , BTR_CUR_BINARY , BTR_CUR_INSERT_TO_IBUF , BTR_CUR_DEL_MARK_IBUF , BTR_CUR_DELETE_IBUF , BTR_CUR_DELETE_REF } |
Values for the flag documenting the used search method. More... | |
Functions | |
static page_cur_t * | btr_cur_get_page_cur (const btr_cur_t *cursor) |
Returns the page cursor component of a tree cursor. More... | |
static buf_block_t * | btr_cur_get_block (const btr_cur_t *cursor) |
Returns the buffer block on which the tree cursor is positioned. More... | |
static rec_t * | btr_cur_get_rec (const btr_cur_t *cursor) |
Returns the record pointer of a tree cursor. More... | |
static page_zip_des_t * | btr_cur_get_page_zip (btr_cur_t *cursor) |
Returns the compressed page on which the tree cursor is positioned. More... | |
static page_t * | btr_cur_get_page (btr_cur_t *cursor) |
Returns the page of a tree cursor. More... | |
static void | btr_cur_position (dict_index_t *index, rec_t *rec, buf_block_t *block, btr_cur_t *cursor) |
Positions a tree cursor at a given record. More... | |
bool | btr_cur_optimistic_latch_leaves (buf_block_t *block, uint64_t modify_clock, ulint *latch_mode, btr_cur_t *cursor, const char *file, ulint line, mtr_t *mtr) |
Optimistically latches the leaf page or pages requested. More... | |
void | btr_cur_search_to_nth_level (dict_index_t *index, ulint level, const dtuple_t *tuple, page_cur_mode_t mode, ulint latch_mode, btr_cur_t *cursor, ulint has_search_latch, const char *file, ulint line, mtr_t *mtr) |
Searches an index tree and positions a tree cursor on a given level. More... | |
void | btr_cur_search_to_nth_level_with_no_latch (dict_index_t *index, ulint level, const dtuple_t *tuple, page_cur_mode_t mode, btr_cur_t *cursor, const char *file, ulint line, mtr_t *mtr, bool mark_dirty=true) |
Searches an index tree and positions a tree cursor on a given level. More... | |
void | btr_cur_open_at_index_side (bool from_left, dict_index_t *index, ulint latch_mode, btr_cur_t *cursor, ulint level, ut::Location location, mtr_t *mtr) |
Opens a cursor at either end of an index. More... | |
void | btr_cur_open_at_index_side_with_no_latch (bool from_left, dict_index_t *index, btr_cur_t *cursor, ulint level, ut::Location location, mtr_t *mtr) |
Opens a cursor at either end of an index. More... | |
bool | btr_cur_open_at_rnd_pos (dict_index_t *index, ulint latch_mode, btr_cur_t *cursor, const char *file, ulint line, mtr_t *mtr) |
Positions a cursor at a randomly chosen position within a B-tree. More... | |
dberr_t | btr_cur_optimistic_insert (ulint flags, btr_cur_t *cursor, ulint **offsets, mem_heap_t **heap, dtuple_t *entry, rec_t **rec, big_rec_t **big_rec, que_thr_t *thr, mtr_t *mtr) |
Tries to perform an insert to a page in an index tree, next to cursor. More... | |
dberr_t | btr_cur_pessimistic_insert (uint32_t flags, btr_cur_t *cursor, ulint **offsets, mem_heap_t **heap, dtuple_t *entry, rec_t **rec, big_rec_t **big_rec, que_thr_t *thr, mtr_t *mtr) |
Performs an insert on a page of an index tree. More... | |
bool | btr_cur_update_alloc_zip_func (page_zip_des_t *page_zip, page_cur_t *cursor, dict_index_t *index, ulint *offsets, ulint length, bool create, mtr_t *mtr) |
See if there is enough place in the page modification log to log an update-in-place. More... | |
bool | btr_cur_update_alloc_zip (page_zip_des_t *page_zip, page_cur_t *cursor, dict_index_t *index, ulint *offsets, ulint len, bool cr, mtr_t *mtr) |
dberr_t | btr_cur_update_in_place (ulint flags, btr_cur_t *cursor, ulint *offsets, const upd_t *update, ulint cmpl_info, que_thr_t *thr, trx_id_t trx_id, mtr_t *mtr) |
Updates a record when the update causes no size changes in its fields. More... | |
void | btr_cur_update_in_place_log (ulint flags, const rec_t *rec, dict_index_t *index, const upd_t *update, trx_id_t trx_id, roll_ptr_t roll_ptr, mtr_t *mtr) |
Writes a redo log record of updating a record in-place. More... | |
dberr_t | btr_cur_optimistic_update (ulint flags, btr_cur_t *cursor, ulint **offsets, mem_heap_t **heap, const upd_t *update, ulint cmpl_info, que_thr_t *thr, trx_id_t trx_id, mtr_t *mtr) |
Tries to update a record on a page in an index tree. More... | |
dberr_t | btr_cur_pessimistic_update (ulint flags, btr_cur_t *cursor, ulint **offsets, mem_heap_t **offsets_heap, mem_heap_t *entry_heap, big_rec_t **big_rec, upd_t *update, ulint cmpl_info, que_thr_t *thr, trx_id_t trx_id, undo_no_t undo_no, mtr_t *mtr, btr_pcur_t *pcur=nullptr) |
Performs an update of a record on a page of a tree. More... | |
dberr_t | btr_cur_del_mark_set_clust_rec (ulint flags, buf_block_t *block, rec_t *rec, dict_index_t *index, const ulint *offsets, que_thr_t *thr, const dtuple_t *entry, mtr_t *mtr) |
Marks a clustered index record deleted. More... | |
dberr_t | btr_cur_del_mark_set_sec_rec (ulint flags, btr_cur_t *cursor, bool val, que_thr_t *thr, mtr_t *mtr) |
Sets a secondary index record delete mark to true or false. More... | |
bool | btr_cur_compress_if_useful (btr_cur_t *cursor, bool adjust, mtr_t *mtr) |
Tries to compress a page of the tree if it seems useful. More... | |
bool | btr_cur_optimistic_delete_func (btr_cur_t *cursor, ulint flags, mtr_t *mtr) |
bool | btr_cur_optimistic_delete (btr_cur_t *cursor, ulint flags, mtr_t *mtr) |
Removes the record on which the tree cursor is positioned on a leaf page. More... | |
bool | btr_cur_pessimistic_delete (dberr_t *err, bool has_reserved_extents, btr_cur_t *cursor, uint32_t flags, bool rollback, trx_id_t trx_id, undo_no_t undo_no, ulint rec_type, mtr_t *mtr, btr_pcur_t *pcur, purge_node_t *node) |
Removes the record on which the tree cursor is positioned. More... | |
const byte * | btr_cur_parse_update_in_place (const byte *ptr, const byte *end_ptr, page_t *page, page_zip_des_t *page_zip, dict_index_t *index) |
Parses a redo log record of updating a record in-place. More... | |
const byte * | btr_cur_parse_del_mark_set_clust_rec (const byte *ptr, const byte *end_ptr, page_t *page, page_zip_des_t *page_zip, dict_index_t *index) |
Parses the redo log record for delete marking or unmarking of a clustered index record. More... | |
const byte * | btr_cur_parse_del_mark_set_sec_rec (const byte *ptr, const byte *end_ptr, page_t *page, page_zip_des_t *page_zip) |
Parses the redo log record for delete marking or unmarking of a secondary index record. More... | |
int64_t | btr_estimate_n_rows_in_range (dict_index_t *index, const dtuple_t *tuple1, page_cur_mode_t mode1, const dtuple_t *tuple2, page_cur_mode_t mode2) |
Estimates the number of rows in a given index range. More... | |
bool | btr_estimate_number_of_different_key_vals (dict_index_t *index) |
Estimates the number of different key values in a given index, for each n-column prefix of the index where 1 <= n <= dict_index_get_n_unique(index). More... | |
byte * | btr_rec_copy_externally_stored_field_func (trx_t *trx, dict_index_t *index, const rec_t *rec, const ulint *offsets, const page_size_t &page_size, ulint no, ulint *len, size_t *lob_version, bool is_sdi, mem_heap_t *heap) |
Copies an externally stored field of a record to mem heap. More... | |
void | btr_cur_set_deleted_flag_for_ibuf (rec_t *rec, page_zip_des_t *page_zip, bool val, mtr_t *mtr) |
Sets a secondary index record's delete mark to the given value. More... | |
static void | btr_rec_set_deleted_flag (rec_t *rec, page_zip_des_t *page_zip, bool flag) |
The following function is used to set the deleted bit of a record. More... | |
btr_latch_leaves_t | btr_cur_latch_leaves (buf_block_t *block, const page_id_t &page_id, const page_size_t &page_size, ulint latch_mode, btr_cur_t *cursor, mtr_t *mtr) |
Latches the leaf page or pages requested. More... | |
bool | materialize_instant_default (const dict_index_t *index, const rec_t *rec) |
If default value of INSTANT ADD column is to be materialize in updated row. More... | |
Variables | |
constexpr uint32_t | BTR_PATH_ARRAY_N_SLOTS = 250 |
size of path array (in slots) More... | |
constexpr uint32_t | BTR_CUR_RETRY_DELETE_N_TIMES = 100 |
If pessimistic delete fails because of lack of file space, there is still a good change of success a little later. More... | |
constexpr uint32_t | BTR_CUR_RETRY_SLEEP_TIME_MS = 50 |
If pessimistic delete fails because of lack of file space, there is still a good change of success a little later. More... | |
ulint | btr_cur_n_non_sea |
Number of searches down the B-tree in btr_cur_search_to_nth_level(). More... | |
ulint | btr_cur_n_sea |
Number of successful adaptive hash index lookups in btr_cur_search_to_nth_level(). More... | |
ulint | btr_cur_n_non_sea_old |
Old value of btr_cur_n_non_sea. More... | |
ulint | btr_cur_n_sea_old |
Old value of btr_cur_n_sea. More... | |
uint | btr_cur_limit_optimistic_insert_debug |
The index tree cursor.
Created 10/16/1994 Heikki Tuuri
#define BTR_CUR_PAGE_COMPRESS_LIMIT | ( | index | ) | ((UNIV_PAGE_SIZE * (ulint)((index)->merge_threshold)) / 100) |
In the pessimistic delete, if the page data size drops below this limit, merging it to a neighbor is tried.
anonymous enum |
Mode flags for btr_cur operations; these can be ORed.
enum btr_cur_method |
Values for the flag documenting the used search method.
Tries to compress a page of the tree if it seems useful.
It is assumed that mtr holds an x-latch on the tree and on the cursor page. To avoid deadlocks, mtr must also own x-latches to brothers of page, if those brothers exist. NOTE: it is assumed that the caller has reserved enough free extents so that the compression will always succeed if done!
It is assumed that mtr holds an x-latch on the tree and on the cursor page. To avoid deadlocks, mtr must also own x-latches to brothers of page, if those brothers exist. NOTE: it is assumed that the caller has reserved enough free extents so that the compression will always succeed if done!
cursor | in/out: cursor on the page to compress; cursor does not stay valid if !adjust and compression occurs |
adjust | in: true if should adjust the cursor position even if compression occurs |
mtr | in/out: mini-transaction |
dberr_t btr_cur_del_mark_set_clust_rec | ( | ulint | flags, |
buf_block_t * | block, | ||
rec_t * | rec, | ||
dict_index_t * | index, | ||
const ulint * | offsets, | ||
que_thr_t * | thr, | ||
const dtuple_t * | entry, | ||
mtr_t * | mtr | ||
) |
Marks a clustered index record deleted.
Writes an undo log record to undo log on this delete marking. Writes in the trx id field the id of the deleting transaction, and in the roll ptr field pointer to the undo log record created.
Writes an undo log record to undo log on this delete marking. Writes in the trx id field the id of the deleting transaction, and in the roll ptr field pointer to the undo log record created.
flags | in: undo logging and locking flags |
block | in/out: buffer block of the record |
rec | in/out: record |
index | in: clustered index of the record |
offsets | in: rec_get_offsets(rec) |
thr | in: query thread |
entry | in: dtuple for the deleting record, also contains the virtual cols if there are any |
mtr | in/out: mini-transaction |
dberr_t btr_cur_del_mark_set_sec_rec | ( | ulint | flags, |
btr_cur_t * | cursor, | ||
bool | val, | ||
que_thr_t * | thr, | ||
mtr_t * | mtr | ||
) |
Sets a secondary index record delete mark to true or false.
flags | in: locking flag |
cursor | in: cursor |
val | in: value to set |
thr | in: query thread |
mtr | in/out: mini-transaction |
|
inlinestatic |
Returns the buffer block on which the tree cursor is positioned.
Returns the page of a tree cursor.
|
inlinestatic |
Returns the page cursor component of a tree cursor.
|
inlinestatic |
Returns the compressed page on which the tree cursor is positioned.
Returns the record pointer of a tree cursor.
btr_latch_leaves_t btr_cur_latch_leaves | ( | buf_block_t * | block, |
const page_id_t & | page_id, | ||
const page_size_t & | page_size, | ||
ulint | latch_mode, | ||
btr_cur_t * | cursor, | ||
mtr_t * | mtr | ||
) |
Latches the leaf page or pages requested.
[in] | block | Leaf page where the search converged |
[in] | page_id | Page id of the leaf |
[in] | page_size | Page size |
[in] | latch_mode | BTR_SEARCH_LEAF, ... |
[in] | cursor | Cursor |
[in] | mtr | Mini-transaction |
void btr_cur_open_at_index_side | ( | bool | from_left, |
dict_index_t * | index, | ||
ulint | latch_mode, | ||
btr_cur_t * | cursor, | ||
ulint | level, | ||
ut::Location | location, | ||
mtr_t * | mtr | ||
) |
Opens a cursor at either end of an index.
[in] | from_left | True if open to the low end, false if to the high end |
[in] | index | Index |
[in] | latch_mode | Latch mode |
[in,out] | cursor | Cursor |
[in] | level | Level to search for (0=leaf) |
[in] | location | Location where called |
[in,out] | mtr | Mini-transaction |
void btr_cur_open_at_index_side_with_no_latch | ( | bool | from_left, |
dict_index_t * | index, | ||
btr_cur_t * | cursor, | ||
ulint | level, | ||
ut::Location | location, | ||
mtr_t * | mtr | ||
) |
Opens a cursor at either end of an index.
Avoid taking latches on buffer, just pin (by incrementing fix_count) to keep them in buffer pool. This mode is used by intrinsic table as they are not shared and so there is no need of latching.
[in] | from_left | true if open to low end, false if open to high end. |
[in] | index | Index |
[in,out] | cursor | Cursor |
[in] | level | Level to search for (0=leaf) |
[in] | location | Location where called |
[in,out] | mtr | Mini-transaction |
bool btr_cur_open_at_rnd_pos | ( | dict_index_t * | index, |
ulint | latch_mode, | ||
btr_cur_t * | cursor, | ||
const char * | file, | ||
ulint | line, | ||
mtr_t * | mtr | ||
) |
Positions a cursor at a randomly chosen position within a B-tree.
index | in: index |
latch_mode | in: BTR_SEARCH_LEAF, ... |
cursor | in/out: B-tree cursor |
file | in: file name |
line | in: line where called |
mtr | in: mtr |
Removes the record on which the tree cursor is positioned on a leaf page.
It is assumed that the mtr has an x-latch on the page where the cursor is positioned, but no latch on the whole tree.
[in] | cursor | cursor on leaf page, on the record to delete; cursor stays valid: if deletion succeeds, on function exit it points to the successor of the deleted record |
[in] | flags | BTR_CREATE_FLAG or 0 |
[in] | mtr | if this function returns true on a leaf page of a secondary index, the mtr must be committed before latching any further pages |
dberr_t btr_cur_optimistic_insert | ( | ulint | flags, |
btr_cur_t * | cursor, | ||
ulint ** | offsets, | ||
mem_heap_t ** | heap, | ||
dtuple_t * | entry, | ||
rec_t ** | rec, | ||
big_rec_t ** | big_rec, | ||
que_thr_t * | thr, | ||
mtr_t * | mtr | ||
) |
Tries to perform an insert to a page in an index tree, next to cursor.
It is assumed that mtr holds an x-latch on the page. The operation does not succeed if there is too little space on the page. If there is just one record on the page, the insert will always succeed; this is to prevent trying to split a page with just one record.
It is assumed that mtr holds an x-latch on the page. The operation does not succeed if there is too little space on the page. If there is just one record on the page, the insert will always succeed; this is to prevent trying to split a page with just one record.
flags | in: undo logging and locking flags: if not zero, the parameters index and thr should be specified |
cursor | in: cursor on page after which to insert; cursor stays valid |
offsets | out: offsets on *rec |
heap | in/out: pointer to memory heap, or NULL |
entry | in/out: entry to insert |
rec | out: pointer to inserted record if succeed |
big_rec | out: big rec vector whose fields have to be stored externally by the caller, or NULL |
thr | in: query thread or NULL |
mtr | in/out: mini-transaction; if this function returns DB_SUCCESS on a leaf page of a secondary index in a compressed tablespace, the caller must mtr_commit(mtr) before latching any further pages |
bool btr_cur_optimistic_latch_leaves | ( | buf_block_t * | block, |
uint64_t | modify_clock, | ||
ulint * | latch_mode, | ||
btr_cur_t * | cursor, | ||
const char * | file, | ||
ulint | line, | ||
mtr_t * | mtr | ||
) |
Optimistically latches the leaf page or pages requested.
[in] | block | Guessed buffer block |
[in] | modify_clock | Modify clock value |
[in,out] | latch_mode | BTR_SEARCH_LEAF, ... |
[in,out] | cursor | Cursor |
[in] | file | File name |
[in] | line | Line where called |
[in] | mtr | Mini-transaction |
dberr_t btr_cur_optimistic_update | ( | ulint | flags, |
btr_cur_t * | cursor, | ||
ulint ** | offsets, | ||
mem_heap_t ** | heap, | ||
const upd_t * | update, | ||
ulint | cmpl_info, | ||
que_thr_t * | thr, | ||
trx_id_t | trx_id, | ||
mtr_t * | mtr | ||
) |
Tries to update a record on a page in an index tree.
It is assumed that mtr holds an x-latch on the page. The operation does not succeed if there is too little space on the page or if the update would result in too empty a page, so that tree compression is recommended. We assume here that the ordering fields of the record do not change.
[in] | flags | undo logging and locking flags |
[in] | cursor | cursor on the record to update; cursor stays valid and positioned on the same record |
[out] | offsets | offsets on cursor->page_cur.rec |
[in,out] | heap | pointer to nullptr or memory heap |
[in] | update | update vector; this must also contain trx id and roll ptr fields |
[in] | cmpl_info | compiler info on secondary index updates |
[in] | thr | query thread, or nullptr if flags & (BTR_NO_UNDO_LOG_FLAG | BTR_NO_LOCKING_FLAG | BTR_CREATE_FLAG | BTR_KEEP_SYS_FLAG) |
[in] | trx_id | transaction id |
[in,out] | mtr | mini-transaction; if this is a secondary index, the caller must mtr_commit(mtr) before latching any further pages |
DB_SUCCESS | on success |
DB_OVERFLOW | if the updated record does not fit |
DB_UNDERFLOW | if the page would become too empty |
DB_ZIP_OVERFLOW | if there is not enough space left on the compressed page (IBUF_BITMAP_FREE was reset outside mtr) |
const byte * btr_cur_parse_del_mark_set_clust_rec | ( | const byte * | ptr, |
const byte * | end_ptr, | ||
page_t * | page, | ||
page_zip_des_t * | page_zip, | ||
dict_index_t * | index | ||
) |
Parses the redo log record for delete marking or unmarking of a clustered index record.
ptr | in: buffer |
end_ptr | in: buffer end |
page | in/out: page or NULL |
page_zip | in/out: compressed page, or NULL |
index | in: index corresponding to page |
const byte * btr_cur_parse_del_mark_set_sec_rec | ( | const byte * | ptr, |
const byte * | end_ptr, | ||
page_t * | page, | ||
page_zip_des_t * | page_zip | ||
) |
Parses the redo log record for delete marking or unmarking of a secondary index record.
ptr | in: buffer |
end_ptr | in: buffer end |
page | in/out: page or NULL |
page_zip | in/out: compressed page, or NULL |
const byte * btr_cur_parse_update_in_place | ( | const byte * | ptr, |
const byte * | end_ptr, | ||
page_t * | page, | ||
page_zip_des_t * | page_zip, | ||
dict_index_t * | index | ||
) |
Parses a redo log record of updating a record in-place.
ptr | in: buffer |
end_ptr | in: buffer end |
page | in/out: page or NULL |
page_zip | in/out: compressed page, or NULL |
index | in: index corresponding to page |
bool btr_cur_pessimistic_delete | ( | dberr_t * | err, |
bool | has_reserved_extents, | ||
btr_cur_t * | cursor, | ||
uint32_t | flags, | ||
bool | rollback, | ||
trx_id_t | trx_id, | ||
undo_no_t | undo_no, | ||
ulint | rec_type, | ||
mtr_t * | mtr, | ||
btr_pcur_t * | pcur, | ||
purge_node_t * | node | ||
) |
Removes the record on which the tree cursor is positioned.
Tries to compress the page if its fillfactor drops below a threshold or if it is the only page on the level. It is assumed that mtr holds an x-latch on the tree and on the cursor page. To avoid deadlocks, mtr must also own x-latches to brothers of page, if those brothers exist.
[out] | err | DB_SUCCESS or DB_OUT_OF_FILE_SPACE; the latter may occur because we may have to update node pointers on upper levels, and in the case of variable length keys these may actually grow in size |
[in] | has_reserved_extents | true if the caller has already reserved enough free extents so that he knows that the operation will succeed |
[in] | cursor | Cursor on the record to delete; if compression does not occur, the cursor stays valid: it points to successor of deleted record on function exit |
[in] | flags | BTR_CREATE_FLAG or 0 |
[in] | rollback | True if performing rollback, false otherwise. |
[in] | trx_id | The current transaction id. |
[in] | undo_no | Undo number of the transaction. This is needed for rollback to savepoint of partially updated LOB. |
[in] | rec_type | Undo record type. |
[in] | mtr | The mini transaction |
[in] | pcur | Persistent cursor on the record to delete. |
[in,out] | node | purge node or nullptr |
dberr_t btr_cur_pessimistic_insert | ( | uint32_t | flags, |
btr_cur_t * | cursor, | ||
ulint ** | offsets, | ||
mem_heap_t ** | heap, | ||
dtuple_t * | entry, | ||
rec_t ** | rec, | ||
big_rec_t ** | big_rec, | ||
que_thr_t * | thr, | ||
mtr_t * | mtr | ||
) |
Performs an insert on a page of an index tree.
It is assumed that mtr holds an x-latch on the tree and on the cursor page. If the insert is made on the leaf level, to avoid deadlocks, mtr must also own x-latches to brothers of page, if those brothers exist.
It is assumed that mtr holds an x-latch on the tree and on the cursor page. If the insert is made on the leaf level, to avoid deadlocks, mtr must also own x-latches to brothers of page, if those brothers exist.
flags | in: undo logging and locking flags: if not zero, the parameter thr should be specified; if no undo logging is specified, then the caller must have reserved enough free extents in the file space so that the insertion will certainly succeed |
cursor | in: cursor after which to insert; cursor stays valid |
offsets | out: offsets on *rec |
heap | in/out: pointer to memory heap that can be emptied, or NULL |
entry | in/out: entry to insert |
rec | out: pointer to inserted record if succeed |
big_rec | out: big rec vector whose fields have to be stored externally by the caller, or NULL |
thr | in: query thread or NULL |
mtr | in/out: mini-transaction |
dberr_t btr_cur_pessimistic_update | ( | ulint | flags, |
btr_cur_t * | cursor, | ||
ulint ** | offsets, | ||
mem_heap_t ** | offsets_heap, | ||
mem_heap_t * | entry_heap, | ||
big_rec_t ** | big_rec, | ||
upd_t * | update, | ||
ulint | cmpl_info, | ||
que_thr_t * | thr, | ||
trx_id_t | trx_id, | ||
undo_no_t | undo_no, | ||
mtr_t * | mtr, | ||
btr_pcur_t * | pcur = nullptr |
||
) |
Performs an update of a record on a page of a tree.
It is assumed that mtr holds an x-latch on the tree and on the cursor page. If the update is made on the leaf level, to avoid deadlocks, mtr must also own x-latches to brothers of page, if those brothers exist.
[in] | flags | Undo logging, locking, and rollback flags |
[in,out] | cursor | cursor on the record to update; cursor may become invalid if *big_rec == NULL || !(flags & BTR_KEEP_POS_FLAG) |
[out] | offsets | Offsets on cursor->page_cur.rec |
[in,out] | offsets_heap | Pointer to memory heap that can be emptied, or NULL |
[in,out] | entry_heap | Memory heap for allocating big_rec and the index tuple. |
[out] | big_rec | Big rec vector whose fields have to be stored externally by the caller, or NULL |
[in,out] | update | Update vector; this is allowed to also contain trx id and roll ptr fields. Non-updated columns that are moved offpage will be appended to this. |
[in] | cmpl_info | Compiler info on secondary index updates |
[in] | thr | Query thread, or NULL if flags & (BTR_NO_UNDO_LOG_FLAG | BTR_NO_LOCKING_FLAG | BTR_CREATE_FLAG | BTR_KEEP_SYS_FLAG) |
[in] | trx_id | Transaction id |
[in] | undo_no | Undo number of the transaction. This is needed for rollback to savepoint of partially updated LOB. |
[in,out] | mtr | Mini-transaction; must be committed before latching any further pages |
[in] | pcur | The persistent cursor on the record to update. |
|
inlinestatic |
Positions a tree cursor at a given record.
[in] | index | index |
[in] | rec | record in tree |
[in] | block | buffer block of rec |
[in] | cursor | cursor |
void btr_cur_search_to_nth_level | ( | dict_index_t * | index, |
ulint | level, | ||
const dtuple_t * | tuple, | ||
page_cur_mode_t | mode, | ||
ulint | latch_mode, | ||
btr_cur_t * | cursor, | ||
ulint | has_search_latch, | ||
const char * | file, | ||
ulint | line, | ||
mtr_t * | mtr | ||
) |
Searches an index tree and positions a tree cursor on a given level.
NOTE: n_fields_cmp in tuple must be set so that it cannot be compared to node pointer page number fields on the upper levels of the tree! Note that if mode is PAGE_CUR_LE, which is used in inserts, then cursor->up_match and cursor->low_match both will have sensible values. If mode is PAGE_CUR_GE, then up_match will a have a sensible value. in: mtr
NOTE: n_fields_cmp in tuple must be set so that it cannot be compared to node pointer page number fields on the upper levels of the tree! Note that if mode is PAGE_CUR_LE, which is used in inserts, then cursor->up_match and cursor->low_match both will have sensible values. If mode is PAGE_CUR_GE, then up_match will a have a sensible value.
If mode is PAGE_CUR_LE , cursor is left at the place where an insert of the search tuple should be performed in the B-tree. InnoDB does an insert immediately after the cursor. Thus, the cursor may end up on a user record, or on a page infimum record.
index | in: index |
level | in: the tree level of search |
tuple | in: data tuple; NOTE: n_fields_cmp in tuple must be set so that it cannot get compared to the node ptr page number field! |
mode | in: PAGE_CUR_L, ...; Inserts should always be made using PAGE_CUR_LE to search the position! |
latch_mode | in: BTR_SEARCH_LEAF, ..., ORed with at most one of BTR_INSERT, BTR_DELETE_MARK, BTR_DELETE, or BTR_ESTIMATE; cursor->left_block is used to store a pointer to the left neighbor page, in the cases BTR_SEARCH_PREV and BTR_MODIFY_PREV; NOTE that if has_search_latch is != 0, we maybe do not have a latch set on the cursor page, we assume the caller uses his search latch to protect the record! |
cursor | in/out: tree cursor; the cursor page is s- or x-latched, but see also above! |
has_search_latch | in: info on the latch mode the caller currently has on search system: RW_S_LATCH, or 0 |
file | in: file name |
line | in: line where called |
mtr | in: mtr |
void btr_cur_search_to_nth_level_with_no_latch | ( | dict_index_t * | index, |
ulint | level, | ||
const dtuple_t * | tuple, | ||
page_cur_mode_t | mode, | ||
btr_cur_t * | cursor, | ||
const char * | file, | ||
ulint | line, | ||
mtr_t * | mtr, | ||
bool | mark_dirty | ||
) |
Searches an index tree and positions a tree cursor on a given level.
This function will avoid placing latches while traversing the path and so should be used only for cases where-in latching is not needed.
[in] | index | Index |
[in] | level | The tree level of search |
[in] | tuple | Data tuple; Note: n_fields_cmp in compared to the node ptr page node field |
[in] | mode | PAGE_CUR_L, .... Insert should always be made using PAGE_CUR_LE to search the position. |
[in,out] | cursor | Tree cursor; points to record of interest. |
[in] | file | File name |
[in] | line | Line where called from |
[in,out] | mtr | Mini-transaction |
[in] | mark_dirty | if true then mark the block as dirty |
void btr_cur_set_deleted_flag_for_ibuf | ( | rec_t * | rec, |
page_zip_des_t * | page_zip, | ||
bool | val, | ||
mtr_t * | mtr | ||
) |
Sets a secondary index record's delete mark to the given value.
This function is only used by the insert buffer merge mechanism. in/out: mini-transaction
This function is only used by the insert buffer merge mechanism.
rec | in/out: record |
page_zip | in/out: compressed page corresponding to rec, or NULL when the tablespace is uncompressed |
val | in: value to set |
mtr | in/out: mini-transaction |
|
inline |
bool btr_cur_update_alloc_zip_func | ( | page_zip_des_t * | page_zip, |
page_cur_t * | cursor, | ||
dict_index_t * | index, | ||
ulint * | offsets, | ||
ulint | length, | ||
bool | create, | ||
mtr_t * | mtr | ||
) |
See if there is enough place in the page modification log to log an update-in-place.
[in,out] | page_zip | Compressed page. |
[in,out] | cursor | B-tree page cursor. |
[in] | index | The index corresponding to cursor. |
[in,out] | offsets | Offsets of the cursor record. |
[in] | length | size needed |
[in] | create | true=delete-and-insert, false=update-in-place |
[in,out] | mtr | Mini-transaction. |
false | if out of space; IBUF_BITMAP_FREE will be reset outside mtr if the page was re-compressed |
true | if enough place; |
IMPORTANT: The caller will have to update IBUF_BITMAP_FREE if this is a secondary index leaf page. This has to be done either within the same mini-transaction, or by invoking ibuf_reset_free_bits() before mtr_commit(mtr).
dberr_t btr_cur_update_in_place | ( | ulint | flags, |
btr_cur_t * | cursor, | ||
ulint * | offsets, | ||
const upd_t * | update, | ||
ulint | cmpl_info, | ||
que_thr_t * | thr, | ||
trx_id_t | trx_id, | ||
mtr_t * | mtr | ||
) |
Updates a record when the update causes no size changes in its fields.
[in] | flags | Undo logging and locking flags |
[in] | cursor | Cursor on the record to update; cursor stays valid and positioned on the same record |
[in,out] | offsets | Offsets on cursor->page_cur.rec |
[in] | update | Update vector |
[in] | cmpl_info | Compiler info on secondary index updates |
[in] | thr | Query thread, or null if flags & (btr_no_locking_flag | btr_no_undo_log_flag | btr_create_flag | btr_keep_sys_flag) |
[in] | trx_id | Transaction id |
[in,out] | mtr | Mini-transaction; if this is a secondary index, the caller must mtr_commit(mtr) before latching any further pages |
DB_SUCCESS | on success |
DB_ZIP_OVERFLOW | if there is not enough space left on the compressed page (IBUF_BITMAP_FREE was reset outside mtr) |
void btr_cur_update_in_place_log | ( | ulint | flags, |
const rec_t * | rec, | ||
dict_index_t * | index, | ||
const upd_t * | update, | ||
trx_id_t | trx_id, | ||
roll_ptr_t | roll_ptr, | ||
mtr_t * | mtr | ||
) |
Writes a redo log record of updating a record in-place.
[in] | flags | Undo logging and locking flags |
[in] | rec | Record |
[in] | index | Index of the record |
[in] | update | Update vector |
[in] | trx_id | Transaction id |
[in] | roll_ptr | Roll ptr |
[in] | mtr | Mini-transaction |
int64_t btr_estimate_n_rows_in_range | ( | dict_index_t * | index, |
const dtuple_t * | tuple1, | ||
page_cur_mode_t | mode1, | ||
const dtuple_t * | tuple2, | ||
page_cur_mode_t | mode2 | ||
) |
Estimates the number of rows in a given index range.
[in] | index | index |
[in] | tuple1 | range start, may also be empty tuple |
[in] | mode1 | search mode for range start |
[in] | tuple2 | range end, may also be empty tuple |
[in] | mode2 | search mode for range end |
bool btr_estimate_number_of_different_key_vals | ( | dict_index_t * | index | ) |
Estimates the number of different key values in a given index, for each n-column prefix of the index where 1 <= n <= dict_index_get_n_unique(index).
The estimates are stored in the array index->stat_n_diff_key_vals[] (indexed 0..n_uniq-1) and the number of pages that were sampled is saved in index->stat_n_sample_sizes[]. If innodb_stats_method is nulls_ignored, we also record the number of non-null values for each prefix and stored the estimates in array index->stat_n_non_null_key_vals.
The estimates are stored in the array index->stat_n_diff_key_vals[] (indexed 0..n_uniq-1) and the number of pages that were sampled is saved in index->stat_n_sample_sizes[]. If innodb_stats_method is nulls_ignored, we also record the number of non-null values for each prefix and stored the estimates in array index->stat_n_non_null_key_vals.
index | in: index |
byte * btr_rec_copy_externally_stored_field_func | ( | trx_t * | trx, |
dict_index_t * | index, | ||
const rec_t * | rec, | ||
const ulint * | offsets, | ||
const page_size_t & | page_size, | ||
ulint | no, | ||
ulint * | len, | ||
size_t * | lob_version, | ||
bool | is_sdi, | ||
mem_heap_t * | heap | ||
) |
Copies an externally stored field of a record to mem heap.
[in] | trx | the trx doing the operation. |
[in] | index | index containing the LOB. |
[in] | rec | record in a clustered index; must be protected by a lock or a page latch |
[in] | offsets | array returned by rec_get_offsets() |
[in] | page_size | BLOB page size |
[in] | no | field number |
[out] | len | length of the field |
[out] | lob_version | version of lob |
[in] | is_sdi | true for SDI Indexes |
[in,out] | heap | mem heap |
|
inlinestatic |
The following function is used to set the deleted bit of a record.
[in,out] | rec | physical record |
[in,out] | page_zip | compressed page (or NULL) |
[in] | flag | nonzero if delete marked |
bool materialize_instant_default | ( | const dict_index_t * | index, |
const rec_t * | rec | ||
) |
If default value of INSTANT ADD column is to be materialize in updated row.
[in] | index | record descriptor |
[in] | rec | record |
|
extern |
|
extern |
Number of searches down the B-tree in btr_cur_search_to_nth_level().
|
extern |
Old value of btr_cur_n_non_sea.
Copied by srv_refresh_innodb_monitor_stats(). Referenced by srv_printf_innodb_monitor().
|
extern |
Number of successful adaptive hash index lookups in btr_cur_search_to_nth_level().
|
extern |
Old value of btr_cur_n_sea.
Copied by srv_refresh_innodb_monitor_stats(). Referenced by srv_printf_innodb_monitor().
|
constexpr |
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.
|
constexpr |
If pessimistic delete fails because of lack of file space, there is still a good change of success a little later.
Sleep this many milliseconds between retries.
|
constexpr |
size of path array (in slots)