MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
btr0btr.cc File Reference
#include "btr0btr.h"
#include "fsp0fsp.h"
#include "page0page.h"
#include "page0zip.h"
#include "btr0cur.h"
#include "btr0sea.h"
#include "btr0pcur.h"
#include "rem0cmp.h"
#include "lock0lock.h"
#include "ibuf0ibuf.h"
#include "trx0trx.h"
#include "srv0mon.h"
Include dependency graph for btr0btr.cc:

Go to the source code of this file.

Macros

#define btr_page_get_father_node_ptr(of, heap, cur, mtr)   btr_page_get_father_node_ptr_func(of,heap,cur,__FILE__,__LINE__,mtr)
#define btr_level_list_remove(space, zip_size, page, index, mtr)   btr_level_list_remove_func(space,zip_size,page,mtr)

Functions

UNIV_INTERN ibool btr_can_merge_with_page (btr_cur_t *cursor, ulint page_no, buf_block_t **merge_block, mtr_t *mtr)
UNIV_INTERN void btr_corruption_report (const buf_block_t *block, const dict_index_t *index)
UNIV_INTERN page_tbtr_root_get (const dict_index_t *index, mtr_t *mtr)
UNIV_INTERN ulint btr_height_get (dict_index_t *index, mtr_t *mtr)
UNIV_INTERN dberr_t btr_root_adjust_on_import (const dict_index_t *index)
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)
 if (level==0)
UNIV_INTERN buf_block_tbtr_page_alloc (dict_index_t *index, ulint hint_page_no, byte file_direction, ulint level, mtr_t *mtr, mtr_t *init_mtr)
UNIV_INTERN ulint btr_get_size (dict_index_t *index, ulint flag, 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 void btr_page_free (dict_index_t *index, buf_block_t *block, mtr_t *mtr)
UNIV_INLINE void btr_node_ptr_set_child_page_no (rec_t *rec, page_zip_des_t *page_zip, const ulint *offsets, ulint page_no, mtr_t *mtr)
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 bool btr_page_reorganize_low (bool recovery, ulint z_level, page_cur_t *cursor, dict_index_t *index, mtr_t *mtr)

Variables

static ulint hint_page_no
static ulint byte file_direction
static ulint byte ulint level
static ulint byte ulint mtr_tmtr
static ulint byte ulint mtr_t
mtr_t *init_mtr fseg_header_t * 
seg_header
page_troot = btr_root_get(index, mtr)
static ulint z_level
static ulint buf_block_tblock
static ulint buf_block_t
dict_index_t
index

Detailed Description

The B-tree

Created 6/2/1994 Heikki Tuuri

Definition in file btr0btr.cc.

Function Documentation

UNIV_INTERN ibool btr_can_merge_with_page ( btr_cur_t cursor,
ulint  page_no,
buf_block_t **  merge_block,
mtr_t mtr 
)

Checks if the page in the cursor can be merged with given page. If necessary, re-organize the merge_page.

Returns
TRUE if possible to merge. in: mini-transaction
Parameters
cursorin: cursor on the page to merge
page_noin: a sibling page
merge_blockout: the merge block
UNIV_INTERN void btr_corruption_report ( const buf_block_t block,
const dict_index_t index 
)

Report that an index page is corrupted.

Parameters
blockin: corrupted block
indexin: index tree

Definition at line 66 of file btr0btr.cc.

Here is the call graph for this function:

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
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 1527 of file btr0btr.cc.

Here is the call graph for this function:

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.

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 1658 of file btr0btr.cc.

Here is the call graph for this function:

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.

Parameters
spacein: space where created
zip_sizein: compressed page size in bytes or 0 for uncompressed pages
root_page_noin: root page number
mtrin/out: mini-transaction

Definition at line 1716 of file btr0btr.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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
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 980 of file btr0btr.cc.

Here is the call graph for this function:

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
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 922 of file btr0btr.cc.

Here is the call graph for this function:

UNIV_INTERN ulint btr_get_size ( dict_index_t index,
ulint  flag,
mtr_t mtr 
)

Gets the number of pages in a B-tree.

Returns
number of pages, or ULINT_UNDEFINED if the index is unavailable
Parameters
indexin: index
flagin: BTR_N_LEAF_PAGES or BTR_TOTAL_SIZE
mtrin/out: mini-transaction where index is s-latched

Definition at line 1189 of file btr0btr.cc.

Here is the call graph for this function:

UNIV_INTERN ulint btr_height_get ( dict_index_t index,
mtr_t mtr 
)

Gets the height of the B-tree (the level of the root, when the leaf level is assumed to be 0). The caller must hold an S or X latch on the index.

Returns
tree height (level of the root)
Parameters
indexin: index tree
mtrin/out: mini-transaction

Definition at line 772 of file btr0btr.cc.

Here is the call graph for this function:

UNIV_INLINE void btr_node_ptr_set_child_page_no ( rec_t *  rec,
page_zip_des_t page_zip,
const ulint *  offsets,
ulint  page_no,
mtr_t mtr 
)

Sets the child node file address in a node pointer.

Parameters
recin: node pointer record
page_zipin/out: compressed page whose uncompressed part will be updated, or NULL
offsetsin: array returned by rec_get_offsets()
page_noin: child node address
mtrin: mtr

Definition at line 1329 of file btr0btr.cc.

Here is the call graph for this function:

UNIV_INTERN buf_block_t* btr_page_alloc ( dict_index_t index,
ulint  hint_page_no,
byte  file_direction,
ulint  level,
mtr_t mtr,
mtr_t init_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!

Return values
NULLif no page could be allocated
block,rw_lock_x_lock_count(&block->lock)== 1 if allocation succeeded (init_mtr == mtr, or the page was not previously freed in mtr)
block(not allocated or initialized) otherwise
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/out: mini-transaction for the allocation
init_mtrin/out: mini-transaction for x-latching and initializing the page

Definition at line 1153 of file btr0btr.cc.

Here is the call graph for this function:

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.

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

Definition at line 1312 of file btr0btr.cc.

Here is the call graph for this function:

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.

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

Definition at line 1261 of file btr0btr.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN bool btr_page_reorganize_low ( bool  recovery,
ulint  z_level,
page_cur_t cursor,
dict_index_t index,
mtr_t mtr 
)

Reorganizes an index page.

IMPORTANT: On success, the caller will have to update IBUF_BITMAP_FREE if this is a compressed leaf page in a secondary index. This has to be done either within the same mini-transaction, or by invoking ibuf_reset_free_bits() before mtr_commit(). On uncompressed pages, IBUF_BITMAP_FREE is unaffected by reorganization.

Return values
trueif the operation was successful
falseif it is a compressed page, and recompression failed
Parameters
recoveryin: true if called in recovery: locks should not be updated, i.e., there cannot exist locks on the page, and a hash index should not be dropped: it cannot exist
z_levelin: compression level to be used if dealing with compressed page
cursorin/out: page cursor
indexin: the index tree of the page
mtrin/out: mini-transaction

Definition at line 1756 of file btr0btr.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN dberr_t btr_root_adjust_on_import ( const dict_index_t index)

Checks and adjusts the root node of a tree during IMPORT TABLESPACE.

Returns
error code, or DB_SUCCESS
Parameters
indexin: index tree

Definition at line 837 of file btr0btr.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN page_t* btr_root_get ( const dict_index_t index,
mtr_t 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 756 of file btr0btr.cc.

Here is the caller graph for this function:

Variable Documentation

ulint buf_block_t* block

in/out: B-tree page

Definition at line 1980 of file btr0btr.cc.

ulint byte file_direction

in: direction where a possible page split is made

Definition at line 1110 of file btr0btr.cc.

ulint hint_page_no

< in: index in: hint of a good page

Definition at line 1110 of file btr0btr.cc.

char * index

in: the index tree of the page

Definition at line 1980 of file btr0btr.cc.

ulint byte ulint level

in: level where the page is placed in the tree

Definition at line 1110 of file btr0btr.cc.

ulint byte ulint mtr_t* mtr

in/out: mini-transaction for the allocation

Definition at line 1110 of file btr0btr.cc.

ulint byte ulint mtr_t mtr_t* init_mtr fseg_header_t* seg_header

< in/out: mtr or another mini-transaction in which the page should be initialized. If init_mtr!=mtr, but the page is already X-latched in mtr, do not initialize the page.

Definition at line 1110 of file btr0btr.cc.

ulint z_level

< in: true if called in recovery: locks should not be updated, i.e., there cannot exist locks on the page, and a hash index should not be dropped: it cannot exist in: compression level to be used if dealing with compressed page

Definition at line 1980 of file btr0btr.cc.