📄 btr0pcur.h
字号:
/******************************************************************Differs from btr_pcur_commit in that we can specify the mtr to commit. */UNIV_INLINEvoidbtr_pcur_commit_specify_mtr(/*========================*/ btr_pcur_t* pcur, /* in: persistent cursor */ mtr_t* mtr); /* in: mtr to commit *//******************************************************************Tests if a cursor is detached: that is the latch mode is BTR_NO_LATCHES. */UNIV_INLINEiboolbtr_pcur_is_detached(/*=================*/ /* out: TRUE if detached */ btr_pcur_t* pcur); /* in: persistent cursor *//*************************************************************Moves the persistent cursor to the next record in the tree. If no records areleft, the cursor stays 'after last in tree'. */UNIV_INLINEiboolbtr_pcur_move_to_next(/*==================*/ /* out: TRUE if the cursor was not after last in tree */ btr_pcur_t* cursor, /* in: persistent cursor; NOTE that the function may release the page latch */ mtr_t* mtr); /* in: mtr *//*************************************************************Moves the persistent cursor to the previous record in the tree. If no recordsare left, the cursor stays 'before first in tree'. */iboolbtr_pcur_move_to_prev(/*==================*/ /* out: TRUE if the cursor was not before first in tree */ btr_pcur_t* cursor, /* in: persistent cursor; NOTE that the function may release the page latch */ mtr_t* mtr); /* in: mtr *//*************************************************************Moves the persistent cursor to the last record on the same page. */UNIV_INLINEvoidbtr_pcur_move_to_last_on_page(/*==========================*/ btr_pcur_t* cursor, /* in: persistent cursor */ mtr_t* mtr); /* in: mtr *//*************************************************************Moves the persistent cursor to the next user record in the tree. If no userrecords are left, the cursor ends up 'after last in tree'. */UNIV_INLINEiboolbtr_pcur_move_to_next_user_rec(/*===========================*/ /* out: TRUE if the cursor moved forward, ending on a user record */ btr_pcur_t* cursor, /* in: persistent cursor; NOTE that the function may release the page latch */ mtr_t* mtr); /* in: 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. */voidbtr_pcur_move_to_next_page(/*=======================*/ btr_pcur_t* cursor, /* in: persistent cursor; must be on the last record of the current page */ mtr_t* mtr); /* in: mtr *//*************************************************************Moves the persistent cursor backward if it is on the first recordof the page. Releases the latch on the current page, and bufferunfixesit. Note that to prevent a possible deadlock, the operation firststores the position of the cursor, releases the leaf latch, acquiresnecessary latches and restores the cursor position again before returning.The alphabetical position of the cursor is guaranteed to be sensibleon return, but it may happen that the cursor is not positioned on thelast record of any page, because the structure of the tree may havechanged while the cursor had no latches. */voidbtr_pcur_move_backward_from_page(/*=============================*/ btr_pcur_t* cursor, /* in: persistent cursor, must be on the first record of the current page */ mtr_t* mtr); /* in: mtr *//*************************************************************Returns the btr cursor component of a persistent cursor. */UNIV_INLINEbtr_cur_t*btr_pcur_get_btr_cur(/*=================*/ /* out: pointer to btr cursor component */ btr_pcur_t* cursor); /* in: persistent cursor *//*************************************************************Returns the page cursor component of a persistent cursor. */UNIV_INLINEpage_cur_t*btr_pcur_get_page_cur(/*==================*/ /* out: pointer to page cursor component */ btr_pcur_t* cursor); /* in: persistent cursor *//*************************************************************Returns the page of a persistent cursor. */UNIV_INLINEpage_t*btr_pcur_get_page(/*==============*/ /* out: pointer to the page */ btr_pcur_t* cursor);/* in: persistent cursor *//*************************************************************Returns the record of a persistent cursor. */UNIV_INLINErec_t*btr_pcur_get_rec(/*=============*/ /* out: pointer to the record */ btr_pcur_t* cursor);/* in: persistent cursor *//*************************************************************Checks if the persistent cursor is on a user record. */UNIV_INLINEiboolbtr_pcur_is_on_user_rec(/*====================*/ btr_pcur_t* cursor, /* in: persistent cursor */ mtr_t* mtr); /* in: mtr *//*************************************************************Checks if the persistent cursor is after the last user record on a page. */UNIV_INLINEiboolbtr_pcur_is_after_last_on_page(/*===========================*/ btr_pcur_t* cursor, /* in: persistent cursor */ mtr_t* mtr); /* in: mtr *//*************************************************************Checks if the persistent cursor is before the first user record on a page. */UNIV_INLINEiboolbtr_pcur_is_before_first_on_page(/*=============================*/ btr_pcur_t* cursor, /* in: persistent cursor */ mtr_t* mtr); /* in: mtr *//*************************************************************Checks if the persistent cursor is before the first user record inthe index tree. */UNIV_INLINEiboolbtr_pcur_is_before_first_in_tree(/*=============================*/ btr_pcur_t* cursor, /* in: persistent cursor */ mtr_t* mtr); /* in: mtr *//*************************************************************Checks if the persistent cursor is after the last user record inthe index tree. */UNIV_INLINEiboolbtr_pcur_is_after_last_in_tree(/*===========================*/ btr_pcur_t* cursor, /* in: persistent cursor */ mtr_t* mtr); /* in: mtr *//*************************************************************Moves the persistent cursor to the next record on the same page. */UNIV_INLINEvoidbtr_pcur_move_to_next_on_page(/*==========================*/ btr_pcur_t* cursor, /* in: persistent cursor */ mtr_t* mtr); /* in: mtr *//*************************************************************Moves the persistent cursor to the previous record on the same page. */UNIV_INLINEvoidbtr_pcur_move_to_prev_on_page(/*==========================*/ btr_pcur_t* cursor, /* in: persistent cursor */ mtr_t* mtr); /* in: mtr *//* The persistent B-tree cursor structure. This is used mainly for SQLselects, updates, and deletes. */struct btr_pcur_struct{ btr_cur_t btr_cur; /* a B-tree cursor */ ulint latch_mode; /* see FIXME 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; the last value 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 */ ulint old_stored; /* BTR_PCUR_OLD_STORED or BTR_PCUR_OLD_NOT_STORED */ rec_t* old_rec; /* if cursor position is stored, contains an initial segment of the latest record cursor was positioned either on, before, or after */ ulint old_n_fields; /* number of fields in old_rec */ ulint rel_pos; /* BTR_PCUR_ON, BTR_PCUR_BEFORE, or BTR_PCUR_AFTER, depending on whether cursor was on, before, or after the old_rec record */ buf_block_t* block_when_stored;/* buffer block when the position was stored; note that if AWE is on, frames may move */ dulint modify_clock; /* the modify clock value of the buffer block when the cursor position was stored */ ulint pos_state; /* see FIXME note below! BTR_PCUR_IS_POSITIONED, BTR_PCUR_WAS_POSITIONED, BTR_PCUR_NOT_POSITIONED */ ulint search_mode; /* PAGE_CUR_G, ... */ trx_t* trx_if_known; /* the transaction, if we know it; otherwise this field is not defined; can ONLY BE USED in error prints in fatal assertion failures! */ /*-----------------------------*/ /* NOTE that the following fields may possess dynamically allocated memory which should be freed if not needed anymore! */ mtr_t* mtr; /* NULL, or this field may contain a mini-transaction which holds the latch on the cursor page */ byte* old_rec_buf; /* NULL, or a dynamically allocated buffer for old_rec */ ulint buf_size; /* old_rec_buf size if old_rec_buf is not NULL */};#define BTR_PCUR_IS_POSITIONED 1997660512 /* FIXME: currently, the state can be BTR_PCUR_IS_POSITIONED, though it really should be BTR_PCUR_WAS_POSITIONED, because we have no obligation to commit the cursor with mtr; similarly latch_mode may be out of date */#define BTR_PCUR_WAS_POSITIONED 1187549791#define BTR_PCUR_NOT_POSITIONED 1328997689#define BTR_PCUR_OLD_STORED 908467085#define BTR_PCUR_OLD_NOT_STORED 122766467#ifndef UNIV_NONINL#include "btr0pcur.ic"#endif #endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -