diff options
Diffstat (limited to 'storage/xtradb/include/btr0pcur.ic')
-rw-r--r-- | storage/xtradb/include/btr0pcur.ic | 50 |
1 files changed, 29 insertions, 21 deletions
diff --git a/storage/xtradb/include/btr0pcur.ic b/storage/xtradb/include/btr0pcur.ic index 696dfc728dc..79afd7c322e 100644 --- a/storage/xtradb/include/btr0pcur.ic +++ b/storage/xtradb/include/btr0pcur.ic @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -11,8 +11,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., -51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA *****************************************************************************/ @@ -406,9 +406,10 @@ Initializes and opens a persistent cursor to an index tree. It should be closed with btr_pcur_close. */ UNIV_INLINE void -btr_pcur_open_func( -/*===============*/ +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, ...; NOTE that if the search is made using a unique @@ -428,14 +429,14 @@ btr_pcur_open_func( btr_pcur_init(cursor); - cursor->latch_mode = latch_mode; + cursor->latch_mode = BTR_LATCH_MODE_WITHOUT_FLAGS(latch_mode); cursor->search_mode = mode; /* Search with the tree cursor */ btr_cursor = btr_pcur_get_btr_cur(cursor); - btr_cur_search_to_nth_level(index, 0, tuple, mode, latch_mode, + btr_cur_search_to_nth_level(index, level, tuple, mode, latch_mode, btr_cursor, 0, file, line, mtr); cursor->pos_state = BTR_PCUR_IS_POSITIONED; @@ -495,28 +496,26 @@ UNIV_INLINE void btr_pcur_open_at_index_side( /*========================*/ - ibool from_left, /*!< in: TRUE if open to the low end, - FALSE if to the high end */ + bool from_left, /*!< in: true if open to the low end, + false if to the high end */ dict_index_t* index, /*!< in: index */ ulint latch_mode, /*!< in: latch mode */ - btr_pcur_t* pcur, /*!< in: cursor */ - ibool do_init, /*!< in: TRUE if should be initialized */ - mtr_t* mtr) /*!< in: mtr */ + btr_pcur_t* pcur, /*!< in/out: cursor */ + bool init_pcur, /*!< in: whether to initialize pcur */ + ulint level, /*!< in: level to search for + (0=leaf) */ + mtr_t* mtr) /*!< in/out: mini-transaction */ { - pcur->latch_mode = latch_mode; + pcur->latch_mode = BTR_LATCH_MODE_WITHOUT_FLAGS(latch_mode); - if (from_left) { - pcur->search_mode = PAGE_CUR_G; - } else { - pcur->search_mode = PAGE_CUR_L; - } + pcur->search_mode = from_left ? PAGE_CUR_G : PAGE_CUR_L; - if (do_init) { + if (init_pcur) { btr_pcur_init(pcur); } btr_cur_open_at_index_side(from_left, index, latch_mode, - btr_pcur_get_btr_cur(pcur), mtr); + btr_pcur_get_btr_cur(pcur), level, mtr); pcur->pos_state = BTR_PCUR_IS_POSITIONED; pcur->old_stored = BTR_PCUR_OLD_NOT_STORED; @@ -555,7 +554,16 @@ btr_pcur_open_at_rnd_pos_func( /**************************************************************//** Frees the possible memory heap of a persistent cursor and sets the latch -mode of the persistent cursor to BTR_NO_LATCHES. */ +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(btr_pcur_get_block(&pcur), 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. */ UNIV_INLINE void btr_pcur_close( |