InnoDB Plugin
1.0
|
#include "univ.i"
#include "dict0dict.h"
#include "page0cur.h"
#include "btr0types.h"
#include "que0types.h"
#include "row0types.h"
#include "ha0ha.h"
#include "btr0cur.ic"
Go to the source code of this file.
Data Structures | |
struct | btr_path_t |
struct | btr_cur_t |
Macros | |
#define | BTR_CUR_ADAPT |
#define | BTR_CUR_HASH_ADAPT |
#define | btr_cur_get_index(cursor) ((cursor)->index) |
#define | btr_cur_open_at_index_side(f, i, l, c, lv, m) btr_cur_open_at_index_side_func(f,i,l,c,lv,__FILE__,__LINE__,m) |
#define | btr_cur_open_at_rnd_pos(i, l, c, m) btr_cur_open_at_rnd_pos_func(i,l,c,__FILE__,__LINE__,m) |
#define | btr_cur_update_alloc_zip(page_zip, cursor, index, offsets, len, cr, mtr) btr_cur_update_alloc_zip_func(page_zip,cursor,index,offsets,len,cr,mtr) |
#define | btr_cur_optimistic_delete(cursor, flags, mtr) btr_cur_optimistic_delete_func(cursor, flags, mtr) |
#define | BTR_CUR_PAGE_COMPRESS_LIMIT (UNIV_PAGE_SIZE / 2) |
#define | BTR_PATH_ARRAY_N_SLOTS 250 |
#define | BTR_CUR_RETRY_DELETE_N_TIMES 100 |
#define | BTR_CUR_RETRY_SLEEP_TIME 50000 |
#define | BTR_EXTERN_SPACE_ID 0 |
#define | BTR_EXTERN_PAGE_NO 4 |
#define | BTR_EXTERN_OFFSET 8 |
#define | BTR_EXTERN_LEN 12 |
#define | BTR_EXTERN_OWNER_FLAG 128 |
#define | BTR_EXTERN_INHERITED_FLAG 64 |
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 } |
enum | blob_op { BTR_STORE_INSERT = 0, BTR_STORE_INSERT_UPDATE, BTR_STORE_UPDATE } |
enum | btr_cur_method { BTR_CUR_HASH = 1, 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 } |
Functions | |
UNIV_INLINE page_cur_t * | btr_cur_get_page_cur (const btr_cur_t *cursor) |
UNIV_INLINE buf_block_t * | btr_cur_get_block (const btr_cur_t *cursor) |
UNIV_INLINE rec_t * | btr_cur_get_rec (const btr_cur_t *cursor) |
UNIV_INLINE page_zip_des_t * | btr_cur_get_page_zip (btr_cur_t *cursor) |
UNIV_INLINE void | btr_cur_invalidate (btr_cur_t *cursor) |
UNIV_INLINE page_t * | btr_cur_get_page (btr_cur_t *cursor) |
UNIV_INLINE void | btr_cur_position (dict_index_t *index, rec_t *rec, buf_block_t *block, btr_cur_t *cursor) |
UNIV_INTERN void | btr_cur_search_to_nth_level (dict_index_t *index, ulint level, const dtuple_t *tuple, ulint mode, ulint latch_mode, btr_cur_t *cursor, ulint has_search_latch, const char *file, ulint line, mtr_t *mtr) |
UNIV_INTERN void | btr_cur_open_at_index_side_func (bool from_left, dict_index_t *index, ulint latch_mode, btr_cur_t *cursor, ulint level, const char *file, ulint line, mtr_t *mtr)) |
UNIV_INTERN void | btr_cur_open_at_rnd_pos_func (dict_index_t *index, ulint latch_mode, btr_cur_t *cursor, const char *file, ulint line, mtr_t *mtr) |
UNIV_INTERN 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, ulint n_ext, que_thr_t *thr, mtr_t *mtr) |
UNIV_INTERN dberr_t | btr_cur_pessimistic_insert (ulint flags, btr_cur_t *cursor, ulint **offsets, mem_heap_t **heap, dtuple_t *entry, rec_t **rec, big_rec_t **big_rec, ulint n_ext, que_thr_t *thr, mtr_t *mtr) |
UNIV_INTERN 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)) |
UNIV_INTERN 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)) |
UNIV_INTERN 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)) |
UNIV_INTERN 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)) |
UNIV_INTERN 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, const upd_t *update, ulint cmpl_info, que_thr_t *thr, trx_id_t trx_id, mtr_t *mtr)) |
UNIV_INTERN dberr_t | btr_cur_del_mark_set_clust_rec (buf_block_t *block, rec_t *rec, dict_index_t *index, const ulint *offsets, que_thr_t *thr, mtr_t *mtr)) |
UNIV_INTERN dberr_t | btr_cur_del_mark_set_sec_rec (ulint flags, btr_cur_t *cursor, ibool val, que_thr_t *thr, mtr_t *mtr)) |
UNIV_INTERN ibool | btr_cur_compress_if_useful (btr_cur_t *cursor, ibool adjust, mtr_t *mtr)) |
UNIV_INTERN ibool | btr_cur_optimistic_delete_func (btr_cur_t *cursor, ulint flags, mtr_t *mtr)) |
UNIV_INTERN ibool | btr_cur_pessimistic_delete (dberr_t *err, ibool has_reserved_extents, btr_cur_t *cursor, ulint flags, enum trx_rb_ctx rb_ctx, mtr_t *mtr)) |
UNIV_INTERN byte * | btr_cur_parse_update_in_place (byte *ptr, byte *end_ptr, page_t *page, page_zip_des_t *page_zip, dict_index_t *index) |
UNIV_INTERN byte * | btr_cur_parse_del_mark_set_clust_rec (byte *ptr, byte *end_ptr, page_t *page, page_zip_des_t *page_zip, dict_index_t *index) |
UNIV_INTERN byte * | btr_cur_parse_del_mark_set_sec_rec (byte *ptr, byte *end_ptr, page_t *page, page_zip_des_t *page_zip) |
UNIV_INTERN ib_int64_t | btr_estimate_n_rows_in_range (dict_index_t *index, const dtuple_t *tuple1, ulint mode1, const dtuple_t *tuple2, ulint mode2) |
UNIV_INTERN void | btr_estimate_number_of_different_key_vals (dict_index_t *index) |
ulint | btr_rec_get_externally_stored_len (const rec_t *rec, const ulint *offsets) |
UNIV_INTERN void | btr_cur_disown_inherited_fields (page_zip_des_t *page_zip, rec_t *rec, dict_index_t *index, const ulint *offsets, const upd_t *update, mtr_t *mtr))) |
UNIV_INLINE ibool | btr_blob_op_is_update (enum blob_op op)) |
UNIV_INTERN dberr_t | btr_store_big_rec_extern_fields (dict_index_t *index, buf_block_t *rec_block, rec_t *rec, const ulint *offsets, const big_rec_t *big_rec_vec, mtr_t *btr_mtr, enum blob_op op)) |
UNIV_INTERN void | btr_free_externally_stored_field (dict_index_t *index, byte *field_ref, const rec_t *rec, const ulint *offsets, page_zip_des_t *page_zip, ulint i, enum trx_rb_ctx rb_ctx, mtr_t *local_mtr) |
UNIV_INTERN ulint | btr_copy_externally_stored_field_prefix (byte *buf, ulint len, ulint zip_size, const byte *data, ulint local_len) |
UNIV_INTERN byte * | btr_copy_externally_stored_field (ulint *len, const byte *data, ulint zip_size, ulint local_len, mem_heap_t *heap) |
UNIV_INTERN byte * | btr_rec_copy_externally_stored_field (const rec_t *rec, const ulint *offsets, ulint zip_size, ulint no, ulint *len, mem_heap_t *heap) |
UNIV_INTERN ulint | btr_push_update_extern_fields (dtuple_t *tuple, const upd_t *update, mem_heap_t *heap)) |
UNIV_INTERN void | btr_cur_set_deleted_flag_for_ibuf (rec_t *rec, page_zip_des_t *page_zip, ibool val, mtr_t *mtr) |
Variables | |
UNIV_INTERN dberr_t | warn_unused_result |
ulint | btr_cur_n_non_sea |
ulint | btr_cur_n_sea |
ulint | btr_cur_n_non_sea_old |
ulint | btr_cur_n_sea_old |
uint | btr_cur_limit_optimistic_insert_debug |
The index tree cursor
Created 10/16/1994 Heikki Tuuri
#define btr_cur_get_index | ( | cursor | ) | ((cursor)->index) |
Returns the index of a cursor.
cursor | b-tree cursor |
#define BTR_CUR_PAGE_COMPRESS_LIMIT (UNIV_PAGE_SIZE / 2) |
In the pessimistic delete, if the page data size drops below this
limit, merging it to a neighbor is tried
#define 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. Try this many times.
#define BTR_CUR_RETRY_SLEEP_TIME 50000 |
If pessimistic delete fails because of lack of file space, there
is still a good change of success a little later. Sleep this many microseconds between retries.
#define BTR_EXTERN_INHERITED_FLAG 64 |
If the second most significant bit of BTR_EXTERN_LEN (i.e., the
second most significant bit of the byte at smallest address) is 1 then it means that the externally stored field was inherited from an earlier version of the row. In rollback we are not allowed to free an inherited external field.
#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_OFFSET 8 |
offset of BLOB header on that page
#define BTR_EXTERN_OWNER_FLAG 128 |
The most significant bit of BTR_EXTERN_LEN (i.e., the most
significant bit of the byte at smallest address) is set to 1 if this field does not 'own' the externally stored field; only the owner field is allowed to free the field in purge!
#define BTR_EXTERN_PAGE_NO 4 |
page no where stored
#define BTR_EXTERN_SPACE_ID 0 |
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 determine the ordering parts of each index record without looking into the externally stored part. space id where stored
#define BTR_PATH_ARRAY_N_SLOTS 250 |
size of path array (in slots)
anonymous enum |
Mode flags for btr_cur operations; these can be ORed
BTR_NO_UNDO_LOG_FLAG |
do no undo logging |
BTR_NO_LOCKING_FLAG |
do no record lock checking |
BTR_KEEP_SYS_FLAG |
sys fields will be found in the update vector or inserted entry |
BTR_KEEP_POS_FLAG |
btr_cur_pessimistic_update() must keep cursor position when moving columns to big_rec |
BTR_CREATE_FLAG |
the caller is creating the index or wants to bypass the index->info.online creation log |
BTR_KEEP_IBUF_BITMAP |
the caller of btr_cur_optimistic_update() or btr_cur_update_in_place() will take care of updating IBUF_BITMAP_FREE |
enum blob_op |
Operation code for btr_store_big_rec_extern_fields().
enum btr_cur_method |
Values for the flag documenting the used search method
BTR_CUR_HASH |
successful shortcut using the hash index |
BTR_CUR_HASH_FAIL |
failure using hash, success using binary search: the misleading hash reference is stored in the field hash_node, and might be necessary to update |
BTR_CUR_BINARY |
success using the binary search |
BTR_CUR_INSERT_TO_IBUF |
performed the intended insert to the insert buffer |
BTR_CUR_DEL_MARK_IBUF |
performed the intended delete mark in the insert/delete buffer |
BTR_CUR_DELETE_IBUF |
performed the intended delete in the insert/delete buffer |
BTR_CUR_DELETE_REF |
row_purge_poss_sec() failed |
Determine if an operation on off-page columns is an update.
op | in: operation |
UNIV_INTERN byte* btr_copy_externally_stored_field | ( | ulint * | len, |
const byte * | data, | ||
ulint | zip_size, | ||
ulint | local_len, | ||
mem_heap_t * | heap | ||
) |
Copies an externally stored field of a record to mem heap. The clustered index record must be protected by a lock or a page latch.
len | out: length of the whole field |
data | in: 'internally' stored part of the field containing also the reference to the external part; must be protected by a lock or a page latch |
zip_size | in: nonzero=compressed BLOB page size, zero for uncompressed BLOBs |
local_len | in: length of data |
UNIV_INTERN ulint btr_copy_externally_stored_field_prefix | ( | byte * | buf, |
ulint | len, | ||
ulint | zip_size, | ||
const byte * | data, | ||
ulint | local_len | ||
) |
Copies the prefix of an externally stored field of a record. The clustered index record must be protected by a lock or a page latch.
buf | out: the field, or a prefix of it |
len | in: length of buf, in bytes |
zip_size | in: nonzero=compressed BLOB page size, zero for uncompressed BLOBs |
data | in: 'internally' stored part of the field containing also the reference to the external part; must be protected by a lock or a page latch |
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!
cursor | in/out: cursor on the page to compress; cursor does not stay valid if compression occurs |
adjust | in: TRUE if should adjust the cursor position even if compression occurs |
mtr | in/out: mini-transaction |
UNIV_INTERN dberr_t btr_cur_del_mark_set_clust_rec | ( | buf_block_t * | block, |
rec_t * | rec, | ||
dict_index_t * | index, | ||
const ulint * | offsets, | ||
que_thr_t * | thr, | ||
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.
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 |
mtr | in/out: mini-transaction |
UNIV_INTERN dberr_t btr_cur_del_mark_set_sec_rec | ( | ulint | flags, |
btr_cur_t * | cursor, | ||
ibool | 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 |
UNIV_INTERN void btr_cur_disown_inherited_fields | ( | page_zip_des_t * | page_zip, |
rec_t * | rec, | ||
dict_index_t * | index, | ||
const ulint * | offsets, | ||
const upd_t * | update, | ||
mtr_t * | mtr | ||
) |
Marks non-updated off-page fields as disowned by this record. The ownership must be transferred to the updated record which is inserted elsewhere in the index tree. In purge only the owner of externally stored field is allowed to free the field.
page_zip | in/out: compressed page whose uncompressed part will be updated, or NULL |
rec | in/out: record in a clustered index |
index | in: index of the page |
offsets | in: array returned by rec_get_offsets() |
update | in: update vector |
mtr | in/out: mini-transaction |
UNIV_INLINE buf_block_t* btr_cur_get_block | ( | const btr_cur_t * | cursor | ) |
Returns the buffer block on which the tree cursor is positioned.
Returns the buffer block on which the tree cursor is positioned.
cursor | in: tree cursor |
Returns the page of a tree cursor.
Returns the page of a tree cursor.
cursor | in: tree cursor |
UNIV_INLINE page_cur_t* btr_cur_get_page_cur | ( | const btr_cur_t * | cursor | ) |
Returns the page cursor component of a tree cursor.
Returns the page cursor component of a tree cursor.
cursor | in: tree cursor |
UNIV_INLINE page_zip_des_t* btr_cur_get_page_zip | ( | btr_cur_t * | cursor | ) |
Returns the compressed page on which the tree cursor is positioned.
Returns the compressed page on which the tree cursor is positioned.
cursor | in: tree cursor |
UNIV_INLINE rec_t* btr_cur_get_rec | ( | const btr_cur_t * | cursor | ) |
Returns the record pointer of a tree cursor.
Returns the record pointer of a tree cursor.
cursor | in: tree cursor |
UNIV_INLINE void btr_cur_invalidate | ( | btr_cur_t * | cursor | ) |
Invalidates a tree cursor by setting record pointer to NULL. in: tree cursor
Invalidates a tree cursor by setting record pointer to NULL.
cursor | in: tree cursor |
UNIV_INTERN void btr_cur_open_at_index_side_func | ( | bool | from_left, |
dict_index_t * | index, | ||
ulint | latch_mode, | ||
btr_cur_t * | cursor, | ||
ulint | level, | ||
const char * | file, | ||
ulint | line, | ||
mtr_t * | mtr | ||
) |
Opens a cursor at either end of an index.
from_left | in: true if open to the low end, false if to the high end |
index | in: index |
latch_mode | in: latch mode |
cursor | in/out: cursor |
level | in: level to search for (0=leaf) |
file | in: file name |
line | in: line where called |
mtr | in/out: mini-transaction |
UNIV_INTERN void btr_cur_open_at_rnd_pos_func | ( | 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. in: mtr
index | in: index |
latch_mode | in: BTR_SEARCH_LEAF, ... |
cursor | in/out: B-tree cursor |
file | in: file name |
line | in: line where called |
Removes the record on which the tree cursor is positioned. 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.
cursor | in: cursor on the record to delete; cursor stays valid: if deletion succeeds, on function exit it points to the successor of the deleted record |
flags | in: BTR_CREATE_FLAG or 0 |
mtr | 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 |
UNIV_INTERN 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, | ||
ulint | n_ext, | ||
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.
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 |
n_ext | in: number of externally stored columns |
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 |
UNIV_INTERN 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.
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 |
flags | in: undo logging and locking flags |
cursor | in: cursor on the record to update; cursor stays valid and positioned on the same record |
offsets | out: offsets on cursor->page_cur.rec |
heap | in/out: pointer to NULL or memory heap |
update | in: update vector; this must also contain trx id and roll ptr fields |
cmpl_info | in: compiler info on secondary index updates |
thr | in: query thread |
trx_id | in: transaction id |
mtr | in/out: mini-transaction; if this is a secondary index, the caller must mtr_commit(mtr) before latching any further pages |
UNIV_INTERN byte* btr_cur_parse_del_mark_set_clust_rec | ( | byte * | ptr, |
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 |
UNIV_INTERN byte* btr_cur_parse_del_mark_set_sec_rec | ( | byte * | ptr, |
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 |
UNIV_INTERN byte* btr_cur_parse_update_in_place | ( | byte * | ptr, |
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 |
UNIV_INTERN ibool btr_cur_pessimistic_delete | ( | dberr_t * | err, |
ibool | has_reserved_extents, | ||
btr_cur_t * | cursor, | ||
ulint | flags, | ||
enum trx_rb_ctx | rb_ctx, | ||
mtr_t * | mtr | ||
) |
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.
err | out: 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 |
has_reserved_extents | in: TRUE if the caller has already reserved enough free extents so that he knows that the operation will succeed |
cursor | in: 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 |
flags | in: BTR_CREATE_FLAG or 0 |
rb_ctx | in: rollback context |
mtr | in: mtr |
UNIV_INTERN dberr_t btr_cur_pessimistic_insert | ( | ulint | flags, |
btr_cur_t * | cursor, | ||
ulint ** | offsets, | ||
mem_heap_t ** | heap, | ||
dtuple_t * | entry, | ||
rec_t ** | rec, | ||
big_rec_t ** | big_rec, | ||
ulint | n_ext, | ||
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.
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 |
n_ext | in: number of externally stored columns |
thr | in: query thread or NULL |
mtr | in/out: mini-transaction |
UNIV_INTERN 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, | ||
const upd_t * | update, | ||
ulint | cmpl_info, | ||
que_thr_t * | thr, | ||
trx_id_t | trx_id, | ||
mtr_t * | mtr | ||
) |
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.
flags | in: undo logging, locking, and rollback flags |
cursor | in/out: cursor on the record to update; cursor may become invalid if *big_rec == NULL || !(flags & BTR_KEEP_POS_FLAG) |
offsets | out: offsets on cursor->page_cur.rec |
offsets_heap | in/out: pointer to memory heap that can be emptied, or NULL |
entry_heap | in/out: memory heap for allocating big_rec and the index tuple |
big_rec | out: big rec vector whose fields have to be stored externally by the caller, or NULL |
update | in: update vector; this is allowed also contain trx id and roll ptr fields, but the values in update vector have no effect |
cmpl_info | in: compiler info on secondary index updates |
thr | in: query thread |
trx_id | in: transaction id |
mtr | in/out: mini-transaction; must be committed before latching any further pages |
UNIV_INLINE 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. in: cursor
Positions a tree cursor at a given record.
index | in: index |
rec | in: record in tree |
block | in: buffer block of rec |
cursor | out: cursor |
UNIV_INTERN void btr_cur_search_to_nth_level | ( | dict_index_t * | index, |
ulint | level, | ||
const dtuple_t * | tuple, | ||
ulint | 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
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, ...; NOTE that if the search is made using a unique prefix of a record, mode should be PAGE_CUR_LE, not PAGE_CUR_GE, as the latter may end up on the previous page of the record! 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: latch mode the caller currently has on btr_search_latch: RW_S_LATCH, or 0 |
file | in: file name |
line | in: line where called |
UNIV_INTERN void btr_cur_set_deleted_flag_for_ibuf | ( | rec_t * | rec, |
page_zip_des_t * | page_zip, | ||
ibool | 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
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 |
UNIV_INTERN 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.
false | if out of space; IBUF_BITMAP_FREE will be reset outside mtr if the page was recompressed |
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).
page_zip | in/out: compressed page |
cursor | in/out: B-tree page cursor |
index | in: the index corresponding to cursor |
offsets | in/out: offsets of the cursor record |
length | in: size needed |
create | in: true=delete-and-insert, false=update-in-place |
mtr | in/out: mini-transaction |
UNIV_INTERN 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.
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) |
flags | in: undo logging and locking flags |
cursor | in: cursor on the record to update; cursor stays valid and positioned on the same record |
offsets | in/out: offsets on cursor->page_cur.rec |
update | in: update vector |
cmpl_info | in: compiler info on secondary index updates |
thr | in: query thread |
trx_id | in: transaction id |
mtr | in/out: mini-transaction; if this is a secondary index, the caller must mtr_commit(mtr) before latching any further pages |
UNIV_INTERN 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.
flags | in: flags |
rec | in: record |
index | in: index of the record |
update | in: update vector |
trx_id | in: transaction id |
roll_ptr | in: roll ptr |
mtr | in: mtr |
UNIV_INTERN ib_int64_t btr_estimate_n_rows_in_range | ( | dict_index_t * | index, |
const dtuple_t * | tuple1, | ||
ulint | mode1, | ||
const dtuple_t * | tuple2, | ||
ulint | mode2 | ||
) |
Estimates the number of rows in a given index range.
index | in: index |
tuple1 | in: range start, may also be empty tuple |
mode1 | in: search mode for range start |
tuple2 | in: range end, may also be empty tuple |
UNIV_INTERN void 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. in: index
UNIV_INTERN void btr_free_externally_stored_field | ( | dict_index_t * | index, |
byte * | field_ref, | ||
const rec_t * | rec, | ||
const ulint * | offsets, | ||
page_zip_des_t * | page_zip, | ||
ulint | i, | ||
enum trx_rb_ctx | rb_ctx, | ||
mtr_t * | local_mtr | ||
) |
Frees the space in an externally stored field to the file space management if the field in data is owned the externally stored field, in a rollback we may have the additional condition that the field must not be inherited. in: mtr containing the latch to data an an X-latch to the index tree
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) |
field_ref | in/out: field reference |
rec | in: record containing field_ref, for page_zip_write_blob_ptr(), or NULL |
offsets | in: rec_get_offsets(rec, index), or NULL |
page_zip | in: compressed page corresponding to rec, or NULL if rec == NULL |
i | in: field number of field_ref; ignored if rec == NULL |
rb_ctx | in: rollback context |
UNIV_INTERN ulint btr_push_update_extern_fields | ( | dtuple_t * | tuple, |
const upd_t * | update, | ||
mem_heap_t * | heap | ||
) |
Flags the data tuple fields that are marked as extern storage in the update vector. We use this function to remember which fields we must mark as extern storage in a record inserted for an update.
tuple | in/out: data tuple |
update | in: update vector |
heap | in: memory heap |
UNIV_INTERN byte* btr_rec_copy_externally_stored_field | ( | const rec_t * | rec, |
const ulint * | offsets, | ||
ulint | zip_size, | ||
ulint | no, | ||
ulint * | len, | ||
mem_heap_t * | heap | ||
) |
Copies an externally stored field of a record to mem heap.
rec | in: record in a clustered index; must be protected by a lock or a page latch |
offsets | in: array returned by rec_get_offsets() |
zip_size | in: nonzero=compressed BLOB page size, zero for uncompressed BLOBs |
no | in: field number |
len | out: length of the field |
ulint btr_rec_get_externally_stored_len | ( | const rec_t * | rec, |
const ulint * | offsets | ||
) |
Gets the externally stored size of a record, in units of a database page.
[in] | rec | record |
[in] | offsets | array returned by rec_get_offsets() |
UNIV_INTERN dberr_t btr_store_big_rec_extern_fields | ( | dict_index_t * | index, |
buf_block_t * | rec_block, | ||
rec_t * | rec, | ||
const ulint * | offsets, | ||
const big_rec_t * | big_rec_vec, | ||
mtr_t * | btr_mtr, | ||
enum blob_op | op | ||
) |
Stores the fields in big_rec_vec to the tablespace and puts pointers to them in rec. The extern flags in rec will have to be set beforehand. The fields are stored on pages allocated from leaf node file segment of the index tree.
in: operation code
index | in: index of rec; the index tree MUST be X-latched |
rec_block | in/out: block containing rec |
rec | in/out: record |
offsets | in: rec_get_offsets(rec, index); the "external storage" flags in offsets will not correspond to rec when this function returns |
big_rec_vec | in: vector containing fields to be stored externally |
btr_mtr | in: mtr containing the latches to the clustered index |
ulint btr_cur_n_non_sea |
Number of searches down the B-tree in btr_cur_search_to_nth_level().
ulint btr_cur_n_non_sea_old |
Old value of btr_cur_n_non_sea. Copied by
srv_refresh_innodb_monitor_stats(). Referenced by srv_printf_innodb_monitor().
ulint btr_cur_n_sea |
Number of successful adaptive hash index lookups in
ulint btr_cur_n_sea_old |
Old value of btr_cur_n_sea. Copied by
srv_refresh_innodb_monitor_stats(). Referenced by srv_printf_innodb_monitor().