MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
btr0cur.cc File Reference
#include "btr0cur.h"
#include "row0upd.h"
#include "mtr0log.h"
#include "page0page.h"
#include "page0zip.h"
#include "rem0rec.h"
#include "rem0cmp.h"
#include "buf0lru.h"
#include "btr0btr.h"
#include "btr0sea.h"
#include "row0log.h"
#include "row0purge.h"
#include "trx0rec.h"
#include "trx0roll.h"
#include "que0que.h"
#include "row0row.h"
#include "srv0srv.h"
#include "ibuf0ibuf.h"
#include "lock0lock.h"
#include "zlib.h"
Include dependency graph for btr0cur.cc:

Go to the source code of this file.

Macros

#define BTR_CUR_PAGE_REORGANIZE_LIMIT   (UNIV_PAGE_SIZE / 32)
#define N_PAGES_READ_LIMIT   10
#define btr_rec_get_field_ref(rec, offsets, n)   ((rec) + btr_rec_get_field_ref_offs(offsets, n))
#define BTR_BLOB_HDR_PART_LEN   0
#define BTR_BLOB_HDR_NEXT_PAGE_NO   4
#define BTR_BLOB_HDR_SIZE   8
#define BTR_TABLE_STATS_FROM_SAMPLE(value, index, sample, ext_size, not_empty)

Enumerations

enum  btr_op_t {
  BTR_NO_OP = 0, BTR_INSERT_OP, BTR_INSERT_IGNORE_UNIQUE_OP, BTR_DELETE_OP,
  BTR_DELMARK_OP
}

Functions

UNIV_INLINE void btr_rec_set_deleted_flag (rec_t *rec, page_zip_des_t *page_zip, ulint flag)
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)

Variables

UNIV_INTERN ulint btr_cur_n_non_sea = 0
UNIV_INTERN ulint btr_cur_n_sea = 0
UNIV_INTERN ulint btr_cur_n_non_sea_old = 0
UNIV_INTERN ulint btr_cur_n_sea_old = 0
const byte field_ref_zero [BTR_EXTERN_FIELD_REF_SIZE]
static const dtuple_ttuple
static const dtuple_t ulint ** offsets
static const dtuple_t ulint
mem_heap_t ** 
heap
static const dtuple_t ulint
mem_heap_t ulint 
n_ext

Detailed Description

The index tree cursor

All changes that row operations make to a B-tree or the records there must go through this module! Undo log records are written here of every modify or insert of a clustered index record.

                    NOTE!!!

To make sure we do not run out of disk space during a pessimistic insert or update, we have to reserve 2 x the height of the index tree many pages in the tablespace before we start the operation, because if leaf splitting has been started, it is difficult to undo, except by crashing the database and doing a roll-forward.

Created 10/16/1994 Heikki Tuuri

Definition in file btr0cur.cc.

Macro Definition Documentation

#define BTR_BLOB_HDR_NEXT_PAGE_NO   4

next BLOB part page no, FIL_NULL if none

Definition at line 116 of file btr0cur.cc.

#define BTR_BLOB_HDR_PART_LEN   0

The structure of a BLOB part header BLOB part len on this page

Definition at line 114 of file btr0cur.cc.

#define BTR_BLOB_HDR_SIZE   8

Size of a BLOB part header, in bytes

Definition at line 119 of file btr0cur.cc.

#define BTR_CUR_PAGE_REORGANIZE_LIMIT   (UNIV_PAGE_SIZE / 32)
In the optimistic insert, if the insert does not fit, but this much space

can be released by page reorganize, then it is reorganized

Definition at line 109 of file btr0cur.cc.

#define BTR_TABLE_STATS_FROM_SAMPLE (   value,
  index,
  sample,
  ext_size,
  not_empty 
)
Value:
(((value) * (ib_int64_t) index->stat_n_leaf_pages \
+ (sample) - 1 + (ext_size) + (not_empty)) / ((sample) + (ext_size)))
Estimated table level stats from sampled value.
Parameters
valuesampled stats
indexindex being sampled
samplenumber of sampled rows
ext_sizeexternal stored data size
not_emptytable not empty
Returns
estimated table wide stats from sampled value

Definition at line 129 of file btr0cur.cc.

Enumeration Type Documentation

enum btr_op_t

Buffered B-tree operation types, introduced as part of delete buffering.

Enumerator:
BTR_NO_OP 

Not buffered

BTR_INSERT_OP 

Insert, do not ignore UNIQUE

BTR_INSERT_IGNORE_UNIQUE_OP 

Insert, ignoring UNIQUE

BTR_DELETE_OP 

Purge a delete-marked record

BTR_DELMARK_OP 

Mark a record for deletion

Definition at line 74 of file btr0cur.cc.

Function Documentation

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.

Parameters
from_leftin: true if open to the low end, false if to the high end
indexin: index
latch_modein: latch mode
cursorin/out: cursor
levelin: level to search for (0=leaf).
filein: file name
linein: line where called
mtrin/out: mini-transaction

Definition at line 839 of file btr0cur.cc.

Here is the call graph for this function:

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.

Parameters
indexin: index
latch_modein: BTR_SEARCH_LEAF, ...
cursorin/out: B-tree cursor
filein: file name
linein: line where called
mtrin: mtr

Definition at line 999 of file btr0cur.cc.

Here is the call graph for this function:

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.

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.

Parameters
indexin: index
levelin: the tree level of search
tuplein: data tuple; NOTE: n_fields_cmp in tuple must be set so that it cannot get compared to the node ptr page number field!
modein: PAGE_CUR_L, ...; Inserts should always be made using PAGE_CUR_LE to search the position!
latch_modein: 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!
cursorin/out: tree cursor; the cursor page is s- or x-latched, but see also above!
has_search_latchin: info on the latch mode the caller currently has on btr_search_latch: RW_S_LATCH, or 0
filein: file name
linein: line where called
mtrin: mtr

Definition at line 359 of file btr0cur.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INLINE void btr_rec_set_deleted_flag ( rec_t *  rec,
page_zip_des_t page_zip,
ulint  flag 
)

The following function is used to set the deleted bit of a record.

Parameters
recin/out: physical record
page_zipin/out: compressed page (or NULL)
flagin: nonzero if delete marked

Definition at line 220 of file btr0cur.cc.

Here is the call graph for this function:

Variable Documentation

UNIV_INTERN ulint btr_cur_n_non_sea = 0

Number of searches down the B-tree in btr_cur_search_to_nth_level().

Definition at line 89 of file btr0cur.cc.

UNIV_INTERN ulint btr_cur_n_non_sea_old = 0
Old value of btr_cur_n_non_sea.  Copied by

srv_refresh_innodb_monitor_stats(). Referenced by srv_printf_innodb_monitor().

Definition at line 96 of file btr0cur.cc.

UNIV_INTERN ulint btr_cur_n_sea = 0
Number of successful adaptive hash index lookups in

btr_cur_search_to_nth_level().

Definition at line 92 of file btr0cur.cc.

UNIV_INTERN ulint btr_cur_n_sea_old = 0
Old value of btr_cur_n_sea.  Copied by

srv_refresh_innodb_monitor_stats(). Referenced by srv_printf_innodb_monitor().

Definition at line 100 of file btr0cur.cc.

const byte field_ref_zero[BTR_EXTERN_FIELD_REF_SIZE]
Initial value:
{
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
}
A BLOB field reference full of zero, for use in assertions and tests.

Initially, BLOB field references are set to zero, in dtuple_convert_big_rec().

Definition at line 139 of file btr0cur.cc.

const dtuple_t ulint mem_heap_t** heap

in/out: pointer to memory heap, or NULL

Definition at line 1103 of file btr0cur.cc.

const dtuple_t ulint mem_heap_t ulint n_ext

in: number of externally stored columns

Definition at line 1103 of file btr0cur.cc.

const dtuple_t ulint** offsets

out: offsets on *rec

Definition at line 1103 of file btr0cur.cc.

const dtuple_t* tuple

< in: cursor on page after which to insert; cursor stays valid in: tuple to insert; the size info need not have been stored to tuple

Definition at line 1103 of file btr0cur.cc.