InnoDB Plugin  1.0
Macros | Typedefs | Functions
page0page.h File Reference
#include "univ.i"
#include "page0types.h"
#include "fil0fil.h"
#include "buf0buf.h"
#include "data0data.h"
#include "dict0dict.h"
#include "rem0rec.h"
#include "fsp0fsp.h"
#include "mtr0mtr.h"
#include "page0page.ic"
Include dependency graph for page0page.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define PAGE_HEADER
#define PAGE_N_DIR_SLOTS   0 /* number of slots in page directory */
#define PAGE_HEAP_TOP   2 /* pointer to record heap top */
#define PAGE_N_HEAP
#define PAGE_FREE   6 /* pointer to start of page free record list */
#define PAGE_GARBAGE   8 /* number of bytes in deleted records */
#define PAGE_LAST_INSERT
#define PAGE_DIRECTION   12 /* last insert direction: PAGE_LEFT, ... */
#define PAGE_N_DIRECTION
#define PAGE_N_RECS   16 /* number of user records on the page */
#define PAGE_MAX_TRX_ID
#define PAGE_HEADER_PRIV_END
#define PAGE_LEVEL
#define PAGE_INDEX_ID
#define PAGE_BTR_SEG_LEAF
#define PAGE_BTR_IBUF_FREE_LIST   PAGE_BTR_SEG_LEAF
#define PAGE_BTR_IBUF_FREE_LIST_NODE   PAGE_BTR_SEG_LEAF
#define PAGE_BTR_SEG_TOP   (36 + FSEG_HEADER_SIZE)
#define PAGE_DATA   (PAGE_HEADER + 36 + 2 * FSEG_HEADER_SIZE)
#define PAGE_OLD_INFIMUM   (PAGE_DATA + 1 + REC_N_OLD_EXTRA_BYTES)
#define PAGE_OLD_SUPREMUM   (PAGE_DATA + 2 + 2 * REC_N_OLD_EXTRA_BYTES + 8)
#define PAGE_OLD_SUPREMUM_END   (PAGE_OLD_SUPREMUM + 9)
#define PAGE_NEW_INFIMUM   (PAGE_DATA + REC_N_NEW_EXTRA_BYTES)
#define PAGE_NEW_SUPREMUM   (PAGE_DATA + 2 * REC_N_NEW_EXTRA_BYTES + 8)
#define PAGE_NEW_SUPREMUM_END   (PAGE_NEW_SUPREMUM + 8)
#define PAGE_HEAP_NO_INFIMUM   0 /* page infimum */
#define PAGE_HEAP_NO_SUPREMUM   1 /* page supremum */
#define PAGE_HEAP_NO_USER_LOW
#define PAGE_LEFT   1
#define PAGE_RIGHT   2
#define PAGE_SAME_REC   3
#define PAGE_SAME_PAGE   4
#define PAGE_NO_DIRECTION   5
#define PAGE_DIR   FIL_PAGE_DATA_END
#define PAGE_DIR_SLOT_SIZE   2
#define PAGE_EMPTY_DIR_START   (PAGE_DIR + 2 * PAGE_DIR_SLOT_SIZE)
#define PAGE_DIR_SLOT_MAX_N_OWNED   8
#define PAGE_DIR_SLOT_MIN_N_OWNED   4
#define page_header_get_ptr(page, field)
#define page_get_infimum_rec(page)   ((page) + page_get_infimum_offset(page))
#define page_get_supremum_rec(page)   ((page) + page_get_supremum_offset(page))

Typedefs

typedef byte page_header_t
typedef byte page_dir_slot_t
typedef page_dir_slot_t page_dir_t

Functions

UNIV_INLINE page_tpage_align (const void *ptr))
UNIV_INLINE ulint page_offset (const void *ptr))
UNIV_INLINE trx_id_t page_get_max_trx_id (const page_t *page)
UNIV_INTERN void page_set_max_trx_id (buf_block_t *block, page_zip_des_t *page_zip, trx_id_t trx_id, mtr_t *mtr)
UNIV_INLINE void page_update_max_trx_id (buf_block_t *block, page_zip_des_t *page_zip, trx_id_t trx_id, mtr_t *mtr)
UNIV_INLINE ulint page_header_get_field (const page_t *page, ulint field)
UNIV_INLINE void page_header_set_field (page_t *page, page_zip_des_t *page_zip, ulint field, ulint val)
UNIV_INLINE ulint page_header_get_offs (const page_t *page, ulint field))
UNIV_INLINE void page_header_set_ptr (page_t *page, page_zip_des_t *page_zip, ulint field, const byte *ptr)
UNIV_INLINE void page_header_reset_last_insert (page_t *page, page_zip_des_t *page_zip, mtr_t *mtr)
UNIV_INLINE ulint page_get_infimum_offset (const page_t *page)
UNIV_INLINE ulint page_get_supremum_offset (const page_t *page)
UNIV_INTERN const rec_t * page_rec_get_nth_const (const page_t *page, ulint nth))
UNIV_INLINE rec_t * page_rec_get_nth (page_t *page, ulint nth))
UNIV_INLINE rec_t * page_get_middle_rec (page_t *page))
UNIV_INLINE int page_cmp_dtuple_rec_with_match (const dtuple_t *dtuple, const rec_t *rec, const ulint *offsets, ulint *matched_fields, ulint *matched_bytes)
UNIV_INLINE ulint page_get_page_no (const page_t *page)
UNIV_INLINE ulint page_get_space_id (const page_t *page)
UNIV_INLINE ulint page_get_n_recs (const page_t *page)
UNIV_INTERN ulint page_rec_get_n_recs_before (const rec_t *rec)
UNIV_INLINE ulint page_dir_get_n_heap (const page_t *page)
UNIV_INLINE void page_dir_set_n_heap (page_t *page, page_zip_des_t *page_zip, ulint n_heap)
UNIV_INLINE ulint page_dir_get_n_slots (const page_t *page)
UNIV_INLINE void page_dir_set_n_slots (page_t *page, page_zip_des_t *page_zip, ulint n_slots)
UNIV_INLINE page_dir_slot_t * page_dir_get_nth_slot (const page_t *page, ulint n)
UNIV_INLINE ibool page_rec_check (const rec_t *rec)
UNIV_INLINE const rec_t * page_dir_slot_get_rec (const page_dir_slot_t *slot)
UNIV_INLINE void page_dir_slot_set_rec (page_dir_slot_t *slot, rec_t *rec)
UNIV_INLINE ulint page_dir_slot_get_n_owned (const page_dir_slot_t *slot)
UNIV_INLINE void page_dir_slot_set_n_owned (page_dir_slot_t *slot, page_zip_des_t *page_zip, ulint n)
UNIV_INLINE ulint page_dir_calc_reserved_space (ulint n_recs)
UNIV_INTERN ulint page_dir_find_owner_slot (const rec_t *rec)
UNIV_INLINE ulint page_is_comp (const page_t *page)
UNIV_INLINE ulint page_rec_is_comp (const rec_t *rec)
UNIV_INLINE ulint page_rec_get_heap_no (const rec_t *rec)
UNIV_INLINE bool page_is_leaf (const page_t *page))
UNIV_INLINE bool page_is_empty (const page_t *page))
UNIV_INLINE bool page_has_garbage (const page_t *page))
UNIV_INLINE const rec_t * page_rec_get_next_low (const rec_t *rec, ulint comp)
UNIV_INLINE rec_t * page_rec_get_next (rec_t *rec)
UNIV_INLINE const rec_t * page_rec_get_next_const (const rec_t *rec)
UNIV_INLINE const rec_t * page_rec_get_next_non_del_marked (const rec_t *rec)
UNIV_INLINE void page_rec_set_next (rec_t *rec, const rec_t *next)
UNIV_INLINE const rec_t * page_rec_get_prev_const (const rec_t *rec)
UNIV_INLINE rec_t * page_rec_get_prev (rec_t *rec)
UNIV_INLINE ibool page_rec_is_user_rec_low (ulint offset))
UNIV_INLINE ibool page_rec_is_supremum_low (ulint offset))
UNIV_INLINE ibool page_rec_is_infimum_low (ulint offset))
UNIV_INLINE ibool page_rec_is_user_rec (const rec_t *rec))
UNIV_INLINE ibool page_rec_is_supremum (const rec_t *rec))
UNIV_INLINE ibool page_rec_is_infimum (const rec_t *rec))
UNIV_INLINE rec_t * page_rec_find_owner_rec (rec_t *rec)
UNIV_INLINE void page_rec_write_field (rec_t *rec, ulint i, ulint val, mtr_t *mtr))
UNIV_INLINE ulint page_get_max_insert_size (const page_t *page, ulint n_recs)
UNIV_INLINE ulint page_get_max_insert_size_after_reorganize (const page_t *page, ulint n_recs)
UNIV_INLINE ulint page_get_free_space_of_empty (ulint comp))
UNIV_INLINE ulint page_rec_get_base_extra_size (const rec_t *rec)
UNIV_INLINE ulint page_get_data_size (const page_t *page)
UNIV_INLINE void page_mem_alloc_free (page_t *page, page_zip_des_t *page_zip, rec_t *next_rec, ulint need)
UNIV_INTERN byte * page_mem_alloc_heap (page_t *page, page_zip_des_t *page_zip, ulint need, ulint *heap_no)
UNIV_INLINE void page_mem_free (page_t *page, page_zip_des_t *page_zip, rec_t *rec, const dict_index_t *index, const ulint *offsets)
UNIV_INTERN page_tpage_create (buf_block_t *block, mtr_t *mtr, ulint comp)
UNIV_INTERN page_tpage_create_zip (buf_block_t *block, dict_index_t *index, ulint level, trx_id_t max_trx_id, mtr_t *mtr))
UNIV_INTERN void page_create_empty (buf_block_t *block, dict_index_t *index, mtr_t *mtr)))
UNIV_INTERN 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)
UNIV_INTERN 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))
UNIV_INTERN 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))
UNIV_INTERN 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))
UNIV_INTERN void page_delete_rec_list_start (rec_t *rec, buf_block_t *block, dict_index_t *index, mtr_t *mtr))
UNIV_INTERN ibool 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)))
UNIV_INTERN ibool 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)))
UNIV_INTERN void page_dir_split_slot (page_t *page, page_zip_des_t *page_zip, ulint slot_no)))
UNIV_INTERN void page_dir_balance_slot (page_t *page, page_zip_des_t *page_zip, ulint slot_no)))
UNIV_INTERN byte * page_parse_delete_rec_list (byte type, byte *ptr, byte *end_ptr, buf_block_t *block, dict_index_t *index, mtr_t *mtr)
UNIV_INTERN byte * page_parse_create (byte *ptr, byte *end_ptr, ulint comp, buf_block_t *block, mtr_t *mtr)
UNIV_INTERN void page_rec_print (const rec_t *rec, const ulint *offsets)
UNIV_INTERN ibool page_rec_validate (const rec_t *rec, const ulint *offsets)
UNIV_INTERN void page_check_dir (const page_t *page)
UNIV_INTERN ibool page_simple_validate_old (const page_t *page)
UNIV_INTERN ibool page_simple_validate_new (const page_t *page)
UNIV_INTERN ibool page_validate (const page_t *page, dict_index_t *index)
const rec_t * page_find_rec_with_heap_no (const page_t *page, ulint heap_no)
const rec_t * page_find_rec_max_not_deleted (const page_t *page)

Detailed Description

Index page routines

Created 2/2/1994 Heikki Tuuri

Macro Definition Documentation

#define PAGE_BTR_SEG_LEAF
Value:
36 /* file segment header for the leaf pages in
a B-tree: defined only on the root page of a
B-tree, but not in the root of an ibuf tree */
#define PAGE_HEADER
Value:
FSEG_PAGE_DATA /* index page header starts at this
offset */
#define page_header_get_ptr (   page,
  field 
)
Value:
(page_header_get_offs(page, field) \
? page + page_header_get_offs(page, field) : NULL)

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

#define PAGE_HEADER_PRIV_END
Value:
26 /* end of private data structure of the page
header which are set in a page create */
#define PAGE_HEAP_NO_USER_LOW
Value:
2 /* first user record in
creation (insertion) order,
not necessarily collation order;
this record may have been deleted */
#define PAGE_INDEX_ID
Value:
28 /* index id where the page belongs.
This field should not be written to after
page creation. */
#define PAGE_LAST_INSERT
Value:
10 /* pointer to the last inserted record, or
NULL if this info has been reset by a delete,
for example */
#define PAGE_LEVEL
Value:
26 /* level of the node in an index tree; the
leaf level is the level 0. This field should
not be written to after page creation. */
#define PAGE_MAX_TRX_ID
Value:
18 /* highest id of a trx which may have modified
a record on the page; trx_id_t; defined only
in secondary indexes and in the insert buffer
tree */
#define PAGE_N_DIRECTION
Value:
14 /* number of consecutive inserts to the same
direction */
#define PAGE_N_HEAP
Value:
4 /* number of records in the heap,
bit 15=flag: new-style compact page format */

Function Documentation

UNIV_INLINE page_t* page_align ( const void *  ptr)

Gets the start of a page.

Returns
start of the page
Parameters
ptrin: pointer to page frame
UNIV_INTERN 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

UNIV_INLINE int page_cmp_dtuple_rec_with_match ( const dtuple_t dtuple,
const rec_t *  rec,
const ulint *  offsets,
ulint *  matched_fields,
ulint *  matched_bytes 
)

Compares a data tuple to a physical record. Differs from the function cmp_dtuple_rec_with_match in the way that the record must reside on an index page, and also page infimum and supremum records can be given in the parameter rec. These are considered as the negative infinity and the positive infinity in the alphabetical order.

Returns
1, 0, -1, if dtuple is greater, equal, less than rec, respectively, when only the common first fields are compared in/out: number of already matched bytes within the first field not completely matched; when function returns contains the value for current comparison

Compares a data tuple to a physical record. Differs from the function cmp_dtuple_rec_with_match in the way that the record must reside on an index page, and also page infimum and supremum records can be given in the parameter rec. These are considered as the negative infinity and the positive infinity in the alphabetical order.

Returns
1, 0, -1, if dtuple is greater, equal, less than rec, respectively, when only the common first fields are compared
Parameters
dtuplein: data tuple
recin: physical record on a page; may also be page infimum or supremum, in which case matched-parameter values below are not affected
offsetsin: array returned by rec_get_offsets()
matched_fieldsin/out: number of already completely matched fields; when function returns contains the value for current comparison
matched_bytesin/out: number of already matched bytes within the first field not completely matched; when function returns contains the value for current comparison
UNIV_INTERN 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)
Parameters
new_blockin/out: index page to copy to
blockin: index page containing rec
recin: record on page
indexin: record descriptor
mtrin: mtr
UNIV_INTERN 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

Parameters
new_blockin: index page to copy to
blockin: index page of rec
recin: record on page
indexin: record descriptor
UNIV_INTERN 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)
Parameters
new_blockin/out: index page to copy to
blockin: index page containing rec
recin: record on page
indexin: record descriptor
mtrin: mtr
UNIV_INTERN page_t* page_create ( buf_block_t block,
mtr_t mtr,
ulint  comp 
)

Create an uncompressed B-tree index page.

Returns
pointer to the page in: nonzero=compact page format
Parameters
blockin: a buffer block where the page is created
mtrin: mini-transaction handle
UNIV_INTERN void page_create_empty ( buf_block_t block,
dict_index_t index,
mtr_t mtr 
)

Empty a previously created B-tree index page.

Parameters
blockin/out: B-tree block
indexin: the index of the page
mtrin/out: mini-transaction
UNIV_INTERN page_t* page_create_zip ( buf_block_t block,
dict_index_t index,
ulint  level,
trx_id_t  max_trx_id,
mtr_t mtr 
)

Create a compressed B-tree index page.

Returns
pointer to the page
Parameters
blockin/out: a buffer frame where the page is created
indexin: the index of the page
levelin: the B-tree level of the page
max_trx_idin: PAGE_MAX_TRX_ID
mtrin/out: mini-transaction
UNIV_INTERN 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.

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
UNIV_INTERN 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.

Parameters
recin: record on page
blockin: buffer block of the page
indexin: record descriptor
mtrin: mtr
UNIV_INTERN 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
pagein/out: index page
page_zipin/out: compressed page, or NULL
slot_noin: the directory slot
UNIV_INLINE ulint page_dir_calc_reserved_space ( ulint  n_recs)

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

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.

Parameters
n_recsin: number of records
UNIV_INTERN 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
UNIV_INLINE ulint page_dir_get_n_heap ( const page_t page)

Gets the number of records in the heap.

Returns
number of user records in: index page

Gets the number of records in the heap.

Returns
number of user records
Parameters
pagein: index page
UNIV_INLINE ulint page_dir_get_n_slots ( const page_t page)

Gets the number of dir slots in directory.

Returns
number of slots in: index page

Gets the number of dir slots in directory.

Returns
number of slots
Parameters
pagein: index page
UNIV_INLINE page_dir_slot_t* page_dir_get_nth_slot ( const page_t page,
ulint  n 
)

Gets pointer to nth directory slot.

Returns
pointer to dir slot in: position

Gets pointer to nth directory slot.

Returns
pointer to dir slot
Parameters
pagein: index page
nin: position
UNIV_INLINE 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. in: number of records

Sets the number of records in the heap.

Parameters
pagein/out: index page
page_zipin/out: compressed 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.
n_heapin: number of records
UNIV_INLINE 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. in: number of slots

Sets the number of dir slots in directory.

Parameters
pagein/out: page
page_zipin/out: compressed page whose uncompressed part will be updated, or NULL
n_slotsin: number of slots
UNIV_INLINE ulint page_dir_slot_get_n_owned ( const page_dir_slot_t *  slot)

Gets the number of records owned by a directory slot.

Returns
number of records in: page directory slot

Gets the number of records owned by a directory slot.

Returns
number of records
Parameters
slotin: page directory slot
UNIV_INLINE const rec_t* page_dir_slot_get_rec ( const page_dir_slot_t *  slot)

Gets the record pointed to by a directory slot.

Returns
pointer to record in: directory slot

Gets the record pointed to by a directory slot.

Returns
pointer to record
Parameters
slotin: directory slot
UNIV_INLINE 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. in: number of records owned by the slot

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

Parameters
slotin/out: directory slot
page_zipin/out: compressed page, or NULL
nin: number of records owned by the slot
UNIV_INLINE 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. in: record on the page

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

Parameters
slotin: directory slot
recin: record on the page
UNIV_INTERN 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
pagein: index page
page_zipin/out: compressed page whose uncompressed part will be written, or NULL
slot_noin: the directory slot
const rec_t* page_find_rec_max_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
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
Parameters
pagein: index page
UNIV_INLINE 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.

Returns
data in bytes in: index page

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

Returns
data in bytes
Parameters
pagein: index page
UNIV_INLINE ulint page_get_free_space_of_empty ( ulint  comp)

Calculates free space if a page is emptied.

Returns
free space
Parameters
compin: nonzero=compact page layout
UNIV_INLINE ulint page_get_infimum_offset ( const page_t page)

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)

Gets the offset of the first record on the page.

Returns
offset of the first record in record list, relative from page
Parameters
pagein: page which must have record(s)
UNIV_INLINE 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.

Returns
maximum combined size for inserted records in: number of records

Each user record on a page, and also the deleted user records in the heap takes its size plus the fraction of the dir cell size / PAGE_DIR_SLOT_MIN_N_OWNED bytes for it. If the sum of these exceeds the value of page_get_free_space_of_empty, the insert is impossible, otherwise it is allowed. This function returns the maximum combined size of records which can be inserted on top of the record heap.

Returns
maximum combined size for inserted records
Parameters
pagein: index page
n_recsin: number of records
UNIV_INLINE 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.

Returns
maximum combined size for inserted records in: number of records

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

Returns
maximum combined size for inserted records
Parameters
pagein: index page
n_recsin: number of records
UNIV_INLINE trx_id_t page_get_max_trx_id ( const page_t page)

Returns the max trx id field value. in: page

Returns the max trx id field value.

Parameters
pagein: page
UNIV_INLINE rec_t* page_get_middle_rec ( page_t page)

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
Parameters
pagein: page
UNIV_INLINE 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).

Returns
number of user records in: index page

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

Returns
number of user records
Parameters
pagein: index page
UNIV_INLINE ulint page_get_page_no ( const page_t page)

Gets the page number.

Returns
page number in: page

Gets the page number.

Returns
page number
Parameters
pagein: page
UNIV_INLINE ulint page_get_space_id ( const page_t page)

Gets the tablespace identifier.

Returns
space id in: page

Gets the tablespace identifier.

Returns
space id
Parameters
pagein: page
UNIV_INLINE ulint page_get_supremum_offset ( const page_t page)

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)

Gets the offset of the last record on the page.

Returns
offset of the last record in record list, relative from page
Parameters
pagein: page which must have record(s)
UNIV_INLINE bool page_has_garbage ( const page_t page)

Determine whether the page contains garbage.

Returns
true if the page contains garbage (PAGE_GARBAGE is not 0)
Parameters
pagein: page
UNIV_INLINE ulint page_header_get_field ( const page_t page,
ulint  field 
)

Reads the given header field. in: PAGE_N_DIR_SLOTS, ...

Reads the given header field.

Parameters
pagein: page
fieldin: PAGE_LEVEL, ...
UNIV_INLINE ulint page_header_get_offs ( const page_t page,
ulint  field 
)

Returns the offset stored in the given header field.

Returns
offset from the start of the page, or 0
Parameters
pagein: page
fieldin: PAGE_FREE, ...
UNIV_INLINE 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. Writes to mlog about this operation. in: mtr

Resets the last insert info field in the page header. Writes to mlog about this operation.

Parameters
pagein/out: page
page_zipin/out: compressed page whose uncompressed part will be updated, or NULL
mtrin: mtr
UNIV_INLINE void page_header_set_field ( page_t page,
page_zip_des_t page_zip,
ulint  field,
ulint  val 
)

Sets the given header field. in: value

Sets the given header field.

Parameters
pagein/out: page
page_zipin/out: compressed page whose uncompressed part will be updated, or NULL
fieldin: PAGE_N_DIR_SLOTS, ...
valin: value
UNIV_INLINE 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. in: pointer or NULL

Sets the pointer stored in the given header field.

Parameters
pagein: page
page_zipin/out: compressed page whose uncompressed part will be updated, or NULL
fieldin: PAGE_FREE, ...
ptrin: pointer or NULL
UNIV_INLINE ulint page_is_comp ( const page_t page)

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

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
Parameters
pagein: index page
UNIV_INLINE bool page_is_empty ( const page_t page)

Determine whether the page is empty.

Returns
true if the page is empty (PAGE_N_RECS = 0)
Parameters
pagein: page
UNIV_INLINE bool page_is_leaf ( const page_t page)

Determine whether the page is a B-tree leaf.

Returns
true if the page is a B-tree leaf (PAGE_LEVEL = 0)
Parameters
pagein: page
UNIV_INLINE 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. in: number of bytes allocated

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

Parameters
pagein/out: index page
page_zipin/out: compressed page with enough space available for inserting the record, or NULL
next_recin: pointer to the new head of the free record list
needin: number of bytes allocated
UNIV_INTERN 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
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
UNIV_INLINE 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. in: array returned by rec_get_offsets()

Puts a record to free list.

Parameters
pagein/out: index page
page_zipin/out: compressed page, or NULL
recin: pointer to the (origin of) record
indexin: index of rec
offsetsin: array returned by rec_get_offsets()
UNIV_INTERN ibool 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)
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
UNIV_INTERN ibool 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
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
UNIV_INLINE ulint page_offset ( const void *  ptr)

Gets the offset within a page.

Returns
offset from the start of the page
Parameters
ptrin: pointer to page frame
UNIV_INTERN byte* page_parse_create ( byte *  ptr,
byte *  end_ptr,
ulint  comp,
buf_block_t block,
mtr_t mtr 
)

Parses a redo log record of creating a page.

Returns
end of log record or NULL in: mtr or NULL
Parameters
ptrin: buffer
end_ptrin: buffer end
compin: nonzero=compact page format
blockin: block or NULL
UNIV_INTERN byte* page_parse_delete_rec_list ( byte  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
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
UNIV_INLINE ibool page_rec_check ( const rec_t *  rec)

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

Returns
TRUE if succeed in: record

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

Returns
TRUE if succeed
Parameters
recin: record
UNIV_INLINE rec_t* page_rec_find_owner_rec ( rec_t *  rec)

Looks for the record which owns the given record.

Returns
the owner record in: the physical record

Looks for the record which owns the given record.

Returns
the owner record
Parameters
recin: the physical record
UNIV_INLINE ulint page_rec_get_base_extra_size ( const rec_t *  rec)

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

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
Parameters
recin: physical record
UNIV_INLINE ulint page_rec_get_heap_no ( const rec_t *  rec)

Returns the heap number of a record.

Returns
heap number in: the physical record

Returns the heap number of a record.

Returns
heap number
Parameters
recin: the physical record
UNIV_INTERN 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
UNIV_INLINE rec_t* page_rec_get_next ( rec_t *  rec)

Gets the pointer to the next record on the page.

Returns
pointer to next record in: pointer to record

Gets the pointer to the next record on the page.

Returns
pointer to next record
Parameters
recin: pointer to record
UNIV_INLINE const rec_t* page_rec_get_next_const ( const rec_t *  rec)

Gets the pointer to the next record on the page.

Returns
pointer to next record in: pointer to record

Gets the pointer to the next record on the page.

Returns
pointer to next record
Parameters
recin: pointer to record
UNIV_INLINE const rec_t* page_rec_get_next_low ( const rec_t *  rec,
ulint  comp 
)

Gets the pointer to the next record on the page.

Returns
pointer to next record in: nonzero=compact page layout

Gets the pointer to the next record on the page.

Returns
pointer to next record
Parameters
recin: pointer to record
compin: nonzero=compact page layout
UNIV_INLINE const rec_t* page_rec_get_next_non_del_marked ( const rec_t *  rec)

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

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
Parameters
recin: pointer to record
UNIV_INLINE rec_t* page_rec_get_nth ( 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
Parameters
pagein: page
nthin: nth record
UNIV_INTERN 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
Parameters
pagein: page
nthin: nth record
UNIV_INLINE rec_t* page_rec_get_prev ( rec_t *  rec)

Gets the pointer to the previous record.

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

Gets the pointer to the previous record.

Returns
pointer to previous record
Parameters
recin: pointer to record, must not be page infimum
UNIV_INLINE const rec_t* page_rec_get_prev_const ( const rec_t *  rec)

Gets the pointer to the previous record.

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

Gets the pointer to the previous record.

Returns
pointer to previous record
Parameters
recin: pointer to record, must not be page infimum
UNIV_INLINE ulint page_rec_is_comp ( const rec_t *  rec)

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

Returns
nonzero if in compact format in: record

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

Returns
nonzero if in compact format
Parameters
recin: record
UNIV_INLINE ibool page_rec_is_infimum ( const rec_t *  rec)

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

Returns
TRUE if the infimum record
Parameters
recin: record
UNIV_INLINE ibool page_rec_is_infimum_low ( ulint  offset)

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

Returns
TRUE if the infimum record
Parameters
offsetin: record offset on page
UNIV_INLINE ibool page_rec_is_supremum ( const rec_t *  rec)

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

Returns
TRUE if the supremum record
Parameters
recin: record
UNIV_INLINE ibool page_rec_is_supremum_low ( ulint  offset)

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

Returns
TRUE if the supremum record
Parameters
offsetin: record offset on page
UNIV_INLINE ibool page_rec_is_user_rec ( const rec_t *  rec)

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

Returns
TRUE if a user record
Parameters
recin: record
UNIV_INLINE ibool page_rec_is_user_rec_low ( ulint  offset)

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

Returns
TRUE if a user record
Parameters
offsetin: record offset on page
UNIV_INTERN void page_rec_print ( const rec_t *  rec,
const ulint *  offsets 
)

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

Parameters
recin: physical record
UNIV_INLINE void page_rec_set_next ( rec_t *  rec,
const rec_t *  next 
)

Sets the pointer to the next record on the page. in: pointer to next record, must not be page infimum

Sets the pointer to the next record on the page.

Parameters
recin: pointer to record, must not be page supremum
nextin: pointer to next record, must not be page infimum
UNIV_INTERN ibool 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()
Parameters
recin: physical record
UNIV_INLINE void page_rec_write_field ( rec_t *  rec,
ulint  i,
ulint  val,
mtr_t mtr 
)

Write a 32-bit field in a data dictionary record.

Parameters
recin/out: record to update
iin: index of the field to update
valin: value to write
mtrin/out: mini-transaction
UNIV_INTERN 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: mini-transaction, or NULL

Parameters
blockin/out: page
page_zipin/out: compressed page, or NULL
trx_idin: transaction id
UNIV_INTERN ibool 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
UNIV_INTERN ibool 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
UNIV_INLINE 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. in/out: mini-transaction

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

Parameters
blockin/out: page
page_zipin/out: compressed page whose uncompressed part will be updated, or NULL
trx_idin: transaction id
mtrin/out: mini-transaction
UNIV_INTERN ibool page_validate ( const page_t page,
dict_index_t index 
)

This function checks the consistency of an index page.

Returns
TRUE if ok in: data dictionary index containing the page record type definition
Parameters
pagein: index page