MySQL 8.0.40
Source Code Documentation
|
Index page routines. More...
#include "my_dbug.h"
#include "btr0btr.h"
#include "buf0buf.h"
#include "ibuf0ibuf.h"
#include "page0cur.h"
#include "page0page.h"
#include "page0zip.h"
#include "btr0sea.h"
#include "fut0lst.h"
#include "lock0lock.h"
#include "srv0srv.h"
Functions | |
ulint | page_dir_find_owner_slot (const rec_t *rec) |
Looks for the directory slot which owns the given record. More... | |
static bool | page_dir_slot_check (const page_dir_slot_t *slot) |
Used to check the consistency of a directory slot. More... | |
void | page_set_max_trx_id (buf_block_t *block, page_zip_des_t *page_zip, trx_id_t trx_id, mtr_t *mtr) |
Sets the max trx id field value. More... | |
byte * | page_mem_alloc_heap (page_t *page, page_zip_des_t *page_zip, ulint need, ulint *heap_no) |
Allocates a block of memory from the heap of an index page. More... | |
static void | page_create_write_log (buf_frame_t *frame, mtr_t *mtr, bool comp, page_type_t page_type) |
Writes a log record of page creation. More... | |
static page_t * | page_create_low (buf_block_t *block, ulint comp, page_type_t page_type) |
The index page creation function. More... | |
void | page_parse_create (buf_block_t *block, ulint comp, page_type_t page_type) |
Parses a redo log record of creating a page. More... | |
page_t * | page_create (buf_block_t *block, mtr_t *mtr, ulint comp, page_type_t page_type) |
Create an uncompressed B-tree or R-tree or SDI index page. More... | |
page_t * | page_create_zip (buf_block_t *block, dict_index_t *index, ulint level, trx_id_t max_trx_id, mtr_t *mtr, page_type_t page_type) |
Create a compressed B-tree index page. More... | |
void | page_create_empty (buf_block_t *block, dict_index_t *index, mtr_t *mtr) |
Empty a previously created B-tree index page. More... | |
void | page_copy_rec_list_end_no_locks (buf_block_t *new_block, buf_block_t *block, rec_t *rec, dict_index_t *index, mtr_t *mtr) |
Differs from page_copy_rec_list_end, because this function does not touch the lock table and max trx id on page or compress the page. More... | |
rec_t * | page_copy_rec_list_end (buf_block_t *new_block, buf_block_t *block, rec_t *rec, dict_index_t *index, mtr_t *mtr) |
Copies records from page to new_page, from a given record onward, including that record. More... | |
rec_t * | page_copy_rec_list_start (buf_block_t *new_block, buf_block_t *block, rec_t *rec, dict_index_t *index, mtr_t *mtr) |
Copies records from page to new_page, up to the given record, NOT including that record. More... | |
static void | page_delete_rec_list_write_log (rec_t *rec, dict_index_t *index, mlog_id_t type, mtr_t *mtr) |
Writes a log record of a record list end or start deletion. More... | |
byte * | page_parse_delete_rec_list (mlog_id_t type, byte *ptr, byte *end_ptr, buf_block_t *block, dict_index_t *index, mtr_t *mtr) |
Parses a log record of a record list end or start deletion. More... | |
void | page_delete_rec_list_end (rec_t *rec, buf_block_t *block, dict_index_t *index, ulint n_recs, ulint size, mtr_t *mtr) |
Deletes records from a page from a given record onward, including that record. More... | |
void | page_delete_rec_list_start (rec_t *rec, buf_block_t *block, dict_index_t *index, mtr_t *mtr) |
Deletes records from page, up to the given record, NOT including that record. More... | |
bool | page_move_rec_list_end (buf_block_t *new_block, buf_block_t *block, rec_t *split_rec, dict_index_t *index, mtr_t *mtr) |
Moves record list end to another page. More... | |
bool | page_move_rec_list_start (buf_block_t *new_block, buf_block_t *block, rec_t *split_rec, dict_index_t *index, mtr_t *mtr) |
Moves record list start to another page. More... | |
static void | page_dir_delete_slot (page_t *page, page_zip_des_t *page_zip, ulint slot_no) |
Used to delete n slots from the directory. More... | |
static void | page_dir_add_slot (page_t *page, page_zip_des_t *page_zip, ulint start) |
Used to add n slots to the directory. More... | |
void | page_dir_split_slot (page_t *page, page_zip_des_t *page_zip, ulint slot_no) |
Splits a directory slot which owns too many records. More... | |
void | page_dir_balance_slot (page_t *page, page_zip_des_t *page_zip, ulint slot_no) |
Tries to balance the given directory slot with too few records with the upper neighbor, so that there are at least the minimum number of records owned by the slot; this may result in the merging of two slots. More... | |
const rec_t * | page_rec_get_nth_const (const page_t *page, ulint nth) |
Returns the nth record of the record list. More... | |
ulint | page_rec_get_n_recs_before (const rec_t *rec) |
Returns the number of records before the given record in chain. More... | |
void | page_rec_print (const rec_t *rec, const ulint *offsets) |
Prints record contents including the data relevant only in the index page context. More... | |
bool | page_rec_validate (const rec_t *rec, const ulint *offsets) |
The following is used to validate a record on a page. More... | |
void | page_check_dir (const page_t *page) |
Checks that the first directory slot points to the infimum record and the last to the supremum. More... | |
bool | page_simple_validate_old (const page_t *page) |
This function checks the consistency of an index page when we do not know the index. More... | |
bool | page_simple_validate_new (const page_t *page) |
This function checks the consistency of an index page when we do not know the index. More... | |
bool | page_is_spatial_non_leaf (const rec_t *rec, dict_index_t *index) |
This function checks if the page in which record is present is a non-leaf node of a spatial index. More... | |
bool | page_validate (const page_t *page, dict_index_t *index) |
This function checks the consistency of an index page. More... | |
const rec_t * | page_find_rec_with_heap_no (const page_t *page, ulint heap_no) |
Looks in the page record list for a record with the given heap number. More... | |
bool | page_delete_rec (const dict_index_t *index, page_cur_t *pcur, const ulint *offsets) |
Removes the record from a leaf page. More... | |
const rec_t * | page_find_rec_last_not_deleted (const page_t *page) |
Get the last non-delete-marked record on a page. More... | |
void | page_warn_strict_checksum (srv_checksum_algorithm_t curr_algo, srv_checksum_algorithm_t page_checksum, const page_id_t &page_id) |
Issue a warning when the checksum that is stored in the page is valid, but different than the global setting innodb_checksum_algorithm. More... | |
Variables | |
static const byte | infimum_supremum_redundant [] |
The page infimum and supremum of an empty page in ROW_FORMAT=REDUNDANT. More... | |
static const byte | infimum_supremum_compact [] |
The page infimum and supremum of an empty page in ROW_FORMAT=COMPACT. More... | |
Index page routines.
Created 2/2/1994 Heikki Tuuri
void page_check_dir | ( | const page_t * | page | ) |
Checks that the first directory slot points to the infimum record and the last to the supremum.
This function is intended to track if the bug fixed in 4.0.14 has caused corruption to users' databases.
page | in: index page |
rec_t * page_copy_rec_list_end | ( | buf_block_t * | new_block, |
buf_block_t * | block, | ||
rec_t * | rec, | ||
dict_index_t * | index, | ||
mtr_t * | mtr | ||
) |
Copies records from page to new_page, from a given record onward, including that record.
Copies records from page to new_page, from the given record onward, including that record.
Infimum and supremum records are not copied. The records are copied to the start of the record list on new_page.
IMPORTANT: The caller will have to update IBUF_BITMAP_FREE if new_block 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().
new_block | in/out: index page to copy to |
block | in: index page containing rec |
rec | in: record on page |
index | in: record descriptor |
mtr | in: mtr |
void page_copy_rec_list_end_no_locks | ( | buf_block_t * | new_block, |
buf_block_t * | block, | ||
rec_t * | rec, | ||
dict_index_t * | index, | ||
mtr_t * | mtr | ||
) |
Differs from page_copy_rec_list_end, because this function does not touch the lock table and max trx id on page or compress the page.
IMPORTANT: The caller will have to update IBUF_BITMAP_FREE if new_block 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().
new_block | in: index page to copy to |
block | in: index page of rec |
rec | in: record on page |
index | in: record descriptor |
mtr | in: mtr |
rec_t * page_copy_rec_list_start | ( | buf_block_t * | new_block, |
buf_block_t * | block, | ||
rec_t * | rec, | ||
dict_index_t * | index, | ||
mtr_t * | mtr | ||
) |
Copies records from page to new_page, up to the given record, NOT including that record.
Infimum and supremum records are not copied. The records are copied to the end of the record list on new_page.
IMPORTANT: The caller will have to update IBUF_BITMAP_FREE if new_block 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().
new_block | in/out: index page to copy to |
block | in: index page containing rec |
rec | in: record on page |
index | in: record descriptor |
mtr | in: mtr |
page_t * page_create | ( | buf_block_t * | block, |
mtr_t * | mtr, | ||
ulint | comp, | ||
page_type_t | page_type | ||
) |
Create an uncompressed B-tree or R-tree or SDI index page.
[in] | block | A buffer block where the page is created |
[in] | mtr | Mini-transaction handle |
[in] | comp | nonzero=compact page format |
[in] | page_type | Page type |
void page_create_empty | ( | buf_block_t * | block, |
dict_index_t * | index, | ||
mtr_t * | mtr | ||
) |
Empty a previously created B-tree index page.
[in,out] | block | B-tree block |
[in] | index | The index of the page |
[in,out] | mtr | Mini-transaction |
|
static |
The index page creation function.
[in,out] | block | a buffer block where the page is created |
[in] | comp | nonzero=compact page format |
[in] | page_type | page type |
|
inlinestatic |
Writes a log record of page creation.
[in] | frame | A buffer frame where the page is created |
[in] | mtr | Mini-transaction handle |
[in] | comp | true=compact page format |
[in] | page_type | Page type |
page_t * page_create_zip | ( | buf_block_t * | block, |
dict_index_t * | index, | ||
ulint | level, | ||
trx_id_t | max_trx_id, | ||
mtr_t * | mtr, | ||
page_type_t | page_type | ||
) |
Create a compressed B-tree index page.
[in,out] | block | Buffer frame where the page is created |
[in] | index | Index of the page, or NULL when applying TRUNCATE log record during recovery |
[in] | level | The B-tree level of the page |
[in] | max_trx_id | PAGE_MAX_TRX_ID |
[in] | mtr | Mini-transaction handle |
[in] | page_type | Page type to be created. Only FIL_PAGE_INDEX, FIL_PAGE_RTREE, FIL_PAGE_SDI allowed |
bool page_delete_rec | ( | const dict_index_t * | index, |
page_cur_t * | pcur, | ||
const ulint * | offsets | ||
) |
Removes the record from a leaf page.
This function does not log any changes. It is used by the IMPORT tablespace functions.
[in] | index | The index that the record belongs to. |
[in,out] | pcur | Page cursor on record to delete. |
[in] | offsets | Offsets for record. |
void page_delete_rec_list_end | ( | rec_t * | rec, |
buf_block_t * | block, | ||
dict_index_t * | index, | ||
ulint | n_recs, | ||
ulint | size, | ||
mtr_t * | mtr | ||
) |
Deletes records from a page from a given record onward, including that record.
The infimum and supremum records are not deleted.
rec | in: pointer to record on page |
block | in: buffer block of the page |
index | in: record descriptor |
n_recs | in: number of records to delete, or ULINT_UNDEFINED if not known |
size | in: the sum of the sizes of the records in the end of the chain to delete, or ULINT_UNDEFINED if not known |
mtr | in: mtr |
void page_delete_rec_list_start | ( | rec_t * | rec, |
buf_block_t * | block, | ||
dict_index_t * | index, | ||
mtr_t * | mtr | ||
) |
Deletes records from page, up to the given record, NOT including that record.
Infimum and supremum records are not deleted.
rec | in: record on page |
block | in: buffer block of the page |
index | in: record descriptor |
mtr | in: mtr |
|
inlinestatic |
Writes a log record of a record list end or start deletion.
rec | in: record on page |
index | in: record descriptor |
type | in: operation type: MLOG_LIST_END_DELETE, ... |
mtr | in: mtr |
|
inlinestatic |
Used to add n slots to the directory.
Does not set the record pointers in the added slots or update n_owned values: this is the responsibility of the caller.
page | in/out: the index page |
page_zip | in/out: comprssed page, or NULL |
start | in: the slot above which the new slots are added |
void page_dir_balance_slot | ( | page_t * | page, |
page_zip_des_t * | page_zip, | ||
ulint | slot_no | ||
) |
Tries to balance the given directory slot with too few records with the upper neighbor, so that there are at least the minimum number of records owned by the slot; this may result in the merging of two slots.
[in,out] | page | Index page |
[in,out] | page_zip | Compressed page, or null |
[in] | slot_no | The directory slot |
|
inlinestatic |
Used to delete n slots from the directory.
This function updates also n_owned fields in the records, so that the first slot after the deleted ones inherits the records of the deleted slots.
page | in/out: the index page |
page_zip | in/out: compressed page, or NULL |
slot_no | in: slot to be deleted |
Looks for the directory slot which owns the given record.
rec | in: the physical record |
|
static |
Used to check the consistency of a directory slot.
slot | in: slot |
void page_dir_split_slot | ( | page_t * | page, |
page_zip_des_t * | page_zip, | ||
ulint | slot_no | ||
) |
Splits a directory slot which owns too many records.
[in,out] | page | Index page |
[in,out] | page_zip | Compressed page whose uncompressed part will be written, or null |
[in] | slot_no | The directory slot |
Get the last non-delete-marked record on a page.
[in] | page | index tree leaf page |
infimum | record if all records are delete-marked |
Looks in the page record list for a record with the given heap number.
page | in: index page |
heap_no | in: heap number |
bool page_is_spatial_non_leaf | ( | const rec_t * | rec, |
dict_index_t * | index | ||
) |
This function checks if the page in which record is present is a non-leaf node of a spatial index.
param[in] rec Btree record param[in] index index
byte * page_mem_alloc_heap | ( | page_t * | page, |
page_zip_des_t * | page_zip, | ||
ulint | need, | ||
ulint * | heap_no | ||
) |
Allocates a block of memory from the heap of an index page.
page | in/out: index page |
page_zip | in/out: compressed page with enough space available for inserting the record, or NULL |
need | in: total number of bytes needed |
heap_no | out: this contains the heap number of the allocated record if allocation succeeds |
bool page_move_rec_list_end | ( | buf_block_t * | new_block, |
buf_block_t * | block, | ||
rec_t * | split_rec, | ||
dict_index_t * | index, | ||
mtr_t * | mtr | ||
) |
Moves record list end to another page.
Moved records include split_rec.
IMPORTANT: The caller will have to update IBUF_BITMAP_FREE if new_block 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().
new_block | in/out: index page where to move |
block | in: index page from where to move |
split_rec | in: first record to move |
index | in: record descriptor |
mtr | in: mtr |
bool page_move_rec_list_start | ( | buf_block_t * | new_block, |
buf_block_t * | block, | ||
rec_t * | split_rec, | ||
dict_index_t * | index, | ||
mtr_t * | mtr | ||
) |
Moves record list start to another page.
Moved records do not include split_rec.
IMPORTANT: The caller will have to update IBUF_BITMAP_FREE if new_block 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().
new_block | in/out: index page where to move |
block | in/out: page containing split_rec |
split_rec | in: first record not to move |
index | in: record descriptor |
mtr | in: mtr |
void page_parse_create | ( | buf_block_t * | block, |
ulint | comp, | ||
page_type_t | page_type | ||
) |
Parses a redo log record of creating a page.
[in,out] | block | buffer block, or NULL |
[in] | comp | nonzero=compact page format |
[in] | page_type | page type (FIL_PAGE_INDEX, FIL_PAGE_RTREE or FIL_PAGE_SDI) |
byte * page_parse_delete_rec_list | ( | mlog_id_t | type, |
byte * | ptr, | ||
byte * | end_ptr, | ||
buf_block_t * | block, | ||
dict_index_t * | index, | ||
mtr_t * | mtr | ||
) |
Parses a log record of a record list end or start deletion.
type | in: MLOG_LIST_END_DELETE, MLOG_LIST_START_DELETE, MLOG_COMP_LIST_END_DELETE or MLOG_COMP_LIST_START_DELETE |
ptr | in: buffer |
end_ptr | in: buffer end |
block | in/out: buffer block or NULL |
index | in: record descriptor |
mtr | in: mtr or NULL |
Returns the number of records before the given record in chain.
The number includes infimum and supremum records.
rec | in: the physical record |
Returns the nth record of the record list.
This is the inverse function of page_rec_get_n_recs_before().
page | in: page |
nth | in: nth record |
Prints record contents including the data relevant only in the index page context.
[in] | rec | Physical record |
[in] | offsets | Record descriptor |
The following is used to validate a record on a page.
This function differs from rec_validate as it can also check the n_owned field and the heap_no field.
rec | in: physical record |
offsets | in: array returned by rec_get_offsets() |
void page_set_max_trx_id | ( | buf_block_t * | block, |
page_zip_des_t * | page_zip, | ||
trx_id_t | trx_id, | ||
mtr_t * | mtr | ||
) |
Sets the max trx id field value.
[in,out] | block | Page |
[in,out] | page_zip | Compressed page, or NULL |
[in] | trx_id | Transaction id |
[in,out] | mtr | Mini-transaction, or NULL |
bool page_simple_validate_new | ( | const page_t * | page | ) |
This function checks the consistency of an index page when we do not know the index.
This is also resilient so that this should never crash even if the page is total garbage.
page | in: index page in ROW_FORMAT!=REDUNDANT |
bool page_simple_validate_old | ( | const page_t * | page | ) |
This function checks the consistency of an index page when we do not know the index.
This is also resilient so that this should never crash even if the page is total garbage.
page | in: index page in ROW_FORMAT=REDUNDANT |
bool page_validate | ( | const page_t * | page, |
dict_index_t * | index | ||
) |
This function checks the consistency of an index page.
[in] | page | index page |
[in] | index | data dictionary index containing the page record type definition |
void page_warn_strict_checksum | ( | srv_checksum_algorithm_t | curr_algo, |
srv_checksum_algorithm_t | page_checksum, | ||
const page_id_t & | page_id | ||
) |
Issue a warning when the checksum that is stored in the page is valid, but different than the global setting innodb_checksum_algorithm.
[in] | curr_algo | current checksum algorithm |
[in] | page_checksum | page valid checksum |
[in] | page_id | page identifier |
|
static |
The page infimum and supremum of an empty page in ROW_FORMAT=COMPACT.
|
static |
The page infimum and supremum of an empty page in ROW_FORMAT=REDUNDANT.