MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
page0page.cc File Reference
#include "page0page.h"
#include "page0cur.h"
#include "page0zip.h"
#include "buf0buf.h"
#include "btr0btr.h"
#include "srv0srv.h"
#include "lock0lock.h"
#include "fut0lst.h"
#include "btr0sea.h"
Include dependency graph for page0page.cc:

Go to the source code of this file.

Functions

UNIV_INTERN ulint page_dir_find_owner_slot (const rec_t *rec)
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_INTERN byte * page_mem_alloc_heap (page_t *page, page_zip_des_t *page_zip, ulint need, ulint *heap_no)
UNIV_INLINE void page_create_write_log (buf_frame_t *frame, mtr_t *mtr, ibool comp)
UNIV_INTERN byte * page_parse_create (byte *ptr, byte *end_ptr __attribute__((unused)), ulint comp, buf_block_t *block, mtr_t *mtr)
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_INLINE void page_delete_rec_list_write_log (rec_t *rec, dict_index_t *index, byte type, mtr_t *mtr)
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 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_INLINE void page_dir_delete_slot (page_t *page, page_zip_des_t *page_zip, ulint slot_no)
UNIV_INLINE void page_dir_add_slot (page_t *page, page_zip_des_t *page_zip, ulint start)
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 const rec_t * page_rec_get_nth_const (const page_t *page, ulint nth)
UNIV_INTERN ulint page_rec_get_n_recs_before (const rec_t *rec)
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)
UNIV_INTERN const rec_t * page_find_rec_with_heap_no (const page_t *page, ulint heap_no)
UNIV_INTERN bool page_delete_rec (const dict_index_t *index, page_cur_t *pcur, page_zip_des_t *page_zip, const ulint *offsets)

Detailed Description

Index page routines

Created 2/2/1994 Heikki Tuuri

Definition in file page0page.cc.

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.

Parameters
pagein: index page

Definition at line 1927 of file page0page.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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

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

Definition at line 655 of file page0page.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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

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 573 of file page0page.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 771 of file page0page.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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
Parameters
blockin: a buffer block where the page is created
mtrin: mini-transaction handle
compin: nonzero=compact page format

Definition at line 481 of file page0page.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 532 of file page0page.cc.

Here is the call graph for this function:

UNIV_INLINE void page_create_write_log ( buf_frame_t frame,
mtr_t mtr,
ibool  comp 
)

Writes a log record of page creation.

Parameters
framein: a buffer frame where the page is created
mtrin: mini-transaction handle
compin: TRUE=compact page format

Definition at line 284 of file page0page.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 497 of file page0page.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN bool page_delete_rec ( const dict_index_t index,
page_cur_t pcur,
page_zip_des_t page_zip,
const ulint *  offsets 
)

Removes the record from a leaf page. This function does not log any changes. It is used by the IMPORT tablespace functions. The cursor is moved to the next record after the deleted one.

Returns
true if success, i.e., the page did not become too empty
Parameters
indexin: The index that the record belongs to
pcurin/out: page cursor on record to delete
page_zipin: compressed page descriptor
offsetsin: offsets for record

Definition at line 2733 of file page0page.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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 977 of file page0page.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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 1183 of file page0page.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INLINE void page_delete_rec_list_write_log ( rec_t *  rec,
dict_index_t index,
byte  type,
mtr_t mtr 
)

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

Parameters
recin: record on page
indexin: record descriptor
typein: operation type: MLOG_LIST_END_DELETE, ...
mtrin: mtr

Definition at line 891 of file page0page.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INLINE void page_dir_add_slot ( page_t page,
page_zip_des_t page_zip,
ulint  start 
)

Used to add n slots to the directory. Does not set the record pointers in the added slots or update n_owned values: this is the responsibility of the caller.

Parameters
pagein/out: the index page
page_zipin/out: comprssed page, or NULL
startin: the slot above which the new slots are added

Definition at line 1404 of file page0page.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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 1494 of file page0page.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INLINE void page_dir_delete_slot ( page_t page,
page_zip_des_t page_zip,
ulint  slot_no 
)

Used to delete n slots from the directory. This function updates also n_owned fields in the records, so that the first slot after the deleted ones inherits the records of the deleted slots.

Parameters
pagein/out: the index page
page_zipin/out: compressed page, or NULL
slot_noin: slot to be deleted

Definition at line 1355 of file page0page.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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
Parameters
recin: the physical record

Definition at line 92 of file page0page.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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 1431 of file page0page.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN 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
Parameters
pagein: index page
heap_noin: heap number

Definition at line 2683 of file page0page.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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
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 246 of file page0page.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 1270 of file page0page.cc.

Here is the call graph for this function:

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

Definition at line 1330 of file page0page.cc.

Here is the call graph for this function:

UNIV_INTERN byte* page_parse_create ( byte *  ptr,
byte *end_ptr   __attribute__(unused),
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
Parameters
ptrin: buffer
__attribute__in: buffer end
compin: nonzero=compact page format
blockin: block or NULL
mtrin: mtr or NULL

Definition at line 304 of file page0page.cc.

Here is the call graph for this function:

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
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 921 of file page0page.cc.

Here is the call graph for this function:

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
Parameters
recin: the physical record

Definition at line 1618 of file page0page.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 1565 of file page0page.cc.

Here is the call graph for this function:

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.

Parameters
recin: physical record
offsetsin: record descriptor

Definition at line 1683 of file page0page.cc.

Here is the call graph for this function:

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

Definition at line 1879 of file page0page.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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.

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

Definition at line 210 of file page0page.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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
Parameters
pagein: index page in ROW_FORMAT!=REDUNDANT

Definition at line 2175 of file page0page.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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
Parameters
pagein: index page in ROW_FORMAT=REDUNDANT

Definition at line 1965 of file page0page.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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
Parameters
pagein: index page
indexin: data dictionary index containing the page record type definition

Definition at line 2384 of file page0page.cc.

Here is the call graph for this function:

Here is the caller graph for this function: