| 1 | /***************************************************************************** |
| 2 | |
| 3 | Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. |
| 4 | Copyright (c) 2016, 2023, MariaDB Corporation. |
| 5 | |
| 6 | This program is free software; you can redistribute it and/or modify it under |
| 7 | the terms of the GNU General Public License as published by the Free Software |
| 8 | Foundation; version 2 of the License. |
| 9 | |
| 10 | This program is distributed in the hope that it will be useful, but WITHOUT |
| 11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 12 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU General Public License along with |
| 15 | this program; if not, write to the Free Software Foundation, Inc., |
| 16 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA |
| 17 | |
| 18 | *****************************************************************************/ |
| 19 | |
| 20 | /**************************************************//** |
| 21 | @file btr/btr0pcur.cc |
| 22 | The index tree persistent cursor |
| 23 | |
| 24 | Created 2/23/1996 Heikki Tuuri |
| 25 | *******************************************************/ |
| 26 | |
| 27 | #include "btr0pcur.h"cxx . . $ `<file>/storage/innobase/include/btr0pcur.h`/ |
| 28 | #include "buf0rea.h"cxx . . $ `<file>/storage/innobase/include/buf0rea.h`/ |
| 29 | #include "btr0sea.h"cxx . . $ `<file>/storage/innobase/include/btr0sea.h`/ |
| 30 | #include "rem0cmp.h"cxx . . $ `<file>/storage/innobase/include/rem0cmp.h`/ |
| 31 | #include "ibuf0ibuf.h"cxx . . $ `<file>/storage/innobase/include/ibuf0ibuf.h`/ |
| 32 | |
| 33 | /**************************************************************//** |
| 34 | Resets a persistent cursor object, freeing ::old_rec_buf if it is |
| 35 | allocated and resetting the other members to their initial values. */ |
| 36 | void |
| 37 | btr_pcur_resetcxx . . $ btr_pcur_reset(57c44ef9c177cfb0).( |
| 38 | /*===========*/ |
| 39 | btr_pcur_tcxx . . $ btr_pcur_t#* cursor) /*!< in, out: persistent cursor */ |
| 40 | { |
| 41 | ut_freecxx . . $ `storage/innobase/include/ut0new.h:1044:9`!(cursor->old_rec_buf); |
| 42 | memset(&cursor->btr_curcxx . . $ btr_pcur_t#btr_cur..page_curcxx . . $ btr_cur_t#page_cur., 0, sizeof(page_cur_tcxx . . $ page_cur_t#)); |
| 43 | cursor->old_rec_bufcxx . . $ btr_pcur_t#old_rec_buf. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 44 | cursor->old_reccxx . . $ btr_pcur_t#old_rec. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 45 | cursor->old_n_core_fieldscxx . . $ btr_pcur_t#old_n_core_fields. = 0; |
| 46 | cursor->old_n_fieldscxx . . $ btr_pcur_t#old_n_fields. = 0; |
| 47 | |
| 48 | cursor->latch_modecxx . . $ btr_pcur_t#latch_mode. = BTR_NO_LATCHEScxx . . $ BTR_NO_LATCHES.; |
| 49 | cursor->pos_statecxx . . $ btr_pcur_t#pos_state. = BTR_PCUR_NOT_POSITIONEDcxx . . $ BTR_PCUR_NOT_POSITIONED.; |
| 50 | } |
| 51 | |
| 52 | /**************************************************************//** |
| 53 | The position of the cursor is stored by taking an initial segment of the |
| 54 | record the cursor is positioned on, before, or after, and copying it to the |
| 55 | cursor data structure, or just setting a flag if the cursor id before the |
| 56 | first in an EMPTY tree, or after the last in an EMPTY tree. NOTE that the |
| 57 | page where the cursor is positioned must not be empty if the index tree is |
| 58 | not totally empty! */ |
| 59 | void |
| 60 | btr_pcur_store_positioncxx . . $ btr_pcur_store_position(f723d369374bc0bf).( |
| 61 | /*====================*/ |
| 62 | btr_pcur_tcxx . . $ btr_pcur_t#* cursor, /*!< in: persistent cursor */ |
| 63 | mtr_tcxx . . $ mtr_t#* mtr) /*!< in: mtr */ |
| 64 | { |
| 65 | page_cur_tcxx . . $ page_cur_t#* page_cursor; |
| 66 | buf_block_tcxx . . $ buf_block_t#* block; |
| 67 | rec_tcxx . . $ rec_t#* rec; |
| 68 | dict_index_tcxx . . $ dict_index_t#* index; |
| 69 | ulintcxx . . $ ulint# offs; |
| 70 | |
| 71 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(cursor->pos_state == BTR_PCUR_IS_POSITIONED); |
| 72 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(cursor->latch_mode != BTR_NO_LATCHES); |
| 73 | |
| 74 | block = btr_pcur_get_blockcxx . . $ btr_pcur_get_block(73fb1691f91dfae3).(cursor); |
| 75 | index = btr_cur_get_indexcxx . . $ `storage/innobase/include/btr0cur.h:82:9`!(btr_pcur_get_btr_curcxx . . $ `storage/innobase/include/btr0pcur.h:214:9`!(cursor)); |
| 76 | |
| 77 | page_cursor = btr_pcur_get_page_curcxx . . $ `storage/innobase/include/btr0pcur.h:215:9`!(cursor); |
| 78 | |
| 79 | rec = page_cur_get_reccxx . . $ `storage/innobase/include/page0cur.h:57:10`!(page_cursor); |
| 80 | offs = rec - block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.; |
| 81 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(block->page.id().page_no() |
| 82 | == page_get_page_no(block->page.frame)); |
| 83 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(block->page.buf_fix_count()); |
| 84 | /* For spatial index, when we do positioning on parent |
| 85 | buffer if necessary, it might not hold latches, but the |
| 86 | tree must be locked to prevent change on the page */ |
| 87 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mtr->memo_contains_flagged(block, MTR_MEMO_PAGE_S_FIX |
| 88 | | MTR_MEMO_PAGE_X_FIX) |
| 89 | || (index->is_spatial() |
| 90 | && mtr->memo_contains_flagged(&index->lock, MTR_MEMO_X_LOCK |
| 91 | | MTR_MEMO_SX_LOCK))); |
| 92 | |
| 93 | if (page_is_emptycxx . . $ page_is_empty(190063cf6fb4afb1).(block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.)) { |
| 94 | /* It must be an empty index tree; NOTE that in this case |
| 95 | we do not store the modify_clock, but always do a search |
| 96 | if we restore the cursor position */ |
| 97 | |
| 98 | ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(!page_has_siblings(block->page.frame)); |
| 99 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(page_is_leaf(block->page.frame)); |
| 100 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(block->page.id().page_no() == index->page); |
| 101 | |
| 102 | if (page_rec_is_supremum_lowcxx . . $ page_rec_is_supremum_low(31596a199e1d8a50).(offs)) { |
| 103 | cursor->rel_poscxx . . $ btr_pcur_t#rel_pos. = BTR_PCUR_AFTER_LAST_IN_TREEcxx . . $ BTR_PCUR_AFTER_LAST_IN_TREE.; |
| 104 | } else { |
| 105 | before_first: |
| 106 | cursor->rel_poscxx . . $ btr_pcur_t#rel_pos. = BTR_PCUR_BEFORE_FIRST_IN_TREEcxx . . $ BTR_PCUR_BEFORE_FIRST_IN_TREE.; |
| 107 | } |
| 108 | |
| 109 | return; |
| 110 | } |
| 111 | |
| 112 | if (page_rec_is_supremum_lowcxx . . $ page_rec_is_supremum_low(31596a199e1d8a50).(offs)) { |
| 113 | rec = page_rec_get_prevcxx . . $ page_rec_get_prev(adcd832f8377c3d8).(rec); |
| 114 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(!rec || page_rec_is_infimum(rec))) { |
| 115 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!("corrupted index" == 0); |
| 116 | cursor->rel_poscxx . . $ btr_pcur_t#rel_pos. = BTR_PCUR_AFTER_LAST_IN_TREEcxx . . $ BTR_PCUR_AFTER_LAST_IN_TREE.; |
| 117 | return; |
| 118 | } |
| 119 | |
| 120 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!page_rec_is_infimum(rec)); |
| 121 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(rec_is_metadata(rec, *index))) { |
| 122 | #if 0 /* MDEV-22867 had to relax this */ |
| 123 | /* If the table is emptied during an ALGORITHM=NOCOPY |
| 124 | DROP COLUMN ... that is not ALGORITHM=INSTANT, |
| 125 | then we must preserve any instant ADD metadata. */ |
| 126 | ut_ad(index->table->instant |
| 127 | || block->page.id().page_no() != index->page); |
| 128 | #endif |
| 129 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(index->is_instant() |
| 130 | || block->page.id().page_no() != index->page); |
| 131 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(page_get_n_recs(block->page.frame) == 1); |
| 132 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(page_is_leaf(block->page.frame)); |
| 133 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!page_has_prev(block->page.frame)); |
| 134 | cursor->rel_poscxx . . $ btr_pcur_t#rel_pos. = BTR_PCUR_AFTER_LAST_IN_TREEcxx . . $ BTR_PCUR_AFTER_LAST_IN_TREE.; |
| 135 | return; |
| 136 | } |
| 137 | |
| 138 | cursor->rel_poscxx . . $ btr_pcur_t#rel_pos. = BTR_PCUR_AFTERcxx . . $ BTR_PCUR_AFTER.; |
| 139 | } else if (page_rec_is_infimum_lowcxx . . $ page_rec_is_infimum_low(31596a199e1d8a50).(offs)) { |
| 140 | rec = page_rec_get_nextcxx . . $ page_rec_get_next(adcd832f8377c3d8).(rec); |
| 141 | |
| 142 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(!rec)) { |
| 143 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!("corrupted page" == 0); |
| 144 | goto before_first; |
| 145 | } |
| 146 | |
| 147 | if (rec_is_metadatacxx . . $ rec_is_metadata(5dcd923c19b1cb7d).(rec, *index)) { |
| 148 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!page_has_prev(block->page.frame)); |
| 149 | rec = page_rec_get_nextcxx . . $ page_rec_get_next(adcd832f8377c3d8).(rec); |
| 150 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rec); |
| 151 | if (!rec || page_rec_is_supremumcxx . . $ page_rec_is_supremum(190063cf6fb4afb1).(rec)) { |
| 152 | goto before_first; |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | cursor->rel_poscxx . . $ btr_pcur_t#rel_pos. = BTR_PCUR_BEFOREcxx . . $ BTR_PCUR_BEFORE.; |
| 157 | } else { |
| 158 | cursor->rel_poscxx . . $ btr_pcur_t#rel_pos. = BTR_PCUR_ONcxx . . $ BTR_PCUR_ON.; |
| 159 | } |
| 160 | |
| 161 | cursor->old_n_fieldscxx . . $ btr_pcur_t#old_n_fields. = static_cast<uint16cxx . . $ uint16#>( |
| 162 | dict_index_get_n_unique_in_treecxx . . $ dict_index_get_n_unique_in_tree(40995254b96f8651).(index)); |
| 163 | if (index->is_spatialcxx . . $ dict_index_t#is_spatial(50ce9a9e25b4a850).() && !page_rec_is_leafcxx . . $ page_rec_is_leaf(190063cf6fb4afb1).(rec)) { |
| 164 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(dict_index_get_n_unique_in_tree_nonleaf(index) |
| 165 | == DICT_INDEX_SPATIAL_NODEPTR_SIZE); |
| 166 | /* For R-tree, we have to compare |
| 167 | the child page numbers as well. */ |
| 168 | cursor->old_n_fieldscxx . . $ btr_pcur_t#old_n_fields. = DICT_INDEX_SPATIAL_NODEPTR_SIZEcxx . . $ `storage/innobase/include/dict0dict.h:940:9`! + 1; |
| 169 | } |
| 170 | |
| 171 | cursor->old_n_core_fieldscxx . . $ btr_pcur_t#old_n_core_fields. = index->n_core_fieldscxx . . $ dict_index_t#n_core_fields.; |
| 172 | cursor->old_reccxx . . $ btr_pcur_t#old_rec. = rec_copy_prefix_to_bufcxx . . $ rec_copy_prefix_to_buf(f7016ffe19911457).(rec, index, |
| 173 | cursor->old_n_fieldscxx . . $ btr_pcur_t#old_n_fields., |
| 174 | &cursor->old_rec_bufcxx . . $ btr_pcur_t#old_rec_buf., |
| 175 | &cursor->buf_sizecxx . . $ btr_pcur_t#buf_size.); |
| 176 | cursor->old_page_idcxx . . $ btr_pcur_t#old_page_id. =cxx . . $ page_id_t#`operator=`(198232b5a711dae6). block->pagecxx . . $ buf_block_t#page..idcxx . . $ buf_page_t#id(9d40bbb65128eac8).(); |
| 177 | cursor->modify_clockcxx . . $ btr_pcur_t#modify_clock. = block->modify_clockcxx . . $ buf_block_t#modify_clock.; |
| 178 | } |
| 179 | |
| 180 | /**************************************************************//** |
| 181 | Copies the stored position of a pcur to another pcur. */ |
| 182 | void |
| 183 | btr_pcur_copy_stored_positioncxx . . $ btr_pcur_copy_stored_position(5a3b75a428c073d8).( |
| 184 | /*==========================*/ |
| 185 | btr_pcur_tcxx . . $ btr_pcur_t#* pcur_receive, /*!< in: pcur which will receive the |
| 186 | position info */ |
| 187 | btr_pcur_tcxx . . $ btr_pcur_t#* pcur_donate) /*!< in: pcur from which the info is |
| 188 | copied */ |
| 189 | { |
| 190 | ut_freecxx . . $ `storage/innobase/include/ut0new.h:1044:9`!(pcur_receive->old_rec_buf); |
| 191 | memcpy(pcur_receive, pcur_donate, sizeof(btr_pcur_tcxx . . $ btr_pcur_t#)); |
| 192 | |
| 193 | if (pcur_donate->old_rec_bufcxx . . $ btr_pcur_t#old_rec_buf.) { |
| 194 | |
| 195 | pcur_receive->old_rec_bufcxx . . $ btr_pcur_t#old_rec_buf. = (bytecxx . . $ byte#*) |
| 196 | ut_malloc_nokeycxx . . $ `storage/innobase/include/ut0new.h:1028:9`!(pcur_donate->buf_size); |
| 197 | |
| 198 | memcpy(pcur_receive->old_rec_bufcxx . . $ btr_pcur_t#old_rec_buf., pcur_donate->old_rec_bufcxx . . $ btr_pcur_t#old_rec_buf., |
| 199 | pcur_donate->buf_sizecxx . . $ btr_pcur_t#buf_size.); |
| 200 | pcur_receive->old_reccxx . . $ btr_pcur_t#old_rec. = pcur_receive->old_rec_bufcxx . . $ btr_pcur_t#old_rec_buf. |
| 201 | + (pcur_donate->old_reccxx . . $ btr_pcur_t#old_rec. - pcur_donate->old_rec_bufcxx . . $ btr_pcur_t#old_rec_buf.); |
| 202 | } |
| 203 | |
| 204 | pcur_receive->old_n_core_fieldscxx . . $ btr_pcur_t#old_n_core_fields. = pcur_donate->old_n_core_fieldscxx . . $ btr_pcur_t#old_n_core_fields.; |
| 205 | pcur_receive->old_n_fieldscxx . . $ btr_pcur_t#old_n_fields. = pcur_donate->old_n_fieldscxx . . $ btr_pcur_t#old_n_fields.; |
| 206 | } |
| 207 | |
| 208 | /** Optimistically latches the leaf page or pages requested. |
| 209 | @param pcur persistent cursor |
| 210 | @param latch_mode BTR_SEARCH_LEAF, ... |
| 211 | @param mtr mini-transaction |
| 212 | @return true on success */ |
| 213 | TRANSACTIONAL_TARGETcxx . . $ `storage/innobase/include/transactional_lock_guard.h:48:12`! |
| 214 | static bool btr_pcur_optimistic_latch_leavescxx . . $ btr_pcur_optimistic_latch_leaves(aeffec72ce80d09b).(btr_pcur_tcxx . . $ btr_pcur_t# *pcur, |
| 215 | btr_latch_modecxx . . $ btr_latch_mode# *latch_mode, |
| 216 | mtr_tcxx . . $ mtr_t# *mtr) |
| 217 | { |
| 218 | buf_block_tcxx . . $ buf_block_t# *const block= |
| 219 | buf_page_optimistic_fixcxx . . $ buf_page_optimistic_fix(ba4814184f63ee9e).(pcur->btr_curcxx . . $ btr_pcur_t#btr_cur..page_curcxx . . $ btr_cur_t#page_cur..blockcxx . . $ page_cur_t#block., pcur->old_page_idcxx . . $ btr_pcur_t#old_page_id.); |
| 220 | |
| 221 | if (!block) |
| 222 | return false; |
| 223 | |
| 224 | if (*latch_mode != BTR_SEARCH_PREVcxx . . $ BTR_SEARCH_PREV.) |
| 225 | { |
| 226 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(*latch_mode == BTR_SEARCH_LEAF || *latch_mode == BTR_MODIFY_LEAF); |
| 227 | return buf_page_optimistic_getcxx . . $ buf_page_optimistic_get(51b069448ad61459).(block, rw_lock_type_tcxx . . $ rw_lock_type_t#(*latch_mode), |
| 228 | pcur->modify_clockcxx . . $ btr_pcur_t#modify_clock., mtr); |
| 229 | } |
| 230 | |
| 231 | uint64_tcxx . . $ uint64_t# modify_clock; |
| 232 | uint32_tcxx . . $ uint32_t# left_page_no; |
| 233 | const page_tcxx . . $ `storage/innobase/include/page0types.h:38:9`! *const page= block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.; |
| 234 | { |
| 235 | transactional_shared_lock_guardcxx . . $ transactional_shared_lock_guard#<block_lockcxx . . $ block_lock#> gcxx . . $ transactional_shared_lock_guard#transactional_shared_lock_guard(926f85bfe424ae64).{block->pagecxx . . $ buf_block_t#page..lockcxx . . $ buf_page_t#lock.}; |
| 236 | modify_clock= block->modify_clockcxx . . $ buf_block_t#modify_clock.; |
| 237 | left_page_no= btr_page_get_prevcxx . . $ btr_page_get_prev(ca1608e2c87725e2).(page); |
| 238 | } |
| 239 | |
| 240 | const auto savepoint= mtr->get_savepointcxx . . $ mtr_t#get_savepoint(fe4d2d262d4164a8).(); |
| 241 | mtr->memo_pushcxx . . $ mtr_t#memo_push(1e7bab2d46fcb4c1).(block, MTR_MEMO_BUF_FIXcxx . . $ MTR_MEMO_BUF_FIX.); |
| 242 | |
| 243 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(modify_clock != pcur->modify_clock)) |
| 244 | { |
| 245 | fail: |
| 246 | mtr->rollback_to_savepointcxx . . $ mtr_t#rollback_to_savepoint(2c44cd906ae4e829).(savepoint); |
| 247 | return false; |
| 248 | } |
| 249 | |
| 250 | buf_block_tcxx . . $ buf_block_t# *prev; |
| 251 | if (left_page_no != FIL_NULLcxx . . $ `storage/innobase/include/fil0fil.h:1175:9`!) |
| 252 | { |
| 253 | prev= buf_page_get_gencxx . . $ buf_page_get_gen(4cc82125c68d4d05).(page_id_tcxx . . $ page_id_t#page_id_t(b4d55b1286ff73e8).(pcur->old_page_idcxx . . $ btr_pcur_t#old_page_id..spacecxx . . $ page_id_t#space(d22c8608b6eae7b5).(), |
| 254 | left_page_no), block->zip_sizecxx . . $ buf_block_t#zip_size(c9b1e749b64d5edc).(), |
| 255 | RW_S_LATCHcxx . . $ RW_S_LATCH., nullptr, BUF_GET_POSSIBLY_FREEDcxx . . $ `storage/innobase/include/buf0buf.h:58:9`!, mtr); |
| 256 | if (!prev || |
| 257 | page_is_compcxx . . $ page_is_comp(f3688bc2ee54ea05).(prev->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.) != page_is_compcxx . . $ page_is_comp(f3688bc2ee54ea05).(block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.) || |
| 258 | memcmp_alignedcxx . . $ memcmp_aligned(36f949851efa3055).<2>(block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame., prev->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame., 2) || |
| 259 | memcmp_alignedcxx . . $ memcmp_aligned(36f949851efa3055).<2>(block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame. + PAGE_HEADERcxx . . $ `storage/innobase/include/page0page.h:48:9`! + PAGE_INDEX_IDcxx . . $ `storage/innobase/include/page0page.h:109:9`!, |
| 260 | prev->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame. + PAGE_HEADERcxx . . $ `storage/innobase/include/page0page.h:48:9`! + PAGE_INDEX_IDcxx . . $ `storage/innobase/include/page0page.h:109:9`!, 8)) |
| 261 | goto fail; |
| 262 | btr_search_drop_page_hash_indexcxx . . $ btr_search_drop_page_hash_index(33307f3566ecc1a8).(prev, pcur->indexcxx . . $ btr_pcur_t#index(4ab6b9797a912635).()); |
| 263 | } |
| 264 | else |
| 265 | prev= nullptr; |
| 266 | |
| 267 | mtr->upgrade_buffer_fixcxx . . $ mtr_t#upgrade_buffer_fix(c5140f264e978609).(savepoint, RW_S_LATCHcxx . . $ RW_S_LATCH.); |
| 268 | btr_search_drop_page_hash_indexcxx . . $ btr_search_drop_page_hash_index(33307f3566ecc1a8).(block, pcur->indexcxx . . $ btr_pcur_t#index(4ab6b9797a912635).()); |
| 269 | |
| 270 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(block->modify_clock != modify_clock) || |
| 271 | UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(block->page.is_freed()) || |
| 272 | (prev && |
| 273 | memcmp_alignedcxx . . $ memcmp_aligned(36f949851efa3055).<4>(FIL_PAGE_NEXTcxx . . $ `storage/innobase/include/fil0fil.h:1203:9`! + prev->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame., |
| 274 | FIL_PAGE_OFFSETcxx . . $ `storage/innobase/include/fil0fil.h:1195:9`! + page, 4))) |
| 275 | goto fail; |
| 276 | |
| 277 | return true; |
| 278 | } |
| 279 | |
| 280 | /** Restores the stored position of a persistent cursor bufferfixing |
| 281 | the page and obtaining the specified latches. If the cursor position |
| 282 | was saved when the |
| 283 | (1) cursor was positioned on a user record: this function restores the |
| 284 | position to the last record LESS OR EQUAL to the stored record; |
| 285 | (2) cursor was positioned on a page infimum record: restores the |
| 286 | position to the last record LESS than the user record which was the |
| 287 | successor of the page infimum; |
| 288 | (3) cursor was positioned on the page supremum: restores to the first |
| 289 | record GREATER than the user record which was the predecessor of the |
| 290 | supremum. |
| 291 | (4) cursor was positioned before the first or after the last in an |
| 292 | empty tree: restores to before first or after the last in the tree. |
| 293 | @param latch_mode BTR_SEARCH_LEAF, ... |
| 294 | @param mtr mini-transaction |
| 295 | @return btr_pcur_t::SAME_ALL cursor position on user rec and points on |
| 296 | the record with the same field values as in the stored record, |
| 297 | btr_pcur_t::SAME_UNIQ cursor position is on user rec and points on the |
| 298 | record with the same unique field values as in the stored record, |
| 299 | btr_pcur_t::NOT_SAME cursor position is not on user rec or points on |
| 300 | the record with not the samebuniq field values as in the stored */ |
| 301 | btr_pcur_tcxx . . $ btr_pcur_t#::restore_statuscxx . . $ btr_pcur_t#restore_status# |
| 302 | btr_pcur_tcxx . . $ btr_pcur_t#::restore_positioncxx . . $ btr_pcur_t#restore_position(8c85f028503b2912).(btr_latch_modecxx . . $ btr_latch_mode# restore_latch_mode, mtr_tcxx . . $ mtr_t# *mtr) |
| 303 | { |
| 304 | dict_index_tcxx . . $ dict_index_t#* index; |
| 305 | dtuple_tcxx . . $ dtuple_t#* tuple; |
| 306 | page_cur_mode_tcxx . . $ page_cur_mode_t# mode; |
| 307 | page_cur_mode_tcxx . . $ page_cur_mode_t# old_mode; |
| 308 | mem_heap_tcxx . . $ mem_heap_t#* heap; |
| 309 | |
| 310 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mtr->is_active()); |
| 311 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(pos_state == BTR_PCUR_WAS_POSITIONED |
| 312 | || pos_state == BTR_PCUR_IS_POSITIONED); |
| 313 | |
| 314 | index = btr_cur_get_indexcxx . . $ `storage/innobase/include/btr0cur.h:82:9`!(&btr_cur); |
| 315 | |
| 316 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`! |
| 317 | (rel_pos == BTR_PCUR_AFTER_LAST_IN_TREE |
| 318 | || rel_pos == BTR_PCUR_BEFORE_FIRST_IN_TREE)) { |
| 319 | /* In these cases we do not try an optimistic restoration, |
| 320 | but always do a search */ |
| 321 | |
| 322 | if (btr_curcxx . . $ btr_pcur_t#btr_cur..open_leafcxx . . $ btr_cur_t#open_leaf(1d074ecb69eae3b8).(rel_poscxx . . $ btr_pcur_t#rel_pos. == BTR_PCUR_BEFORE_FIRST_IN_TREEcxx . . $ BTR_PCUR_BEFORE_FIRST_IN_TREE., |
| 323 | index, restore_latch_mode, mtr) |
| 324 | != DB_SUCCESScxx . . $ DB_SUCCESS.) { |
| 325 | return restore_statuscxx . . $ btr_pcur_t#restore_status#::CORRUPTEDcxx . . $ btr_pcur_t#CORRUPTED.; |
| 326 | } |
| 327 | |
| 328 | latch_modecxx . . $ btr_pcur_t#latch_mode. = |
| 329 | BTR_LATCH_MODE_WITHOUT_INTENTIONcxx . . $ `storage/innobase/include/btr0btr.h:65:9`!(restore_latch_mode); |
| 330 | pos_statecxx . . $ btr_pcur_t#pos_state. = BTR_PCUR_IS_POSITIONEDcxx . . $ BTR_PCUR_IS_POSITIONED.; |
| 331 | |
| 332 | return restore_statuscxx . . $ btr_pcur_t#restore_status#::NOT_SAMEcxx . . $ btr_pcur_t#NOT_SAME.; |
| 333 | } |
| 334 | |
| 335 | ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(old_rec); |
| 336 | ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(old_n_core_fields); |
| 337 | ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(old_n_core_fields <= index->n_core_fields); |
| 338 | ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(old_n_fields); |
| 339 | |
| 340 | static_assert(int{BTR_SEARCH_PREVcxx . . $ BTR_SEARCH_PREV.} == (4 | BTR_SEARCH_LEAFcxx . . $ BTR_SEARCH_LEAF.), ""); |
| 341 | |
| 342 | if ((restore_latch_mode | 4) == BTR_SEARCH_PREVcxx . . $ BTR_SEARCH_PREV.) { |
| 343 | /* Try optimistic restoration. */ |
| 344 | if (btr_pcur_optimistic_latch_leavescxx . . $ btr_pcur_optimistic_latch_leaves(aeffec72ce80d09b).(this, &restore_latch_mode, |
| 345 | mtr)) { |
| 346 | pos_statecxx . . $ btr_pcur_t#pos_state. = BTR_PCUR_IS_POSITIONEDcxx . . $ BTR_PCUR_IS_POSITIONED.; |
| 347 | latch_modecxx . . $ btr_pcur_t#latch_mode. = restore_latch_mode; |
| 348 | |
| 349 | if (rel_poscxx . . $ btr_pcur_t#rel_pos. == BTR_PCUR_ONcxx . . $ BTR_PCUR_ON.) { |
| 350 | #ifdef UNIV_DEBUG |
| 351 | const rec_t* rec; |
| 352 | rec_offs offsets1_[REC_OFFS_NORMAL_SIZE]; |
| 353 | rec_offs offsets2_[REC_OFFS_NORMAL_SIZE]; |
| 354 | rec_offs* offsets1 = offsets1_; |
| 355 | rec_offs* offsets2 = offsets2_; |
| 356 | rec = btr_pcur_get_rec(this); |
| 357 | |
| 358 | rec_offs_init(offsets1_); |
| 359 | rec_offs_init(offsets2_); |
| 360 | |
| 361 | heap = mem_heap_create(256); |
| 362 | ut_ad(old_n_core_fields |
| 363 | == index->n_core_fields); |
| 364 | |
| 365 | offsets1 = rec_get_offsets( |
| 366 | old_rec, index, offsets1, |
| 367 | old_n_core_fields, |
| 368 | old_n_fields, &heap); |
| 369 | offsets2 = rec_get_offsets( |
| 370 | rec, index, offsets2, |
| 371 | index->n_core_fields, |
| 372 | old_n_fields, &heap); |
| 373 | |
| 374 | ut_ad(!cmp_rec_rec(old_rec, |
| 375 | rec, offsets1, offsets2, |
| 376 | index)); |
| 377 | mem_heap_free(heap); |
| 378 | #endif /* UNIV_DEBUG */ |
| 379 | return restore_statuscxx . . $ btr_pcur_t#restore_status#::SAME_ALLcxx . . $ btr_pcur_t#SAME_ALL.; |
| 380 | } |
| 381 | /* This is the same record as stored, |
| 382 | may need to be adjusted for BTR_PCUR_BEFORE/AFTER, |
| 383 | depending on search mode and direction. */ |
| 384 | if (btr_pcur_is_on_user_reccxx . . $ btr_pcur_is_on_user_rec(c5e2b82e26308d5e).(this)) { |
| 385 | pos_statecxx . . $ btr_pcur_t#pos_state. |
| 386 | = BTR_PCUR_IS_POSITIONED_OPTIMISTICcxx . . $ BTR_PCUR_IS_POSITIONED_OPTIMISTIC.; |
| 387 | } |
| 388 | return restore_statuscxx . . $ btr_pcur_t#restore_status#::NOT_SAMEcxx . . $ btr_pcur_t#NOT_SAME.; |
| 389 | } |
| 390 | } |
| 391 | |
| 392 | /* If optimistic restoration did not succeed, open the cursor anew */ |
| 393 | |
| 394 | heap = mem_heap_createcxx . . $ `storage/innobase/include/mem0mem.h:85:10`!(256); |
| 395 | |
| 396 | tuple = dtuple_createcxx . . $ dtuple_create(7b6cbdd22997b910).(heap, old_n_fieldscxx . . $ btr_pcur_t#old_n_fields.); |
| 397 | |
| 398 | dict_index_copy_typescxx . . $ dict_index_copy_types(9015429b5b64dc2b).(tuple, index, old_n_fieldscxx . . $ btr_pcur_t#old_n_fields.); |
| 399 | |
| 400 | rec_copy_prefix_to_dtuplecxx . . $ rec_copy_prefix_to_dtuple(998ea8bc26803b49).(tuple, old_reccxx . . $ btr_pcur_t#old_rec., index, |
| 401 | old_n_core_fieldscxx . . $ btr_pcur_t#old_n_core_fields., |
| 402 | old_n_fieldscxx . . $ btr_pcur_t#old_n_fields., heap); |
| 403 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(dtuple_check_typed(tuple)); |
| 404 | |
| 405 | /* Save the old search mode of the cursor */ |
| 406 | old_mode = search_modecxx . . $ btr_pcur_t#search_mode.; |
| 407 | |
| 408 | switch (rel_poscxx . . $ btr_pcur_t#rel_pos.) { |
| 409 | case BTR_PCUR_ONcxx . . $ BTR_PCUR_ON.: |
| 410 | mode = PAGE_CUR_LEcxx . . $ PAGE_CUR_LE.; |
| 411 | break; |
| 412 | case BTR_PCUR_AFTERcxx . . $ BTR_PCUR_AFTER.: |
| 413 | mode = PAGE_CUR_Gcxx . . $ PAGE_CUR_G.; |
| 414 | break; |
| 415 | case BTR_PCUR_BEFOREcxx . . $ BTR_PCUR_BEFORE.: |
| 416 | mode = PAGE_CUR_Lcxx . . $ PAGE_CUR_L.; |
| 417 | break; |
| 418 | default: |
| 419 | MY_ASSERT_UNREACHABLEcxx . . $ `include/my_compiler.h:51:10`!(); |
| 420 | mode = PAGE_CUR_UNSUPPcxx . . $ PAGE_CUR_UNSUPP.; |
| 421 | } |
| 422 | |
| 423 | if (btr_pcur_open_with_no_initcxx . . $ btr_pcur_open_with_no_init(fc6cd1a58061ff83).(tuple, mode, restore_latch_mode, |
| 424 | this, mtr) != DB_SUCCESScxx . . $ DB_SUCCESS.) { |
| 425 | mem_heap_freecxx . . $ mem_heap_free(5231cf397463bfab).(heap); |
| 426 | return restore_statuscxx . . $ btr_pcur_t#restore_status#::CORRUPTEDcxx . . $ btr_pcur_t#CORRUPTED.; |
| 427 | } |
| 428 | |
| 429 | /* Restore the old search mode */ |
| 430 | search_modecxx . . $ btr_pcur_t#search_mode. = old_mode; |
| 431 | |
| 432 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rel_pos == BTR_PCUR_ON |
| 433 | || rel_pos == BTR_PCUR_BEFORE |
| 434 | || rel_pos == BTR_PCUR_AFTER); |
| 435 | rec_offscxx . . $ rec_offs# offsets[REC_OFFS_NORMAL_SIZEcxx . . $ REC_OFFS_NORMAL_SIZE.]; |
| 436 | rec_offs_initcxx . . $ `storage/innobase/include/rem0rec.h:844:9`!(offsets); |
| 437 | restore_statuscxx . . $ btr_pcur_t#restore_status# ret_val= restore_statuscxx . . $ btr_pcur_t#restore_status#::NOT_SAMEcxx . . $ btr_pcur_t#NOT_SAME.; |
| 438 | if (rel_poscxx . . $ btr_pcur_t#rel_pos. == BTR_PCUR_ONcxx . . $ BTR_PCUR_ON. && btr_pcur_is_on_user_reccxx . . $ btr_pcur_is_on_user_rec(c5e2b82e26308d5e).(this)) { |
| 439 | uint16_tcxx . . $ uint16_t# n_matched_fields= 0; |
| 440 | if (!cmp_dtuple_rec_with_matchcxx . . $ `storage/innobase/include/rem0cmp.h:154:9`!( |
| 441 | tuple, btr_pcur_get_rec(this), index, |
| 442 | rec_get_offsetscxx . . $ `storage/innobase/include/rem0rec.h:475:10`!(btr_pcur_get_rec(this), index, offsets, |
| 443 | index->n_core_fields, ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!, &heap), |
| 444 | &n_matched_fields)) { |
| 445 | |
| 446 | /* We have to store the NEW value for the modify clock, |
| 447 | since the cursor can now be on a different page! |
| 448 | But we can retain the value of old_rec */ |
| 449 | |
| 450 | old_page_idcxx . . $ btr_pcur_t#old_page_id. =cxx . . $ page_id_t#`operator=`(198232b5a711dae6). btr_curcxx . . $ btr_pcur_t#btr_cur..page_curcxx . . $ btr_cur_t#page_cur..blockcxx . . $ page_cur_t#block.->pagecxx . . $ buf_block_t#page..idcxx . . $ buf_page_t#id(9d40bbb65128eac8).(); |
| 451 | modify_clockcxx . . $ btr_pcur_t#modify_clock. = btr_curcxx . . $ btr_pcur_t#btr_cur..page_curcxx . . $ btr_cur_t#page_cur..blockcxx . . $ page_cur_t#block.->modify_clockcxx . . $ buf_block_t#modify_clock.; |
| 452 | |
| 453 | mem_heap_freecxx . . $ mem_heap_free(5231cf397463bfab).(heap); |
| 454 | |
| 455 | return restore_statuscxx . . $ btr_pcur_t#restore_status#::SAME_ALLcxx . . $ btr_pcur_t#SAME_ALL.; |
| 456 | } |
| 457 | if (n_matched_fields >= index->n_uniqcxx . . $ dict_index_t#n_uniq. |
| 458 | /* Unique indexes can contain "NULL" keys, and if all |
| 459 | unique fields are NULL and not all tuple |
| 460 | fields match to record fields, then treat it as if |
| 461 | restored cursor position points to the record with |
| 462 | not the same unique key. */ |
| 463 | && !(index->n_nullablecxx . . $ dict_index_t#n_nullable. |
| 464 | && dtuple_contains_nullcxx . . $ dtuple_contains_null(28b68f272fc56fd2).(tuple, index->n_uniqcxx . . $ dict_index_t#n_uniq.))) |
| 465 | ret_val= restore_statuscxx . . $ btr_pcur_t#restore_status#::SAME_UNIQcxx . . $ btr_pcur_t#SAME_UNIQ.; |
| 466 | } |
| 467 | |
| 468 | mem_heap_freecxx . . $ mem_heap_free(5231cf397463bfab).(heap); |
| 469 | |
| 470 | /* We have to store new position information, modify_clock etc., |
| 471 | to the cursor because it can now be on a different page, the record |
| 472 | under it may have been removed, etc. */ |
| 473 | |
| 474 | btr_pcur_store_positioncxx . . $ btr_pcur_store_position(f723d369374bc0bf).(this, mtr); |
| 475 | |
| 476 | return ret_val; |
| 477 | } |
| 478 | |
| 479 | /*********************************************************//** |
| 480 | Moves the persistent cursor to the first record on the next page. Releases the |
| 481 | latch on the current page, and bufferunfixes it. Note that there must not be |
| 482 | modifications on the current page, as then the x-latch can be released only in |
| 483 | mtr_commit. */ |
| 484 | dberr_tcxx . . $ dberr_t# |
| 485 | btr_pcur_move_to_next_pagecxx . . $ btr_pcur_move_to_next_page(99a21eb954beaf5a).( |
| 486 | /*=======================*/ |
| 487 | btr_pcur_tcxx . . $ btr_pcur_t#* cursor, /*!< in: persistent cursor; must be on the |
| 488 | last record of the current page */ |
| 489 | mtr_tcxx . . $ mtr_t#* mtr) /*!< in: mtr */ |
| 490 | { |
| 491 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(cursor->pos_state == BTR_PCUR_IS_POSITIONED); |
| 492 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(cursor->latch_mode != BTR_NO_LATCHES); |
| 493 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(btr_pcur_is_after_last_on_page(cursor)); |
| 494 | |
| 495 | cursor->old_reccxx . . $ btr_pcur_t#old_rec. = nullptr; |
| 496 | |
| 497 | const page_tcxx . . $ `storage/innobase/include/page0types.h:38:9`!* page = btr_pcur_get_pagecxx . . $ `storage/innobase/include/btr0pcur.h:216:9`!(cursor); |
| 498 | const uint32_tcxx . . $ uint32_t# next_page_no = btr_page_get_nextcxx . . $ btr_page_get_next(ca1608e2c87725e2).(page); |
| 499 | |
| 500 | switch (next_page_no) { |
| 501 | case 0: |
| 502 | case 1: |
| 503 | case FIL_NULLcxx . . $ `storage/innobase/include/fil0fil.h:1175:9`!: |
| 504 | return DB_CORRUPTIONcxx . . $ DB_CORRUPTION.; |
| 505 | } |
| 506 | |
| 507 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(next_page_no == btr_pcur_get_block(cursor) |
| 508 | ->page.id().page_no())) { |
| 509 | return DB_CORRUPTIONcxx . . $ DB_CORRUPTION.; |
| 510 | } |
| 511 | |
| 512 | dberr_tcxx . . $ dberr_t# err; |
| 513 | bool first_access = false; |
| 514 | buf_block_tcxx . . $ buf_block_t#* next_block = btr_block_getcxx . . $ btr_block_get(fa2ba45a54fcd0c4).( |
| 515 | *cursor->indexcxx . . $ btr_pcur_t#index(4ab6b9797a912635).(), next_page_no, |
| 516 | rw_lock_type_tcxx . . $ rw_lock_type_t#(cursor->latch_modecxx . . $ btr_pcur_t#latch_mode. & (RW_X_LATCHcxx . . $ RW_X_LATCH. | RW_S_LATCHcxx . . $ RW_S_LATCH.)), |
| 517 | mtr, &err, &first_access); |
| 518 | |
| 519 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(!next_block)) { |
| 520 | return err; |
| 521 | } |
| 522 | |
| 523 | const page_tcxx . . $ `storage/innobase/include/page0types.h:38:9`!* next_page = buf_block_get_framecxx . . $ `storage/innobase/include/buf0buf.h:385:9`!(next_block); |
| 524 | |
| 525 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(memcmp_aligned<4>(next_page + FIL_PAGE_PREVcxx . . $ `storage/innobase/include/fil0fil.h:1196:9`!, |
| 526 | page + FIL_PAGE_OFFSETcxx . . $ `storage/innobase/include/fil0fil.h:1195:9`!, 4))) { |
| 527 | return DB_CORRUPTIONcxx . . $ DB_CORRUPTION.; |
| 528 | } |
| 529 | |
| 530 | page_cur_set_before_firstcxx . . $ page_cur_set_before_first(34f1922d808032bb).(next_block, btr_pcur_get_page_curcxx . . $ `storage/innobase/include/btr0pcur.h:215:9`!(cursor)); |
| 531 | |
| 532 | ut_dcxx . . $ `storage/innobase/include/ut0dbg.h:68:9`!(page_check_dir(next_page)); |
| 533 | |
| 534 | const auto s = mtr->get_savepointcxx . . $ mtr_t#get_savepoint(fe4d2d262d4164a8).(); |
| 535 | mtr->rollback_to_savepointcxx . . $ mtr_t#rollback_to_savepoint(6714b5f2551eea49).(s - 2, s - 1); |
| 536 | if (first_access) { |
| 537 | buf_read_ahead_linearcxx . . $ buf_read_ahead_linear(3269ed12c418f19c).(next_block->pagecxx . . $ buf_block_t#page..idcxx . . $ buf_page_t#id(9d40bbb65128eac8).()); |
| 538 | } |
| 539 | return DB_SUCCESScxx . . $ DB_SUCCESS.; |
| 540 | } |
| 541 | |
| 542 | MY_ATTRIBUTEcxx . . $ `storage/innobase/include/univ.i:162:11`!((nonnull,warn_unused_result)) |
| 543 | /*********************************************************//** |
| 544 | Moves the persistent cursor backward if it is on the first record of the page. |
| 545 | Commits mtr. Note that to prevent a possible deadlock, the operation |
| 546 | first stores the position of the cursor, commits mtr, acquires the necessary |
| 547 | latches and restores the cursor position again before returning. The |
| 548 | alphabetical position of the cursor is guaranteed to be sensible on |
| 549 | return, but it may happen that the cursor is not positioned on the last |
| 550 | record of any page, because the structure of the tree may have changed |
| 551 | during the time when the cursor had no latches. */ |
| 552 | static |
| 553 | bool |
| 554 | btr_pcur_move_backward_from_pagecxx . . $ btr_pcur_move_backward_from_page(b502365d707569d7).( |
| 555 | /*=============================*/ |
| 556 | btr_pcur_tcxx . . $ btr_pcur_t#* cursor, /*!< in: persistent cursor, must be on the first |
| 557 | record of the current page */ |
| 558 | mtr_tcxx . . $ mtr_t#* mtr) /*!< in: mtr */ |
| 559 | { |
| 560 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(btr_pcur_is_before_first_on_page(cursor)); |
| 561 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!btr_pcur_is_before_first_in_tree(cursor)); |
| 562 | |
| 563 | btr_pcur_store_positioncxx . . $ btr_pcur_store_position(f723d369374bc0bf).(cursor, mtr); |
| 564 | |
| 565 | mtr_commitcxx . . $ `storage/innobase/include/mtr0mtr.h:38:9`!(mtr); |
| 566 | |
| 567 | mtr_startcxx . . $ `storage/innobase/include/mtr0mtr.h:35:9`!(mtr); |
| 568 | |
| 569 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(cursor->restore_position(BTR_SEARCH_PREV, mtr) |
| 570 | == btr_pcur_t::CORRUPTED)) { |
| 571 | return true; |
| 572 | } |
| 573 | |
| 574 | buf_block_tcxx . . $ buf_block_t#* block = mtr->at_savepointcxx . . $ mtr_t#at_savepoint(af74c280cb0dfd96).(0); |
| 575 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(block == btr_pcur_get_block(cursor)); |
| 576 | const page_tcxx . . $ `storage/innobase/include/page0types.h:38:9`!* const page = block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.; |
| 577 | /* btr_pcur_optimistic_latch_leaves() will acquire a latch on |
| 578 | the preceding page if one exists; |
| 579 | if that fails, btr_cur_t::search_leaf() invoked by |
| 580 | btr_pcur_open_with_no_init() will also acquire a latch on the |
| 581 | succeeding page. Our caller only needs one page latch. */ |
| 582 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mtr->get_savepoint() <= 3); |
| 583 | |
| 584 | if (page_has_prevcxx . . $ page_has_prev(190063cf6fb4afb1).(page)) { |
| 585 | buf_block_tcxx . . $ buf_block_t#* const left_block = mtr->at_savepointcxx . . $ mtr_t#at_savepoint(af74c280cb0dfd96).(1); |
| 586 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!memcmp_aligned<4>(page + FIL_PAGE_OFFSET, |
| 587 | left_block->page.frame |
| 588 | + FIL_PAGE_NEXT, 4)); |
| 589 | if (btr_pcur_is_before_first_on_pagecxx . . $ btr_pcur_is_before_first_on_page(c5e2b82e26308d5e).(cursor)) { |
| 590 | /* Reposition on the previous page. */ |
| 591 | page_cur_set_after_lastcxx . . $ page_cur_set_after_last(34f1922d808032bb).(left_block, |
| 592 | &cursor->btr_curcxx . . $ btr_pcur_t#btr_cur..page_curcxx . . $ btr_cur_t#page_cur.); |
| 593 | /* Release the right sibling. */ |
| 594 | mtr->rollback_to_savepointcxx . . $ mtr_t#rollback_to_savepoint(6714b5f2551eea49).(0, 1); |
| 595 | block = left_block; |
| 596 | } |
| 597 | } |
| 598 | |
| 599 | mtr->rollback_to_savepointcxx . . $ mtr_t#rollback_to_savepoint(2c44cd906ae4e829).(1); |
| 600 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(block == mtr->at_savepoint(0)); |
| 601 | cursor->latch_modecxx . . $ btr_pcur_t#latch_mode. = BTR_SEARCH_LEAFcxx . . $ BTR_SEARCH_LEAF.; |
| 602 | cursor->old_reccxx . . $ btr_pcur_t#old_rec. = nullptr; |
| 603 | return false; |
| 604 | } |
| 605 | |
| 606 | /*********************************************************//** |
| 607 | Moves the persistent cursor to the previous record in the tree. If no records |
| 608 | are left, the cursor stays 'before first in tree'. |
| 609 | @return TRUE if the cursor was not before first in tree */ |
| 610 | bool |
| 611 | btr_pcur_move_to_prevcxx . . $ btr_pcur_move_to_prev(b502365d707569d7).( |
| 612 | /*==================*/ |
| 613 | btr_pcur_tcxx . . $ btr_pcur_t#* cursor, /*!< in: persistent cursor; NOTE that the |
| 614 | function may release the page latch */ |
| 615 | mtr_tcxx . . $ mtr_t#* mtr) /*!< in: mtr */ |
| 616 | { |
| 617 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(cursor->pos_state == BTR_PCUR_IS_POSITIONED); |
| 618 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(cursor->latch_mode == BTR_SEARCH_LEAF); |
| 619 | |
| 620 | cursor->old_reccxx . . $ btr_pcur_t#old_rec. = nullptr; |
| 621 | |
| 622 | if (btr_pcur_is_before_first_on_pagecxx . . $ btr_pcur_is_before_first_on_page(c5e2b82e26308d5e).(cursor)) { |
| 623 | return (!btr_pcur_is_before_first_in_treecxx . . $ btr_pcur_is_before_first_in_tree(c531874abcfa91bf).(cursor) |
| 624 | && !btr_pcur_move_backward_from_pagecxx . . $ btr_pcur_move_backward_from_page(b502365d707569d7).(cursor, mtr)); |
| 625 | } |
| 626 | |
| 627 | return btr_pcur_move_to_prev_on_pagecxx . . $ btr_pcur_move_to_prev_on_page(6864a1bdc33d982).(cursor) != nullptr; |
| 628 | } |