Drizzled Public API Documentation

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"

Go to the source code of this file.

Defines

#define PAGE_HEADER   FSEG_PAGE_DATA
#define PAGE_N_DIR_SLOTS   0
#define PAGE_HEAP_TOP   2
#define PAGE_N_HEAP   4
#define PAGE_FREE   6
#define PAGE_GARBAGE   8
#define PAGE_LAST_INSERT   10
#define PAGE_DIRECTION   12
#define PAGE_N_DIRECTION   14
#define PAGE_N_RECS   16
#define PAGE_MAX_TRX_ID   18
#define PAGE_HEADER_PRIV_END   26
#define PAGE_LEVEL   26
#define PAGE_INDEX_ID   28
#define PAGE_BTR_SEG_LEAF   36
#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
#define PAGE_HEAP_NO_SUPREMUM   1
#define PAGE_HEAP_NO_USER_LOW   2
#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))
#define page_dir_get_nth_slot(page, n)

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) __attribute__((const ))
UNIV_INLINE ulint page_offset (const void *ptr) __attribute__((const ))
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) __attribute__((nonnull
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 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 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 ibool page_is_leaf (const page_t *page) __attribute__((nonnull
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 void page_rec_set_next (rec_t *rec, 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) __attribute__((const ))
UNIV_INLINE ibool page_rec_is_supremum_low (ulint offset) __attribute__((const ))
UNIV_INLINE ibool page_rec_is_infimum_low (ulint offset) __attribute__((const ))
UNIV_INLINE ibool page_rec_is_user_rec (const rec_t *rec) __attribute__((const ))
UNIV_INLINE ibool page_rec_is_supremum (const rec_t *rec) __attribute__((const ))
UNIV_INLINE ibool page_rec_is_infimum (const rec_t *rec) __attribute__((const ))
UNIV_INLINE rec_t * page_rec_find_owner_rec (rec_t *rec)
UNIV_INTERN void page_rec_write_index_page_no (rec_t *rec, ulint i, ulint page_no, 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) __attribute__((const ))
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, 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, 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) __attribute__((nonnull))
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) __attribute__((nonnull))
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) __attribute__((nonnull))
UNIV_INTERN void page_delete_rec_list_start (rec_t *rec, buf_block_t *block, dict_index_t *index, mtr_t *mtr) __attribute__((nonnull))
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) __attribute__((nonnull(1
UNIV_INTERN ibool 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) __attribute__((nonnull(1
UNIV_INTERN ibool UNIV_INTERN
ibool UNIV_INTERN void 
page_dir_split_slot (page_t *page, page_zip_des_t *page_zip, ulint slot_no) __attribute__((nonnull(1)))
UNIV_INTERN void page_dir_balance_slot (page_t *page, page_zip_des_t *page_zip, ulint slot_no) __attribute__((nonnull(1)))
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 void page_dir_print (page_t *page, ulint pr_n)
UNIV_INTERN void page_print_list (buf_block_t *block, dict_index_t *index, ulint pr_n)
UNIV_INTERN void page_header_print (const page_t *page)
UNIV_INTERN void page_print (buf_block_t *block, dict_index_t *index, ulint dn, ulint rn)
UNIV_INTERN ibool page_rec_validate (rec_t *rec, const ulint *offsets)
UNIV_INTERN void page_check_dir (const page_t *page)
UNIV_INTERN ibool page_simple_validate_old (page_t *page)
UNIV_INTERN ibool page_simple_validate_new (page_t *block)
UNIV_INTERN ibool page_validate (page_t *page, dict_index_t *index)
const rec_t * page_find_rec_with_heap_no (const page_t *page, ulint heap_no)

Variables

UNIV_INLINE ulint pure

Detailed Description

Index page routines

Created 2/2/1994 Heikki Tuuri

Definition in file page0page.h.


Define Documentation

#define page_dir_get_nth_slot (   page,
 
)
Value:
((page) + UNIV_PAGE_SIZE - PAGE_DIR \
   - (n + 1) * PAGE_DIR_SLOT_SIZE)

Definition at line 408 of file page0page.h.

#define page_header_get_ptr (   page,
  field 
)

Function Documentation

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

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.

Parameters:
pagein: index page

Definition at line 1839 of file page0page.cc.

References mach_read_from_2(), page_check_dir(), page_dir_get_n_slots(), page_rec_is_infimum_low(), and page_rec_is_supremum_low().

Referenced by btr_pcur_move_to_next_page(), page_check_dir(), and page_cur_search_with_match().

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

Referenced by page_cur_search_with_match().

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.

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

Copies records from page to new_page, from a 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.

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

Definition at line 614 of file page0page.cc.

References buf_block_get_page_zip, dict_index_is_sec_or_ibuf(), lock_move_rec_list_end(), mtr_set_log_mode(), page_align(), page_copy_rec_list_end(), page_copy_rec_list_end_no_locks(), page_copy_rec_list_end_to_created_page(), page_dir_get_n_heap(), page_get_max_trx_id(), page_is_comp(), page_is_leaf(), page_rec_get_n_recs_before(), page_rec_get_next(), page_update_max_trx_id(), page_validate(), page_zip_compress(), page_zip_decompress(), page_zip_reorganize(), rec_get_next_ptr(), ut_a, ut_ad, and ut_error.

Referenced by btr_compress(), btr_root_raise_and_insert(), and page_copy_rec_list_end().

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

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

Definition at line 539 of file page0page.cc.

References dict_table_is_comp(), mach_read_from_2(), mem_heap_free, page_align(), page_copy_rec_list_end_no_locks(), page_cur_insert_rec_low(), page_cur_is_after_last(), page_cur_is_before_first(), page_cur_move_to_next(), page_cur_position(), page_is_comp(), page_offset(), page_rec_is_comp(), dict_index_struct::table, ut_a, ut_error, and ut_print_timestamp().

Referenced by page_copy_rec_list_end(), page_copy_rec_list_end_no_locks(), and page_zip_reorganize().

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.

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

Definition at line 722 of file page0page.cc.

References buf_block_get_page_zip, dict_index_is_sec_or_ibuf(), lock_move_rec_list_start(), mem_heap_free, mtr_set_log_mode(), page_align(), page_copy_rec_list_start(), page_cur_insert_rec_low(), page_cur_move_to_next(), page_cur_set_before_first(), page_get_max_trx_id(), page_is_leaf(), page_rec_get_n_recs_before(), page_rec_get_prev(), page_rec_is_infimum(), page_update_max_trx_id(), page_validate(), page_zip_compress(), page_zip_decompress(), page_zip_reorganize(), rec_get_next_ptr(), ut_a, ut_ad, and ut_error.

Referenced by btr_compress(), and page_copy_rec_list_start().

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

Create an uncompressed B-tree index page.

Returns:
pointer to the page
Parameters:
blockin: a buffer block where the page is created
mtrin: mini-transaction handle
compin: nonzero=compact page format

Definition at line 490 of file page0page.cc.

References page_create().

Referenced by btr_create(), page_create(), page_parse_create(), and page_zip_reorganize().

UNIV_INTERN page_t* page_create_zip ( buf_block_t block,
dict_index_t index,
ulint  level,
mtr_t mtr 
)

Create a compressed B-tree index page.

Returns:
pointer to the page in: mini-transaction handle

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
mtrin: mini-transaction handle

Definition at line 506 of file page0page.cc.

References buf_block_get_page_zip, dict_table_is_comp(), mach_write_to_2(), page_create_zip(), page_zip_compress(), dict_index_struct::table, ut_ad, and ut_error.

Referenced by btr_create(), and page_create_zip().

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

Definition at line 922 of file page0page.cc.

References buf_block_get_page_zip, buf_block_modify_clock_inc(), mem_heap_free, MLOG_COMP_LIST_END_DELETE, MLOG_LIST_END_DELETE, mtr_set_log_mode(), page_align(), page_cur_delete_rec(), page_cur_position(), page_delete_rec_list_end(), page_dir_find_owner_slot(), page_dir_set_n_slots(), page_dir_slot_set_n_owned(), page_dir_slot_set_rec(), page_get_n_recs(), page_header_get_field(), page_header_get_ptr, page_header_set_field(), page_header_set_ptr(), page_is_comp(), page_offset(), page_rec_get_next(), page_rec_get_prev(), page_rec_is_comp(), page_rec_is_infimum(), page_rec_is_supremum(), page_rec_set_next(), rec_get_n_owned_new(), rec_get_n_owned_old(), rec_get_next_ptr(), rec_offs_extra_size(), rec_offs_size(), ut_a, and ut_ad.

Referenced by btr_page_split_and_insert(), page_delete_rec_list_end(), and page_parse_delete_rec_list().

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

Definition at line 1098 of file page0page.cc.

References buf_block_get_page_zip, dict_table_is_comp(), mem_heap_free, MLOG_COMP_LIST_START_DELETE, MLOG_LIST_START_DELETE, mtr_set_log_mode(), page_cur_delete_rec(), page_cur_move_to_next(), page_cur_set_before_first(), page_delete_rec_list_start(), page_rec_is_comp(), page_rec_is_infimum(), dict_index_struct::table, ut_a, and ut_ad.

Referenced by btr_page_split_and_insert(), page_delete_rec_list_start(), and page_parse_delete_rec_list().

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

Definition at line 1412 of file page0page.cc.

References page_dir_balance_slot(), page_dir_get_n_slots(), page_dir_slot_get_n_owned(), page_dir_slot_get_rec(), page_dir_slot_set_n_owned(), page_dir_slot_set_rec(), page_is_comp(), rec_get_next_ptr(), rec_set_n_owned_new(), rec_set_n_owned_old(), and ut_ad.

Referenced by page_cur_delete_rec(), and page_dir_balance_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

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

Looks for the directory slot which owns the given record.

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

Definition at line 89 of file page0page.cc.

References mach_decode_2(), mach_encode_2(), page_align(), page_dir_find_owner_slot(), page_dir_get_n_slots(), page_get_page_no(), page_is_comp(), page_rec_check(), rec_get_n_owned_new(), rec_get_n_owned_old(), rec_get_next_ptr_const(), rec_print_old(), ut_ad, and ut_error.

Referenced by page_cur_delete_rec(), page_cur_insert_rec_low(), page_cur_insert_rec_zip(), page_delete_rec_list_end(), and page_dir_find_owner_slot().

UNIV_INLINE ulint page_dir_get_n_slots ( const page_t page)
UNIV_INTERN void page_dir_print ( page_t page,
ulint  pr_n 
)

This is used to print the contents of the directory for debugging purposes. in: print n first and n last entries

This is used to print the contents of the directory for debugging purposes.

Parameters:
pagein: index page
pr_nin: print n first and n last entries

Definition at line 1627 of file page0page.cc.

References page_dir_get_n_slots(), page_dir_print(), page_dir_slot_get_n_owned(), page_dir_slot_get_rec(), page_get_n_recs(), and page_offset().

Referenced by page_dir_print(), and page_print().

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

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.

Referenced by page_copy_rec_list_end_to_created_page(), and page_mem_alloc_heap().

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

Parameters:
pagein/out: page
page_zipin/out: compressed page whose uncompressed part will be updated, or NULL

Referenced by page_copy_rec_list_end_to_created_page(), and page_delete_rec_list_end().

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

Referenced by page_cur_delete_rec(), page_dir_balance_slot(), page_dir_print(), page_dir_split_slot(), and page_get_middle_rec().

UNIV_INLINE const rec_t* page_dir_slot_get_rec ( 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 
)

This is used to set the owned records field of a directory slot. in: number of records owned by the slot

Parameters:
slotin/out: directory slot
page_zipin/out: compressed page, or NULL

Referenced by page_copy_rec_list_end_to_created_page(), page_cur_delete_rec(), page_delete_rec_list_end(), page_dir_balance_slot(), and page_dir_split_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

Parameters:
slotin: directory slot

Referenced by page_copy_rec_list_end_to_created_page(), page_cur_delete_rec(), page_delete_rec_list_end(), page_dir_balance_slot(), and page_dir_split_slot().

UNIV_INTERN ibool UNIV_INTERN ibool 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/out: index page
page_zipin/out: compressed page whose uncompressed part will be written, or NULL
slot_noin: the directory slot

Definition at line 1349 of file page0page.cc.

References page_dir_slot_get_n_owned(), page_dir_slot_get_rec(), page_dir_slot_set_n_owned(), page_dir_slot_set_rec(), page_dir_split_slot(), page_is_comp(), page_rec_get_next(), and ut_ad.

Referenced by page_cur_insert_rec_low(), page_cur_insert_rec_zip(), and page_dir_split_slot().

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

Looks in the page record list for a record with the given heap number.

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

Definition at line 2583 of file page0page.cc.

References page_find_rec_with_heap_no(), page_is_comp(), rec_get_heap_no_new(), rec_get_heap_no_old(), and rec_get_next_offs().

Referenced by lock_rec_print(), and page_find_rec_with_heap_no().

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

Referenced by btr_compress(), btr_cur_optimistic_update(), and page_validate().

UNIV_INLINE ulint page_get_free_space_of_empty ( ulint  comp) const

Calculates free space if a page is emptied.

Returns:
free space
Parameters:
compin: nonzero=compact page format

Referenced by btr_cur_optimistic_update(), convert_error_code_to_mysql(), and ibuf_insert().

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

Referenced by btr_compress(), btr_create(), btr_cur_optimistic_insert(), and page_mem_alloc_heap().

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
Parameters:
pagein: index page

Referenced by btr_compress(), btr_cur_optimistic_delete(), btr_cur_optimistic_insert(), and btr_cur_optimistic_update().

UNIV_INLINE trx_id_t page_get_max_trx_id ( const page_t page)
UNIV_INTERN rec_t* page_get_middle_rec ( page_t page)

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

Returns:
middle record in: page

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

Returns:
middle record
Parameters:
pagein: page

Definition at line 1484 of file page0page.cc.

References page_dir_slot_get_n_owned(), page_dir_slot_get_rec(), page_get_middle_rec(), page_get_n_recs(), page_rec_get_next(), and ut_ad.

Referenced by btr_page_split_and_insert(), and page_get_middle_rec().

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)
UNIV_INLINE ulint page_header_get_field ( const page_t page,
ulint  field 
)
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_INTERN void page_header_print ( const page_t page)

Prints the info in a page header. in: index page

Prints the info in a page header.

Definition at line 1739 of file page0page.cc.

References page_dir_get_n_heap(), page_header_get_field(), page_header_print(), and page_is_comp().

Referenced by page_header_print(), and page_print().

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

Parameters:
pagein: page
page_zipin/out: compressed page whose uncompressed part will be updated, or NULL
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

Parameters:
pagein/out: page
page_zipin/out: compressed page whose uncompressed part will be updated, or NULL
fieldin: PAGE_N_DIR_SLOTS, ...

Referenced by page_copy_rec_list_end_to_created_page(), page_cur_insert_rec_low(), page_cur_insert_rec_zip(), page_delete_rec_list_end(), and page_parse_copy_rec_list_to_created_page().

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

Parameters:
pagein/out: page
page_zipin/out: compressed page whose uncompressed part will be updated, or NULL
fieldin/out: PAGE_FREE, ...

Referenced by page_copy_rec_list_end_to_created_page(), page_cur_delete_rec(), page_cur_insert_rec_low(), page_cur_insert_rec_zip(), page_delete_rec_list_end(), page_mem_alloc_heap(), and page_parse_copy_rec_list_to_created_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

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

Referenced by page_cur_insert_rec_low(), and page_cur_insert_rec_zip().

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

Allocates a block of memory from the heap of an index page.

Returns:
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

Definition at line 255 of file page0page.cc.

References page_dir_get_n_heap(), page_dir_set_n_heap(), page_get_max_insert_size(), page_header_get_ptr, page_header_set_ptr(), page_mem_alloc_heap(), and ut_ad.

Referenced by page_cur_insert_rec_low(), page_cur_insert_rec_zip(), and page_mem_alloc_heap().

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

Puts a record to free list. in: array returned by rec_get_offsets()

Parameters:
pagein/out: index page
page_zipin/out: compressed page, or NULL
recin: pointer to the (origin of) record
indexin: index of rec

Referenced by page_cur_delete_rec().

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.

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

Referenced by btr_page_split_and_insert().

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

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

Referenced by btr_page_split_and_insert().

UNIV_INTERN byte* page_parse_create ( byte *  ptr,
byte *  ,
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

Parses a redo log record of creating a page.

Returns:
end of log record or NULL
Parameters:
ptrin: buffer
compin: nonzero=compact page format
blockin: block or NULL
mtrin: mtr or NULL

Definition at line 313 of file page0page.cc.

References page_create(), page_parse_create(), and ut_ad.

Referenced by page_parse_create().

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

Parses a log record of a record list end or start deletion.

Returns:
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

Definition at line 866 of file page0page.cc.

References dict_table_is_comp(), mach_read_from_2(), MLOG_COMP_LIST_END_DELETE, MLOG_COMP_LIST_START_DELETE, MLOG_LIST_END_DELETE, MLOG_LIST_START_DELETE, page_delete_rec_list_end(), page_delete_rec_list_start(), page_is_comp(), page_parse_delete_rec_list(), dict_index_struct::table, and ut_ad.

Referenced by page_parse_delete_rec_list().

UNIV_INTERN void page_print ( buf_block_t block,
dict_index_t index,
ulint  dn,
ulint  rn 
)

This is used to print the contents of the page for debugging purposes. in: print rn first and last records in directory

This is used to print the contents of the page for debugging purposes.

Parameters:
blockin: index page
indexin: dictionary index of the page
dnin: print dn first and last entries in directory
rnin: print rn first and last records in directory

Definition at line 1767 of file page0page.cc.

References buf_block_struct::frame, page_dir_print(), page_header_print(), page_print(), and page_print_list().

Referenced by page_print().

UNIV_INTERN void page_print_list ( buf_block_t block,
dict_index_t index,
ulint  pr_n 
)

This is used to print the contents of the page record list for debugging purposes. in: print n first and n last entries

This is used to print the contents of the page record list for debugging purposes.

Parameters:
blockin: index page
indexin: dictionary index of the page
pr_nin: print n first and n last entries

Definition at line 1669 of file page0page.cc.

References dict_table_is_comp(), buf_block_struct::frame, mem_heap_free, page_cur_is_after_last(), page_cur_move_to_next(), page_cur_set_before_first(), page_get_n_recs(), page_is_comp(), page_print_list(), page_rec_print(), page_cur_struct::rec, dict_index_struct::table, and ut_a.

Referenced by page_print(), and page_print_list().

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

Referenced by page_dir_find_owner_slot(), page_rec_get_n_recs_before(), page_rec_print(), and page_rec_validate().

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

Referenced by page_cur_insert_rec_low(), and page_cur_insert_rec_zip().

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

Returns:
number of records in: the physical record

Returns the number of records before the given record in chain. The number includes infimum and supremum records.

Returns:
number of records
Parameters:
recin: the physical record

Definition at line 1533 of file page0page.cc.

References page_align(), page_dir_slot_get_rec(), page_is_comp(), page_rec_check(), page_rec_get_n_recs_before(), rec_get_n_owned_new(), rec_get_n_owned_old(), rec_get_next_ptr_const(), and ut_ad.

Referenced by page_copy_rec_list_end(), page_copy_rec_list_start(), and page_rec_get_n_recs_before().

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

Referenced by lock_rec_insert_check_and_lock(), lock_update_merge_left(), page_cur_search_with_match(), and row_search_for_mysql().

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
Parameters:
recin: pointer to record

Referenced by btr_search_drop_page_hash_index(), and lock_update_insert().

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

Referenced by btr_get_prev_user_rec(), btr_pcur_store_position(), page_copy_rec_list_start(), page_cur_parse_insert_rec(), and page_delete_rec_list_end().

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
UNIV_INLINE ibool page_rec_is_infimum ( const rec_t *  rec) const
UNIV_INLINE ibool page_rec_is_infimum_low ( ulint  offset) const

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

Returns:
TRUE if the infimum record
Parameters:
offsetin: record offset on page

Referenced by btr_pcur_store_position(), and page_check_dir().

UNIV_INLINE ibool page_rec_is_supremum_low ( ulint  offset) const

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

Returns:
TRUE if the supremum record
Parameters:
offsetin: record offset on page

Referenced by btr_pcur_store_position(), and page_check_dir().

UNIV_INLINE ibool page_rec_is_user_rec ( const rec_t *  rec) const

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

Returns:
TRUE if a user record
Parameters:
recin: record

Referenced by btr_discard_page(), btr_search_guess_on_hash(), lock_clust_rec_cons_read_sees(), lock_clust_rec_read_check_and_lock(), lock_sec_rec_cons_read_sees(), lock_sec_rec_read_check_and_lock(), page_cur_delete_rec(), and page_validate().

UNIV_INLINE ibool page_rec_is_user_rec_low ( ulint  offset) const

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

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

Parameters:
recin: physical record
offsetsin: record descriptor

Definition at line 1597 of file page0page.cc.

References page_rec_check(), page_rec_is_comp(), page_rec_print(), rec_get_heap_no_new(), rec_get_heap_no_old(), rec_get_n_owned_new(), rec_get_n_owned_old(), rec_get_next_offs(), rec_offs_comp(), rec_print_new(), rec_validate(), and ut_a.

Referenced by page_print_list(), and page_rec_print().

UNIV_INLINE void page_rec_set_next ( rec_t *  rec,
rec_t *  next 
)

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

Parameters:
recin: pointer to record, must not be page supremum

Referenced by page_cur_delete_rec(), page_cur_insert_rec_low(), page_cur_insert_rec_zip(), and page_delete_rec_list_end().

UNIV_INTERN ibool page_rec_validate ( 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()

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
Parameters:
recin: physical record
offsetsin: array returned by rec_get_offsets()

Definition at line 1791 of file page0page.cc.

References page_align(), page_dir_get_n_heap(), page_is_comp(), page_offset(), page_rec_check(), page_rec_is_comp(), page_rec_validate(), rec_get_heap_no_new(), rec_get_heap_no_old(), rec_get_n_owned_new(), rec_get_n_owned_old(), rec_offs_comp(), rec_validate(), and ut_a.

Referenced by page_rec_validate(), and page_validate().

UNIV_INTERN void page_rec_write_index_page_no ( rec_t *  rec,
ulint  i,
ulint  page_no,
mtr_t mtr 
)

This is a low-level operation which is used in a database index creation to update the page number of a created B-tree to a data dictionary record. in: mtr

This is a low-level operation which is used in a database index creation to update the page number of a created B-tree to a data dictionary record.

Parameters:
recin: record to update
iin: index of the field to update
page_noin: value to write
mtrin: mtr

Definition at line 1249 of file page0page.cc.

References MLOG_4BYTES, mlog_write_ulint(), page_rec_write_index_page_no(), and ut_ad.

Referenced by dict_drop_index_tree(), dict_truncate_index_tree(), page_rec_write_index_page_no(), and row_truncate_table_for_mysql().

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

Sets the max trx id field value.

Parameters:
blockin/out: page
page_zipin/out: compressed page, or NULL
trx_idin: transaction id
mtrin/out: mini-transaction, or NULL

Definition at line 207 of file page0page.cc.

References btr_search_latch, buf_block_struct::is_hashed, mach_write_to_8(), mlog_write_ull(), page_set_max_trx_id(), page_zip_write_header(), and ut_ad.

Referenced by page_set_max_trx_id(), and page_zip_reorganize().

UNIV_INTERN ibool page_simple_validate_new ( 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: new-style index 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
Parameters:
pagein: new-style index page

Definition at line 2087 of file page0page.cc.

References FIL_PAGE_DATA, page_dir_get_n_heap(), page_dir_get_n_slots(), page_dir_slot_get_rec(), page_header_get_field(), page_header_get_ptr, page_is_comp(), page_offset(), page_rec_get_next(), page_rec_is_supremum(), page_simple_validate_new(), rec_get_n_owned_new(), rec_get_next_offs(), and ut_a.

Referenced by page_simple_validate_new(), page_validate(), page_zip_write_rec(), and page_zip_write_trx_id_and_roll_ptr().

UNIV_INTERN ibool page_simple_validate_old ( 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: old-style index 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
Parameters:
pagein: old-style index page

Definition at line 1877 of file page0page.cc.

References FIL_PAGE_DATA, page_dir_get_n_heap(), page_dir_get_n_slots(), page_dir_slot_get_rec(), page_header_get_field(), page_header_get_ptr, page_is_comp(), page_offset(), page_rec_get_next(), page_rec_is_supremum(), page_simple_validate_old(), rec_get_n_owned_old(), rec_get_next_offs(), and ut_a.

Referenced by page_simple_validate_old(), and page_validate().

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

Parameters:
blockin/out: page
page_zipin/out: compressed page whose uncompressed part will be updated, or NULL
trx_idin: transaction id

Referenced by btr_cur_pessimistic_update(), lock_rec_insert_check_and_lock(), lock_sec_rec_modify_check_and_lock(), page_copy_rec_list_end(), and page_copy_rec_list_start().

UNIV_INTERN ibool page_validate ( page_t page,
dict_index_t index 
)