MySQL 8.0.40
Source Code Documentation
page0page.h File Reference

Index page routines. More...

#include <stddef.h>
#include <sys/types.h>
#include "univ.i"
#include "buf0buf.h"
#include "data0data.h"
#include "dict0dict.h"
#include "fil0fil.h"
#include "fsp0fsp.h"
#include "mtr0mtr.h"
#include "page0types.h"
#include "rem0rec.h"
#include "page0page.ic"

Go to the source code of this file.

Typedefs

typedef byte page_dir_slot_t
 
typedef page_dir_slot_t page_dir_t
 

Functions

static page_tpage_align (const void *ptr)
 Gets the start of a page. More...
 
static ulint page_offset (const void *ptr)
 Gets the offset within a page. More...
 
static trx_id_t page_get_max_trx_id (const page_t *page)
 Returns the max trx id field value. 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...
 
static void page_update_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 if trx_id is bigger than the previous value. More...
 
static node_seq_t page_get_ssn_id (const page_t *page)
 Returns the RTREE SPLIT SEQUENCE NUMBER (FIL_RTREE_SPLIT_SEQ_NUM). More...
 
static void page_set_ssn_id (buf_block_t *block, page_zip_des_t *page_zip, node_seq_t ssn_id, mtr_t *mtr)
 Sets the RTREE SPLIT SEQUENCE NUMBER field value. More...
 
static uint16_t page_header_get_field (const page_t *page, ulint field)
 Reads the given header field. More...
 
static void page_header_set_field (page_t *page, page_zip_des_t *page_zip, ulint field, ulint val)
 Sets the given header field. More...
 
static ulint page_header_get_offs (const page_t *page, ulint field)
 Returns the offset stored in the given header field. More...
 
static bytepage_header_get_ptr (page_t *page, uint32_t field)
 Returns the pointer stored in the given header field, or NULL. More...
 
static const bytepage_header_get_ptr (const page_t *page, uint32_t field)
 
static void page_header_set_ptr (page_t *page, page_zip_des_t *page_zip, ulint field, const byte *ptr)
 Sets the pointer stored in the given header field. More...
 
static void page_header_reset_last_insert (page_t *page, page_zip_des_t *page_zip, mtr_t *mtr)
 Resets the last insert info field in the page header. More...
 
static ulint page_get_infimum_offset (const page_t *page)
 Gets the offset of the first record on the page. More...
 
static ulint page_get_supremum_offset (const page_t *page)
 Gets the offset of the last record on the page. More...
 
static bytepage_get_infimum_rec (byte *page)
 
static const bytepage_get_infimum_rec (const byte *page)
 
static bytepage_get_supremum_rec (byte *page)
 
static const bytepage_get_supremum_rec (const byte *page)
 
const rec_tpage_rec_get_nth_const (const page_t *page, ulint nth)
 Returns the nth record of the record list. More...
 
static rec_tpage_rec_get_nth (page_t *page, ulint nth)
 Returns the nth record of the record list. More...
 
static rec_tpage_get_middle_rec (page_t *page)
 Returns the middle record of the records on the page. More...
 
static page_no_t page_get_page_no (const page_t *page)
 Gets the page number. More...
 
static space_id_t page_get_space_id (const page_t *page)
 Gets the tablespace identifier. More...
 
static page_id_t page_get_page_id (const page_t *page)
 Gets the space id and page number identifying the page. More...
 
static ulint page_get_n_recs (const page_t *page)
 Gets the number of user records on page (the infimum and supremum records are not user records). More...
 
ulint page_rec_get_n_recs_before (const rec_t *rec)
 Returns the number of records before the given record in chain. More...
 
static uint16_t page_dir_get_n_heap (const page_t *page)
 Gets the number of records in the heap. More...
 
static void page_dir_set_n_heap (page_t *page, page_zip_des_t *page_zip, ulint n_heap)
 Sets the number of records in the heap. More...
 
static ulint page_dir_get_n_slots (const page_t *page)
 Gets the number of dir slots in directory. More...
 
static void page_dir_set_n_slots (page_t *page, page_zip_des_t *page_zip, ulint n_slots)
 Sets the number of dir slots in directory. More...
 
static page_dir_slot_tpage_dir_get_nth_slot (const page_t *page, ulint n)
 Gets pointer to nth directory slot. More...
 
static bool page_rec_check (const rec_t *rec)
 Used to check the consistency of a record on a page. More...
 
static const rec_tpage_dir_slot_get_rec (const page_dir_slot_t *slot)
 Gets the record pointed to by a directory slot. More...
 
static void page_dir_slot_set_rec (page_dir_slot_t *slot, rec_t *rec)
 This is used to set the record offset in a directory slot. More...
 
static ulint page_dir_slot_get_n_owned (const page_dir_slot_t *slot)
 Gets the number of records owned by a directory slot. More...
 
static void page_dir_slot_set_n_owned (page_dir_slot_t *slot, page_zip_des_t *page_zip, ulint n)
 This is used to set the owned records field of a directory slot. More...
 
static ulint page_dir_calc_reserved_space (ulint n_recs)
 Calculates the space reserved for directory slots of a given number of records. More...
 
ulint page_dir_find_owner_slot (const rec_t *rec)
 Looks for the directory slot which owns the given record. More...
 
static bool page_is_comp (const page_t *page)
 Determine whether the page is in new-style compact format. More...
 
static bool page_rec_is_comp (const rec_t *rec)
 true if the record is on a page in compact format. More...
 
static ulint page_rec_get_heap_no (const rec_t *rec)
 Returns the heap number of a record. More...
 
static bool page_is_leaf (const page_t *page)
 Determine whether the page is a B-tree leaf. More...
 
static bool page_is_empty (const page_t *page)
 Determine whether the page is empty. More...
 
static bool page_is_root (const page_t *page)
 Determine whether a page is an index root page. More...
 
static bool page_has_garbage (const page_t *page)
 Determine whether the page contains garbage. More...
 
static const rec_tpage_rec_get_next_low (const rec_t *rec, ulint comp)
 Gets the pointer to the next record on the page. More...
 
static rec_tpage_rec_get_next (rec_t *rec)
 Gets the pointer to the next record on the page. More...
 
static const rec_tpage_rec_get_next_const (const rec_t *rec)
 Gets the pointer to the next record on the page. More...
 
static const rec_tpage_rec_get_next_non_del_marked (const rec_t *rec)
 Gets the pointer to the next non delete-marked record on the page. More...
 
static void page_rec_set_next (rec_t *rec, const rec_t *next)
 Sets the pointer to the next record on the page. More...
 
static const rec_tpage_rec_get_prev_const (const rec_t *rec)
 Gets the pointer to the previous record. More...
 
static rec_tpage_rec_get_prev (rec_t *rec)
 Gets the pointer to the previous record. More...
 
static bool page_rec_is_user_rec_low (ulint offset)
 true if the record is a user record on the page. More...
 
static bool page_rec_is_supremum_low (ulint offset)
 true if the record is the supremum record on a page. More...
 
static bool page_rec_is_infimum_low (ulint offset)
 true if the record is the infimum record on a page. More...
 
static bool page_rec_is_user_rec (const rec_t *rec)
 true if the record is a user record on the page. More...
 
static bool page_rec_is_supremum (const rec_t *rec)
 true if the record is the supremum record on a page. More...
 
static bool page_rec_is_infimum (const rec_t *rec)
 true if the record is the infimum record on a page. More...
 
static bool page_rec_is_first (const rec_t *rec, const page_t *page)
 true if the record is the first user record on a page. More...
 
static bool page_rec_is_second (const rec_t *rec, const page_t *page)
 true if the record is the second user record on a page. More...
 
static bool page_rec_is_last (const rec_t *rec, const page_t *page)
 true if the record is the last user record on a page. More...
 
static bool page_rec_distance_is_at_most (const rec_t *left_rec, const rec_t *right_rec, ulint val)
 true if distance between the records (measured in number of times we have to move to the next record) is at most the specified value More...
 
static bool page_rec_is_second_last (const rec_t *rec, const page_t *page)
 true if the record is the second last user record on a page. More...
 
static rec_tpage_rec_find_owner_rec (rec_t *rec)
 Looks for the record which owns the given record. More...
 
static ulint page_get_max_insert_size (const page_t *page, ulint n_recs)
 Returns the maximum combined size of records which can be inserted on top of record heap. More...
 
static ulint page_get_max_insert_size_after_reorganize (const page_t *page, ulint n_recs)
 Returns the maximum combined size of records which can be inserted on top of record heap if page is first reorganized. More...
 
static ulint page_get_free_space_of_empty (bool comp)
 Calculates free space if a page is emptied. More...
 
static ulint page_rec_get_base_extra_size (const rec_t *rec)
 Returns the base extra size of a physical record. More...
 
static ulint page_get_data_size (const page_t *page)
 Returns the sum of the sizes of the records in the record list excluding the infimum and supremum records. More...
 
static void page_mem_alloc_free (page_t *page, page_zip_des_t *page_zip, rec_t *next_rec, ulint need)
 Allocates a block of memory from the head of the free list of an index page. More...
 
bytepage_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_mem_free (page_t *page, page_zip_des_t *page_zip, rec_t *rec, const dict_index_t *index, const ulint *offsets)
 Puts a record to free list. More...
 
page_tpage_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_tpage_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_tpage_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 the given record onward, including that record. More...
 
rec_tpage_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...
 
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...
 
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...
 
bytepage_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_parse_create (buf_block_t *block, ulint comp, page_type_t page_type)
 Parses a redo log record of creating a page. 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_validate (const page_t *page, dict_index_t *index)
 This function checks the consistency of an index page. More...
 
const rec_tpage_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...
 
const rec_tpage_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...
 
ulong page_size_validate (ulong page_size)
 Check that a page_size is correct for InnoDB. 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...
 

Variables

constexpr uint32_t PAGE_DIR = FIL_PAGE_DATA_END
 
constexpr uint32_t PAGE_DIR_SLOT_SIZE = 2
 
constexpr uint32_t PAGE_EMPTY_DIR_START = PAGE_DIR + 2 * PAGE_DIR_SLOT_SIZE
 
constexpr uint32_t PAGE_DIR_SLOT_MAX_N_OWNED = 8
 
constexpr uint32_t PAGE_DIR_SLOT_MIN_N_OWNED = 4
 
static const byte infimum_extra []
 Extra bytes of an infimum record. More...
 
static const byte infimum_data []
 Data bytes of an infimum record. More...
 
static const byte supremum_extra_data []
 Extra bytes and data bytes of a supremum record. More...
 

Detailed Description

Index page routines.

Created 2/2/1994 Heikki Tuuri

Typedef Documentation

◆ page_dir_slot_t

◆ page_dir_t

Function Documentation

◆ page_align()

static page_t * page_align ( const void *  ptr)
inlinestatic

Gets the start of a page.

Parameters
[in]ptrpointer to page frame
Returns
start of the page

◆ page_check_dir()

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. in: index page

This function is intended to track if the bug fixed in 4.0.14 has caused corruption to users' databases.

Parameters
pagein: index page

◆ page_copy_rec_list_end()

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 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().

Returns
pointer to the original successor of the infimum record on new_page, or NULL on zip overflow (new_block will be decompressed) in: mtr

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().

Returns
pointer to the original successor of the infimum record on new_page, or NULL on zip overflow (new_block will be decompressed)
Parameters
new_blockin/out: index page to copy to
blockin: index page containing rec
recin: record on page
indexin: record descriptor
mtrin: mtr

◆ page_copy_rec_list_end_no_locks()

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(). in: mtr

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().

Parameters
new_blockin: index page to copy to
blockin: index page of rec
recin: record on page
indexin: record descriptor
mtrin: mtr

◆ page_copy_rec_list_start()

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().

Returns
pointer to the original predecessor of the supremum record on new_page, or NULL on zip overflow (new_block will be decompressed) in: mtr

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().

Returns
pointer to the original predecessor of the supremum record on new_page, or NULL on zip overflow (new_block will be decompressed)
Parameters
new_blockin/out: index page to copy to
blockin: index page containing rec
recin: record on page
indexin: record descriptor
mtrin: mtr

◆ page_create()

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.

Parameters
[in]blockA buffer block where the page is created
[in]mtrMini-transaction handle
[in]compnonzero=compact page format
[in]page_typePage type
Returns
pointer to the page

◆ page_create_empty()

void page_create_empty ( buf_block_t block,
dict_index_t index,
mtr_t mtr 
)

Empty a previously created B-tree index page.

Parameters
[in,out]blockB-tree block
[in]indexThe index of the page
[in,out]mtrMini-transaction

◆ page_create_zip()

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.

Parameters
[in,out]blockBuffer frame where the page is created
[in]indexIndex of the page, or NULL when applying TRUNCATE log record during recovery
[in]levelThe B-tree level of the page
[in]max_trx_idPAGE_MAX_TRX_ID
[in]mtrMini-transaction handle
[in]page_typePage type to be created. Only FIL_PAGE_INDEX, FIL_PAGE_RTREE, FIL_PAGE_SDI allowed
Returns
pointer to the page

◆ page_delete_rec_list_end()

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. in: mtr

The infimum and supremum records are not deleted.

Parameters
recin: pointer to record on page
blockin: buffer block of the page
indexin: record descriptor
n_recsin: number of records to delete, or ULINT_UNDEFINED if not known
sizein: the sum of the sizes of the records in the end of the chain to delete, or ULINT_UNDEFINED if not known
mtrin: mtr

◆ page_delete_rec_list_start()

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. in: mtr

Infimum and supremum records are not deleted.

Parameters
recin: record on page
blockin: buffer block of the page
indexin: record descriptor
mtrin: mtr

◆ page_dir_balance_slot()

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.

Parameters
[in,out]pageIndex page
[in,out]page_zipCompressed page, or null
[in]slot_noThe directory slot

◆ page_dir_calc_reserved_space()

static ulint page_dir_calc_reserved_space ( ulint  n_recs)
inlinestatic

Calculates the space reserved for directory slots of a given number of records.

The exact value is a fraction number n * PAGE_DIR_SLOT_SIZE / PAGE_DIR_SLOT_MIN_N_OWNED, and it is rounded upwards to an integer. in: number of records

◆ page_dir_find_owner_slot()

ulint page_dir_find_owner_slot ( const rec_t rec)

Looks for the directory slot which owns the given record.

Returns
the directory slot number in: the physical record
the directory slot number
Parameters
recin: the physical record

◆ page_dir_get_n_heap()

static uint16_t page_dir_get_n_heap ( const page_t page)
inlinestatic

Gets the number of records in the heap.

Parameters
[in]pageindex page
Returns
number of user records

◆ page_dir_get_n_slots()

static ulint page_dir_get_n_slots ( const page_t page)
inlinestatic

Gets the number of dir slots in directory.

Returns
number of slots in: index page

◆ page_dir_get_nth_slot()

static page_dir_slot_t * page_dir_get_nth_slot ( const page_t page,
ulint  n 
)
inlinestatic

Gets pointer to nth directory slot.

Parameters
[in]pageindex page
[in]nposition
Returns
pointer to dir slot

◆ page_dir_set_n_heap()

static void page_dir_set_n_heap ( page_t page,
page_zip_des_t page_zip,
ulint  n_heap 
)
inlinestatic

Sets the number of records in the heap.

Parameters
[in,out]pageindex page
[in,out]page_zipcompressed page whose uncompressed part will be updated, or NULL. Note that the size of the dense page directory in the compressed page trailer is n_heap * PAGE_ZIP_DIR_SLOT_SIZE.
[in]n_heapnumber of records

◆ page_dir_set_n_slots()

static void page_dir_set_n_slots ( page_t page,
page_zip_des_t page_zip,
ulint  n_slots 
)
inlinestatic

Sets the number of dir slots in directory.

Parameters
[in,out]pagepage
[in,out]page_zipcompressed page whose uncompressed part will be updated, or NULL
[in]n_slotsnumber of slots

◆ page_dir_slot_get_n_owned()

static ulint page_dir_slot_get_n_owned ( const page_dir_slot_t slot)
inlinestatic

Gets the number of records owned by a directory slot.

Returns
number of records in: page directory slot

◆ page_dir_slot_get_rec()

static const rec_t * page_dir_slot_get_rec ( const page_dir_slot_t slot)
inlinestatic

Gets the record pointed to by a directory slot.

Returns
pointer to record in: directory slot

◆ page_dir_slot_set_n_owned()

static void page_dir_slot_set_n_owned ( page_dir_slot_t slot,
page_zip_des_t page_zip,
ulint  n 
)
inlinestatic

This is used to set the owned records field of a directory slot.

Parameters
[in,out]slotdirectory slot
[in,out]page_zipcompressed page, or NULL
[in]nnumber of records owned by the slot

◆ page_dir_slot_set_rec()

static void page_dir_slot_set_rec ( page_dir_slot_t slot,
rec_t rec 
)
inlinestatic

This is used to set the record offset in a directory slot.

Parameters
[in]recrecord on the page
[in]slotdirectory slot

◆ page_dir_split_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.

Parameters
[in,out]pageIndex page
[in,out]page_zipCompressed page whose uncompressed part will be written, or null
[in]slot_noThe directory slot

◆ page_find_rec_last_not_deleted()

const rec_t * page_find_rec_last_not_deleted ( const page_t page)

Get the last non-delete-marked record on a page.

Parameters
[in]pageindex tree leaf page
Returns
the last record, not delete-marked
Return values
infimumrecord if all records are delete-marked

◆ page_find_rec_with_heap_no()

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.

Returns
record, NULL if not found in: heap number
record, NULL if not found
Parameters
pagein: index page
heap_noin: heap number

◆ page_get_data_size()

static ulint page_get_data_size ( const page_t page)
inlinestatic

Returns the sum of the sizes of the records in the record list excluding the infimum and supremum records.

Returns
data in bytes in: index page

◆ page_get_free_space_of_empty()

static ulint page_get_free_space_of_empty ( bool  comp)
inlinestatic

Calculates free space if a page is emptied.

Parameters
[in]compnonzero=compact page format
Returns
free space

◆ page_get_infimum_offset()

static ulint page_get_infimum_offset ( const page_t page)
inlinestatic

Gets the offset of the first record on the page.

Returns
offset of the first record in record list, relative from page in: page which must have record(s)

◆ page_get_infimum_rec() [1/2]

static byte * page_get_infimum_rec ( byte page)
inlinestatic

◆ page_get_infimum_rec() [2/2]

static const byte * page_get_infimum_rec ( const byte page)
inlinestatic

◆ page_get_max_insert_size()

static ulint page_get_max_insert_size ( const page_t page,
ulint  n_recs 
)
inlinestatic

Returns the maximum combined size of records which can be inserted on top of record heap.

Parameters
[in]pageindex page
[in]n_recsnumber of records
Returns
maximum combined size for inserted records

◆ page_get_max_insert_size_after_reorganize()

static ulint page_get_max_insert_size_after_reorganize ( const page_t page,
ulint  n_recs 
)
inlinestatic

Returns the maximum combined size of records which can be inserted on top of record heap if page is first reorganized.

Parameters
[in]pageindex page
[in]n_recsnumber of records
Returns
maximum combined size for inserted records

◆ page_get_max_trx_id()

static trx_id_t page_get_max_trx_id ( const page_t page)
inlinestatic

Returns the max trx id field value.

in: page

◆ page_get_middle_rec()

static rec_t * page_get_middle_rec ( page_t page)
inlinestatic

Returns the middle record of the records on the page.

If there is an even number of records in the list, returns the first record of the upper half-list.

Returns
middle record in: page

◆ page_get_n_recs()

static ulint page_get_n_recs ( const page_t page)
inlinestatic

Gets the number of user records on page (the infimum and supremum records are not user records).

Returns
number of user records in: index page

◆ page_get_page_id()

static page_id_t page_get_page_id ( const page_t page)
inlinestatic

Gets the space id and page number identifying the page.

Returns
page number

◆ page_get_page_no()

static page_no_t page_get_page_no ( const page_t page)
inlinestatic

Gets the page number.

Returns
page number in: page

◆ page_get_space_id()

static space_id_t page_get_space_id ( const page_t page)
inlinestatic

Gets the tablespace identifier.

Returns
space id in: page

◆ page_get_ssn_id()

static node_seq_t page_get_ssn_id ( const page_t page)
inlinestatic

Returns the RTREE SPLIT SEQUENCE NUMBER (FIL_RTREE_SPLIT_SEQ_NUM).

Parameters
[in]pagepage
Returns
SPLIT SEQUENCE NUMBER

◆ page_get_supremum_offset()

static ulint page_get_supremum_offset ( const page_t page)
inlinestatic

Gets the offset of the last record on the page.

Returns
offset of the last record in record list, relative from page in: page which must have record(s)

◆ page_get_supremum_rec() [1/2]

static byte * page_get_supremum_rec ( byte page)
inlinestatic

◆ page_get_supremum_rec() [2/2]

static const byte * page_get_supremum_rec ( const byte page)
inlinestatic

◆ page_has_garbage()

static bool page_has_garbage ( const page_t page)
inlinestatic

Determine whether the page contains garbage.

Returns
true if the page contains garbage (PAGE_GARBAGE is not 0) in: page

◆ page_header_get_field()

static uint16_t page_header_get_field ( const page_t page,
ulint  field 
)
inlinestatic

Reads the given header field.

Parameters
[in]pagepage
[in]fieldPAGE_N_DIR_SLOTS, ...

◆ page_header_get_offs()

static ulint page_header_get_offs ( const page_t page,
ulint  field 
)
inlinestatic

Returns the offset stored in the given header field.

Parameters
[in]pagePage.
[in]fieldPAGE_FREE, ...
Returns
offset from the start of the page, or 0

◆ page_header_get_ptr() [1/2]

static const byte * page_header_get_ptr ( const page_t page,
uint32_t  field 
)
inlinestatic

◆ page_header_get_ptr() [2/2]

static byte * page_header_get_ptr ( page_t page,
uint32_t  field 
)
inlinestatic

Returns the pointer stored in the given header field, or NULL.

◆ page_header_reset_last_insert()

static void page_header_reset_last_insert ( page_t page,
page_zip_des_t page_zip,
mtr_t mtr 
)
inlinestatic

Resets the last insert info field in the page header.

Writes to mlog about this operation.

Parameters
[in]pagepage
[in,out]page_zipcompressed page whose uncompressed part will be updated, or NULL
[in]mtrmtr

◆ page_header_set_field()

static void page_header_set_field ( page_t page,
page_zip_des_t page_zip,
ulint  field,
ulint  val 
)
inlinestatic

Sets the given header field.

Parameters
[in,out]pagepage
[in,out]page_zipcompressed page whose uncompressed part will be updated, or NULL
[in]fieldPAGE_N_DIR_SLOTS, ...
[in]valvalue

◆ page_header_set_ptr()

static void page_header_set_ptr ( page_t page,
page_zip_des_t page_zip,
ulint  field,
const byte ptr 
)
inlinestatic

Sets the pointer stored in the given header field.

Parameters
[in,out]pagepage
[in,out]page_zipcompressed page whose uncompressed part will be updated, or NULL
[in,out]fieldPAGE_FREE, ...
[in]ptrpointer or NULL

◆ page_is_comp()

static bool page_is_comp ( const page_t page)
inlinestatic

Determine whether the page is in new-style compact format.

Returns
nonzero if the page is in compact format, zero if it is in old-style format in: index page

◆ page_is_empty()

static bool page_is_empty ( const page_t page)
inlinestatic

Determine whether the page is empty.

Returns
true if the page is empty (PAGE_N_RECS = 0) in: page

◆ page_is_leaf()

static bool page_is_leaf ( const page_t page)
inlinestatic

Determine whether the page is a B-tree leaf.

Returns
true if the page is a B-tree leaf (PAGE_LEVEL = 0) in: page

◆ page_is_root()

static bool page_is_root ( const page_t page)
inlinestatic

Determine whether a page is an index root page.

Parameters
[in]pagepage frame
Returns
true if the page is a root page of an index

◆ page_is_spatial_non_leaf()

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

Returns
true if ok

◆ page_mem_alloc_free()

static void page_mem_alloc_free ( page_t page,
page_zip_des_t page_zip,
rec_t next_rec,
ulint  need 
)
inlinestatic

Allocates a block of memory from the head of the free list of an index page.

Parameters
[in,out]pageindex page
[in,out]page_zipcompressed page with enough space available for inserting the record, or NULL
[in]next_recpointer to the new head of the free record list
[in]neednumber of bytes allocated

◆ page_mem_alloc_heap()

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.

Returns
pointer to start of allocated buffer, or NULL if allocation fails out: this contains the heap number of the allocated record if allocation succeeds
pointer to start of allocated buffer, or NULL if allocation fails
Parameters
pagein/out: index page
page_zipin/out: compressed page with enough space available for inserting the record, or NULL
needin: total number of bytes needed
heap_noout: this contains the heap number of the allocated record if allocation succeeds

◆ page_mem_free()

static void page_mem_free ( page_t page,
page_zip_des_t page_zip,
rec_t rec,
const dict_index_t index,
const ulint offsets 
)
inlinestatic

Puts a record to free list.

Parameters
[in,out]pageindex page
[in,out]page_zipcompressed page, or NULL
[in]recpointer to the (origin of) record
[in]indexindex of rec
[in]offsetsarray returned by rec_get_offsets()

◆ page_move_rec_list_end()

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().

Returns
true on success; false on compression failure (new_block will be decompressed) in: mtr

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().

Returns
true on success; false on compression failure (new_block will be decompressed)
Parameters
new_blockin/out: index page where to move
blockin: index page from where to move
split_recin: first record to move
indexin: record descriptor
mtrin: mtr

◆ page_move_rec_list_start()

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().

Returns
true on success; false on compression failure in: mtr

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().

Returns
true on success; false on compression failure
Parameters
new_blockin/out: index page where to move
blockin/out: page containing split_rec
split_recin: first record not to move
indexin: record descriptor
mtrin: mtr

◆ page_offset()

static ulint page_offset ( const void *  ptr)
inlinestatic

Gets the offset within a page.

Parameters
[in]ptrpointer to page frame
Returns
offset from the start of the page

◆ page_parse_create()

void page_parse_create ( buf_block_t block,
ulint  comp,
page_type_t  page_type 
)

Parses a redo log record of creating a page.

Parameters
[in,out]blockbuffer block, or NULL
[in]compnonzero=compact page format
[in]page_typepage type (FIL_PAGE_INDEX, FIL_PAGE_RTREE or FIL_PAGE_SDI)

◆ page_parse_delete_rec_list()

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.

Returns
end of log record or NULL in: mtr or NULL
end of log record or NULL
Parameters
typein: MLOG_LIST_END_DELETE, MLOG_LIST_START_DELETE, MLOG_COMP_LIST_END_DELETE or MLOG_COMP_LIST_START_DELETE
ptrin: buffer
end_ptrin: buffer end
blockin/out: buffer block or NULL
indexin: record descriptor
mtrin: mtr or NULL

◆ page_rec_check()

static bool page_rec_check ( const rec_t rec)
inlinestatic

Used to check the consistency of a record on a page.

Returns
true if succeed in: record

◆ page_rec_distance_is_at_most()

static bool page_rec_distance_is_at_most ( const rec_t left_rec,
const rec_t right_rec,
ulint  val 
)
inlinestatic

true if distance between the records (measured in number of times we have to move to the next record) is at most the specified value

Parameters
[in]left_reclefter record
[in]right_recrighter record
[in]valspecified value to compare
Returns
true if the distance is smaller than the value

◆ page_rec_find_owner_rec()

static rec_t * page_rec_find_owner_rec ( rec_t rec)
inlinestatic

Looks for the record which owns the given record.

Returns
the owner record in: the physical record

◆ page_rec_get_base_extra_size()

static ulint page_rec_get_base_extra_size ( const rec_t rec)
inlinestatic

Returns the base extra size of a physical record.

This is the size of the fixed header, independent of the record size.

Returns
REC_N_NEW_EXTRA_BYTES or REC_N_OLD_EXTRA_BYTES in: physical record

◆ page_rec_get_heap_no()

static ulint page_rec_get_heap_no ( const rec_t rec)
inlinestatic

Returns the heap number of a record.

Returns
heap number in: the physical record

◆ page_rec_get_n_recs_before()

ulint page_rec_get_n_recs_before ( const rec_t rec)

Returns the number of records before the given record in chain.

The number includes infimum and supremum records. This is the inverse function of page_rec_get_nth().

Returns
number of records in: the physical record

The number includes infimum and supremum records.

Returns
number of records
Parameters
recin: the physical record

◆ page_rec_get_next()

static rec_t * page_rec_get_next ( rec_t rec)
inlinestatic

Gets the pointer to the next record on the page.

Returns
pointer to next record in: pointer to record

◆ page_rec_get_next_const()

static const rec_t * page_rec_get_next_const ( const rec_t rec)
inlinestatic

Gets the pointer to the next record on the page.

Returns
pointer to next record in: pointer to record

◆ page_rec_get_next_low()

static const rec_t * page_rec_get_next_low ( const rec_t rec,
ulint  comp 
)
inlinestatic

Gets the pointer to the next record on the page.

Parameters
[in]recpointer to record
[in]compnonzero=compact page layout
Returns
pointer to next record

◆ page_rec_get_next_non_del_marked()

static const rec_t * page_rec_get_next_non_del_marked ( const rec_t rec)
inlinestatic

Gets the pointer to the next non delete-marked record on the page.

If all subsequent records are delete-marked, then this function will return the supremum record.

Returns
pointer to next non delete-marked record or pointer to supremum in: pointer to record

◆ page_rec_get_nth()

static rec_t * page_rec_get_nth ( page_t page,
ulint  nth 
)
inlinestatic

Returns the nth record of the record list.

This is the inverse function of page_rec_get_n_recs_before().

Parameters
[in]pagepage
[in]nthnth record
Returns
nth record

◆ page_rec_get_nth_const()

const rec_t * page_rec_get_nth_const ( const page_t page,
ulint  nth 
)

Returns the nth record of the record list.

This is the inverse function of page_rec_get_n_recs_before().

Returns
nth record in: nth record

This is the inverse function of page_rec_get_n_recs_before().

Returns
nth record
Parameters
pagein: page
nthin: nth record

◆ page_rec_get_prev()

static rec_t * page_rec_get_prev ( rec_t rec)
inlinestatic

Gets the pointer to the previous record.

Returns
pointer to previous record in: pointer to record, must not be page infimum

◆ page_rec_get_prev_const()

static const rec_t * page_rec_get_prev_const ( const rec_t rec)
inlinestatic

Gets the pointer to the previous record.

Returns
pointer to previous record in: pointer to record, must not be page infimum

◆ page_rec_is_comp()

static bool page_rec_is_comp ( const rec_t rec)
inlinestatic

true if the record is on a page in compact format.

Returns
nonzero if in compact format in: record

◆ page_rec_is_first()

static bool page_rec_is_first ( const rec_t rec,
const page_t page 
)
inlinestatic

true if the record is the first user record on a page.

Parameters
[in]recRecord.
[in]pagePage.
Returns
true if the first user record

◆ page_rec_is_infimum()

static bool page_rec_is_infimum ( const rec_t rec)
inlinestatic

true if the record is the infimum record on a page.

Returns
true if the infimum record in: record

◆ page_rec_is_infimum_low()

static bool page_rec_is_infimum_low ( ulint  offset)
inlinestatic

true if the record is the infimum record on a page.

Parameters
[in]offsetrecord offset on page
Returns
true if the infimum record

◆ page_rec_is_last()

static bool page_rec_is_last ( const rec_t rec,
const page_t page 
)
inlinestatic

true if the record is the last user record on a page.

Parameters
[in]recRecord.
[in]pagePage.
Returns
true if the last user record

◆ page_rec_is_second()

static bool page_rec_is_second ( const rec_t rec,
const page_t page 
)
inlinestatic

true if the record is the second user record on a page.

Parameters
[in]recRecord.
[in]pagePage.
Returns
true if the second user record

◆ page_rec_is_second_last()

static bool page_rec_is_second_last ( const rec_t rec,
const page_t page 
)
inlinestatic

true if the record is the second last user record on a page.

Parameters
[in]recRecord.
[in]pagePage.
Returns
true if the second last user record

◆ page_rec_is_supremum()

static bool page_rec_is_supremum ( const rec_t rec)
inlinestatic

true if the record is the supremum record on a page.

Returns
true if the supremum record in: record

◆ page_rec_is_supremum_low()

static bool page_rec_is_supremum_low ( ulint  offset)
inlinestatic

true if the record is the supremum record on a page.

Parameters
[in]offsetrecord offset on page
Returns
true if the supremum record

◆ page_rec_is_user_rec()

static bool page_rec_is_user_rec ( const rec_t rec)
inlinestatic

true if the record is a user record on the page.

Returns
true if a user record in: record

◆ page_rec_is_user_rec_low()

static bool page_rec_is_user_rec_low ( ulint  offset)
inlinestatic

true if the record is a user record on the page.

Parameters
[in]offsetrecord offset on page
Returns
true if a user record

◆ page_rec_print()

void page_rec_print ( const rec_t rec,
const ulint offsets 
)

Prints record contents including the data relevant only in the index page context.

Parameters
[in]recPhysical record
[in]offsetsRecord descriptor

◆ page_rec_set_next()

static void page_rec_set_next ( rec_t rec,
const rec_t next 
)
inlinestatic

Sets the pointer to the next record on the page.

Parameters
[in]recpointer to record, must not be page supremum
[in]nextpointer to next record, must not be page infimum

◆ page_rec_validate()

bool page_rec_validate ( const rec_t rec,
const ulint offsets 
)

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.

Returns
true if ok in: array returned by rec_get_offsets()

This function differs from rec_validate as it can also check the n_owned field and the heap_no field.

Returns
true if ok
Parameters
recin: physical record
offsetsin: array returned by rec_get_offsets()

◆ page_set_max_trx_id()

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.

Parameters
[in,out]blockPage
[in,out]page_zipCompressed page, or NULL
[in]trx_idTransaction id
[in,out]mtrMini-transaction, or NULL

◆ page_set_ssn_id()

static void page_set_ssn_id ( buf_block_t block,
page_zip_des_t page_zip,
node_seq_t  ssn_id,
mtr_t mtr 
)
inlinestatic

Sets the RTREE SPLIT SEQUENCE NUMBER field value.

Parameters
[in,out]blockPage
[in,out]page_zipCompressed page whose uncompressed part will be updated, or NULL
[in]ssn_idSplit sequence id
[in,out]mtrMini-transaction

◆ page_simple_validate_new()

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.

Returns
true if ok in: index page in ROW_FORMAT!=REDUNDANT

This is also resilient so that this should never crash even if the page is total garbage.

Returns
true if ok
Parameters
pagein: index page in ROW_FORMAT!=REDUNDANT

◆ page_simple_validate_old()

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.

Returns
true if ok in: index page in ROW_FORMAT=REDUNDANT

This is also resilient so that this should never crash even if the page is total garbage.

Returns
true if ok
Parameters
pagein: index page in ROW_FORMAT=REDUNDANT

◆ page_size_validate()

ulong page_size_validate ( ulong  page_size)
inline

Check that a page_size is correct for InnoDB.

If correct, set the associated page_size_shift which is the power of 2 for this page size.

Parameters
[in]page_sizePage Size to evaluate
Returns
an associated page_size_shift if valid, 0 if invalid.

◆ page_update_max_trx_id()

static void page_update_max_trx_id ( buf_block_t block,
page_zip_des_t page_zip,
trx_id_t  trx_id,
mtr_t mtr 
)
inlinestatic

Sets the max trx id field value if trx_id is bigger than the previous value.

Parameters
[in,out]blockPage
[in,out]page_zipCompressed page whose uncompressed part will be updated, or NULL
[in]trx_idTransaction id
[in,out]mtrMini-transaction

◆ page_validate()

bool page_validate ( const page_t page,
dict_index_t index 
)

This function checks the consistency of an index page.

Parameters
[in]pageindex page
[in]indexdata dictionary index containing the page record type definition
Returns
true if ok

◆ page_warn_strict_checksum()

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.

Parameters
[in]curr_algocurrent checksum algorithm
[in]page_checksumpage valid checksum
[in]page_idpage identifier

Variable Documentation

◆ infimum_data

const byte infimum_data[]
static
Initial value:
= {
0x69, 0x6e, 0x66, 0x69, 0x6d, 0x75, 0x6d, 0x00
}

Data bytes of an infimum record.

◆ infimum_extra

const byte infimum_extra[]
static
Initial value:
= {
0x01,
0x00, 0x02
}

Extra bytes of an infimum record.

◆ PAGE_DIR

constexpr uint32_t PAGE_DIR = FIL_PAGE_DATA_END
constexpr

◆ PAGE_DIR_SLOT_MAX_N_OWNED

constexpr uint32_t PAGE_DIR_SLOT_MAX_N_OWNED = 8
constexpr

◆ PAGE_DIR_SLOT_MIN_N_OWNED

constexpr uint32_t PAGE_DIR_SLOT_MIN_N_OWNED = 4
constexpr

◆ PAGE_DIR_SLOT_SIZE

constexpr uint32_t PAGE_DIR_SLOT_SIZE = 2
constexpr

◆ PAGE_EMPTY_DIR_START

constexpr uint32_t PAGE_EMPTY_DIR_START = PAGE_DIR + 2 * PAGE_DIR_SLOT_SIZE
constexpr

◆ supremum_extra_data

const byte supremum_extra_data[]
static
Initial value:
= {
0x00,
0x0b,
0x00,
0x00,
0x73,
0x75,
0x70,
0x72,
0x65,
0x6d,
0x75,
0x6d
}

Extra bytes and data bytes of a supremum record.