MySQL 9.1.0
Source Code Documentation
page0cur.cc File Reference

The page cursor. More...

#include "page0cur.h"
#include "btr0btr.h"
#include "ha_prototypes.h"
#include "log0recv.h"
#include "mtr0log.h"
#include <algorithm>
#include "page0zip.h"
#include "gis0rtree.h"
#include "rem0cmp.h"

Functions

static bool page_cur_has_null (const rec_t *rec, const dict_index_t *index)
 Check if rec has at least one NULL value among the columns for which rec_cache.offsets was cached, which means rec_cache.offsets should not be used for this rec as it has a different layout of fields than the cached version. More...
 
void page_cur_search_with_match (const buf_block_t *block, const dict_index_t *index, const dtuple_t *tuple, page_cur_mode_t mode, ulint *iup_matched_fields, ulint *ilow_matched_fields, page_cur_t *cursor, rtr_info_t *rtr_info)
 Searches the right position for a page cursor. More...
 
void page_cur_search_with_match_bytes (const buf_block_t *block, const dict_index_t *index, const dtuple_t *tuple, page_cur_mode_t mode, ulint *iup_matched_fields, ulint *iup_matched_bytes, ulint *ilow_matched_fields, ulint *ilow_matched_bytes, page_cur_t *cursor)
 Search the right position for a page cursor. More...
 
void page_cur_open_on_rnd_user_rec (buf_block_t *block, page_cur_t *cursor)
 Positions a page cursor on a randomly chosen user record on a page. More...
 
static void page_cur_insert_rec_write_log (rec_t *insert_rec, ulint rec_size, rec_t *cursor_rec, dict_index_t *index, mtr_t *mtr)
 Writes the log record of a record insert on a page. More...
 
const bytepage_cur_parse_insert_rec (bool is_short, const byte *ptr, const byte *end_ptr, buf_block_t *block, dict_index_t *index, mtr_t *mtr)
 Parses a log record of a record insert on a page. More...
 
rec_tpage_cur_insert_rec_low (rec_t *current_rec, dict_index_t *index, const rec_t *rec, ulint *offsets, mtr_t *mtr)
 Inserts a record next to page cursor on an uncompressed page. More...
 
rec_tpage_cur_direct_insert_rec_low (rec_t *current_rec, dict_index_t *index, const dtuple_t *tuple, mtr_t *mtr, ulint rec_size)
 Inserts a record next to page cursor on an uncompressed page. More...
 
rec_tpage_cur_insert_rec_zip (page_cur_t *cursor, dict_index_t *index, const rec_t *rec, ulint *offsets, mtr_t *mtr)
 Inserts a record next to page cursor on a compressed and uncompressed page. More...
 
static bool page_copy_rec_list_to_created_page_write_log (page_t *page, dict_index_t *index, mtr_t *mtr, byte *&log_ptr)
 Writes a log record of copying a record list end to a new created page. More...
 
const bytepage_parse_copy_rec_list_to_created_page (const byte *ptr, const byte *end_ptr, buf_block_t *block, dict_index_t *index, mtr_t *mtr)
 Parses a log record of copying a record list end to a new created page. More...
 
void page_copy_rec_list_end_to_created_page (page_t *new_page, rec_t *rec, dict_index_t *index, mtr_t *mtr)
 Copies records from page to a newly created page, from a given record onward, including that record. More...
 
static void page_cur_delete_rec_write_log (rec_t *rec, const dict_index_t *index, mtr_t *mtr)
 Writes log record of a record delete on a page. More...
 
const bytepage_cur_parse_delete_rec (const byte *ptr, const byte *end_ptr, buf_block_t *block, dict_index_t *index, mtr_t *mtr)
 Parses log record of a record delete on a page. More...
 
void page_cur_delete_rec (page_cur_t *cursor, const dict_index_t *index, const ulint *offsets, mtr_t *mtr)
 Deletes a record at the page cursor. More...
 

Detailed Description

The page cursor.

Created 10/4/1994 Heikki Tuuri

Function Documentation

◆ page_copy_rec_list_end_to_created_page()

void page_copy_rec_list_end_to_created_page ( page_t new_page,
rec_t rec,
dict_index_t index,
mtr_t mtr 
)

Copies records from page to a newly created page, from a given record onward, including that record.

Infimum and supremum records are not copied.

IMPORTANT: The caller will have to update IBUF_BITMAP_FREE if this 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_pagein/out: index page to copy to
recin: first record to copy
indexin: record descriptor
mtrin: mtr

◆ page_copy_rec_list_to_created_page_write_log()

static bool page_copy_rec_list_to_created_page_write_log ( page_t page,
dict_index_t index,
mtr_t mtr,
byte *&  log_ptr 
)
inlinestatic

Writes a log record of copying a record list end to a new created page.

Parameters
[in,out]pageIndex page
[in,out]indexRecord descriptor
[in,out]mtrMini-transaction
[out]log_ptr4-byte field where to write the log data length
Return values
trueif mtr log is opened successfully.
falseif mtr log is not opened. One case is when redo is disabled.

◆ page_cur_delete_rec()

void page_cur_delete_rec ( page_cur_t cursor,
const dict_index_t index,
const ulint offsets,
mtr_t mtr 
)

Deletes a record at the page cursor.

The cursor is moved to the next record after the deleted one.

Parameters
cursorin/out: a page cursor
indexin: record descriptor
offsetsin: rec_get_offsets( cursor->rec, index)
mtrin: mini-transaction handle or NULL

◆ page_cur_delete_rec_write_log()

static void page_cur_delete_rec_write_log ( rec_t rec,
const dict_index_t index,
mtr_t mtr 
)
inlinestatic

Writes log record of a record delete on a page.

Parameters
recin: record to be deleted
indexin: record descriptor
mtrin: mini-transaction handle

◆ page_cur_direct_insert_rec_low()

rec_t * page_cur_direct_insert_rec_low ( rec_t current_rec,
dict_index_t index,
const dtuple_t tuple,
mtr_t mtr,
ulint  rec_size 
)

Inserts a record next to page cursor on an uncompressed page.

Parameters
[in]current_recPointer to current record after which the new record is inserted.
[in]indexRecord descriptor
[in]tuplePointer to a data tuple
[in]mtrMini-transaction handle, or NULL
[in]rec_sizeThe size of new record
Returns
pointer to record if succeed, NULL otherwise

< the relevant page

< cursor position at previous insert

< a free record that was reused, or NULL

< inserted record

< heap number of the inserted record

◆ page_cur_has_null()

static bool page_cur_has_null ( const rec_t rec,
const dict_index_t index 
)
static

Check if rec has at least one NULL value among the columns for which rec_cache.offsets was cached, which means rec_cache.offsets should not be used for this rec as it has a different layout of fields than the cached version.

Parameters
[in]recB-Tree record
[in]indexThe index from which the rec was taken
Returns
true iff the rec has at least one relevant column with NULL

◆ page_cur_insert_rec_low()

rec_t * page_cur_insert_rec_low ( rec_t current_rec,
dict_index_t index,
const rec_t rec,
ulint offsets,
mtr_t mtr 
)

Inserts a record next to page cursor on an uncompressed page.

Returns pointer to inserted record if succeed, i.e., enough space available, NULL otherwise. The cursor stays at the same position.

Returns
pointer to record if succeed, NULL otherwise

< the relevant page

< cursor position at previous insert

< a free record that was reused, or NULL

< inserted record

< heap number of the inserted record

Parameters
current_recin: pointer to current record after which the new record is inserted
indexin: record descriptor
recin: pointer to a physical record
offsetsin/out: rec_get_offsets(rec, index)
mtrin: mini-transaction handle, or NULL

◆ page_cur_insert_rec_write_log()

static void page_cur_insert_rec_write_log ( rec_t insert_rec,
ulint  rec_size,
rec_t cursor_rec,
dict_index_t index,
mtr_t mtr 
)
static

Writes the log record of a record insert on a page.

Parameters
insert_recin: inserted physical record
rec_sizein: insert_rec size
cursor_recin: record the cursor is pointing to
indexin: record descriptor
mtrin: mini-transaction handle

◆ page_cur_insert_rec_zip()

rec_t * page_cur_insert_rec_zip ( page_cur_t cursor,
dict_index_t index,
const rec_t rec,
ulint offsets,
mtr_t mtr 
)

Inserts a record next to page cursor on a compressed and uncompressed page.

Returns pointer to inserted record if succeed, i.e., enough space available, NULL otherwise. The cursor stays at the same position.

IMPORTANT: The caller will have to update IBUF_BITMAP_FREE if this 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 record if succeed, NULL otherwise

< the relevant page

< cursor position at previous insert

< a free record that was reused, or NULL

< inserted record

< heap number of the inserted record

Parameters
cursorin/out: page cursor
indexin: record descriptor
recin: pointer to a physical record
offsetsin/out: rec_get_offsets(rec, index)
mtrin: mini-transaction handle, or NULL

◆ page_cur_open_on_rnd_user_rec()

void page_cur_open_on_rnd_user_rec ( buf_block_t block,
page_cur_t cursor 
)

Positions a page cursor on a randomly chosen user record on a page.

If there are no user records, sets the cursor on the infimum record.

Parameters
blockin: page
cursorout: page cursor

◆ page_cur_parse_delete_rec()

const byte * page_cur_parse_delete_rec ( const byte ptr,
const byte end_ptr,
buf_block_t block,
dict_index_t index,
mtr_t mtr 
)

Parses log record of a record delete on a page.

Returns
pointer to record end or NULL
Parameters
ptrin: buffer
end_ptrin: buffer end
blockin: page or NULL
indexin: record descriptor
mtrin: mtr or NULL

◆ page_cur_parse_insert_rec()

const byte * page_cur_parse_insert_rec ( bool  is_short,
const byte ptr,
const byte end_ptr,
buf_block_t block,
dict_index_t index,
mtr_t mtr 
)

Parses a log record of a record insert on a page.

Returns
end of log record or NULL
Parameters
is_shortin: true if short inserts
ptrin: buffer
end_ptrin: buffer end
blockin: page or NULL
indexin: record descriptor
mtrin: mtr or NULL

◆ page_cur_search_with_match()

void page_cur_search_with_match ( const buf_block_t block,
const dict_index_t index,
const dtuple_t tuple,
page_cur_mode_t  mode,
ulint iup_matched_fields,
ulint ilow_matched_fields,
page_cur_t cursor,
rtr_info_t rtr_info 
)

Searches the right position for a page cursor.

Parameters
[in]blockBuffer block
[in]indexRecord descriptor
[in]tupleData tuple
[in]modePAGE_CUR_L, PAGE_CUR_LE, PAGE_CUR_G, or PAGE_CUR_GE
[in,out]iup_matched_fieldsAlready matched fields in upper limit record
[in,out]ilow_matched_fieldsAlready matched fields in lower limit record
[out]cursorPage cursor
[in,out]rtr_infoRtree search stack

◆ page_cur_search_with_match_bytes()

void page_cur_search_with_match_bytes ( const buf_block_t block,
const dict_index_t index,
const dtuple_t tuple,
page_cur_mode_t  mode,
ulint iup_matched_fields,
ulint iup_matched_bytes,
ulint ilow_matched_fields,
ulint ilow_matched_bytes,
page_cur_t cursor 
)

Search the right position for a page cursor.

Parameters
[in]blockbuffer block
[in]indexindex tree
[in]tuplekey to be searched for
[in]modesearch mode
[in,out]iup_matched_fieldsalready matched fields in the upper limit record
[in,out]iup_matched_bytesalready matched bytes in the first partially matched field in the upper limit record
[in,out]ilow_matched_fieldsalready matched fields in the lower limit record
[in,out]ilow_matched_bytesalready matched bytes in the first partially matched field in the lower limit record
[out]cursorpage cursor

◆ page_parse_copy_rec_list_to_created_page()

const byte * page_parse_copy_rec_list_to_created_page ( const byte ptr,
const byte end_ptr,
buf_block_t block,
dict_index_t index,
mtr_t mtr 
)

Parses a log record of copying a record list end to a new created page.

Returns
end of log record or NULL
Parameters
ptrin: buffer
end_ptrin: buffer end
blockin: page or NULL
indexin: record descriptor
mtrin: mtr or NULL