MySQL  8.0.19
Source Code Documentation
page0cur.h File Reference
#include "univ.i"
#include "buf0types.h"
#include "data0data.h"
#include "gis0type.h"
#include "mtr0mtr.h"
#include "page0page.h"
#include "rem0rec.h"
#include "page0cur.ic"

Go to the source code of this file.

Classes

struct  page_cur_t
 Index page cursor. More...
 

Macros

#define PAGE_CUR_ADAPT
 

Functions

UNIV_INLINE page_tpage_cur_get_page (page_cur_t *cur)
 Gets pointer to the page frame where the cursor is positioned. More...
 
UNIV_INLINE buf_block_tpage_cur_get_block (page_cur_t *cur)
 Gets pointer to the buffer block where the cursor is positioned. More...
 
UNIV_INLINE page_zip_des_tpage_cur_get_page_zip (page_cur_t *cur)
 Gets pointer to the page frame where the cursor is positioned. More...
 
UNIV_INLINE rec_tpage_cur_get_rec (page_cur_t *cur)
 Gets the record where the cursor is positioned. More...
 
UNIV_INLINE void page_cur_set_before_first (const buf_block_t *block, page_cur_t *cur)
 Sets the cursor object to point before the first user record on the page. More...
 
UNIV_INLINE void page_cur_set_after_last (const buf_block_t *block, page_cur_t *cur)
 Sets the cursor object to point after the last user record on the page. More...
 
UNIV_INLINE ibool page_cur_is_before_first (const page_cur_t *cur)
 Returns TRUE if the cursor is before first user record on page. More...
 
UNIV_INLINE ibool page_cur_is_after_last (const page_cur_t *cur)
 Returns TRUE if the cursor is after last user record. More...
 
UNIV_INLINE void page_cur_position (const rec_t *rec, const buf_block_t *block, page_cur_t *cur)
 Positions the cursor on the given record. More...
 
UNIV_INLINE void page_cur_move_to_next (page_cur_t *cur)
 Moves the cursor to the next record on page. More...
 
UNIV_INLINE void page_cur_move_to_prev (page_cur_t *cur)
 Moves the cursor to the previous record on page. More...
 
UNIV_INLINE rec_tpage_cur_tuple_insert (page_cur_t *cursor, const dtuple_t *tuple, dict_index_t *index, ulint **offsets, mem_heap_t **heap, ulint n_ext, mtr_t *mtr, bool use_cache=false)
 Inserts a record next to page cursor. More...
 
UNIV_INLINE rec_tpage_cur_rec_insert (page_cur_t *cursor, const rec_t *rec, dict_index_t *index, ulint *offsets, mtr_t *mtr)
 Inserts a record next to page cursor. 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, ulint n_ext, mtr_t *mtr)
 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...
 
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...
 
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...
 
UNIV_INLINE ulint page_cur_search (const buf_block_t *block, const dict_index_t *index, const dtuple_t *tuple, page_cur_mode_t mode, page_cur_t *cursor)
 Search the right position for a page cursor. More...
 
UNIV_INLINE ulint page_cur_search (const buf_block_t *block, const dict_index_t *index, const dtuple_t *tuple, page_cur_t *cursor)
 Search the right position for a page cursor. 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...
 
bytepage_cur_parse_insert_rec (ibool 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...
 
bytepage_parse_copy_rec_list_to_created_page (byte *ptr, 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...
 
bytepage_cur_parse_delete_rec (byte *ptr, 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...
 
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. More...
 

Detailed Description

The page cursor

Created 10/4/1994 Heikki Tuuri

Macro Definition Documentation

◆ PAGE_CUR_ADAPT

#define PAGE_CUR_ADAPT

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(). in: mtr

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

◆ 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. in: mini-transaction handle

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

◆ 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,
ulint  n_ext,
mtr_t mtr 
)

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]n_extnumber of externally stored columns
[in]mtrmini-transaction handle, or NULL
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_get_block()

UNIV_INLINE buf_block_t* page_cur_get_block ( page_cur_t cur)

Gets pointer to the buffer block where the cursor is positioned.

Returns
page in: page cursor

◆ page_cur_get_page()

UNIV_INLINE page_t* page_cur_get_page ( page_cur_t cur)

Gets pointer to the page frame where the cursor is positioned.

Returns
page in: page cursor

◆ page_cur_get_page_zip()

UNIV_INLINE page_zip_des_t* page_cur_get_page_zip ( page_cur_t cur)

Gets pointer to the page frame where the cursor is positioned.

Returns
page in: page cursor

◆ page_cur_get_rec()

UNIV_INLINE rec_t* page_cur_get_rec ( page_cur_t cur)

Gets the record where the cursor is positioned.

Returns
record in: page cursor

◆ 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

◆ 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

◆ page_cur_is_after_last()

UNIV_INLINE ibool page_cur_is_after_last ( const page_cur_t cur)

Returns TRUE if the cursor is after last user record.

Returns
true if at end in: cursor

◆ page_cur_is_before_first()

UNIV_INLINE ibool page_cur_is_before_first ( const page_cur_t cur)

Returns TRUE if the cursor is before first user record on page.

Returns
true if at start in: cursor

◆ page_cur_move_to_next()

UNIV_INLINE void page_cur_move_to_next ( page_cur_t cur)

Moves the cursor to the next record on page.

in/out: cursor; must not be after last

◆ page_cur_move_to_prev()

UNIV_INLINE void page_cur_move_to_prev ( page_cur_t cur)

Moves the cursor to the previous record on page.

in/out: cursor; not before first

◆ 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. out: page cursor

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

◆ page_cur_parse_delete_rec()

byte* page_cur_parse_delete_rec ( byte ptr,
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 in: mtr or NULL
pointer to record end or NULL

◆ page_cur_parse_insert_rec()

byte* page_cur_parse_insert_rec ( ibool  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 in: mtr or NULL
end of log record or NULL

◆ page_cur_position()

UNIV_INLINE void page_cur_position ( const rec_t rec,
const buf_block_t block,
page_cur_t cur 
)

Positions the cursor on the given record.

Parameters
[in]recrecord on a page
[in]blockbuffer block containing the record
[out]curpage cursor

◆ page_cur_rec_insert()

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

Inserts a record next to page cursor.

Returns pointer to inserted record if succeed, i.e., enough space available, NULL otherwise. The cursor stays at the same logical position, but the physical position may change if it is pointing to a compressed page that was reorganized.

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
[in,out]cursora page cursor
[in]recrecord to insert
[in]indexrecord descriptor
[in,out]offsetsrec_get_offsets(rec, index)
[in]mtrmini-transaction handle, or NULL
Returns
pointer to record if succeed, NULL otherwise

◆ page_cur_search() [1/2]

UNIV_INLINE ulint page_cur_search ( const buf_block_t block,
const dict_index_t index,
const dtuple_t tuple,
page_cur_mode_t  mode,
page_cur_t cursor 
)

Search the right position for a page cursor.

Parameters
[in]blockbuffer block
[in]indexindex tree
[in]tupledata tuple
[in]modePAGE_CUR_L, PAGE_CUR_LE, PAGE_CUR_G, or PAGE_CUR_GE
[out]cursorpage cursor
Returns
number of matched fields on the left

◆ page_cur_search() [2/2]

UNIV_INLINE ulint page_cur_search ( const buf_block_t block,
const dict_index_t index,
const dtuple_t tuple,
page_cur_t cursor 
)

Search the right position for a page cursor.

Parameters
[in]blockbuffer block
[in]indexindex tree
[in]tupledata tuple
[out]cursorpage cursor
Returns
number of matched fields on the left

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

in/out: rtree search stack

Parameters
blockin: buffer block
indexin: record descriptor
tuplein: data tuple
modein: PAGE_CUR_L, PAGE_CUR_LE, PAGE_CUR_G, or PAGE_CUR_GE
iup_matched_fieldsin/out: already matched fields in upper limit record
ilow_matched_fieldsin/out: already matched fields in lower limit record
cursorout: page cursor

◆ 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_cur_set_after_last()

UNIV_INLINE void page_cur_set_after_last ( const buf_block_t block,
page_cur_t cur 
)

Sets the cursor object to point after the last user record on the page.

Parameters
[in]blockindex page
[in]curcursor

◆ page_cur_set_before_first()

UNIV_INLINE void page_cur_set_before_first ( const buf_block_t block,
page_cur_t cur 
)

Sets the cursor object to point before the first user record on the page.

Parameters
[in]blockindex page
[in]curcursor

◆ page_cur_tuple_insert()

UNIV_INLINE rec_t* page_cur_tuple_insert ( page_cur_t cursor,
const dtuple_t tuple,
dict_index_t index,
ulint **  offsets,
mem_heap_t **  heap,
ulint  n_ext,
mtr_t mtr,
bool  use_cache = false 
)

Inserts a record next to page cursor.

Returns pointer to inserted record if succeed, i.e., enough space available, NULL otherwise. The cursor stays at the same logical position, but the physical position may change if it is pointing to a compressed page that was reorganized.

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
Parameters
cursorin/out: a page cursor
tuplein: pointer to a data tuple
indexin: record descriptor
offsetsout: offsets on *rec
heapin/out: pointer to memory heap, or NULL
n_extin: number of externally stored columns
mtrin: mini-transaction handle, or NULL
use_cachein: if true, then use record cache to hold the tuple converted record.

◆ page_delete_rec()

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.

Returns
true if success, i.e., the page did not become too empty in: offsets for record

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

◆ page_parse_copy_rec_list_to_created_page()

byte* page_parse_copy_rec_list_to_created_page ( byte ptr,
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 in: mtr or NULL
end of log record or NULL