MySQL 8.4.3
Source Code Documentation
|
#include <btr0pcur.h>
Public Member Functions | |
void | init (size_t read_level=0) |
Sets the old_rec_buf field to nullptr. More... | |
dict_index_t * | index () |
bool | set_random_position (dict_index_t *index, ulint latch_mode, mtr_t *mtr, ut::Location location) |
Positions a cursor at a randomly chosen position within a B-tree. More... | |
void | open_at_side (bool from_left, dict_index_t *index, ulint latch_mode, bool init_pcur, ulint level, mtr_t *mtr) |
Opens a persistent cursor at either end of an index. More... | |
void | begin_leaf (dict_index_t *index, ulint latch_mode, mtr_t *mtr) |
Opens a persistent cursor at first leaf page (low end). More... | |
void | open_no_init (dict_index_t *index, const dtuple_t *tuple, page_cur_mode_t mode, ulint latch_mode, ulint has_search_latch, mtr_t *mtr, ut::Location location) |
Opens an persistent cursor to an index tree without initializing the cursor. More... | |
void | open_on_user_rec (dict_index_t *index, const dtuple_t *tuple, page_cur_mode_t mode, ulint latch_mode, mtr_t *mtr, ut::Location location) |
If mode is PAGE_CUR_G or PAGE_CUR_GE, opens a persistent cursor on the first user record satisfying the search condition, in the case PAGE_CUR_L or PAGE_CUR_LE, on the last user record. More... | |
void | open_on_user_rec (const page_cur_t &cursor, page_cur_mode_t mode, ulint latch_mode) |
Allows setting the persistent cursor manually. More... | |
void | open (dict_index_t *index, ulint level, const dtuple_t *tuple, page_cur_mode_t mode, ulint latch_mode, mtr_t *mtr, ut::Location location) |
Initializes and opens a persistent cursor to an index tree It should be closed with btr_pcur::close. More... | |
bool | restore_position (ulint latch_mode, mtr_t *mtr, ut::Location location) |
Restores the stored position of a persistent cursor bufferfixing the page and obtaining the specified latches. More... | |
void | close () |
Frees the possible memory heap of a persistent cursor and sets the latch mode of the persistent cursor to BTR_NO_LATCHES. More... | |
void | free_rec_buf () |
Free old_rec_buf. More... | |
ulint | get_rel_pos () const |
Gets the rel_pos field for a cursor whose position has been stored. More... | |
const btr_cur_t * | get_btr_cur () const |
btr_cur_t * | get_btr_cur () |
page_cur_t * | get_page_cur () |
const page_cur_t * | get_page_cur () const |
page_t * | get_page () |
Returns the page of a persistent pcur (non const version). More... | |
const page_t * | get_page () const |
Returns the page of a persistent pcur (const version). More... | |
buf_block_t * | get_block () |
Returns the current buffer block (non const version). More... | |
const buf_block_t * | get_block () const |
Returns the current buffer block (const version). More... | |
rec_t * | get_rec () |
Returns the current record (non const version). More... | |
const rec_t * | get_rec () const |
Returns the current record (const version). More... | |
ulint | get_up_match () const |
Gets the up_match value for a pcur after a search. More... | |
ulint | get_low_match () const |
Gets the low_match value for a pcur after a search. More... | |
bool | is_after_last_on_page () const |
Checks if the persistent cursor is after the last user record on a page. More... | |
bool | is_before_first_on_page () const |
Checks if the persistent cursor is before the first user record on a page. More... | |
bool | is_on_user_rec () const |
Checks if the persistent cursor is on a user record. More... | |
bool | is_before_first_in_tree (mtr_t *mtr) const |
Checks if the persistent cursor is before the first user record in the index tree. More... | |
bool | is_after_last_in_tree (mtr_t *mtr) const |
Checks if the persistent cursor is after the last user record in the index tree. More... | |
void | move_to_next_on_page () |
Moves the persistent cursor to the next record on the same page. More... | |
void | move_to_prev_on_page () |
Moves the persistent cursor to the prev record on the same page. More... | |
void | move_to_last_on_page (mtr_t *mtr) |
Moves the persistent cursor to the last record on the same page. More... | |
dberr_t | move_to_next_user_rec (mtr_t *mtr) |
Moves the persistent cursor to the next user record in the tree. More... | |
bool | move_to_next (mtr_t *mtr) |
Moves the persistent cursor to the next record in the tree. More... | |
bool | move_to_prev (mtr_t *mtr) |
Moves the persistent cursor to the previous record in the tree. More... | |
void | move_to_next_page (mtr_t *mtr) |
Moves the persistent cursor to the first record on the next page. More... | |
void | commit_specify_mtr (mtr_t *mtr) |
Commits the mtr and sets the pcur latch mode to BTR_NO_LATCHES, that is, the cursor becomes detached. More... | |
void | move_before_first_on_page () |
Moves the persistent cursor to the infimum record on the same page. More... | |
void | store_position (mtr_t *mtr) |
The position of the cursor is stored by taking an initial segment of the record the cursor is positioned on, before, or after, and copying it to the cursor data structure, or just setting a flag if the cursor id before the first in an EMPTY tree, or after the last in an EMPTY tree. More... | |
bool | is_positioned () const |
bool | is_clustered () const |
void | reset () |
Resets a persistent cursor object, freeing "::old_rec_buf" if it is allocated and resetting the other members to their initial values. More... | |
Page_fetch | set_fetch_type (Page_fetch fetch_mode) |
Set the cursor access type: Normal or Scan. More... | |
Static Public Member Functions | |
static void | copy_stored_position (btr_pcur_t *dst, const btr_pcur_t *src) |
Copies the stored position of a pcur to another pcur. More... | |
static btr_pcur_t * | create_for_mysql () |
Allocates memory for a persistent cursor object and initializes the cursor. More... | |
static void | free_for_mysql (btr_pcur_t *&pcur) |
Frees the memory for a persistent cursor object and the cursor itself. More... | |
Public Attributes | |
btr_cur_t | m_btr_cur |
a B-tree cursor More... | |
ulint | m_latch_mode {0} |
see TODO note below! BTR_SEARCH_LEAF, BTR_MODIFY_LEAF, BTR_MODIFY_TREE or BTR_NO_LATCHES, depending on the latching state of the page and tree where the cursor is positioned; BTR_NO_LATCHES means that the cursor is not currently positioned: we say then that the cursor is detached; it can be restored to attached if the old position was stored in old_rec More... | |
bool | m_old_stored {false} |
true if old_rec is stored More... | |
rec_t * | m_old_rec {nullptr} |
if cursor position is stored, contains an initial segment of the latest record cursor was positioned either on, before or after More... | |
ulint | m_old_n_fields {0} |
number of fields in old_rec More... | |
btr_pcur_pos_t | m_rel_pos {BTR_PCUR_UNSET} |
BTR_PCUR_ON, BTR_PCUR_BEFORE, or BTR_PCUR_AFTER, depending on whether cursor was on, before, or after the old_rec record. More... | |
buf::Block_hint | m_block_when_stored |
buffer block when the position was stored More... | |
uint64_t | m_modify_clock {0} |
the modify clock value of the buffer block when the cursor position was stored More... | |
pcur_pos_t | m_pos_state {BTR_PCUR_NOT_POSITIONED} |
position() and restore_position() state. More... | |
page_cur_mode_t | m_search_mode {PAGE_CUR_UNSUPP} |
PAGE_CUR_G, ... More... | |
trx_t * | m_trx_if_known {nullptr} |
the transaction, if we know it; otherwise this field is not defined; can ONLY BE USED in error prints in fatal assertion failures! More... | |
byte * | m_old_rec_buf {nullptr} |
nullptr, or a dynamically allocated buffer for old_rec More... | |
size_t | m_buf_size {0} |
old_rec_buf size if old_rec_buf is not nullptr More... | |
ulint | m_read_level {0} |
Read level where the cursor would be positioned or re-positioned. More... | |
import_ctx_t * | import_ctx {nullptr} |
Private Member Functions | |
void | move_backward_from_page (mtr_t *mtr) |
Moves the persistent cursor backward if it is on the first record of the page. More... | |
|
inline |
Opens a persistent cursor at first leaf page (low end).
It will not call init().
[in] | index | Index |
[in] | latch_mode | Latch mode |
[in,out] | mtr | Mini-transaction |
|
inline |
Frees the possible memory heap of a persistent cursor and sets the latch mode of the persistent cursor to BTR_NO_LATCHES.
WARNING: this function does not release the latch on the page where the cursor is currently positioned. The latch is acquired by the "move to next/previous" family of functions. Since recursive shared locks are not allowed, you must take care (if using the cursor in S-mode) to manually release the latch by either calling btr_leaf_page_release(pcur.get_block(), pcur.latch_mode, mtr) or by committing the mini-transaction right after btr_pcur::close(). A subsequent attempt to crawl the same page in the same mtr would cause an assertion failure.
|
inline |
Commits the mtr and sets the pcur latch mode to BTR_NO_LATCHES, that is, the cursor becomes detached.
Function btr_pcur::store_position should be used before calling this, if restoration of cursor is wanted later.
[in,out] | mtr | Mini-transaction. |
|
static |
Copies the stored position of a pcur to another pcur.
[in,out] | dst | Which will receive the position info. |
[in] | src | From which the info is copied |
|
inlinestatic |
Allocates memory for a persistent cursor object and initializes the cursor.
|
inlinestatic |
Frees the memory for a persistent cursor object and the cursor itself.
[in,out] | pcur | Cursor to free. |
|
inline |
Free old_rec_buf.
|
inline |
Returns the current buffer block (non const version).
|
inline |
Returns the current buffer block (const version).
|
inline |
|
inline |
|
inline |
Gets the low_match value for a pcur after a search.
|
inline |
Returns the page of a persistent pcur (non const version).
|
inline |
Returns the page of a persistent pcur (const version).
|
inline |
|
inline |
|
inline |
Returns the current record (non const version).
|
inline |
Returns the current record (const version).
|
inline |
Gets the rel_pos field for a cursor whose position has been stored.
|
inline |
Gets the up_match value for a pcur after a search.
|
inline |
|
inline |
Sets the old_rec_buf field to nullptr.
[in] | read_level | read level where the cursor would be positioned or re-positioned. |
|
inline |
Checks if the persistent cursor is after the last user record in the index tree.
[in,out] | mtr | Mini-transaction. |
|
inline |
Checks if the persistent cursor is after the last user record on a page.
|
inline |
Checks if the persistent cursor is before the first user record in the index tree.
[in,out] | mtr | Mini-transaction. |
|
inline |
Checks if the persistent cursor is before the first user record on a page.
|
inline |
|
inline |
Checks if the persistent cursor is on a user record.
|
inline |
|
private |
Moves the persistent cursor backward if it is on the first record of the page.
Commits mtr. Note that to prevent a possible deadlock, the operation first stores the position of the cursor, commits mtr, acquires the necessary latches and restores the cursor position again before returning. The alphabetical position of the cursor is guaranteed to be sensible on return, but it may happen that the cursor is not positioned on the last record of any page, because the structure of the tree may have changed during the time when the cursor had no latches.
[in,out] | mtr | Mini-tranaction. |
|
inline |
Moves the persistent cursor to the infimum record on the same page.
|
inline |
Moves the persistent cursor to the last record on the same page.
[in,out] | mtr | Mini-transaction. |
|
inline |
Moves the persistent cursor to the next record in the tree.
If no records are left, the cursor stays 'after last in tree'. Note: Function may release the page latch.
[in,out] | mtr | Mini-transaction. |
|
inline |
Moves the persistent cursor to the next record on the same page.
void btr_pcur_t::move_to_next_page | ( | mtr_t * | mtr | ) |
Moves the persistent cursor to the first record on the next page.
Releases the latch on the current page, and bufferunfixes it. Note that there must not be modifications on the current page, as then the x-latch can be released only in mtr_commit.
[in,out] | mtr | Mini-transaction. |
Moves the persistent cursor to the next user record in the tree.
If no user records are left, the cursor ends up 'after last in tree'.
[in,out] | mtr | Mini-transaction. |
bool btr_pcur_t::move_to_prev | ( | mtr_t * | mtr | ) |
Moves the persistent cursor to the previous record in the tree.
If no records are left, the cursor stays 'before first in tree'. Note: Function may release the page latch.
[in,out] | mtr | Mini-transaction. |
|
inline |
Moves the persistent cursor to the prev record on the same page.
|
inline |
Initializes and opens a persistent cursor to an index tree It should be closed with btr_pcur::close.
[in] | index | Index. |
[in] | level | Level in the btree. |
[in] | tuple | Tuple on which search done. |
[in] | mode | PAGE_CUR_L, ...; NOTE that if the search is made using a unique prefix of a record, mode should be PAGE_CUR_LE, not PAGE_CUR_GE, as the latter may end up on the previous page from the record! |
[in] | latch_mode | BTR_SEARCH_LEAF, ... |
[in] | mtr | Mini-transaction. |
[in] | location | Location where called. |
|
inline |
Opens a persistent cursor at either end of an index.
[in] | from_left | True if open to the low end, false if to the high end. |
[in] | index | Index |
[in] | latch_mode | Latch mode |
[in] | init_pcur | Whether to initialize pcur. |
[in] | level | Level to search for (0=leaf). |
[in,out] | mtr | Mini-transaction |
|
inline |
Opens an persistent cursor to an index tree without initializing the cursor.
[in] | index | Index. |
[in] | tuple | Tuple on which search done. |
[in] | mode | PAGE_CUR_L, ...; NOTE that if the search is made using a unique prefix of a record, mode should be PAGE_CUR_LE, not PAGE_CUR_GE, as the latter may end up on the previous page of the record! |
[in] | latch_mode | BTR_SEARCH_LEAF, ...; NOTE that if has_search_latch != 0 then we maybe do not acquire a latch on the cursor page, but assume that the caller uses his btr search latch to protect the record! |
[in] | has_search_latch | latch mode the caller currently has on search system: RW_S_LATCH, or 0 |
[in] | mtr | Mini-transaction |
[in] | location | Location where called |
void btr_pcur_t::open_on_user_rec | ( | const page_cur_t & | cursor, |
page_cur_mode_t | mode, | ||
ulint | latch_mode | ||
) |
Allows setting the persistent cursor manually.
[in] | cursor | Page cursor where positioned. |
[in] | mode | PAGE_CUR_L, ... |
[in] | latch_mode | BTR_SEARCH_LEAF or BTR_MODIFY_LEAF |
void btr_pcur_t::open_on_user_rec | ( | dict_index_t * | index, |
const dtuple_t * | tuple, | ||
page_cur_mode_t | mode, | ||
ulint | latch_mode, | ||
mtr_t * | mtr, | ||
ut::Location | location | ||
) |
If mode is PAGE_CUR_G or PAGE_CUR_GE, opens a persistent cursor on the first user record satisfying the search condition, in the case PAGE_CUR_L or PAGE_CUR_LE, on the last user record.
If no such user record exists, then in the first case sets the cursor after last in tree, and in the latter case before first in tree. The latching mode must be BTR_SEARCH_LEAF or BTR_MODIFY_LEAF.
[in] | index | Index |
[in] | tuple | Tuple on which search done. |
[in] | mode | PAGE_CUR_L, ... |
[in] | latch_mode | BTR_SEARCH_LEAF or BTR_MODIFY_LEAF |
[in] | mtr | Mini-transaction. |
[in] | location | Location in file from where called. |
|
inline |
Resets a persistent cursor object, freeing "::old_rec_buf" if it is allocated and resetting the other members to their initial values.
bool btr_pcur_t::restore_position | ( | ulint | latch_mode, |
mtr_t * | mtr, | ||
ut::Location | location | ||
) |
Restores the stored position of a persistent cursor bufferfixing the page and obtaining the specified latches.
If the cursor position was saved when the (1) cursor was positioned on a user record: this function restores the position to the last record LESS OR EQUAL to the stored record; (2) cursor was positioned on a page infimum record: restores the position to the last record LESS than the user record which was the successor of the page infimum; (3) cursor was positioned on the page supremum: restores to the first record GREATER than the user record which was the predecessor of the supremum. (4) cursor was positioned before the first or after the last in an empty tree: restores to before first or after the last in the tree.
[in] | latch_mode | BTR_SEARCH_LEAF, ... |
[in,out] | mtr | Mini-transaction |
[in] | location | Location where called. |
|
inline |
Set the cursor access type: Normal or Scan.
[in] | fetch_mode | One of Page_fetch::NORMAL or Page_fetch::SCAN. |
|
inline |
Positions a cursor at a randomly chosen position within a B-tree.
[in] | index | Index to position on. |
[in] | latch_mode | BTR_SEARCH_LEAF, ... |
[in,out] | mtr | Mini-transaction. |
[in] | location | Location from where called. |
void btr_pcur_t::store_position | ( | mtr_t * | mtr | ) |
The position of the cursor is stored by taking an initial segment of the record the cursor is positioned on, before, or after, and copying it to the cursor data structure, or just setting a flag if the cursor id before the first in an EMPTY tree, or after the last in an EMPTY tree.
NOTE that the page where the cursor is positioned must not be empty if the index tree is not totally empty!
[in,out] | mtr | Mini-transaction. |
import_ctx_t* btr_pcur_t::import_ctx {nullptr} |
buf::Block_hint btr_pcur_t::m_block_when_stored |
buffer block when the position was stored
btr_cur_t btr_pcur_t::m_btr_cur |
a B-tree cursor
size_t btr_pcur_t::m_buf_size {0} |
old_rec_buf size if old_rec_buf is not nullptr
ulint btr_pcur_t::m_latch_mode {0} |
see TODO note below! BTR_SEARCH_LEAF, BTR_MODIFY_LEAF, BTR_MODIFY_TREE or BTR_NO_LATCHES, depending on the latching state of the page and tree where the cursor is positioned; BTR_NO_LATCHES means that the cursor is not currently positioned: we say then that the cursor is detached; it can be restored to attached if the old position was stored in old_rec
uint64_t btr_pcur_t::m_modify_clock {0} |
the modify clock value of the buffer block when the cursor position was stored
ulint btr_pcur_t::m_old_n_fields {0} |
number of fields in old_rec
if cursor position is stored, contains an initial segment of the latest record cursor was positioned either on, before or after
bool btr_pcur_t::m_old_stored {false} |
true if old_rec is stored
pcur_pos_t btr_pcur_t::m_pos_state {BTR_PCUR_NOT_POSITIONED} |
position() and restore_position() state.
ulint btr_pcur_t::m_read_level {0} |
Read level where the cursor would be positioned or re-positioned.
btr_pcur_pos_t btr_pcur_t::m_rel_pos {BTR_PCUR_UNSET} |
BTR_PCUR_ON, BTR_PCUR_BEFORE, or BTR_PCUR_AFTER, depending on whether cursor was on, before, or after the old_rec record.
page_cur_mode_t btr_pcur_t::m_search_mode {PAGE_CUR_UNSUPP} |
PAGE_CUR_G, ...
the transaction, if we know it; otherwise this field is not defined; can ONLY BE USED in error prints in fatal assertion failures!