Drizzled Public API Documentation

btr0btr.h File Reference
#include "univ.i"
#include "dict0dict.h"
#include "data0data.h"
#include "page0cur.h"
#include "mtr0mtr.h"
#include "btr0types.h"

Go to the source code of this file.

Defines

#define BTR_PAGE_MAX_REC_SIZE   (UNIV_PAGE_SIZE / 2 - 200)
#define BTR_MAX_LEVELS   100
 Maximum depth of a B-tree in InnoDB.
#define BTR_INSERT   512
#define BTR_ESTIMATE   1024
#define BTR_IGNORE_SEC_UNIQUE   2048
#define BTR_DELETE_MARK   4096
#define BTR_DELETE   8192
#define btr_block_get(space, zip_size, page_no, mode, mtr)   btr_block_get_func(space,zip_size,page_no,mode,__FILE__,__LINE__,mtr)
#define btr_page_get(space, zip_size, page_no, mode, mtr)   buf_block_get_frame(btr_block_get(space,zip_size,page_no,mode,mtr))
#define btr_insert_on_non_leaf_level(i, l, t, m)   btr_insert_on_non_leaf_level_func(i,l,t,__FILE__,__LINE__,m)
#define BTR_N_LEAF_PAGES   1
#define BTR_TOTAL_SIZE   2

Enumerations

enum  btr_latch_mode {
  BTR_SEARCH_LEAF = RW_S_LATCH, BTR_MODIFY_LEAF = RW_X_LATCH, BTR_NO_LATCHES = RW_NO_LATCH, BTR_MODIFY_TREE = 33,
  BTR_CONT_MODIFY_TREE = 34, BTR_SEARCH_PREV = 35, BTR_MODIFY_PREV = 36
}

Functions

UNIV_INTERN page_tbtr_root_get (dict_index_t *index, mtr_t *mtr)
UNIV_INLINE buf_block_tbtr_block_get_func (ulint space, ulint zip_size, ulint page_no, ulint mode, const char *file, ulint line, mtr_t *mtr) __attribute__((nonnull))
UNIV_INLINE index_id_t btr_page_get_index_id (const page_t *page)
UNIV_INLINE ulint btr_page_get_level_low (const page_t *page)
UNIV_INLINE ulint btr_page_get_level (const page_t *page, mtr_t *mtr)
UNIV_INLINE ulint btr_page_get_next (const page_t *page, mtr_t *mtr)
UNIV_INLINE ulint btr_page_get_prev (const page_t *page, mtr_t *mtr)
UNIV_INTERN rec_t * btr_get_prev_user_rec (rec_t *rec, mtr_t *mtr)
UNIV_INTERN rec_t * btr_get_next_user_rec (rec_t *rec, mtr_t *mtr)
UNIV_INLINE void btr_leaf_page_release (buf_block_t *block, ulint latch_mode, mtr_t *mtr)
UNIV_INLINE ulint btr_node_ptr_get_child_page_no (const rec_t *rec, const ulint *offsets)
UNIV_INTERN ulint btr_create (ulint type, ulint space, ulint zip_size, index_id_t index_id, dict_index_t *index, mtr_t *mtr)
UNIV_INTERN void btr_free_but_not_root (ulint space, ulint zip_size, ulint root_page_no)
UNIV_INTERN void btr_free_root (ulint space, ulint zip_size, ulint root_page_no, mtr_t *mtr)
UNIV_INTERN rec_t * btr_root_raise_and_insert (btr_cur_t *cursor, const dtuple_t *tuple, ulint n_ext, mtr_t *mtr)
UNIV_INTERN ibool btr_page_reorganize (buf_block_t *block, dict_index_t *index, mtr_t *mtr)
UNIV_INTERN ibool btr_page_get_split_rec_to_left (btr_cur_t *cursor, rec_t **split_rec)
UNIV_INTERN ibool btr_page_get_split_rec_to_right (btr_cur_t *cursor, rec_t **split_rec)
UNIV_INTERN rec_t * btr_page_split_and_insert (btr_cur_t *cursor, const dtuple_t *tuple, ulint n_ext, mtr_t *mtr)
UNIV_INTERN void btr_insert_on_non_leaf_level_func (dict_index_t *index, ulint level, dtuple_t *tuple, const char *file, ulint line, mtr_t *mtr)
UNIV_INTERN void btr_set_min_rec_mark (rec_t *rec, mtr_t *mtr)
UNIV_INTERN void btr_node_ptr_delete (dict_index_t *index, buf_block_t *block, mtr_t *mtr)
UNIV_INTERN ibool btr_compress (btr_cur_t *cursor, mtr_t *mtr)
UNIV_INTERN void btr_discard_page (btr_cur_t *cursor, mtr_t *mtr)
UNIV_INTERN byte * btr_parse_set_min_rec_mark (byte *ptr, byte *end_ptr, ulint comp, page_t *page, mtr_t *mtr)
UNIV_INTERN byte * btr_parse_page_reorganize (byte *ptr, byte *end_ptr, dict_index_t *index, buf_block_t *block, mtr_t *mtr)
UNIV_INTERN ulint btr_get_size (dict_index_t *index, ulint flag)
UNIV_INTERN buf_block_tbtr_page_alloc (dict_index_t *index, ulint hint_page_no, byte file_direction, ulint level, mtr_t *mtr)
UNIV_INTERN void btr_page_free (dict_index_t *index, buf_block_t *block, mtr_t *mtr)
UNIV_INTERN void btr_page_free_low (dict_index_t *index, buf_block_t *block, ulint level, mtr_t *mtr)
UNIV_INTERN ibool btr_index_rec_validate (const rec_t *rec, const dict_index_t *index, ibool dump_on_error)
UNIV_INTERN ibool btr_validate_index (dict_index_t *index, trx_t *trx)

Detailed Description

The B-tree

Created 6/2/1994 Heikki Tuuri

Definition in file btr0btr.h.


Define Documentation

#define btr_block_get (   space,
  zip_size,
  page_no,
  mode,
  mtr 
)    btr_block_get_func(space,zip_size,page_no,mode,__FILE__,__LINE__,mtr)

Gets a buffer page and declares its latching order level.

Parameters:
spacetablespace identifier
zip_sizecompressed page size in bytes or 0 for uncompressed pages
page_nopage number
modelatch mode
mtrmini-transaction handle
Returns:
the block descriptor

Definition at line 127 of file btr0btr.h.

Referenced by btr_compress(), btr_discard_page(), btr_free_root(), btr_pcur_move_to_next_page(), and dict_truncate_index_tree().

#define BTR_DELETE   8192

Try to purge the record at the searched position using the insert/delete buffer when the record is not in the buffer pool.

Definition at line 94 of file btr0btr.h.

Referenced by btr_cur_search_to_nth_level(), and row_search_index_entry().

#define BTR_DELETE_MARK   4096

Try to delete mark the record at the searched position using the insert/delete buffer when the record is not in the buffer pool.

Definition at line 90 of file btr0btr.h.

Referenced by btr_cur_search_to_nth_level().

#define BTR_ESTIMATE   1024

This flag ORed to btr_latch_mode says that we do the search in query optimization

Definition at line 81 of file btr0btr.h.

Referenced by btr_cur_open_at_index_side_func(), btr_cur_search_to_nth_level(), and btr_estimate_n_rows_in_range().

#define BTR_IGNORE_SEC_UNIQUE   2048

This flag ORed to BTR_INSERT says that we can ignore possible UNIQUE definition on secondary indexes when we decide if we can use the insert buffer to speed up inserts

Definition at line 86 of file btr0btr.h.

Referenced by btr_cur_search_to_nth_level().

#define BTR_INSERT   512

If this is ORed to btr_latch_mode, it means that the search tuple will be inserted to the index, at the searched position. When the record is not in the buffer pool, try to use the insert buffer.

Definition at line 77 of file btr0btr.h.

Referenced by btr_cur_search_to_nth_level().

#define BTR_MAX_LEVELS   100

Maximum depth of a B-tree in InnoDB.

Note that this isn't a maximum as such; none of the tree operations avoid producing trees bigger than this. It is instead a "max depth that other code must work with", useful for e.g. fixed-size arrays that must store some information about each level in a tree. In other words: if a B-tree with bigger depth than this is encountered, it is not acceptable for it to lead to mysterious memory corruption, but it is acceptable for the program to die with a clear assert failure.

Definition at line 52 of file btr0btr.h.

#define btr_page_get (   space,
  zip_size,
  page_no,
  mode,
  mtr 
)    buf_block_get_frame(btr_block_get(space,zip_size,page_no,mode,mtr))

Gets a buffer page and declares its latching order level.

Parameters:
spacetablespace identifier
zip_sizecompressed page size in bytes or 0 for uncompressed pages
page_nopage number
modelatch mode
mtrmini-transaction handle
Returns:
the uncompressed page frame

Definition at line 136 of file btr0btr.h.

Referenced by btr_cur_search_to_nth_level(), and btr_free_but_not_root().

#define BTR_PAGE_MAX_REC_SIZE   (UNIV_PAGE_SIZE / 2 - 200)

Maximum record size which can be stored on a page, without using the special big record storage structure

Definition at line 41 of file btr0btr.h.

Referenced by btr_create().


Enumeration Type Documentation

Latching modes for btr_cur_search_to_nth_level().

Enumerator:
BTR_SEARCH_LEAF 

Search a record on a leaf page and S-latch it.

BTR_MODIFY_LEAF 

(Prepare to) modify a record on a leaf page and X-latch it.

BTR_NO_LATCHES 

Obtain no latches.

BTR_MODIFY_TREE 

Start modifying the entire B-tree.

BTR_CONT_MODIFY_TREE 

Continue modifying the entire B-tree.

BTR_SEARCH_PREV 

Search the previous record.

BTR_MODIFY_PREV 

Modify the previous record.

Definition at line 55 of file btr0btr.h.


Function Documentation

UNIV_INLINE buf_block_t* btr_block_get_func ( ulint  space,
ulint  zip_size,
ulint  page_no,
ulint  mode,
const char *  file,
ulint  line,
mtr_t mtr 
)

Gets a buffer page and declares its latching order level.

Parameters:
spacein: space id
zip_sizein: compressed page size in bytes or 0 for uncompressed pages
page_noin: page number
modein: latch mode
filein: file name
linein: line where called
mtrin/out: mtr
UNIV_INTERN ibool btr_compress ( btr_cur_t cursor,
mtr_t mtr 
)

Tries to merge the page first to the left immediate brother if such a brother exists, and the node pointers to the current page and to the brother reside on the same page. If the left brother does not satisfy these conditions, looks at the right brother. If the page is the only one on that level lifts the records of the page to the father page, thus reducing the tree height. It is assumed that mtr holds an x-latch on the tree and on the page. If cursor is on the leaf level, mtr must also hold x-latches to the brothers, if they exist.

Returns:
TRUE on success in: mtr

Tries to merge the page first to the left immediate brother if such a brother exists, and the node pointers to the current page and to the brother reside on the same page. If the left brother does not satisfy these conditions, looks at the right brother. If the page is the only one on that level lifts the records of the page to the father page, thus reducing the tree height. It is assumed that mtr holds an x-latch on the tree and on the page. If cursor is on the leaf level, mtr must also hold x-latches to the brothers, if they exist.

Returns:
TRUE on success
Parameters:
cursorin: cursor on the page to merge or lift; the page must not be empty: in record delete use btr_discard_page if the page would become empty
mtrin: mtr

Definition at line 2538 of file btr0btr.cc.

References btr_block_get, btr_cur_get_block(), btr_cur_get_index(), btr_cur_get_page(), btr_cur_get_page_zip(), btr_cur_get_rec(), btr_page_get_next(), btr_page_get_prev(), buf_block_get_page_no(), buf_block_get_page_zip, dict_index_get_lock(), dict_index_get_space(), dict_index_is_clust(), dict_table_is_comp(), dict_table_zip_size(), FIL_NULL, FIL_PAGE_PREV, ibuf_update_free_bits_if_full(), btr_cur_struct::index, lock_update_merge_left(), lock_update_merge_right(), mem_heap_create, mem_heap_free, page_copy_rec_list_end(), page_copy_rec_list_start(), page_get_data_size(), page_get_max_insert_size(), page_get_max_insert_size_after_reorganize(), page_get_n_recs(), page_is_comp(), page_is_leaf(), page_validate(), dict_index_struct::table, ut_a, and ut_ad.

UNIV_INTERN ulint btr_create ( ulint  type,
ulint  space,
ulint  zip_size,
index_id_t  index_id,
dict_index_t index,
mtr_t mtr 
)

Creates the root node for a new index tree.

Returns:
page number of the created root, FIL_NULL if did not succeed in: mini-transaction handle

Creates the root node for a new index tree.

Returns:
page number of the created root, FIL_NULL if did not succeed
Parameters:
typein: type of the index
spacein: space where created
zip_sizein: compressed page size in bytes or 0 for uncompressed pages
index_idin: index id
indexin: index
mtrin: mini-transaction handle

Definition at line 732 of file btr0btr.cc.

References BTR_PAGE_MAX_REC_SIZE, buf_block_get_page_no(), buf_block_get_page_zip, buf_page_get, buf_block_struct::check_index_page_at_flush, DICT_CLUSTERED, DICT_IBUF, dict_table_is_comp(), FIL_NULL, flst_init(), page_create(), page_create_zip(), page_get_max_insert_size(), dict_index_struct::table, and ut_ad.

UNIV_INTERN void btr_discard_page ( btr_cur_t cursor,
mtr_t mtr 
)

Discards a page from a B-tree. This is used to remove the last record from a B-tree page: the whole page must be removed at the same time. This cannot be used for the root page, which is allowed to be empty. in: mtr

Discards a page from a B-tree. This is used to remove the last record from a B-tree page: the whole page must be removed at the same time. This cannot be used for the root page, which is allowed to be empty.

Parameters:
cursorin: cursor on the page to discard: not on the root page
mtrin: mtr

Definition at line 2895 of file btr0btr.cc.

References btr_block_get, btr_cur_get_block(), btr_cur_get_index(), btr_page_get_next(), btr_page_get_prev(), buf_block_get_page_no(), buf_block_get_page_zip, dict_index_get_lock(), dict_index_get_page(), dict_index_get_space(), dict_table_zip_size(), FIL_NULL, lock_get_min_heap_no(), lock_update_discard(), page_is_comp(), page_is_leaf(), page_rec_get_next(), page_rec_is_user_rec(), dict_index_struct::table, ut_a, and ut_ad.

UNIV_INTERN void btr_free_but_not_root ( ulint  space,
ulint  zip_size,
ulint  root_page_no 
)

Frees a B-tree except the root page, which MUST be freed after this by calling btr_free_root. in: root page number

Frees a B-tree except the root page, which MUST be freed after this by calling btr_free_root.

Parameters:
spacein: space where created
zip_sizein: compressed page size in bytes or 0 for uncompressed pages
root_page_noin: root page number

Definition at line 857 of file btr0btr.cc.

References btr_page_get, FIL_PAGE_DATA, mtr_commit(), mtr_start(), and ut_a.

UNIV_INTERN void btr_free_root ( ulint  space,
ulint  zip_size,
ulint  root_page_no,
mtr_t mtr 
)

Frees the B-tree root page. Other tree MUST already have been freed. in: a mini-transaction which has already been started

Frees the B-tree root page. Other tree MUST already have been freed.

Parameters:
spacein: space where created
zip_sizein: compressed page size in bytes or 0 for uncompressed pages
root_page_noin: root page number
mtrin: a mini-transaction which has already been started

Definition at line 913 of file btr0btr.cc.

References btr_block_get, and ut_a.

UNIV_INTERN rec_t* btr_get_next_user_rec ( rec_t *  rec,
mtr_t mtr 
)

Gets pointer to the next user record in the tree. It is assumed that the caller has appropriate latches on the page and its neighbor.

Returns:
next user record, NULL if there is none in: mtr holding a latch on the page, and if needed, also to the next page

Gets pointer to the next user record in the tree. It is assumed that the caller has appropriate latches on the page and its neighbor.

Returns:
next user record, NULL if there is none
Parameters:
recin: record on leaf level
mtrin: mtr holding a latch on the page, and if needed, also to the next page

Definition at line 233 of file btr0btr.cc.

References btr_page_get_next(), btr_page_get_prev(), buf_page_get_with_no_latch, FIL_NULL, page_align(), page_get_page_no(), page_get_space_id(), page_is_comp(), page_rec_get_next(), page_rec_is_supremum(), ut_a, and ut_ad.

UNIV_INTERN rec_t* btr_get_prev_user_rec ( rec_t *  rec,
mtr_t mtr 
)

Gets pointer to the previous user record in the tree. It is assumed that the caller has appropriate latches on the page and its neighbor.

Returns:
previous user record, NULL if there is none in: mtr holding a latch on the page, and if needed, also to the previous page

Gets pointer to the previous user record in the tree. It is assumed that the caller has appropriate latches on the page and its neighbor.

Returns:
previous user record, NULL if there is none
Parameters:
recin: record on leaf level
mtrin: mtr holding a latch on the page, and if needed, also to the previous page

Definition at line 175 of file btr0btr.cc.

References btr_page_get_next(), btr_page_get_prev(), buf_page_get_with_no_latch, FIL_NULL, page_align(), page_get_page_no(), page_get_space_id(), page_is_comp(), page_rec_get_prev(), page_rec_is_infimum(), ut_a, and ut_ad.

UNIV_INTERN ulint btr_get_size ( dict_index_t index,
ulint  flag 
)

Gets the number of pages in a B-tree.

Returns:
number of pages in: BTR_N_LEAF_PAGES or BTR_TOTAL_SIZE

Gets the number of pages in a B-tree.

Returns:
number of pages
Parameters:
indexin: index
flagin: BTR_N_LEAF_PAGES or BTR_TOTAL_SIZE

Definition at line 408 of file btr0btr.cc.

References dict_index_get_lock(), mtr_commit(), mtr_s_lock, mtr_start(), and ut_error.

UNIV_INTERN ibool btr_index_rec_validate ( const rec_t *  rec,
const dict_index_t index,
ibool  dump_on_error 
)

Checks the size and number of fields in a record based on the definition of the index.

Returns:
TRUE if ok in: TRUE if the function should print hex dump of record and page on error

Checks the size and number of fields in a record based on the definition of the index.

Returns:
TRUE if ok
Parameters:
recin: index record
indexin: index
dump_on_errorin: TRUE if the function should print hex dump of record and page on error

Definition at line 3201 of file btr0btr.cc.

References dict_col_get_fixed_size(), dict_index_get_n_fields(), dict_index_get_nth_col(), dict_table_is_comp(), DICT_UNIVERSAL, mem_heap_free, page_align(), page_is_comp(), rec_get_n_fields_old(), rec_get_nth_field_offs(), rec_print_new(), rec_print_old(), dict_index_struct::table, and dict_index_struct::type.

UNIV_INTERN void btr_insert_on_non_leaf_level_func ( dict_index_t index,
ulint  level,
dtuple_t tuple,
const char *  file,
ulint  line,
mtr_t mtr 
)

Inserts a data tuple to a tree on a non-leaf level. It is assumed that mtr holds an x-latch on the tree. in: mtr

Inserts a data tuple to a tree on a non-leaf level. It is assumed that mtr holds an x-latch on the tree.

Parameters:
indexin: index
levelin: level, must be > 0
tuplein: the record to be inserted
filein: file name
linein: line where called
mtrin: mtr

Definition at line 1673 of file btr0btr.cc.

References BTR_CONT_MODIFY_TREE, ut_a, and ut_ad.

UNIV_INLINE void btr_leaf_page_release ( buf_block_t block,
ulint  latch_mode,
mtr_t mtr 
)

Releases the latch on a leaf page and bufferunfixes it. in: mtr

Parameters:
blockin: buffer block
latch_modein: BTR_SEARCH_LEAF or BTR_MODIFY_LEAF

Referenced by btr_pcur_move_backward_from_page(), btr_pcur_move_to_next_page(), btr_pcur_release_leaf(), and btr_search_guess_on_hash().

UNIV_INTERN void btr_node_ptr_delete ( dict_index_t index,
buf_block_t block,
mtr_t mtr 
)

Deletes on the upper level the node pointer to a page. in: mtr

Deletes on the upper level the node pointer to a page.

Parameters:
indexin: index tree
blockin: page whose node pointer is deleted
mtrin: mtr

Definition at line 2380 of file btr0btr.cc.

References RB_NONE, ut_a, and ut_ad.

UNIV_INLINE ulint btr_node_ptr_get_child_page_no ( const rec_t *  rec,
const ulint *  offsets 
)

Gets the child node file address in a node pointer. NOTE: the offsets array must contain all offsets for the record since we read the last field according to offsets and assume that it contains the child page number. In other words offsets must have been retrieved with rec_get_offsets(n_fields=ULINT_UNDEFINED).

Returns:
child node address in: array returned by rec_get_offsets()
Parameters:
recin: node pointer record

Referenced by btr_cur_open_at_index_side_func(), btr_cur_open_at_rnd_pos_func(), and btr_cur_search_to_nth_level().

UNIV_INTERN buf_block_t* btr_page_alloc ( dict_index_t index,
ulint  hint_page_no,
byte  file_direction,
ulint  level,
mtr_t mtr 
)

Allocates a new file page to be used in an index tree. NOTE: we assume that the caller has made the reservation for free extents!

Returns:
new allocated block, x-latched; NULL if out of space in: mtr

Allocates a new file page to be used in an index tree. NOTE: we assume that the caller has made the reservation for free extents!

Returns:
new allocated block, x-latched; NULL if out of space
Parameters:
indexin: index
hint_page_noin: hint of a good page
file_directionin: direction where a possible page split is made
levelin: level where the page is placed in the tree
mtrin: mtr

Definition at line 356 of file btr0btr.cc.

References buf_page_get, dict_index_get_space(), dict_index_is_ibuf(), dict_table_zip_size(), FIL_NULL, and dict_index_struct::table.

UNIV_INTERN void btr_page_free ( dict_index_t index,
buf_block_t block,
mtr_t mtr 
)

Frees a file page used in an index tree. NOTE: cannot free field external storage pages because the page must contain info on its level. in: mtr

Frees a file page used in an index tree. NOTE: cannot free field external storage pages because the page must contain info on its level.

Parameters:
indexin: index tree
blockin: block to be freed, x-latched
mtrin: mtr

Definition at line 518 of file btr0btr.cc.

References btr_page_get_level().

UNIV_INTERN void btr_page_free_low ( dict_index_t index,
buf_block_t block,
ulint  level,
mtr_t mtr 
)

Frees a file page used in an index tree. Can be used also to BLOB external storage pages, because the page level 0 can be given as an argument. in: mtr

Frees a file page used in an index tree. Can be used also to (BLOB) external storage pages, because the page level 0 can be given as an argument.

Parameters:
indexin: index tree
blockin: block to be freed, x-latched
levelin: page level
mtrin: mtr

Definition at line 477 of file btr0btr.cc.

References buf_block_get_page_no(), buf_block_get_space(), buf_block_modify_clock_inc(), dict_index_is_ibuf(), and ut_ad.

UNIV_INLINE index_id_t btr_page_get_index_id ( const page_t page)
UNIV_INLINE ulint btr_page_get_level ( const page_t page,
mtr_t mtr 
)

Gets the node level field in an index page.

Returns:
level, leaf level == 0 in: mini-transaction handle
Parameters:
pagein: index page

Referenced by btr_cur_open_at_index_side_func(), btr_cur_open_at_rnd_pos_func(), btr_cur_pessimistic_delete(), btr_cur_search_to_nth_level(), btr_page_free(), btr_page_split_and_insert(), btr_root_raise_and_insert(), and btr_validate_index().

UNIV_INLINE ulint btr_page_get_level_low ( const page_t page)

Gets the node level field in an index page.

Returns:
level, leaf level == 0 in: index page
UNIV_INLINE ulint btr_page_get_next ( const page_t page,
mtr_t mtr 
)

Gets the next index page number.

Returns:
next page number in: mini-transaction handle
Parameters:
pagein: index page

Referenced by btr_compress(), btr_discard_page(), btr_estimate_number_of_different_key_vals(), btr_get_next_user_rec(), btr_get_prev_user_rec(), btr_pcur_move_to_next_page(), and btr_pcur_store_position().

UNIV_INLINE ulint btr_page_get_prev ( const page_t page,
mtr_t mtr 
)

Gets the previous index page number.

Returns:
prev page number in: mini-transaction handle
Parameters:
pagein: index page

Referenced by btr_compress(), btr_cur_pessimistic_delete(), btr_discard_page(), btr_estimate_number_of_different_key_vals(), btr_get_next_user_rec(), btr_get_prev_user_rec(), btr_pcur_move_backward_from_page(), btr_pcur_move_to_next_page(), and btr_pcur_store_position().

UNIV_INTERN ibool btr_page_get_split_rec_to_left ( btr_cur_t cursor,
rec_t **  split_rec 
)

Decides if the page should be split at the convergence point of inserts converging to left.

Returns:
TRUE if split recommended out: if split recommended, the first record on upper half page, or NULL if tuple should be first

Decides if the page should be split at the convergence point of inserts converging to the left.

Returns:
TRUE if split recommended
Parameters:
cursorin: cursor at which to insert
split_recout: if split recommended, the first record on upper half page, or NULL if tuple to be inserted should be first

Definition at line 1354 of file btr0btr.cc.

References btr_cur_get_page(), btr_cur_get_rec(), page_header_get_ptr, and page_rec_get_next().

UNIV_INTERN ibool btr_page_get_split_rec_to_right ( btr_cur_t cursor,
rec_t **  split_rec 
)

Decides if the page should be split at the convergence point of inserts converging to right.

Returns:
TRUE if split recommended out: if split recommended, the first record on upper half page, or NULL if tuple should be first

Decides if the page should be split at the convergence point of inserts converging to the right.

Returns:
TRUE if split recommended
Parameters:
cursorin: cursor at which to insert
split_recout: if split recommended, the first record on upper half page, or NULL if tuple to be inserted should be first

Definition at line 1399 of file btr0btr.cc.

References btr_cur_get_page(), btr_cur_get_rec(), page_header_get_ptr, page_rec_get_next(), and page_rec_is_supremum().

UNIV_INTERN ibool btr_page_reorganize ( buf_block_t block,
dict_index_t index,
mtr_t mtr 
)

Reorganizes an index page. IMPORTANT: if btr_page_reorganize() is invoked on a compressed leaf page of a non-clustered index, the caller must update the insert buffer free bits in the same mini-transaction in such a way that the modification will be redo-logged.

Returns:
TRUE on success, FALSE on failure in: mtr

Reorganizes an index page. IMPORTANT: if btr_page_reorganize() is invoked on a compressed leaf page of a non-clustered index, the caller must update the insert buffer free bits in the same mini-transaction in such a way that the modification will be redo-logged.

Returns:
TRUE on success, FALSE on failure
Parameters:
blockin: page to be reorganized
indexin: record descriptor
mtrin: mtr

Definition at line 1105 of file btr0btr.cc.

UNIV_INTERN rec_t* btr_page_split_and_insert ( btr_cur_t cursor,
const dtuple_t tuple,
ulint  n_ext,
mtr_t mtr 
)

Splits an index page to halves and inserts the tuple. It is assumed that mtr holds an x-latch to the index tree. NOTE: the tree x-latch is released within this function! NOTE that the operation of this function must always succeed, we cannot reverse it: therefore enough free disk space (2 pages) must be guaranteed to be available before this function is called.

Returns:
inserted record in: mtr

Splits an index page to halves and inserts the tuple. It is assumed that mtr holds an x-latch to the index tree. NOTE: the tree x-latch is released within this function! NOTE that the operation of this function must always succeed, we cannot reverse it: therefore enough free disk space (2 pages) must be guaranteed to be available before this function is called.

Returns:
inserted record
Parameters:
cursorin: cursor at which to insert; when the function returns, the cursor is positioned on the predecessor of the inserted record
tuplein: tuple to insert
n_extin: number of externally stored columns
mtrin: mtr

Definition at line 1878 of file btr0btr.cc.

References btr_cur_get_block(), btr_cur_get_rec(), btr_page_get_level(), buf_block_get_page_no(), buf_block_get_page_zip, buf_block_get_zip_size(), cmp_dtuple_rec(), dict_index_get_lock(), dict_index_get_n_unique_in_tree(), dict_index_is_clust(), btr_cur_struct::index, lock_move_rec_list_end(), lock_move_rec_list_start(), lock_update_split_left(), lock_update_split_right(), mem_free, mem_heap_create, mem_heap_empty(), mem_heap_free, mtr_memo_release(), page_cur_search(), page_cur_tuple_insert(), page_delete_rec_list_end(), page_delete_rec_list_start(), page_get_middle_rec(), page_get_n_recs(), page_is_leaf(), page_move_rec_list_end(), page_move_rec_list_start(), page_rec_get_next(), page_validate(), page_zip_copy_recs(), rec_convert_dtuple_to_rec(), rec_get_converted_size(), ut_a, and ut_ad.

UNIV_INTERN byte* btr_parse_page_reorganize ( byte *  ptr,
byte *  ,
dict_index_t index,
buf_block_t block,
mtr_t mtr 
)

Parses a redo log record of reorganizing a page.

Returns:
end of log record or NULL in: mtr or NULL

Parses a redo log record of reorganizing a page.

Returns:
end of log record or NULL
Parameters:
ptrin: buffer
indexin: record descriptor
blockin: page to be reorganized, or NULL
mtrin: mtr or NULL

Definition at line 1120 of file btr0btr.cc.

References ut_ad.

UNIV_INTERN byte* btr_parse_set_min_rec_mark ( byte *  ptr,
byte *  end_ptr,
ulint  comp,
page_t page,
mtr_t mtr 
)

Parses the redo log record for setting an index record as the predefined minimum record.

Returns:
end of log record or NULL in: mtr or NULL

Parses the redo log record for setting an index record as the predefined minimum record.

Returns:
end of log record or NULL
Parameters:
ptrin: buffer
end_ptrin: buffer end
compin: nonzero=compact page format
pagein: page or NULL
mtrin: mtr or NULL

Definition at line 2323 of file btr0btr.cc.

References mach_read_from_2(), page_is_comp(), and ut_a.

UNIV_INTERN page_t* btr_root_get ( dict_index_t index,
mtr_t mtr 
)

Gets the root node of a tree and x-latches it.

Returns:
root page, x-latched in: mtr

Gets the root node of a tree and x-latches it.

Returns:
root page, x-latched
Parameters:
indexin: index tree
mtrin: mtr

Definition at line 161 of file btr0btr.cc.

UNIV_INTERN rec_t* btr_root_raise_and_insert ( btr_cur_t cursor,
const dtuple_t tuple,
ulint  n_ext,
mtr_t mtr 
)

Makes tree one level higher by splitting the root, and inserts the tuple. It is assumed that mtr contains an x-latch on the tree. NOTE that the operation of this function must always succeed, we cannot reverse it: therefore enough free disk space must be guaranteed to be available before this function is called.

Returns:
inserted record in: mtr

Makes tree one level higher by splitting the root, and inserts the tuple. It is assumed that mtr contains an x-latch on the tree. NOTE that the operation of this function must always succeed, we cannot reverse it: therefore enough free disk space must be guaranteed to be available before this function is called.

Returns:
inserted record
Parameters:
cursorin: cursor at which to insert: must be on the root page; when the function returns, the cursor is positioned on the predecessor of the inserted record
tuplein: tuple to insert
n_extin: number of externally stored columns
mtrin: mtr

Definition at line 1185 of file btr0btr.cc.

References btr_cur_get_block(), btr_cur_get_index(), btr_cur_get_page(), btr_page_get_level(), buf_block_get_page_no(), buf_block_get_page_zip, dict_index_get_lock(), dict_index_get_page(), dict_index_get_space(), dict_index_is_clust(), dict_index_is_ibuf(), dtuple_get_info_bits(), dtuple_set_info_bits(), FIL_NULL, FIL_PAGE_DATA, lock_move_rec_list_end(), lock_update_root_raise(), mem_heap_create, mem_heap_free, page_copy_rec_list_end(), page_cur_search(), page_cur_set_before_first(), page_cur_tuple_insert(), page_get_page_no(), page_rec_get_next(), page_zip_copy_recs(), page_zip_get_size(), ut_a, and ut_ad.

UNIV_INTERN void btr_set_min_rec_mark ( rec_t *  rec,
mtr_t mtr 
)

Sets a record as the predefined minimum record. in: mtr

Sets a record as the predefined minimum record.

Parameters:
recin: record
mtrin: mtr

Definition at line 2353 of file btr0btr.cc.

References MLOG_COMP_REC_MIN_MARK, MLOG_REC_MIN_MARK, page_rec_is_comp(), rec_get_info_bits(), rec_set_info_bits_new(), and rec_set_info_bits_old().

UNIV_INTERN ibool btr_validate_index ( dict_index_t index,
trx_t trx 
)

Checks the consistency of an index tree.

Returns:
TRUE if ok in: transaction or NULL

Checks the consistency of an index tree.

Returns:
TRUE if ok
Parameters:
indexin: index
trxin: transaction or NULL

Definition at line 3729 of file btr0btr.cc.

References btr_page_get_level(), dict_index_get_lock(), mtr_commit(), mtr_start(), mtr_x_lock, and trx_is_interrupted().