InnoDB Plugin  1.0
Functions
page0page.ic File Reference
#include "mach0data.h"
#include "log0recv.h"
#include "rem0cmp.h"
#include "mtr0log.h"
#include "page0zip.h"
Include dependency graph for page0page.ic:
This graph shows which files directly or indirectly include this file:

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_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_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 ulint page_get_infimum_offset (const page_t *page)
UNIV_INLINE ulint page_get_supremum_offset (const page_t *page)
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_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_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 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 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_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 rec_t * page_rec_find_owner_rec (rec_t *rec)
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_INLINE ulint page_get_free_space_of_empty (ulint comp)
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 void page_mem_free (page_t *page, page_zip_des_t *page_zip, rec_t *rec, const dict_index_t *index, const ulint *offsets)

Detailed Description

Index page routines

Created 2/2/1994 Heikki Tuuri

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

Parameters
n_recsin: number of records
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
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
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
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.

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.

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

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.

Parameters
slotin: directory slot
recin: record on the 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
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
Parameters
pagein: page which must have record(s)
UNIV_INLINE ulint page_get_max_insert_size ( const page_t page,
ulint  n_recs 
)

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

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 (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
Parameters
pagein: page
UNIV_INLINE ulint page_get_space_id ( const page_t 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
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.

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.

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.

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.

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

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_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_INLINE ibool page_rec_check ( const rec_t *  rec)

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
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
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
Parameters
recin: 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
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
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
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
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_INLINE rec_t* page_rec_get_prev ( rec_t *  rec)

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
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
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_INLINE void page_rec_set_next ( rec_t *  rec,
const rec_t *  next 
)

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

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