diff options
author | Jan Lindström <jan.lindstrom@mariadb.com> | 2016-08-12 11:17:45 +0300 |
---|---|---|
committer | Jan Lindström <jan.lindstrom@mariadb.com> | 2016-09-02 13:22:28 +0300 |
commit | 2e814d4702d71a04388386a9f591d14a35980bfe (patch) | |
tree | f3f9b48d116a3738c5e71f3a360ca61f16cfb632 /storage/innobase/include/btr0pcur.h | |
parent | 848d211c5c4df00b819cd84d7530cf7d29bb0524 (diff) | |
download | mariadb-git-2e814d4702d71a04388386a9f591d14a35980bfe.tar.gz |
Merge InnoDB 5.7 from mysql-5.7.9.
Contains also
MDEV-10547: Test multi_update_innodb fails with InnoDB 5.7
The failure happened because 5.7 has changed the signature of
the bool handler::primary_key_is_clustered() const
virtual function ("const" was added). InnoDB was using the old
signature which caused the function not to be used.
MDEV-10550: Parallel replication lock waits/deadlock handling does not work with InnoDB 5.7
Fixed mutexing problem on lock_trx_handle_wait. Note that
rpl_parallel and rpl_optimistic_parallel tests still
fail.
MDEV-10156 : Group commit tests fail on 10.2 InnoDB (branch bb-10.2-jan)
Reason: incorrect merge
MDEV-10550: Parallel replication can't sync with master in InnoDB 5.7 (branch bb-10.2-jan)
Reason: incorrect merge
Diffstat (limited to 'storage/innobase/include/btr0pcur.h')
-rw-r--r-- | storage/innobase/include/btr0pcur.h | 152 |
1 files changed, 78 insertions, 74 deletions
diff --git a/storage/innobase/include/btr0pcur.h b/storage/innobase/include/btr0pcur.h index dafe14ce556..02f4faf24a5 100644 --- a/storage/innobase/include/btr0pcur.h +++ b/storage/innobase/include/btr0pcur.h @@ -34,22 +34,24 @@ Created 2/23/1996 Heikki Tuuri #include "btr0cur.h" #include "btr0btr.h" #include "btr0types.h" +#include "gis0rtree.h" /* Relative positions for a stored cursor position */ -#define BTR_PCUR_ON 1 -#define BTR_PCUR_BEFORE 2 -#define BTR_PCUR_AFTER 3 +enum btr_pcur_pos_t { + BTR_PCUR_ON = 1, + BTR_PCUR_BEFORE = 2, + BTR_PCUR_AFTER = 3, /* Note that if the tree is not empty, btr_pcur_store_position does not use the following, but only uses the above three alternatives, where the position is stored relative to a specific record: this makes implementation of a scroll cursor easier */ -#define BTR_PCUR_BEFORE_FIRST_IN_TREE 4 /* in an empty tree */ -#define BTR_PCUR_AFTER_LAST_IN_TREE 5 /* in an empty tree */ + BTR_PCUR_BEFORE_FIRST_IN_TREE = 4, /* in an empty tree */ + BTR_PCUR_AFTER_LAST_IN_TREE = 5 /* in an empty tree */ +}; /**************************************************************//** Allocates memory for a persistent cursor object and initializes the cursor. -@return own: persistent cursor */ -UNIV_INTERN +@return own: persistent cursor */ btr_pcur_t* btr_pcur_create_for_mysql(void); /*============================*/ @@ -57,7 +59,6 @@ btr_pcur_create_for_mysql(void); /**************************************************************//** Resets a persistent cursor object, freeing ::old_rec_buf if it is allocated and resetting the other members to their initial values. */ -UNIV_INTERN void btr_pcur_reset( /*===========*/ @@ -65,14 +66,12 @@ btr_pcur_reset( /**************************************************************//** Frees the memory for a persistent cursor object. */ -UNIV_INTERN void btr_pcur_free_for_mysql( /*====================*/ btr_pcur_t* cursor); /*!< in, own: persistent cursor */ /**************************************************************//** Copies the stored position of a pcur to another pcur. */ -UNIV_INTERN void btr_pcur_copy_stored_position( /*==========================*/ @@ -87,6 +86,14 @@ void btr_pcur_init( /*==========*/ btr_pcur_t* pcur); /*!< in: persistent cursor */ + +/** Free old_rec_buf. +@param[in] pcur Persistent cursor holding old_rec to be freed. */ +UNIV_INLINE +void +btr_pcur_free( + btr_pcur_t* pcur); + /**************************************************************//** Initializes and opens a persistent cursor to an index tree. It should be closed with btr_pcur_close. */ @@ -97,7 +104,7 @@ btr_pcur_open_low( dict_index_t* index, /*!< in: index */ ulint level, /*!< in: level in the btree */ const dtuple_t* tuple, /*!< in: tuple on which search done */ - ulint mode, /*!< in: PAGE_CUR_L, ...; + page_cur_mode_t mode, /*!< in: 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 @@ -119,7 +126,7 @@ btr_pcur_open_with_no_init_func( /*============================*/ dict_index_t* index, /*!< in: index */ const dtuple_t* tuple, /*!< in: tuple on which search done */ - ulint mode, /*!< in: PAGE_CUR_L, ...; + page_cur_mode_t mode, /*!< in: 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 @@ -131,8 +138,9 @@ btr_pcur_open_with_no_init_func( page, but assume that the caller uses his btr search latch to protect the record! */ btr_pcur_t* cursor, /*!< in: memory buffer for persistent cursor */ - ulint has_search_latch,/*!< in: latch mode the caller - currently has on btr_search_latch: + ulint has_search_latch, + /*!< in: latch mode the caller + currently has on search system: RW_S_LATCH, or 0 */ const char* file, /*!< in: file name */ ulint line, /*!< in: line where called */ @@ -181,13 +189,12 @@ 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. */ -UNIV_INTERN void btr_pcur_open_on_user_rec_func( /*===========================*/ dict_index_t* index, /*!< in: index */ const dtuple_t* tuple, /*!< in: tuple on which search done */ - ulint mode, /*!< in: PAGE_CUR_L, ... */ + page_cur_mode_t mode, /*!< in: PAGE_CUR_L, ... */ ulint latch_mode, /*!< in: BTR_SEARCH_LEAF or BTR_MODIFY_LEAF */ btr_pcur_t* cursor, /*!< in: memory buffer for persistent @@ -198,9 +205,11 @@ btr_pcur_open_on_user_rec_func( #define btr_pcur_open_on_user_rec(i,t,md,l,c,m) \ btr_pcur_open_on_user_rec_func(i,t,md,l,c,__FILE__,__LINE__,m) /**********************************************************************//** -Positions a cursor at a randomly chosen position within a B-tree. */ +Positions a cursor at a randomly chosen position within a B-tree. +@return true if the index is available and we have put the cursor, false +if the index is unavailable */ UNIV_INLINE -void +bool btr_pcur_open_at_rnd_pos_func( /*==========================*/ dict_index_t* index, /*!< in: index */ @@ -235,7 +244,6 @@ 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! */ -UNIV_INTERN void btr_pcur_store_position( /*====================*/ @@ -256,7 +264,6 @@ restores to before first or after the last in the tree. @return TRUE if the cursor position was stored when it was on a user record and it can be restored on a user record whose ordering fields are identical to the ones of the original user record */ -UNIV_INTERN ibool btr_pcur_restore_position_func( /*===========================*/ @@ -269,7 +276,7 @@ btr_pcur_restore_position_func( btr_pcur_restore_position_func(l,cur,__FILE__,__LINE__,mtr) /*********************************************************//** Gets the rel_pos field for a cursor whose position has been stored. -@return BTR_PCUR_ON, ... */ +@return BTR_PCUR_ON, ... */ UNIV_INLINE ulint btr_pcur_get_rel_pos( @@ -289,7 +296,7 @@ btr_pcur_commit_specify_mtr( /*********************************************************//** Moves the persistent cursor to the next record in the tree. If no records are left, the cursor stays 'after last in tree'. -@return TRUE if the cursor was not after last in tree */ +@return TRUE if the cursor was not after last in tree */ UNIV_INLINE ibool btr_pcur_move_to_next( @@ -300,8 +307,7 @@ btr_pcur_move_to_next( /*********************************************************//** Moves the persistent cursor to the previous record in the tree. If no records are left, the cursor stays 'before first in tree'. -@return TRUE if the cursor was not before first in tree */ -UNIV_INTERN +@return TRUE if the cursor was not before first in tree */ ibool btr_pcur_move_to_prev( /*==================*/ @@ -319,7 +325,7 @@ btr_pcur_move_to_last_on_page( /*********************************************************//** 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'. -@return TRUE if the cursor moved forward, ending on a user record */ +@return TRUE if the cursor moved forward, ending on a user record */ UNIV_INLINE ibool btr_pcur_move_to_next_user_rec( @@ -332,7 +338,6 @@ 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. */ -UNIV_INTERN void btr_pcur_move_to_next_page( /*=======================*/ @@ -349,7 +354,6 @@ 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 while the cursor had no latches. */ -UNIV_INTERN void btr_pcur_move_backward_from_page( /*=============================*/ @@ -359,7 +363,7 @@ btr_pcur_move_backward_from_page( #ifdef UNIV_DEBUG /*********************************************************//** Returns the btr cursor component of a persistent cursor. -@return pointer to btr cursor component */ +@return pointer to btr cursor component */ UNIV_INLINE btr_cur_t* btr_pcur_get_btr_cur( @@ -367,7 +371,7 @@ btr_pcur_get_btr_cur( const btr_pcur_t* cursor); /*!< in: persistent cursor */ /*********************************************************//** Returns the page cursor component of a persistent cursor. -@return pointer to page cursor component */ +@return pointer to page cursor component */ UNIV_INLINE page_cur_t* btr_pcur_get_page_cur( @@ -375,7 +379,7 @@ btr_pcur_get_page_cur( const btr_pcur_t* cursor); /*!< in: persistent cursor */ /*********************************************************//** Returns the page of a persistent cursor. -@return pointer to the page */ +@return pointer to the page */ UNIV_INLINE page_t* btr_pcur_get_page( @@ -383,7 +387,7 @@ btr_pcur_get_page( const btr_pcur_t* cursor);/*!< in: persistent cursor */ /*********************************************************//** Returns the buffer block of a persistent cursor. -@return pointer to the block */ +@return pointer to the block */ UNIV_INLINE buf_block_t* btr_pcur_get_block( @@ -391,7 +395,7 @@ btr_pcur_get_block( const btr_pcur_t* cursor);/*!< in: persistent cursor */ /*********************************************************//** Returns the record of a persistent cursor. -@return pointer to the record */ +@return pointer to the record */ UNIV_INLINE rec_t* btr_pcur_get_rec( @@ -493,53 +497,53 @@ enum pcur_pos_t { selects, updates, and deletes. */ struct btr_pcur_t{ - btr_cur_t btr_cur; /*!< a B-tree cursor */ - ulint latch_mode; /*!< 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 */ - 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 */ - ib_uint64_t modify_clock; /*!< the modify clock value of the - buffer block when the cursor position - was stored */ - enum pcur_pos_t pos_state; /*!< btr_pcur_store_position() and - btr_pcur_restore_position() state. */ - 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! */ + /** a B-tree cursor */ + btr_cur_t btr_cur; + /** 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 */ + ulint latch_mode; + /** true if old_rec is stored */ + bool old_stored; + /** if cursor position is stored, contains an initial segment of the + latest record cursor was positioned either on, before or after */ + rec_t* old_rec; + /** number of fields in old_rec */ + ulint old_n_fields; + /** BTR_PCUR_ON, BTR_PCUR_BEFORE, or BTR_PCUR_AFTER, depending on + whether cursor was on, before, or after the old_rec record */ + enum btr_pcur_pos_t rel_pos; + /** buffer block when the position was stored */ + buf_block_t* block_when_stored; + /** the modify clock value of the buffer block when the cursor position + was stored */ + ib_uint64_t modify_clock; + /** the withdraw clock value of the buffer pool when the cursor + position was stored */ + ulint withdraw_clock; + /** btr_pcur_store_position() and btr_pcur_restore_position() state. */ + enum pcur_pos_t pos_state; + /** PAGE_CUR_G, ... */ + page_cur_mode_t search_mode; + /** the transaction, if we know it; otherwise this field is not defined; + can ONLY BE USED in error prints in fatal assertion failures! */ + trx_t* trx_if_known; /*-----------------------------*/ /* NOTE that the following fields may possess dynamically allocated memory which should be freed if not needed anymore! */ - 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 */ -}; + /** NULL, or a dynamically allocated buffer for old_rec */ + byte* old_rec_buf; + /** old_rec_buf size if old_rec_buf is not NULL */ + ulint buf_size; -#define BTR_PCUR_OLD_STORED 908467085 -#define BTR_PCUR_OLD_NOT_STORED 122766467 + /** Return the index of this persistent cursor */ + dict_index_t* index() const { return(btr_cur.index); } +}; #ifndef UNIV_NONINL #include "btr0pcur.ic" |