| 1 | /***************************************************************************** |
| 2 | |
| 3 | Copyright (c) 1994, 2019, Oracle and/or its affiliates. All Rights Reserved. |
| 4 | Copyright (c) 2012, Facebook Inc. |
| 5 | Copyright (c) 2015, 2023, MariaDB Corporation. |
| 6 | |
| 7 | This program is free software; you can redistribute it and/or modify it under |
| 8 | the terms of the GNU General Public License as published by the Free Software |
| 9 | Foundation; version 2 of the License. |
| 10 | |
| 11 | This program is distributed in the hope that it will be useful, but WITHOUT |
| 12 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 13 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU General Public License along with |
| 16 | this program; if not, write to the Free Software Foundation, Inc., |
| 17 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA |
| 18 | |
| 19 | *****************************************************************************/ |
| 20 | |
| 21 | /**************************************************//** |
| 22 | @file btr/btr0cur.cc |
| 23 | The index tree cursor |
| 24 | |
| 25 | All changes that row operations make to a B-tree or the records |
| 26 | there must go through this module! Undo log records are written here |
| 27 | of every modify or insert of a clustered index record. |
| 28 | |
| 29 | NOTE!!! |
| 30 | To make sure we do not run out of disk space during a pessimistic |
| 31 | insert or update, we have to reserve 2 x the height of the index tree |
| 32 | many pages in the tablespace before we start the operation, because |
| 33 | if leaf splitting has been started, it is difficult to undo, except |
| 34 | by crashing the database and doing a roll-forward. |
| 35 | |
| 36 | Created 10/16/1994 Heikki Tuuri |
| 37 | *******************************************************/ |
| 38 | |
| 39 | #include "btr0cur.h"cxx . . $ `<file>/storage/innobase/include/btr0cur.h`/ |
| 40 | #include "row0upd.h"cxx . . $ `<file>/storage/innobase/include/row0upd.h`/ |
| 41 | #include "mtr0log.h"cxx . . $ `<file>/storage/innobase/include/mtr0log.h`/ |
| 42 | #include "page0page.h"cxx . . $ `<file>/storage/innobase/include/page0page.h`/ |
| 43 | #include "page0zip.h"cxx . . $ `<file>/storage/innobase/include/page0zip.h`/ |
| 44 | #include "rem0rec.h"cxx . . $ `<file>/storage/innobase/include/rem0rec.h`/ |
| 45 | #include "rem0cmp.h"cxx . . $ `<file>/storage/innobase/include/rem0cmp.h`/ |
| 46 | #include "buf0lru.h"cxx . . $ `<file>/storage/innobase/include/buf0lru.h`/ |
| 47 | #include "buf0rea.h"cxx . . $ `<file>/storage/innobase/include/buf0rea.h`/ |
| 48 | #include "btr0btr.h"cxx . . $ `<file>/storage/innobase/include/btr0btr.h`/ |
| 49 | #include "btr0sea.h"cxx . . $ `<file>/storage/innobase/include/btr0sea.h`/ |
| 50 | #include "row0log.h"cxx . . $ `<file>/storage/innobase/include/row0log.h`/ |
| 51 | #include "row0purge.h"cxx . . $ `<file>/storage/innobase/include/row0purge.h`/ |
| 52 | #include "row0upd.h"cxx . . $ `<file>/storage/innobase/include/row0upd.h`/ |
| 53 | #include "trx0rec.h"cxx . . $ `<file>/storage/innobase/include/trx0rec.h`/ |
| 54 | #include "trx0roll.h"cxx . . $ `<file>/storage/innobase/include/trx0roll.h`/ |
| 55 | #include "que0que.h"cxx . . $ `<file>/storage/innobase/include/que0que.h`/ |
| 56 | #include "row0row.h"cxx . . $ `<file>/storage/innobase/include/row0row.h`/ |
| 57 | #include "srv0srv.h"cxx . . $ `<file>/storage/innobase/include/srv0srv.h`/ |
| 58 | #include "lock0lock.h"cxx . . $ `<file>/storage/innobase/include/lock0lock.h`/ |
| 59 | #include "zlib.h" |
| 60 | #include "srv0start.h"cxx . . $ `<file>/storage/innobase/include/srv0start.h`/ |
| 61 | #include "mysql_com.h"cxx . . $ `<file>/include/mysql_com.h`/ |
| 62 | #include "dict0stats.h"cxx . . $ `<file>/storage/innobase/include/dict0stats.h`/ |
| 63 | #include "row0ins.h"cxx . . $ `<file>/storage/innobase/include/row0ins.h`/ |
| 64 | #ifdef WITH_WSREPcxx . . $ `/build/tmp.NxIY9EeyJN/package/build/include/my_config.h:539:9`! |
| 65 | #include "mysql/service_wsrep.h"cxx . . $ `<file>/include/mysql/service_wsrep.h`/ |
| 66 | #endif /* WITH_WSREP */ |
| 67 | #include "log.h"cxx . . $ `<file>/sql/log.h`/ |
| 68 | |
| 69 | /** Modification types for the B-tree operation. |
| 70 | Note that the order must be DELETE, BOTH, INSERT !! |
| 71 | */ |
| 72 | enum btr_intention_tcxx . . $ btr_intention_t# { |
| 73 | BTR_INTENTION_DELETEcxx . . $ BTR_INTENTION_DELETE., |
| 74 | BTR_INTENTION_BOTHcxx . . $ BTR_INTENTION_BOTH., |
| 75 | BTR_INTENTION_INSERTcxx . . $ BTR_INTENTION_INSERT. |
| 76 | }; |
| 77 | |
| 78 | /** For the index->lock scalability improvement, only possibility of clear |
| 79 | performance regression observed was caused by grown huge history list length. |
| 80 | That is because the exclusive use of index->lock also worked as reserving |
| 81 | free blocks and read IO bandwidth with priority. To avoid huge glowing history |
| 82 | list as same level with previous implementation, prioritizes pessimistic tree |
| 83 | operations by purge as the previous, when it seems to be growing huge. |
| 84 | |
| 85 | Experimentally, the history list length starts to affect to performance |
| 86 | throughput clearly from about 100000. */ |
| 87 | #define BTR_CUR_FINE_HISTORY_LENGTHcxx . . $ `storage/innobase/btr/btr0cur.cc:87:9`! 100000 |
| 88 | |
| 89 | #ifdef BTR_CUR_HASH_ADAPTcxx . . $ `<built-in>:481:9`! |
| 90 | /** Number of searches down the B-tree in btr_cur_t::search_leaf(). */ |
| 91 | ib_counter_tcxx . . $ ib_counter_t#<ulintcxx . . $ ulint#, ib_counter_element_t> btr_cur_n_non_seacxx . . $ btr_cur_n_non_sea.; |
| 92 | /** Old value of btr_cur_n_non_sea. Copied by |
| 93 | srv_refresh_innodb_monitor_stats(). Referenced by |
| 94 | srv_printf_innodb_monitor(). */ |
| 95 | ulintcxx . . $ ulint# btr_cur_n_non_sea_oldcxx . . $ btr_cur_n_non_sea_old.; |
| 96 | /** Number of successful adaptive hash index lookups in |
| 97 | btr_cur_t::search_leaf(). */ |
| 98 | ib_counter_tcxx . . $ ib_counter_t#<ulintcxx . . $ ulint#, ib_counter_element_t> btr_cur_n_seacxx . . $ btr_cur_n_sea.; |
| 99 | /** Old value of btr_cur_n_sea. Copied by |
| 100 | srv_refresh_innodb_monitor_stats(). Referenced by |
| 101 | srv_printf_innodb_monitor(). */ |
| 102 | ulintcxx . . $ ulint# btr_cur_n_sea_oldcxx . . $ btr_cur_n_sea_old.; |
| 103 | #endif /* BTR_CUR_HASH_ADAPT */ |
| 104 | |
| 105 | #ifdef UNIV_DEBUG |
| 106 | /* Flag to limit optimistic insert records */ |
| 107 | uint btr_cur_limit_optimistic_insert_debug; |
| 108 | #endif /* UNIV_DEBUG */ |
| 109 | |
| 110 | /** In the optimistic insert, if the insert does not fit, but this much space |
| 111 | can be released by page reorganize, then it is reorganized */ |
| 112 | #define BTR_CUR_PAGE_REORGANIZE_LIMITcxx . . $ `storage/innobase/btr/btr0cur.cc:112:9`! (srv_page_size / 32) |
| 113 | |
| 114 | /** The structure of a BLOB part header */ |
| 115 | /* @{ */ |
| 116 | /*--------------------------------------*/ |
| 117 | #define BTR_BLOB_HDR_PART_LENcxx . . $ `storage/innobase/btr/btr0cur.cc:117:9`! 0 /*!< BLOB part len on this |
| 118 | page */ |
| 119 | #define BTR_BLOB_HDR_NEXT_PAGE_NOcxx . . $ `storage/innobase/btr/btr0cur.cc:119:9`! 4 /*!< next BLOB part page no, |
| 120 | FIL_NULL if none */ |
| 121 | /*--------------------------------------*/ |
| 122 | #define BTR_BLOB_HDR_SIZEcxx . . $ `storage/innobase/btr/btr0cur.cc:122:9`! 8 /*!< Size of a BLOB |
| 123 | part header, in bytes */ |
| 124 | |
| 125 | /* @} */ |
| 126 | |
| 127 | /*******************************************************************//** |
| 128 | Marks all extern fields in a record as owned by the record. This function |
| 129 | should be called if the delete mark of a record is removed: a not delete |
| 130 | marked record always owns all its extern fields. */ |
| 131 | static |
| 132 | void |
| 133 | btr_cur_unmark_extern_fieldscxx . . $ btr_cur_unmark_extern_fields(2a7528bc66954456).( |
| 134 | /*=========================*/ |
| 135 | buf_block_tcxx . . $ buf_block_t#* block, /*!< in/out: index page */ |
| 136 | rec_tcxx . . $ rec_t#* rec, /*!< in/out: record in a clustered index */ |
| 137 | dict_index_tcxx . . $ dict_index_t#* index, /*!< in: index of the page */ |
| 138 | const rec_offscxx . . $ rec_offs#* offsets,/*!< in: array returned by rec_get_offsets() */ |
| 139 | mtr_tcxx . . $ mtr_t#* mtr); /*!< in: mtr, or NULL if not logged */ |
| 140 | /***********************************************************//** |
| 141 | Frees the externally stored fields for a record, if the field is mentioned |
| 142 | in the update vector. */ |
| 143 | static |
| 144 | void |
| 145 | btr_rec_free_updated_extern_fieldscxx . . $ btr_rec_free_updated_extern_fields(1e02f8a3eb9379da).( |
| 146 | /*===============================*/ |
| 147 | dict_index_tcxx . . $ dict_index_t#* index, /*!< in: index of rec; the index tree MUST be |
| 148 | X-latched */ |
| 149 | rec_tcxx . . $ rec_t#* rec, /*!< in: record */ |
| 150 | buf_block_tcxx . . $ buf_block_t#* block, /*!< in: index page of rec */ |
| 151 | const rec_offscxx . . $ rec_offs#* offsets,/*!< in: rec_get_offsets(rec, index) */ |
| 152 | const upd_tcxx . . $ upd_t#* update, /*!< in: update vector */ |
| 153 | bool rollback,/*!< in: performing rollback? */ |
| 154 | mtr_tcxx . . $ mtr_t#* mtr); /*!< in: mini-transaction handle which contains |
| 155 | an X-latch to record page and to the tree */ |
| 156 | /***********************************************************//** |
| 157 | Frees the externally stored fields for a record. */ |
| 158 | static |
| 159 | void |
| 160 | btr_rec_free_externally_stored_fieldscxx . . $ btr_rec_free_externally_stored_fields(e4c61c0bfa48221b).( |
| 161 | /*==================================*/ |
| 162 | dict_index_tcxx . . $ dict_index_t#* index, /*!< in: index of the data, the index |
| 163 | tree MUST be X-latched */ |
| 164 | rec_tcxx . . $ rec_t#* rec, /*!< in: record */ |
| 165 | const rec_offscxx . . $ rec_offs#* offsets,/*!< in: rec_get_offsets(rec, index) */ |
| 166 | buf_block_tcxx . . $ buf_block_t#* block, /*!< in: index page of rec */ |
| 167 | bool rollback,/*!< in: performing rollback? */ |
| 168 | mtr_tcxx . . $ mtr_t#* mtr); /*!< in: mini-transaction handle which contains |
| 169 | an X-latch to record page and to the index |
| 170 | tree */ |
| 171 | |
| 172 | /*==================== B-TREE SEARCH =========================*/ |
| 173 | |
| 174 | /** Load the instant ALTER TABLE metadata from the clustered index |
| 175 | when loading a table definition. |
| 176 | @param[in,out] index clustered index definition |
| 177 | @param[in,out] mtr mini-transaction |
| 178 | @return error code |
| 179 | @retval DB_SUCCESS if no error occurred |
| 180 | @retval DB_CORRUPTION if any corruption was noticed */ |
| 181 | static dberr_tcxx . . $ dberr_t# btr_cur_instant_init_lowcxx . . $ btr_cur_instant_init_low(fff474d1ceee93e7).(dict_index_tcxx . . $ dict_index_t#* index, mtr_tcxx . . $ mtr_t#* mtr) |
| 182 | { |
| 183 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(index->is_primary()); |
| 184 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(index->table->is_readable()); |
| 185 | |
| 186 | if (!index->tablecxx . . $ dict_index_t#table.->supports_instantcxx . . $ dict_table_t#supports_instant(50ce9a9e25b4a850).()) { |
| 187 | return DB_SUCCESScxx . . $ DB_SUCCESS.; |
| 188 | } |
| 189 | |
| 190 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(index->n_core_null_bytes == dict_index_t::NO_CORE_NULL_BYTES); |
| 191 | |
| 192 | dberr_tcxx . . $ dberr_t# err; |
| 193 | const fil_space_tcxx . . $ fil_space_t#* space = index->tablecxx . . $ dict_index_t#table.->spacecxx . . $ dict_table_t#space.; |
| 194 | if (!space) { |
| 195 | corrupted: |
| 196 | err = DB_CORRUPTIONcxx . . $ DB_CORRUPTION.; |
| 197 | unreadable: |
| 198 | ibcxx . . $ ib/::errorcxx . . $ ib/error#() <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). "Table " <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). index->tablecxx . . $ dict_index_t#table.->namecxx . . $ dict_table_t#name. |
| 199 | <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). " has an unreadable root page"; |
| 200 | index->tablecxx . . $ dict_index_t#table.->corruptedcxx . . $ dict_table_t#corrupted. = true; |
| 201 | index->tablecxx . . $ dict_index_t#table.->file_unreadablecxx . . $ dict_table_t#file_unreadable. = true; |
| 202 | return err; |
| 203 | } |
| 204 | |
| 205 | buf_block_tcxx . . $ buf_block_t#* root = btr_root_block_getcxx . . $ btr_root_block_get(4bcbd40788d58e0a).(index, RW_SX_LATCHcxx . . $ RW_SX_LATCH., mtr, &err); |
| 206 | if (!root) { |
| 207 | goto unreadable; |
| 208 | } |
| 209 | |
| 210 | if (btr_cur_instant_root_initcxx . . $ btr_cur_instant_root_init(7e226d7d2ee27c41).(index, root->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.)) { |
| 211 | goto corrupted; |
| 212 | } |
| 213 | |
| 214 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(index->n_core_null_bytes != dict_index_t::NO_CORE_NULL_BYTES); |
| 215 | |
| 216 | if (fil_page_get_typecxx . . $ fil_page_get_type(422f7ec86fa2a2fb).(root->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.) == FIL_PAGE_INDEXcxx . . $ FIL_PAGE_INDEX.) { |
| 217 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!index->is_instant()); |
| 218 | return DB_SUCCESScxx . . $ DB_SUCCESS.; |
| 219 | } |
| 220 | |
| 221 | btr_cur_tcxx . . $ btr_cur_t# curcxx . . $ btr_cur_t#btr_cur_t(49f6e7a06ebc5aa8).; |
| 222 | /* Relax the assertion in rec_init_offsets(). */ |
| 223 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!index->in_instant_init); |
| 224 | ut_dcxx . . $ `storage/innobase/include/ut0dbg.h:68:9`!(index->in_instant_init = true); |
| 225 | err = cur.open_leafcxx . . $ btr_cur_t#open_leaf(1d074ecb69eae3b8).(true, index, BTR_SEARCH_LEAFcxx . . $ BTR_SEARCH_LEAF., mtr); |
| 226 | ut_dcxx . . $ `storage/innobase/include/ut0dbg.h:68:9`!(index->in_instant_init = false); |
| 227 | if (err != DB_SUCCESScxx . . $ DB_SUCCESS.) { |
| 228 | index->tablecxx . . $ dict_index_t#table.->file_unreadablecxx . . $ dict_table_t#file_unreadable. = true; |
| 229 | index->tablecxx . . $ dict_index_t#table.->corruptedcxx . . $ dict_table_t#corrupted. = true; |
| 230 | return err; |
| 231 | } |
| 232 | |
| 233 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(page_cur_is_before_first(&cur.page_cur)); |
| 234 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(page_is_leaf(btr_cur_get_page(&cur))); |
| 235 | |
| 236 | const rec_tcxx . . $ rec_t#* rec = page_cur_move_to_nextcxx . . $ page_cur_move_to_next(99e08e4d4839908).(&cur.page_curcxx . . $ btr_cur_t#page_cur.); |
| 237 | const ulintcxx . . $ ulint# comp = dict_table_is_compcxx . . $ `storage/innobase/include/dict0dict.h:776:9`!(index->table); |
| 238 | const ulintcxx . . $ ulint# info_bits = rec ? rec_get_info_bitscxx . . $ rec_get_info_bits(24af2a219f1a922e).(rec, comp) : 0; |
| 239 | |
| 240 | if (page_rec_is_supremumcxx . . $ page_rec_is_supremum(190063cf6fb4afb1).(rec) |
| 241 | || !(info_bits & REC_INFO_MIN_REC_FLAGcxx . . $ `storage/innobase/include/data0type.h:504:9`!)) { |
| 242 | if (rec && !index->is_instantcxx . . $ dict_index_t#is_instant(50ce9a9e25b4a850).()) { |
| 243 | /* The FIL_PAGE_TYPE_INSTANT and PAGE_INSTANT may be |
| 244 | assigned even if instant ADD COLUMN was not |
| 245 | committed. Changes to these page header fields are not |
| 246 | undo-logged, but changes to the hidden metadata record |
| 247 | are. If the server is killed and restarted, the page |
| 248 | header fields could remain set even though no metadata |
| 249 | record is present. */ |
| 250 | return DB_SUCCESScxx . . $ DB_SUCCESS.; |
| 251 | } |
| 252 | |
| 253 | ibcxx . . $ ib/::errorcxx . . $ ib/error#() <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). "Table " <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). index->tablecxx . . $ dict_index_t#table.->namecxx . . $ dict_table_t#name. |
| 254 | <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). " is missing instant ALTER metadata"; |
| 255 | index->tablecxx . . $ dict_index_t#table.->corruptedcxx . . $ dict_table_t#corrupted. = true; |
| 256 | return DB_CORRUPTIONcxx . . $ DB_CORRUPTION.; |
| 257 | } |
| 258 | |
| 259 | if ((info_bits & ~REC_INFO_DELETED_FLAGcxx . . $ `storage/innobase/include/data0type.h:506:9`!) != REC_INFO_MIN_REC_FLAGcxx . . $ `storage/innobase/include/data0type.h:504:9`! |
| 260 | || (comp && rec_get_statuscxx . . $ rec_get_status(f593bf8bf3023f2).(rec) != REC_STATUS_INSTANTcxx . . $ REC_STATUS_INSTANT.)) { |
| 261 | incompatible: |
| 262 | ibcxx . . $ ib/::errorcxx . . $ ib/error#() <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). "Table " <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). index->tablecxx . . $ dict_index_t#table.->namecxx . . $ dict_table_t#name. |
| 263 | <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). " contains unrecognizable instant ALTER metadata"; |
| 264 | index->tablecxx . . $ dict_index_t#table.->corruptedcxx . . $ dict_table_t#corrupted. = true; |
| 265 | return DB_CORRUPTIONcxx . . $ DB_CORRUPTION.; |
| 266 | } |
| 267 | |
| 268 | /* Read the metadata. We can get here on server restart |
| 269 | or when the table was evicted from the data dictionary cache |
| 270 | and is now being accessed again. |
| 271 | |
| 272 | Here, READ COMMITTED and REPEATABLE READ should be equivalent. |
| 273 | Committing the ADD COLUMN operation would acquire |
| 274 | MDL_EXCLUSIVE and LOCK_X|LOCK_TABLE, which would prevent any |
| 275 | concurrent operations on the table, including table eviction |
| 276 | from the cache. */ |
| 277 | |
| 278 | if (info_bits & REC_INFO_DELETED_FLAGcxx . . $ `storage/innobase/include/data0type.h:506:9`!) { |
| 279 | /* This metadata record includes a BLOB that identifies |
| 280 | any dropped or reordered columns. */ |
| 281 | ulintcxx . . $ ulint# trx_id_offset = index->trx_id_offsetcxx . . $ dict_index_t#trx_id_offset.; |
| 282 | /* If !index->trx_id_offset, the PRIMARY KEY contains |
| 283 | variable-length columns. For the metadata record, |
| 284 | variable-length columns should be written with zero |
| 285 | length. However, before MDEV-21088 was fixed, for |
| 286 | variable-length encoded PRIMARY KEY column of type |
| 287 | CHAR, we wrote more than zero bytes. That is why we |
| 288 | must determine the actual length of each PRIMARY KEY |
| 289 | column. The DB_TRX_ID will start right after any |
| 290 | PRIMARY KEY columns. */ |
| 291 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(index->n_uniq); |
| 292 | |
| 293 | /* We cannot invoke rec_get_offsets() before |
| 294 | index->table->deserialise_columns(). Therefore, |
| 295 | we must duplicate some logic here. */ |
| 296 | if (trx_id_offset) { |
| 297 | } else if (index->tablecxx . . $ dict_index_t#table.->not_redundantcxx . . $ dict_table_t#not_redundant(50ce9a9e25b4a850).()) { |
| 298 | /* The PRIMARY KEY contains variable-length columns. |
| 299 | For the metadata record, variable-length columns are |
| 300 | always written with zero length. The DB_TRX_ID will |
| 301 | start right after any fixed-length columns. */ |
| 302 | |
| 303 | /* OK, before MDEV-21088 was fixed, for |
| 304 | variable-length encoded PRIMARY KEY column of |
| 305 | type CHAR, we wrote more than zero bytes. In |
| 306 | order to allow affected tables to be accessed, |
| 307 | it would be nice to determine the actual |
| 308 | length of each PRIMARY KEY column. However, to |
| 309 | be able to do that, we should determine the |
| 310 | size of the null-bit bitmap in the metadata |
| 311 | record. And we cannot know that before reading |
| 312 | the metadata BLOB, whose starting point we are |
| 313 | trying to find here. (Although the PRIMARY KEY |
| 314 | columns cannot be NULL, we would have to know |
| 315 | where the lengths of variable-length PRIMARY KEY |
| 316 | columns start.) |
| 317 | |
| 318 | So, unfortunately we cannot help users who |
| 319 | were affected by MDEV-21088 on a ROW_FORMAT=COMPACT |
| 320 | or ROW_FORMAT=DYNAMIC table. */ |
| 321 | |
| 322 | for (uint i = index->n_uniqcxx . . $ dict_index_t#n_uniq.; i--; ) { |
| 323 | trx_id_offset += index->fieldscxx . . $ dict_index_t#fields.[i].fixed_lencxx . . $ dict_field_t#fixed_len.; |
| 324 | } |
| 325 | } else if (rec_get_1byte_offs_flagcxx . . $ rec_get_1byte_offs_flag(b191ace3c5bffbd9).(rec)) { |
| 326 | trx_id_offset = rec_1_get_field_end_infocxx . . $ rec_1_get_field_end_info(24af2a219f1a922e).( |
| 327 | rec, index->n_uniqcxx . . $ dict_index_t#n_uniq. - 1); |
| 328 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!(trx_id_offset & REC_1BYTE_SQL_NULL_MASK)); |
| 329 | trx_id_offset &= ~REC_1BYTE_SQL_NULL_MASKcxx . . $ REC_1BYTE_SQL_NULL_MASK.; |
| 330 | } else { |
| 331 | trx_id_offset = rec_2_get_field_end_infocxx . . $ rec_2_get_field_end_info(cbdda48327e67104).( |
| 332 | rec, index->n_uniqcxx . . $ dict_index_t#n_uniq. - 1); |
| 333 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!(trx_id_offset & REC_2BYTE_SQL_NULL_MASK)); |
| 334 | trx_id_offset &= ~REC_2BYTE_SQL_NULL_MASKcxx . . $ REC_2BYTE_SQL_NULL_MASK.; |
| 335 | } |
| 336 | |
| 337 | const bytecxx . . $ byte#* ptr = rec + trx_id_offset |
| 338 | + (DATA_TRX_ID_LENcxx . . $ `storage/innobase/include/data0type.h:156:9`! + DATA_ROLL_PTR_LENcxx . . $ `storage/innobase/include/data0type.h:159:9`!); |
| 339 | |
| 340 | if (mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(ptr + BTR_EXTERN_LENcxx . . $ `storage/innobase/include/btr0cur.h:797:9`!)) { |
| 341 | goto incompatible; |
| 342 | } |
| 343 | |
| 344 | uint len = mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(ptr + BTR_EXTERN_LENcxx . . $ `storage/innobase/include/btr0cur.h:797:9`! + 4); |
| 345 | if (!len |
| 346 | || mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(ptr + BTR_EXTERN_OFFSETcxx . . $ `storage/innobase/include/btr0cur.h:795:9`!) |
| 347 | != FIL_PAGE_DATAcxx . . $ `storage/innobase/include/fil0fil.h:1249:9`! |
| 348 | || mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(ptr + BTR_EXTERN_SPACE_IDcxx . . $ `storage/innobase/include/btr0cur.h:793:9`!) |
| 349 | != space->idcxx . . $ fil_space_t#id.) { |
| 350 | goto incompatible; |
| 351 | } |
| 352 | |
| 353 | buf_block_tcxx . . $ buf_block_t#* block = buf_page_getcxx . . $ `storage/innobase/include/buf0buf.h:149:10`!( |
| 354 | page_id_t(space->id, |
| 355 | mach_read_from_4(ptr + BTR_EXTERN_PAGE_NOcxx . . $ `storage/innobase/include/btr0cur.h:794:9`!)), |
| 356 | 0, RW_S_LATCH, mtr); |
| 357 | if (!block) { |
| 358 | goto incompatible; |
| 359 | } |
| 360 | |
| 361 | btr_search_drop_page_hash_indexcxx . . $ btr_search_drop_page_hash_index(33307f3566ecc1a8).(block, index); |
| 362 | |
| 363 | if (fil_page_get_typecxx . . $ fil_page_get_type(422f7ec86fa2a2fb).(block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.) != FIL_PAGE_TYPE_BLOBcxx . . $ FIL_PAGE_TYPE_BLOB. |
| 364 | || mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(&block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame. |
| 365 | [FIL_PAGE_DATAcxx . . $ `storage/innobase/include/fil0fil.h:1249:9`! |
| 366 | + BTR_BLOB_HDR_NEXT_PAGE_NOcxx . . $ `storage/innobase/btr/btr0cur.cc:119:9`!]) |
| 367 | != FIL_NULLcxx . . $ `storage/innobase/include/fil0fil.h:1175:9`! |
| 368 | || mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(&block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame. |
| 369 | [FIL_PAGE_DATAcxx . . $ `storage/innobase/include/fil0fil.h:1249:9`! |
| 370 | + BTR_BLOB_HDR_PART_LENcxx . . $ `storage/innobase/btr/btr0cur.cc:117:9`!]) |
| 371 | != len) { |
| 372 | goto incompatible; |
| 373 | } |
| 374 | |
| 375 | /* The unused part of the BLOB page should be zero-filled. */ |
| 376 | for (const bytecxx . . $ byte#* b = block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame. |
| 377 | + (FIL_PAGE_DATAcxx . . $ `storage/innobase/include/fil0fil.h:1249:9`! + BTR_BLOB_HDR_SIZEcxx . . $ `storage/innobase/btr/btr0cur.cc:122:9`!) + len, |
| 378 | * const end = block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame. + srv_page_sizecxx . . $ srv_page_size. |
| 379 | - BTR_EXTERN_LENcxx . . $ `storage/innobase/include/btr0cur.h:797:9`!; |
| 380 | b < end; ) { |
| 381 | if (*b++) { |
| 382 | goto incompatible; |
| 383 | } |
| 384 | } |
| 385 | |
| 386 | if (index->tablecxx . . $ dict_index_t#table.->deserialise_columnscxx . . $ dict_table_t#deserialise_columns(3a706fe4966174d9).( |
| 387 | &block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame. |
| 388 | [FIL_PAGE_DATAcxx . . $ `storage/innobase/include/fil0fil.h:1249:9`! + BTR_BLOB_HDR_SIZEcxx . . $ `storage/innobase/btr/btr0cur.cc:122:9`!], len)) { |
| 389 | goto incompatible; |
| 390 | } |
| 391 | |
| 392 | /* Proceed to initialize the default values of |
| 393 | any instantly added columns. */ |
| 394 | } |
| 395 | |
| 396 | mem_heap_tcxx . . $ mem_heap_t#* heap = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 397 | rec_offscxx . . $ rec_offs#* offsets = rec_get_offsetscxx . . $ `storage/innobase/include/rem0rec.h:475:10`!(rec, index, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, |
| 398 | index->n_core_fields, |
| 399 | ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!, &heap); |
| 400 | if (rec_offs_any_defaultcxx . . $ rec_offs_any_default(6fce5c29061b60f9).(offsets)) { |
| 401 | inconsistent: |
| 402 | mem_heap_freecxx . . $ mem_heap_free(5231cf397463bfab).(heap); |
| 403 | goto incompatible; |
| 404 | } |
| 405 | |
| 406 | /* In fact, because we only ever append fields to the metadata |
| 407 | record, it is also OK to perform READ UNCOMMITTED and |
| 408 | then ignore any extra fields, provided that |
| 409 | trx_sys.is_registered(DB_TRX_ID). */ |
| 410 | if (rec_offs_n_fieldscxx . . $ rec_offs_n_fields(6fce5c29061b60f9).(offsets) |
| 411 | > ulintcxx . . $ ulint#(index->n_fieldscxx . . $ dict_index_t#n_fields.) + !!index->tablecxx . . $ dict_index_t#table.->instantcxx . . $ dict_table_t#instant. |
| 412 | && !trx_syscxx . . $ trx_sys..is_registeredcxx . . $ trx_sys_t#is_registered(f362c00213891b66).(current_trxcxx . . $ current_trx(7b66df4b3acf80bb).(), |
| 413 | row_get_rec_trx_idcxx . . $ row_get_rec_trx_id(e491d669e75572c9).(rec, index, |
| 414 | offsets))) { |
| 415 | goto inconsistent; |
| 416 | } |
| 417 | |
| 418 | for (unsigned i = index->n_core_fieldscxx . . $ dict_index_t#n_core_fields.; i < index->n_fieldscxx . . $ dict_index_t#n_fields.; i++) { |
| 419 | dict_col_tcxx . . $ dict_col_t#* col = index->fieldscxx . . $ dict_index_t#fields.[i].colcxx . . $ dict_field_t#col.; |
| 420 | const unsigned o = i + !!index->tablecxx . . $ dict_index_t#table.->instantcxx . . $ dict_table_t#instant.; |
| 421 | ulintcxx . . $ ulint# len; |
| 422 | const bytecxx . . $ byte#* data = rec_get_nth_fieldcxx . . $ `storage/innobase/include/rem0rec.h:562:9`!(rec, offsets, o, &len); |
| 423 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!col->is_added()); |
| 424 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!col->def_val.data); |
| 425 | col->def_valcxx . . $ dict_col_t#def_val..lencxx . . $ dict_col_t#def_t#len. = len; |
| 426 | switch (len) { |
| 427 | case UNIV_SQL_NULLcxx . . $ `storage/innobase/include/univ.i:372:9`!: |
| 428 | continue; |
| 429 | case 0: |
| 430 | col->def_valcxx . . $ dict_col_t#def_val..datacxx . . $ dict_col_t#def_t#data. = field_ref_zerocxx . . $ field_ref_zero.; |
| 431 | continue; |
| 432 | } |
| 433 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(len != UNIV_SQL_DEFAULT); |
| 434 | if (!rec_offs_nth_externcxx . . $ rec_offs_nth_extern(878e7dc5509530f1).(offsets, o)) { |
| 435 | col->def_valcxx . . $ dict_col_t#def_val..datacxx . . $ dict_col_t#def_t#data. = mem_heap_dupcxx . . $ mem_heap_dup(4a4c334168a9388d).( |
| 436 | index->tablecxx . . $ dict_index_t#table.->heapcxx . . $ dict_table_t#heap., data, len); |
| 437 | } else if (len < BTR_EXTERN_FIELD_REF_SIZEcxx . . $ `storage/innobase/include/btr0types.h:41:9`! |
| 438 | || !memcmp(data + len - BTR_EXTERN_FIELD_REF_SIZEcxx . . $ `storage/innobase/include/btr0types.h:41:9`!, |
| 439 | field_ref_zerocxx . . $ field_ref_zero., |
| 440 | BTR_EXTERN_FIELD_REF_SIZEcxx . . $ `storage/innobase/include/btr0types.h:41:9`!)) { |
| 441 | col->def_valcxx . . $ dict_col_t#def_val..lencxx . . $ dict_col_t#def_t#len. = UNIV_SQL_DEFAULTcxx . . $ `storage/innobase/include/data0type.h:31:9`!; |
| 442 | goto inconsistent; |
| 443 | } else { |
| 444 | col->def_valcxx . . $ dict_col_t#def_val..datacxx . . $ dict_col_t#def_t#data. = btr_copy_externally_stored_fieldcxx . . $ btr_copy_externally_stored_field(c9f32e0dbefa3c3f).( |
| 445 | &col->def_valcxx . . $ dict_col_t#def_val..lencxx . . $ dict_col_t#def_t#len., data, |
| 446 | cur.page_curcxx . . $ btr_cur_t#page_cur..blockcxx . . $ page_cur_t#block.->zip_sizecxx . . $ buf_block_t#zip_size(c9b1e749b64d5edc).(), |
| 447 | len, index->tablecxx . . $ dict_index_t#table.->heapcxx . . $ dict_table_t#heap.); |
| 448 | } |
| 449 | } |
| 450 | |
| 451 | mem_heap_freecxx . . $ mem_heap_free(5231cf397463bfab).(heap); |
| 452 | return DB_SUCCESScxx . . $ DB_SUCCESS.; |
| 453 | } |
| 454 | |
| 455 | /** Load the instant ALTER TABLE metadata from the clustered index |
| 456 | when loading a table definition. |
| 457 | @param[in,out] mtr mini-transaction |
| 458 | @param[in,out] table table definition from the data dictionary |
| 459 | @return error code |
| 460 | @retval DB_SUCCESS if no error occurred */ |
| 461 | dberr_tcxx . . $ dberr_t# btr_cur_instant_initcxx . . $ btr_cur_instant_init(2e0c606a2d65a22a).(mtr_tcxx . . $ mtr_t# *mtr, dict_table_tcxx . . $ dict_table_t# *table) |
| 462 | { |
| 463 | dict_index_tcxx . . $ dict_index_t# *index= dict_table_get_first_indexcxx . . $ `storage/innobase/include/dict0dict.h:612:10`!(table); |
| 464 | mtr->startcxx . . $ mtr_t#start(49f6e7a06ebc5aa8).(); |
| 465 | dberr_tcxx . . $ dberr_t# err= index ? btr_cur_instant_init_lowcxx . . $ btr_cur_instant_init_low(fff474d1ceee93e7).(index, mtr) : DB_CORRUPTIONcxx . . $ DB_CORRUPTION.; |
| 466 | mtr->commitcxx . . $ mtr_t#commit(49f6e7a06ebc5aa8).(); |
| 467 | if (err == DB_SUCCESScxx . . $ DB_SUCCESS. && index->is_gen_clustcxx . . $ dict_index_t#is_gen_clust(50ce9a9e25b4a850).()) |
| 468 | { |
| 469 | btr_cur_tcxx . . $ btr_cur_t# curcxx . . $ btr_cur_t#btr_cur_t(49f6e7a06ebc5aa8).; |
| 470 | mtr->startcxx . . $ mtr_t#start(49f6e7a06ebc5aa8).(); |
| 471 | err= cur.open_leafcxx . . $ btr_cur_t#open_leaf(1d074ecb69eae3b8).(false, index, BTR_SEARCH_LEAFcxx . . $ BTR_SEARCH_LEAF., mtr); |
| 472 | if (err != DB_SUCCESScxx . . $ DB_SUCCESS.); |
| 473 | else if (const rec_tcxx . . $ rec_t# *rec= page_rec_get_prevcxx . . $ page_rec_get_prev(adcd832f8377c3d8).(btr_cur_get_reccxx . . $ `storage/innobase/include/btr0cur.h:64:9`!(&cur))) |
| 474 | if (page_rec_is_user_reccxx . . $ page_rec_is_user_rec(190063cf6fb4afb1).(rec)) |
| 475 | table->row_idcxx . . $ dict_table_t#row_id.=cxx . . $ Atomic_counter#`operator=`(ada6a8422704cf8a). mach_read_from_6cxx . . $ mach_read_from_6(b191ace3c5bffbd9).(rec); |
| 476 | mtr->commitcxx . . $ mtr_t#commit(49f6e7a06ebc5aa8).(); |
| 477 | } |
| 478 | return err; |
| 479 | } |
| 480 | |
| 481 | /** Initialize the n_core_null_bytes on first access to a clustered |
| 482 | index root page. |
| 483 | @param[in] index clustered index that is on its first access |
| 484 | @param[in] page clustered index root page |
| 485 | @return whether the page is corrupted */ |
| 486 | bool btr_cur_instant_root_initcxx . . $ btr_cur_instant_root_init(7e226d7d2ee27c41).(dict_index_tcxx . . $ dict_index_t#* index, const page_tcxx . . $ `storage/innobase/include/page0types.h:38:9`!* page) |
| 487 | { |
| 488 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!index->is_dummy); |
| 489 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(index->is_primary()); |
| 490 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!index->is_instant()); |
| 491 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(index->table->supports_instant()); |
| 492 | |
| 493 | if (page_has_siblingscxx . . $ page_has_siblings(190063cf6fb4afb1).(page)) { |
| 494 | return true; |
| 495 | } |
| 496 | |
| 497 | /* This is normally executed as part of btr_cur_instant_init() |
| 498 | when dict_load_table_one() is loading a table definition. |
| 499 | Other threads should not access or modify the n_core_null_bytes, |
| 500 | n_core_fields before dict_load_table_one() returns. |
| 501 | |
| 502 | This can also be executed during IMPORT TABLESPACE, where the |
| 503 | table definition is exclusively locked. */ |
| 504 | |
| 505 | switch (fil_page_get_typecxx . . $ fil_page_get_type(422f7ec86fa2a2fb).(page)) { |
| 506 | default: |
| 507 | return true; |
| 508 | case FIL_PAGE_INDEXcxx . . $ FIL_PAGE_INDEX.: |
| 509 | /* The field PAGE_INSTANT is guaranteed 0 on clustered |
| 510 | index root pages of ROW_FORMAT=COMPACT or |
| 511 | ROW_FORMAT=DYNAMIC when instant ADD COLUMN is not used. */ |
| 512 | if (page_is_compcxx . . $ page_is_comp(f3688bc2ee54ea05).(page) && page_get_instantcxx . . $ page_get_instant(469dcb4e54b221a8).(page)) { |
| 513 | return true; |
| 514 | } |
| 515 | index->n_core_null_bytescxx . . $ dict_index_t#n_core_null_bytes. = static_cast<uint8_tcxx . . $ uint8_t#>( |
| 516 | UT_BITS_IN_BYTEScxx . . $ `storage/innobase/include/ut0ut.h:93:9`!(unsigned(index->n_nullable))); |
| 517 | return false; |
| 518 | case FIL_PAGE_TYPE_INSTANTcxx . . $ FIL_PAGE_TYPE_INSTANT.: |
| 519 | break; |
| 520 | } |
| 521 | |
| 522 | const uint16_tcxx . . $ uint16_t# n = page_get_instantcxx . . $ page_get_instant(469dcb4e54b221a8).(page); |
| 523 | |
| 524 | if (n < index->n_uniqcxx . . $ dict_index_t#n_uniq. + DATA_ROLL_PTRcxx . . $ `storage/innobase/include/data0type.h:158:9`!) { |
| 525 | /* The PRIMARY KEY (or hidden DB_ROW_ID) and |
| 526 | DB_TRX_ID,DB_ROLL_PTR columns must always be present |
| 527 | as 'core' fields. */ |
| 528 | return true; |
| 529 | } |
| 530 | |
| 531 | if (n > REC_MAX_N_FIELDScxx . . $ `storage/innobase/include/rem0types.h:37:9`!) { |
| 532 | return true; |
| 533 | } |
| 534 | |
| 535 | index->n_core_fieldscxx . . $ dict_index_t#n_core_fields. = n & dict_index_tcxx . . $ dict_index_t#::MAX_N_FIELDScxx . . $ dict_index_t#MAX_N_FIELDS.; |
| 536 | |
| 537 | const rec_tcxx . . $ rec_t#* infimum = page_get_infimum_reccxx . . $ `storage/innobase/include/page0page.h:531:9`!(page); |
| 538 | const rec_tcxx . . $ rec_t#* supremum = page_get_supremum_reccxx . . $ `storage/innobase/include/page0page.h:532:9`!(page); |
| 539 | |
| 540 | if (!memcmp(infimum, "infimum", 8) |
| 541 | && !memcmp(supremum, "supremum", 8)) { |
| 542 | if (n > index->n_fieldscxx . . $ dict_index_t#n_fields.) { |
| 543 | /* All fields, including those for instantly |
| 544 | added columns, must be present in the |
| 545 | data dictionary. */ |
| 546 | return true; |
| 547 | } |
| 548 | |
| 549 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!index->is_dummy); |
| 550 | ut_dcxx . . $ `storage/innobase/include/ut0dbg.h:68:9`!(index->is_dummy = true); |
| 551 | index->n_core_null_bytescxx . . $ dict_index_t#n_core_null_bytes. = static_cast<uint8_tcxx . . $ uint8_t#>( |
| 552 | UT_BITS_IN_BYTEScxx . . $ `storage/innobase/include/ut0ut.h:93:9`!(index->get_n_nullable(n))); |
| 553 | ut_dcxx . . $ `storage/innobase/include/ut0dbg.h:68:9`!(index->is_dummy = false); |
| 554 | return false; |
| 555 | } |
| 556 | |
| 557 | if (memcmp(infimum, field_ref_zerocxx . . $ field_ref_zero., 8) |
| 558 | || memcmp(supremum, field_ref_zerocxx . . $ field_ref_zero., 7)) { |
| 559 | /* The infimum and supremum records must either contain |
| 560 | the original strings, or they must be filled with zero |
| 561 | bytes, except for the bytes that we have repurposed. */ |
| 562 | return true; |
| 563 | } |
| 564 | |
| 565 | index->n_core_null_bytescxx . . $ dict_index_t#n_core_null_bytes. = supremum[7]; |
| 566 | return index->n_core_null_bytescxx . . $ dict_index_t#n_core_null_bytes. > 128; |
| 567 | } |
| 568 | |
| 569 | /** |
| 570 | Gets intention in btr_intention_t from latch_mode, and cleares the intention |
| 571 | at the latch_mode. |
| 572 | @param latch_mode in/out: pointer to latch_mode |
| 573 | @return intention for latching tree */ |
| 574 | static |
| 575 | btr_intention_tcxx . . $ btr_intention_t# btr_cur_get_and_clear_intentioncxx . . $ btr_cur_get_and_clear_intention(7c930369ca6c389e).(btr_latch_modecxx . . $ btr_latch_mode# *latch_mode) |
| 576 | { |
| 577 | btr_intention_tcxx . . $ btr_intention_t# intention; |
| 578 | |
| 579 | switch (*latch_mode & (BTR_LATCH_FOR_INSERTcxx . . $ BTR_LATCH_FOR_INSERT. | BTR_LATCH_FOR_DELETEcxx . . $ BTR_LATCH_FOR_DELETE.)) { |
| 580 | case BTR_LATCH_FOR_INSERTcxx . . $ BTR_LATCH_FOR_INSERT.: |
| 581 | intention = BTR_INTENTION_INSERTcxx . . $ BTR_INTENTION_INSERT.; |
| 582 | break; |
| 583 | case BTR_LATCH_FOR_DELETEcxx . . $ BTR_LATCH_FOR_DELETE.: |
| 584 | intention = BTR_INTENTION_DELETEcxx . . $ BTR_INTENTION_DELETE.; |
| 585 | break; |
| 586 | default: |
| 587 | /* both or unknown */ |
| 588 | intention = BTR_INTENTION_BOTHcxx . . $ BTR_INTENTION_BOTH.; |
| 589 | } |
| 590 | *latch_mode = btr_latch_modecxx . . $ btr_latch_mode#( |
| 591 | *latch_mode & ~(BTR_LATCH_FOR_INSERTcxx . . $ BTR_LATCH_FOR_INSERT. | BTR_LATCH_FOR_DELETEcxx . . $ BTR_LATCH_FOR_DELETE.)); |
| 592 | |
| 593 | return(intention); |
| 594 | } |
| 595 | |
| 596 | /** @return whether the distance between two records is at most the |
| 597 | specified value */ |
| 598 | template<bool comp> |
| 599 | static bool |
| 600 | page_rec_distance_is_at_mostcxx . . $ page_rec_distance_is_at_most(9f5ff192e1e8b219).(const page_tcxx . . $ `storage/innobase/include/page0types.h:38:9`! *page, const rec_tcxx . . $ rec_t# *left, |
| 601 | const rec_tcxx . . $ rec_t# *right, ulintcxx . . $ ulint# val) |
| 602 | noexcept |
| 603 | { |
| 604 | do |
| 605 | { |
| 606 | if (left == right) |
| 607 | return true; |
| 608 | left= page_rec_next_getcxx . . $ page_rec_next_get(f5cba2a7e3e0d594).<comp>(page, left); |
| 609 | } |
| 610 | while (left && val--); |
| 611 | return false; |
| 612 | } |
| 613 | |
| 614 | /** Detects whether the modifying record might need a modifying tree structure. |
| 615 | @param[in] index index |
| 616 | @param[in] page page |
| 617 | @param[in] lock_intention lock intention for the tree operation |
| 618 | @param[in] rec record (current node_ptr) |
| 619 | @param[in] rec_size size of the record or max size of node_ptr |
| 620 | @param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 |
| 621 | @param[in] mtr mtr |
| 622 | @return true if tree modification is needed */ |
| 623 | static |
| 624 | bool |
| 625 | btr_cur_will_modify_treecxx . . $ btr_cur_will_modify_tree(2ced6e53d49ba5b0).( |
| 626 | dict_index_tcxx . . $ dict_index_t#* index, |
| 627 | const page_tcxx . . $ `storage/innobase/include/page0types.h:38:9`!* page, |
| 628 | btr_intention_tcxx . . $ btr_intention_t# lock_intention, |
| 629 | const rec_tcxx . . $ rec_t#* rec, |
| 630 | ulintcxx . . $ ulint# rec_size, |
| 631 | ulintcxx . . $ ulint# zip_size, |
| 632 | mtr_tcxx . . $ mtr_t#* mtr) |
| 633 | { |
| 634 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!page_is_leaf(page)); |
| 635 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mtr->memo_contains_flagged(&index->lock, MTR_MEMO_X_LOCK |
| 636 | | MTR_MEMO_SX_LOCK)); |
| 637 | |
| 638 | /* Pessimistic delete of the first record causes delete & insert |
| 639 | of node_ptr at upper level. And a subsequent page shrink is |
| 640 | possible. It causes delete of node_ptr at the upper level. |
| 641 | So we should pay attention also to 2nd record not only |
| 642 | first record and last record. Because if the "delete & insert" are |
| 643 | done for the different page, the 2nd record become |
| 644 | first record and following compress might delete the record and causes |
| 645 | the uppper level node_ptr modification. */ |
| 646 | |
| 647 | const ulintcxx . . $ ulint# n_recs = page_get_n_recscxx . . $ page_get_n_recs(469dcb4e54b221a8).(page); |
| 648 | |
| 649 | if (lock_intention <= BTR_INTENTION_BOTHcxx . . $ BTR_INTENTION_BOTH.) { |
| 650 | compile_time_assertcxx . . $ `include/my_global.h:377:9`!(BTR_INTENTION_DELETE < BTR_INTENTION_BOTH); |
| 651 | compile_time_assertcxx . . $ `include/my_global.h:377:9`!(BTR_INTENTION_BOTH < BTR_INTENTION_INSERT); |
| 652 | |
| 653 | if (!page_has_siblingscxx . . $ page_has_siblings(190063cf6fb4afb1).(page)) { |
| 654 | return true; |
| 655 | } |
| 656 | |
| 657 | ulintcxx . . $ ulint# margin = rec_size; |
| 658 | |
| 659 | if (lock_intention == BTR_INTENTION_BOTHcxx . . $ BTR_INTENTION_BOTH.) { |
| 660 | ulintcxx . . $ ulint# level = btr_page_get_levelcxx . . $ btr_page_get_level(469dcb4e54b221a8).(page); |
| 661 | |
| 662 | /* This value is the worst expectation for the node_ptr |
| 663 | records to be deleted from this page. It is used to |
| 664 | expect whether the cursor position can be the left_most |
| 665 | record in this page or not. */ |
| 666 | ulintcxx . . $ ulint# max_nodes_deleted = 0; |
| 667 | |
| 668 | /* By modifying tree operations from the under of this |
| 669 | level, logically (2 ^ (level - 1)) opportunities to |
| 670 | deleting records in maximum even unreally rare case. */ |
| 671 | if (level > 7) { |
| 672 | /* TODO: adjust this practical limit. */ |
| 673 | max_nodes_deleted = 64; |
| 674 | } else if (level > 0) { |
| 675 | max_nodes_deleted = (ulintcxx . . $ ulint#)1 << (level - 1); |
| 676 | } |
| 677 | /* check delete will cause. (BTR_INTENTION_BOTH |
| 678 | or BTR_INTENTION_DELETE) */ |
| 679 | if (n_recs <= max_nodes_deleted * 2) { |
| 680 | /* The cursor record can be the left most record |
| 681 | in this page. */ |
| 682 | return true; |
| 683 | } |
| 684 | |
| 685 | if (page_is_compcxx . . $ page_is_comp(f3688bc2ee54ea05).(page)) { |
| 686 | const rec_tcxx . . $ rec_t# *const infimum |
| 687 | = page + PAGE_NEW_INFIMUMcxx . . $ `storage/innobase/include/page0page.h:141:9`!; |
| 688 | if (page_rec_next_getcxx . . $ page_rec_next_get(f5cba2a7e3e0d594).<true>(page, infimum) |
| 689 | == rec) { |
| 690 | return true; |
| 691 | } |
| 692 | if (page_has_prevcxx . . $ page_has_prev(190063cf6fb4afb1).(page) |
| 693 | && page_rec_distance_is_at_mostcxx . . $ page_rec_distance_is_at_most(9f5ff192e1e8b219).<true>( |
| 694 | page, infimum, rec, |
| 695 | max_nodes_deleted)) { |
| 696 | return true; |
| 697 | } |
| 698 | if (page_has_nextcxx . . $ page_has_next(190063cf6fb4afb1).(page) |
| 699 | && page_rec_distance_is_at_mostcxx . . $ page_rec_distance_is_at_most(9f5ff192e1e8b219).<true>( |
| 700 | page, rec, |
| 701 | page + PAGE_NEW_SUPREMUMcxx . . $ `storage/innobase/include/page0page.h:144:9`!, |
| 702 | max_nodes_deleted)) { |
| 703 | return true; |
| 704 | } |
| 705 | } else { |
| 706 | const rec_tcxx . . $ rec_t# *const infimum |
| 707 | = page + PAGE_OLD_INFIMUMcxx . . $ `storage/innobase/include/page0page.h:132:9`!; |
| 708 | if (page_rec_next_getcxx . . $ page_rec_next_get(f5cba2a7e3e0d594).<false>(page, infimum) |
| 709 | == rec) { |
| 710 | return true; |
| 711 | } |
| 712 | if (page_has_prevcxx . . $ page_has_prev(190063cf6fb4afb1).(page) |
| 713 | && page_rec_distance_is_at_mostcxx . . $ page_rec_distance_is_at_most(9f5ff192e1e8b219).<false>( |
| 714 | page, infimum, rec, |
| 715 | max_nodes_deleted)) { |
| 716 | return true; |
| 717 | } |
| 718 | if (page_has_nextcxx . . $ page_has_next(190063cf6fb4afb1).(page) |
| 719 | && page_rec_distance_is_at_mostcxx . . $ page_rec_distance_is_at_most(9f5ff192e1e8b219).<false>( |
| 720 | page, rec, |
| 721 | page + PAGE_OLD_SUPREMUMcxx . . $ `storage/innobase/include/page0page.h:135:9`!, |
| 722 | max_nodes_deleted)) { |
| 723 | return true; |
| 724 | } |
| 725 | } |
| 726 | |
| 727 | /* Delete at leftmost record in a page causes delete |
| 728 | & insert at its parent page. After that, the delete |
| 729 | might cause btr_compress() and delete record at its |
| 730 | parent page. Thus we should consider max deletes. */ |
| 731 | margin *= max_nodes_deleted; |
| 732 | } |
| 733 | |
| 734 | /* Safe because we already have SX latch of the index tree */ |
| 735 | if (page_get_data_sizecxx . . $ page_get_data_size(469dcb4e54b221a8).(page) |
| 736 | < margin + BTR_CUR_PAGE_COMPRESS_LIMITcxx . . $ `storage/innobase/include/btr0cur.h:616:9`!(index)) { |
| 737 | return(true); |
| 738 | } |
| 739 | } |
| 740 | |
| 741 | if (lock_intention >= BTR_INTENTION_BOTHcxx . . $ BTR_INTENTION_BOTH.) { |
| 742 | /* check insert will cause. BTR_INTENTION_BOTH |
| 743 | or BTR_INTENTION_INSERT*/ |
| 744 | |
| 745 | /* Once we invoke the btr_cur_limit_optimistic_insert_debug, |
| 746 | we should check it here in advance, since the max allowable |
| 747 | records in a page is limited. */ |
| 748 | LIMIT_OPTIMISTIC_INSERT_DEBUGcxx . . $ `storage/innobase/include/btr0cur.inl:36:10`!(n_recs, return true); |
| 749 | |
| 750 | /* needs 2 records' space for the case the single split and |
| 751 | insert cannot fit. |
| 752 | page_get_max_insert_size_after_reorganize() includes space |
| 753 | for page directory already */ |
| 754 | ulintcxx . . $ ulint# max_size |
| 755 | = page_get_max_insert_size_after_reorganizecxx . . $ page_get_max_insert_size_after_reorganize(4adc7973d4c4f159).(page, 2); |
| 756 | |
| 757 | if (max_size < BTR_CUR_PAGE_REORGANIZE_LIMITcxx . . $ `storage/innobase/btr/btr0cur.cc:112:9`! + rec_size |
| 758 | || max_size < rec_size * 2) { |
| 759 | return(true); |
| 760 | } |
| 761 | |
| 762 | /* TODO: optimize this condition for ROW_FORMAT=COMPRESSED. |
| 763 | This is based on the worst case, and we could invoke |
| 764 | page_zip_available() on the block->page.zip. */ |
| 765 | /* needs 2 records' space also for worst compress rate. */ |
| 766 | if (zip_size |
| 767 | && page_zip_empty_sizecxx . . $ page_zip_empty_size(80bad76eed2d2579).(index->n_fieldscxx . . $ dict_index_t#n_fields., zip_size) |
| 768 | <= rec_size * 2 + page_get_data_sizecxx . . $ page_get_data_size(469dcb4e54b221a8).(page) |
| 769 | + page_dir_calc_reserved_spacecxx . . $ page_dir_calc_reserved_space(ecdaa1632f49f591).(n_recs + 2)) { |
| 770 | return(true); |
| 771 | } |
| 772 | } |
| 773 | |
| 774 | return(false); |
| 775 | } |
| 776 | |
| 777 | /** Detects whether the modifying record might need a opposite modification |
| 778 | to the intention. |
| 779 | @param bpage buffer pool page |
| 780 | @param is_clust whether this is a clustered index |
| 781 | @param lock_intention lock intention for the tree operation |
| 782 | @param node_ptr_max_size the maximum size of a node pointer |
| 783 | @param compress_limit BTR_CUR_PAGE_COMPRESS_LIMIT(index) |
| 784 | @param rec record (current node_ptr) |
| 785 | @return true if tree modification is needed */ |
| 786 | static bool btr_cur_need_opposite_intentioncxx . . $ btr_cur_need_opposite_intention(256c00016b8e20d9).(const buf_page_tcxx . . $ buf_page_t# &bpage, |
| 787 | bool is_clust, |
| 788 | btr_intention_tcxx . . $ btr_intention_t# lock_intention, |
| 789 | ulintcxx . . $ ulint# node_ptr_max_size, |
| 790 | ulintcxx . . $ ulint# compress_limit, |
| 791 | const rec_tcxx . . $ rec_t# *rec) |
| 792 | { |
| 793 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(bpage.frame == page_align(rec)); |
| 794 | if (UNIV_LIKELY_NULLcxx . . $ `storage/innobase/include/univ.i:393:10`!(bpage.zip.data) && |
| 795 | !page_zip_availablecxx . . $ page_zip_available(b51f516ccf7dc7b1).(&bpage.zipcxx . . $ buf_page_t#zip., is_clust, node_ptr_max_size, 1)) |
| 796 | return true; |
| 797 | const page_tcxx . . $ `storage/innobase/include/page0types.h:38:9`! *const page= bpage.framecxx . . $ buf_page_t#frame.; |
| 798 | if (lock_intention != BTR_INTENTION_INSERTcxx . . $ BTR_INTENTION_INSERT.) |
| 799 | { |
| 800 | /* We compensate also for btr_cur_compress_recommendation() */ |
| 801 | if (!page_has_siblingscxx . . $ page_has_siblings(190063cf6fb4afb1).(page) || |
| 802 | page_rec_is_firstcxx . . $ page_rec_is_first(27c8776bc8033bc9).(rec, page) || page_rec_is_lastcxx . . $ page_rec_is_last(27c8776bc8033bc9).(rec, page) || |
| 803 | page_get_data_sizecxx . . $ page_get_data_size(469dcb4e54b221a8).(page) < node_ptr_max_size + compress_limit) |
| 804 | return true; |
| 805 | if (lock_intention == BTR_INTENTION_DELETEcxx . . $ BTR_INTENTION_DELETE.) |
| 806 | return false; |
| 807 | } |
| 808 | else if (page_has_nextcxx . . $ page_has_next(190063cf6fb4afb1).(page) && page_rec_is_lastcxx . . $ page_rec_is_last(27c8776bc8033bc9).(rec, page)) |
| 809 | return true; |
| 810 | LIMIT_OPTIMISTIC_INSERT_DEBUGcxx . . $ `storage/innobase/include/btr0cur.inl:36:10`!(page_get_n_recs(page), return true); |
| 811 | const ulintcxx . . $ ulint# max_size= page_get_max_insert_size_after_reorganizecxx . . $ page_get_max_insert_size_after_reorganize(4adc7973d4c4f159).(page, 2); |
| 812 | return max_size < BTR_CUR_PAGE_REORGANIZE_LIMITcxx . . $ `storage/innobase/btr/btr0cur.cc:112:9`! + node_ptr_max_size || |
| 813 | max_size < node_ptr_max_size * 2; |
| 814 | } |
| 815 | |
| 816 | /** |
| 817 | @param[in] index b-tree |
| 818 | @return maximum size of a node pointer record in bytes */ |
| 819 | static ulintcxx . . $ ulint# btr_node_ptr_max_sizecxx . . $ btr_node_ptr_max_size(67f37f56c055bd3e).(const dict_index_tcxx . . $ dict_index_t#* index) |
| 820 | { |
| 821 | /* Each record has page_no, length of page_no and header. */ |
| 822 | ulintcxx . . $ ulint# comp = dict_table_is_compcxx . . $ `storage/innobase/include/dict0dict.h:776:9`!(index->table); |
| 823 | ulintcxx . . $ ulint# rec_max_size = comp |
| 824 | ? REC_NODE_PTR_SIZEcxx . . $ `storage/innobase/include/rem0rec.h:62:9`! + 1 + REC_N_NEW_EXTRA_BYTEScxx . . $ `storage/innobase/include/rem0rec.h:46:9`! |
| 825 | + UT_BITS_IN_BYTEScxx . . $ `storage/innobase/include/ut0ut.h:93:9`!(index->n_nullable) |
| 826 | : REC_NODE_PTR_SIZEcxx . . $ `storage/innobase/include/rem0rec.h:62:9`! + 2 + REC_N_OLD_EXTRA_BYTEScxx . . $ `storage/innobase/include/rem0rec.h:43:9`! |
| 827 | + 2 * index->n_fieldscxx . . $ dict_index_t#n_fields.; |
| 828 | |
| 829 | /* Compute the maximum possible record size. */ |
| 830 | for (ulintcxx . . $ ulint# i = 0; i < dict_index_get_n_unique_in_treecxx . . $ dict_index_get_n_unique_in_tree(40995254b96f8651).(index); i++) { |
| 831 | const dict_field_tcxx . . $ dict_field_t#* field |
| 832 | = dict_index_get_nth_fieldcxx . . $ `storage/innobase/include/dict0dict.h:978:10`!(index, i); |
| 833 | const dict_col_tcxx . . $ dict_col_t#* col |
| 834 | = dict_field_get_colcxx . . $ dict_field_get_col(1e51e24f56ba30aa).(field); |
| 835 | ulintcxx . . $ ulint# field_max_size; |
| 836 | ulintcxx . . $ ulint# field_ext_max_size; |
| 837 | |
| 838 | /* Determine the maximum length of the index field. */ |
| 839 | |
| 840 | field_max_size = dict_col_get_fixed_sizecxx . . $ dict_col_get_fixed_size(441363759254a725).(col, comp); |
| 841 | if (field_max_size && field->fixed_lencxx . . $ dict_field_t#fixed_len.) { |
| 842 | /* dict_index_add_col() should guarantee this */ |
| 843 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!field->prefix_len |
| 844 | || field->fixed_len == field->prefix_len); |
| 845 | /* Fixed lengths are not encoded |
| 846 | in ROW_FORMAT=COMPACT. */ |
| 847 | rec_max_size += field_max_size; |
| 848 | continue; |
| 849 | } |
| 850 | |
| 851 | field_max_size = dict_col_get_max_sizecxx . . $ dict_col_get_max_size(f708a6536a1a73ff).(col); |
| 852 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(!field_max_size)) { |
| 853 | switch (col->mtypecxx . . $ dict_col_t#mtype.) { |
| 854 | case DATA_VARCHARcxx . . $ `storage/innobase/include/data0type.h:50:9`!: |
| 855 | if (!comp |
| 856 | && (!strcmp(index->tablecxx . . $ dict_index_t#table.->namecxx . . $ dict_table_t#name..m_namecxx . . $ table_name_t#m_name., |
| 857 | "SYS_FOREIGN") |
| 858 | || !strcmp(index->tablecxx . . $ dict_index_t#table.->namecxx . . $ dict_table_t#name..m_namecxx . . $ table_name_t#m_name., |
| 859 | "SYS_FOREIGN_COLS"))) { |
| 860 | break; |
| 861 | } |
| 862 | /* fall through */ |
| 863 | case DATA_FIXBINARYcxx . . $ `storage/innobase/include/data0type.h:58:9`!: |
| 864 | case DATA_BINARYcxx . . $ `storage/innobase/include/data0type.h:59:9`!: |
| 865 | case DATA_VARMYSQLcxx . . $ `storage/innobase/include/data0type.h:76:9`!: |
| 866 | case DATA_CHARcxx . . $ `storage/innobase/include/data0type.h:56:9`!: |
| 867 | case DATA_MYSQLcxx . . $ `storage/innobase/include/data0type.h:77:9`!: |
| 868 | /* BINARY(0), VARBINARY(0), |
| 869 | CHAR(0) and VARCHAR(0) are possible |
| 870 | data type definitions in MariaDB. |
| 871 | The InnoDB internal SQL parser maps |
| 872 | CHAR to DATA_VARCHAR, so DATA_CHAR (or |
| 873 | DATA_MYSQL) is only coming from the |
| 874 | MariaDB SQL layer. */ |
| 875 | if (comp) { |
| 876 | /* Add a length byte, because |
| 877 | fixed-length empty field are |
| 878 | encoded as variable-length. |
| 879 | For ROW_FORMAT=REDUNDANT, |
| 880 | these bytes were added to |
| 881 | rec_max_size before this loop. */ |
| 882 | rec_max_size++; |
| 883 | } |
| 884 | continue; |
| 885 | } |
| 886 | |
| 887 | /* SYS_FOREIGN.ID is defined as CHAR in the |
| 888 | InnoDB internal SQL parser, which translates |
| 889 | into the incorrect VARCHAR(0). InnoDB does |
| 890 | not enforce maximum lengths of columns, so |
| 891 | that is why any data can be inserted in the |
| 892 | first place. |
| 893 | |
| 894 | Likewise, SYS_FOREIGN.FOR_NAME, |
| 895 | SYS_FOREIGN.REF_NAME, SYS_FOREIGN_COLS.ID, are |
| 896 | defined as CHAR, and also they are part of a key. */ |
| 897 | |
| 898 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!strcmp(index->table->name.m_name, |
| 899 | "SYS_FOREIGN") |
| 900 | || !strcmp(index->table->name.m_name, |
| 901 | "SYS_FOREIGN_COLS")); |
| 902 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!comp); |
| 903 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(col->mtype == DATA_VARCHAR); |
| 904 | |
| 905 | rec_max_size += (srv_page_sizecxx . . $ srv_page_size. == UNIV_PAGE_SIZE_MAXcxx . . $ `storage/innobase/include/univ.i:214:9`!) |
| 906 | ? REDUNDANT_REC_MAX_DATA_SIZEcxx . . $ `storage/innobase/include/rem0rec.h:1256:9`! |
| 907 | : page_get_free_space_of_emptycxx . . $ page_get_free_space_of_empty(ecdaa1632f49f591).(FALSEcxx . . $ `include/my_global.h:477:9`!) / 2; |
| 908 | } else if (field_max_size == NAME_LENcxx . . $ `include/mysql_com.h:33:9`! && i == 1 |
| 909 | && (!strcmp(index->tablecxx . . $ dict_index_t#table.->namecxx . . $ dict_table_t#name..m_namecxx . . $ table_name_t#m_name., |
| 910 | TABLE_STATS_NAMEcxx . . $ `storage/innobase/include/dict0types.h:178:9`!) |
| 911 | || !strcmp(index->tablecxx . . $ dict_index_t#table.->namecxx . . $ dict_table_t#name..m_namecxx . . $ table_name_t#m_name., |
| 912 | INDEX_STATS_NAMEcxx . . $ `storage/innobase/include/dict0types.h:179:9`!))) { |
| 913 | /* Interpret "table_name" as VARCHAR(199) even |
| 914 | if it was incorrectly defined as VARCHAR(64). |
| 915 | While the caller of ha_innobase enforces the |
| 916 | maximum length on any data written, the InnoDB |
| 917 | internal SQL parser will happily write as much |
| 918 | data as is provided. The purpose of this hack |
| 919 | is to avoid InnoDB hangs after persistent |
| 920 | statistics on partitioned tables are |
| 921 | deleted. */ |
| 922 | field_max_size = 199 * SYSTEM_CHARSET_MBMAXLENcxx . . $ `include/mysql_com.h:28:9`!; |
| 923 | } |
| 924 | field_ext_max_size = field_max_size < 256 ? 1 : 2; |
| 925 | |
| 926 | if (field->prefix_lencxx . . $ dict_field_t#prefix_len. |
| 927 | && field->prefix_lencxx . . $ dict_field_t#prefix_len. < field_max_size) { |
| 928 | field_max_size = field->prefix_lencxx . . $ dict_field_t#prefix_len.; |
| 929 | } |
| 930 | |
| 931 | if (comp) { |
| 932 | /* Add the extra size for ROW_FORMAT=COMPACT. |
| 933 | For ROW_FORMAT=REDUNDANT, these bytes were |
| 934 | added to rec_max_size before this loop. */ |
| 935 | rec_max_size += field_ext_max_size; |
| 936 | } |
| 937 | |
| 938 | rec_max_size += field_max_size; |
| 939 | } |
| 940 | |
| 941 | return rec_max_size; |
| 942 | } |
| 943 | |
| 944 | /** @return a B-tree search mode suitable for non-leaf pages |
| 945 | @param mode leaf page search mode */ |
| 946 | static inline page_cur_mode_tcxx . . $ page_cur_mode_t# btr_cur_nonleaf_modecxx . . $ btr_cur_nonleaf_mode(61e4b25c51d635cf).(page_cur_mode_tcxx . . $ page_cur_mode_t# mode) |
| 947 | { |
| 948 | if (mode > PAGE_CUR_GEcxx . . $ PAGE_CUR_GE.) |
| 949 | { |
| 950 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mode == PAGE_CUR_L || mode == PAGE_CUR_LE); |
| 951 | return mode; |
| 952 | } |
| 953 | if (mode == PAGE_CUR_GEcxx . . $ PAGE_CUR_GE.) |
| 954 | return PAGE_CUR_Lcxx . . $ PAGE_CUR_L.; |
| 955 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mode == PAGE_CUR_G); |
| 956 | return PAGE_CUR_LEcxx . . $ PAGE_CUR_LE.; |
| 957 | } |
| 958 | |
| 959 | MY_ATTRIBUTEcxx . . $ `storage/innobase/include/univ.i:162:11`!((nonnull,warn_unused_result)) |
| 960 | /** Acquire a latch on the previous page without violating the latching order. |
| 961 | @param rw_latch the latch on block (RW_S_LATCH or RW_X_LATCH) |
| 962 | @param page_id page identifier with valid space identifier |
| 963 | @param err error code |
| 964 | @param mtr mini-transaction |
| 965 | @retval 0 if an error occurred |
| 966 | @retval 1 if the page could be latched in the wrong order |
| 967 | @retval -1 if the latch on block was temporarily released */ |
| 968 | static int btr_latch_prevcxx . . $ btr_latch_prev(d1651efd08c7b088).(rw_lock_type_tcxx . . $ rw_lock_type_t# rw_latch, |
| 969 | page_id_tcxx . . $ page_id_t# page_id, dberr_tcxx . . $ dberr_t# *err, mtr_tcxx . . $ mtr_t# *mtr) noexcept |
| 970 | { |
| 971 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rw_latch == RW_S_LATCH || rw_latch == RW_X_LATCH); |
| 972 | |
| 973 | buf_block_tcxx . . $ buf_block_t# *block= mtr->at_savepointcxx . . $ mtr_t#at_savepoint(af74c280cb0dfd96).(mtr->get_savepointcxx . . $ mtr_t#get_savepoint(fe4d2d262d4164a8).() - 1); |
| 974 | |
| 975 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(page_id.space() == block->page.id().space()); |
| 976 | |
| 977 | const page_tcxx . . $ `storage/innobase/include/page0types.h:38:9`! *const page= block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.; |
| 978 | page_id.set_page_nocxx . . $ page_id_t#set_page_no(6bab9b75950d6f3).(btr_page_get_prevcxx . . $ btr_page_get_prev(ca1608e2c87725e2).(page)); |
| 979 | /* We are holding a latch on the current page. |
| 980 | |
| 981 | We will start by buffer-fixing the left sibling. Waiting for a latch |
| 982 | on it while holding a latch on the current page could lead to a |
| 983 | deadlock, because another thread could hold that latch and wait for |
| 984 | a right sibling page latch (the current page). |
| 985 | |
| 986 | If there is a conflict, we will temporarily release our latch on the |
| 987 | current block while waiting for a latch on the left sibling. The |
| 988 | buffer-fixes on both blocks will prevent eviction. */ |
| 989 | |
| 990 | retry: |
| 991 | int ret= 1; |
| 992 | buf_block_tcxx . . $ buf_block_t# *prev= |
| 993 | buf_poolcxx . . $ buf_pool..page_fixcxx . . $ buf_pool_t#page_fix(8948a7da6c323fff).(page_id, err, mtr->trxcxx . . $ mtr_t#trx., buf_pool_tcxx . . $ buf_pool_t#::FIX_NOWAITcxx . . $ buf_pool_t#FIX_NOWAIT.); |
| 994 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(!prev)) |
| 995 | return 0; |
| 996 | if (prev == reinterpret_cast<buf_block_tcxx . . $ buf_block_t#*>(-1)) |
| 997 | { |
| 998 | /* The block existed in buf_pool.page_hash, but not in a state that is |
| 999 | safe to access without waiting for some pending operation, such as |
| 1000 | buf_page_t::read_complete() or buf_pool_t::unzip(). |
| 1001 | |
| 1002 | Retry while temporarily releasing the successor block->page.lock |
| 1003 | (but retaining a buffer-fix so that the block cannot be evicted. */ |
| 1004 | |
| 1005 | if (rw_latch == RW_S_LATCHcxx . . $ RW_S_LATCH.) |
| 1006 | block->pagecxx . . $ buf_block_t#page..lockcxx . . $ buf_page_t#lock..s_unlockcxx . . $ sux_lock#s_unlock(49f6e7a06ebc5aa8).(); |
| 1007 | else |
| 1008 | block->pagecxx . . $ buf_block_t#page..lockcxx . . $ buf_page_t#lock..x_unlockcxx . . $ sux_lock#x_unlock(b45ddcbc8423892c).(); |
| 1009 | |
| 1010 | prev= buf_poolcxx . . $ buf_pool..page_fixcxx . . $ buf_pool_t#page_fix(8948a7da6c323fff).(page_id, err, mtr->trxcxx . . $ mtr_t#trx., buf_pool_tcxx . . $ buf_pool_t#::FIX_WAIT_READcxx . . $ buf_pool_t#FIX_WAIT_READ.); |
| 1011 | |
| 1012 | if (!prev) |
| 1013 | { |
| 1014 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(*err != DB_SUCCESS); |
| 1015 | if (rw_latch == RW_S_LATCHcxx . . $ RW_S_LATCH.) |
| 1016 | block->pagecxx . . $ buf_block_t#page..lockcxx . . $ buf_page_t#lock..s_lockcxx . . $ sux_lock#s_lock(49f6e7a06ebc5aa8).(); |
| 1017 | else |
| 1018 | block->pagecxx . . $ buf_block_t#page..lockcxx . . $ buf_page_t#lock..x_lockcxx . . $ sux_lock#x_lock(b45ddcbc8423892c).(); |
| 1019 | return 0; |
| 1020 | } |
| 1021 | else if (rw_latch == RW_S_LATCHcxx . . $ RW_S_LATCH.) |
| 1022 | goto wait_for_s; |
| 1023 | else |
| 1024 | goto wait_for_x; |
| 1025 | } |
| 1026 | |
| 1027 | static_assert(MTR_MEMO_PAGE_S_FIXcxx . . $ MTR_MEMO_PAGE_S_FIX. == mtr_memo_type_tcxx . . $ mtr_memo_type_t#(BTR_SEARCH_LEAFcxx . . $ BTR_SEARCH_LEAF.), ""); |
| 1028 | static_assert(MTR_MEMO_PAGE_X_FIXcxx . . $ MTR_MEMO_PAGE_X_FIX. == mtr_memo_type_tcxx . . $ mtr_memo_type_t#(BTR_MODIFY_LEAFcxx . . $ BTR_MODIFY_LEAF.), ""); |
| 1029 | |
| 1030 | if (rw_latch == RW_S_LATCHcxx . . $ RW_S_LATCH. |
| 1031 | ? prev->pagecxx . . $ buf_block_t#page..lockcxx . . $ buf_page_t#lock..s_lock_trycxx . . $ sux_lock#s_lock_try(c9857a73d68e59ba).() |
| 1032 | : prev->pagecxx . . $ buf_block_t#page..lockcxx . . $ buf_page_t#lock..x_lock_trycxx . . $ sux_lock#x_lock_try(c9857a73d68e59ba).()) |
| 1033 | mtr->memo_pushcxx . . $ mtr_t#memo_push(1e7bab2d46fcb4c1).(prev, mtr_memo_type_tcxx . . $ mtr_memo_type_t#(rw_latch)); |
| 1034 | else |
| 1035 | { |
| 1036 | if (rw_latch == RW_S_LATCHcxx . . $ RW_S_LATCH.) |
| 1037 | { |
| 1038 | block->pagecxx . . $ buf_block_t#page..lockcxx . . $ buf_page_t#lock..s_unlockcxx . . $ sux_lock#s_unlock(49f6e7a06ebc5aa8).(); |
| 1039 | wait_for_s: |
| 1040 | prev->pagecxx . . $ buf_block_t#page..lockcxx . . $ buf_page_t#lock..s_lockcxx . . $ sux_lock#s_lock(49f6e7a06ebc5aa8).(); |
| 1041 | block->pagecxx . . $ buf_block_t#page..lockcxx . . $ buf_page_t#lock..s_lockcxx . . $ sux_lock#s_lock(49f6e7a06ebc5aa8).(); |
| 1042 | } |
| 1043 | else |
| 1044 | { |
| 1045 | block->pagecxx . . $ buf_block_t#page..lockcxx . . $ buf_page_t#lock..x_unlockcxx . . $ sux_lock#x_unlock(b45ddcbc8423892c).(); |
| 1046 | wait_for_x: |
| 1047 | prev->pagecxx . . $ buf_block_t#page..lockcxx . . $ buf_page_t#lock..x_lockcxx . . $ sux_lock#x_lock(b45ddcbc8423892c).(); |
| 1048 | block->pagecxx . . $ buf_block_t#page..lockcxx . . $ buf_page_t#lock..x_lockcxx . . $ sux_lock#x_lock(b45ddcbc8423892c).(); |
| 1049 | } |
| 1050 | |
| 1051 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(block == mtr->at_savepoint(mtr->get_savepoint() - 1)); |
| 1052 | mtr->memo_pushcxx . . $ mtr_t#memo_push(1e7bab2d46fcb4c1).(prev, mtr_memo_type_tcxx . . $ mtr_memo_type_t#(rw_latch)); |
| 1053 | const page_id_tcxx . . $ page_id_t# prev_page_id= page_id; |
| 1054 | page_id.set_page_nocxx . . $ page_id_t#set_page_no(6bab9b75950d6f3).(btr_page_get_prevcxx . . $ btr_page_get_prev(ca1608e2c87725e2).(page)); |
| 1055 | ret= -1; |
| 1056 | |
| 1057 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(page_id != prev_page_id)) |
| 1058 | { |
| 1059 | mtr->release_last_pagecxx . . $ mtr_t#release_last_page(49f6e7a06ebc5aa8).(); |
| 1060 | if (page_id.page_nocxx . . $ page_id_t#page_no(d22c8608b6eae7b5).() == FIL_NULLcxx . . $ `storage/innobase/include/fil0fil.h:1175:9`!) |
| 1061 | return ret; |
| 1062 | goto retry; |
| 1063 | } |
| 1064 | } |
| 1065 | |
| 1066 | const page_tcxx . . $ `storage/innobase/include/page0types.h:38:9`! *const p= prev->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.; |
| 1067 | if (memcmp_alignedcxx . . $ memcmp_aligned(36f949851efa3055).<4>(FIL_PAGE_NEXTcxx . . $ `storage/innobase/include/fil0fil.h:1203:9`! + p, FIL_PAGE_OFFSETcxx . . $ `storage/innobase/include/fil0fil.h:1195:9`! + page, 4) || |
| 1068 | memcmp_alignedcxx . . $ memcmp_aligned(36f949851efa3055).<2>(FIL_PAGE_TYPEcxx . . $ `storage/innobase/include/fil0fil.h:1215:9`! + p, FIL_PAGE_TYPEcxx . . $ `storage/innobase/include/fil0fil.h:1215:9`! + page, 2) || |
| 1069 | memcmp_alignedcxx . . $ memcmp_aligned(36f949851efa3055).<2>(PAGE_HEADERcxx . . $ `storage/innobase/include/page0page.h:48:9`! + PAGE_INDEX_IDcxx . . $ `storage/innobase/include/page0page.h:109:9`! + p, |
| 1070 | PAGE_HEADERcxx . . $ `storage/innobase/include/page0page.h:48:9`! + PAGE_INDEX_IDcxx . . $ `storage/innobase/include/page0page.h:109:9`! + page, 8) || |
| 1071 | page_is_compcxx . . $ page_is_comp(f3688bc2ee54ea05).(p) != page_is_compcxx . . $ page_is_comp(f3688bc2ee54ea05).(page)) |
| 1072 | { |
| 1073 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!("corrupted" == 0); // FIXME: remove this |
| 1074 | *err= DB_CORRUPTIONcxx . . $ DB_CORRUPTION.; |
| 1075 | ret= 0; |
| 1076 | } |
| 1077 | |
| 1078 | return ret; |
| 1079 | } |
| 1080 | |
| 1081 | dberr_tcxx . . $ dberr_t# btr_cur_tcxx . . $ btr_cur_t#::search_leafcxx . . $ btr_cur_t#search_leaf(90b82fc0cc54a008).(const dtuple_tcxx . . $ dtuple_t# *tuple, page_cur_mode_tcxx . . $ page_cur_mode_t# mode, |
| 1082 | btr_latch_modecxx . . $ btr_latch_mode# latch_mode, mtr_tcxx . . $ mtr_t# *mtr) |
| 1083 | { |
| 1084 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(index()->is_btree()); |
| 1085 | |
| 1086 | buf_block_tcxx . . $ buf_block_t# *guess; |
| 1087 | btr_intention_tcxx . . $ btr_intention_t# lock_intention; |
| 1088 | bool detected_same_key_root= false; |
| 1089 | |
| 1090 | mem_heap_tcxx . . $ mem_heap_t# *heap= nullptr; |
| 1091 | rec_offscxx . . $ rec_offs# offsets_[REC_OFFS_NORMAL_SIZEcxx . . $ REC_OFFS_NORMAL_SIZE.]; |
| 1092 | rec_offscxx . . $ rec_offs# *offsets= offsets_; |
| 1093 | rec_offscxx . . $ rec_offs# offsets2_[REC_OFFS_NORMAL_SIZEcxx . . $ REC_OFFS_NORMAL_SIZE.]; |
| 1094 | rec_offscxx . . $ rec_offs# *offsets2= offsets2_; |
| 1095 | rec_offs_initcxx . . $ `storage/innobase/include/rem0rec.h:844:9`!(offsets_); |
| 1096 | rec_offs_initcxx . . $ `storage/innobase/include/rem0rec.h:844:9`!(offsets2_); |
| 1097 | |
| 1098 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(dict_index_check_search_tuple(index(), tuple)); |
| 1099 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(dtuple_check_typed(tuple)); |
| 1100 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(index()->page != FIL_NULL); |
| 1101 | |
| 1102 | MEM_UNDEFINEDcxx . . $ `include/my_valgrind.h:67:10`!(&up_match, sizeof up_match); |
| 1103 | MEM_UNDEFINEDcxx . . $ `include/my_valgrind.h:67:10`!(&up_bytes, sizeof up_bytes); |
| 1104 | MEM_UNDEFINEDcxx . . $ `include/my_valgrind.h:67:10`!(&low_match, sizeof low_match); |
| 1105 | MEM_UNDEFINEDcxx . . $ `include/my_valgrind.h:67:10`!(&low_bytes, sizeof low_bytes); |
| 1106 | ut_dcxx . . $ `storage/innobase/include/ut0dbg.h:68:9`!(up_match= low_match= uint16_t(~0u)); |
| 1107 | |
| 1108 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!(latch_mode & BTR_ALREADY_S_LATCHED) || |
| 1109 | mtr->memo_contains_flagged(&index()->lock, |
| 1110 | MTR_MEMO_S_LOCK | MTR_MEMO_SX_LOCK | |
| 1111 | MTR_MEMO_X_LOCK)); |
| 1112 | |
| 1113 | const bool latch_by_caller= latch_mode & BTR_ALREADY_S_LATCHEDcxx . . $ BTR_ALREADY_S_LATCHED.; |
| 1114 | lock_intention= btr_cur_get_and_clear_intentioncxx . . $ btr_cur_get_and_clear_intention(7c930369ca6c389e).(&latch_mode); |
| 1115 | latch_mode= BTR_LATCH_MODE_WITHOUT_FLAGScxx . . $ `storage/innobase/include/btr0btr.h:58:9`!(latch_mode); |
| 1116 | |
| 1117 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!latch_by_caller |
| 1118 | || latch_mode == BTR_SEARCH_LEAF |
| 1119 | || latch_mode == BTR_MODIFY_LEAF |
| 1120 | || latch_mode == BTR_MODIFY_TREE |
| 1121 | || latch_mode == BTR_MODIFY_ROOT_AND_LEAF); |
| 1122 | |
| 1123 | #ifndef BTR_CUR_ADAPTcxx . . $ `<built-in>:480:9`! |
| 1124 | guess= nullptr; |
| 1125 | #else |
| 1126 | auto info= &indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).()->search_infocxx . . $ dict_index_t#search_info.; |
| 1127 | guess= info->root_guesscxx . . $ dict_index_t#ahi#root_guess.; |
| 1128 | |
| 1129 | # ifdef BTR_CUR_HASH_ADAPTcxx . . $ `<built-in>:481:9`! |
| 1130 | flagcxx . . $ btr_cur_t#flag.= BTR_CUR_BINARYcxx . . $ BTR_CUR_BINARY.; |
| 1131 | # ifdef UNIV_SEARCH_PERF_STAT |
| 1132 | info->n_searches++; |
| 1133 | # endif |
| 1134 | if (latch_mode > BTR_MODIFY_LEAFcxx . . $ BTR_MODIFY_LEAF.) |
| 1135 | /* The adaptive hash index cannot be useful for these searches. */; |
| 1136 | else if (mode != PAGE_CUR_LEcxx . . $ PAGE_CUR_LE. && mode != PAGE_CUR_GEcxx . . $ PAGE_CUR_GE.) |
| 1137 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mode == PAGE_CUR_L || mode == PAGE_CUR_G); |
| 1138 | /* We do a dirty read of btr_search.enabled below, |
| 1139 | and btr_search_guess_on_hash() will have to check it again. */ |
| 1140 | else if (!btr_searchcxx . . $ btr_search..enabledcxx . . $ btr_sea#enabled.); |
| 1141 | else if (btr_search_guess_on_hashcxx . . $ btr_search_guess_on_hash(e1ceb7bc25972087).(indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).(), tuple, mode != PAGE_CUR_LEcxx . . $ PAGE_CUR_LE., |
| 1142 | latch_mode, this, mtr)) |
| 1143 | { |
| 1144 | /* Search using the hash index succeeded */ |
| 1145 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(up_match != uint16_t(~0U) || mode != PAGE_CUR_GE); |
| 1146 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(up_match != uint16_t(~0U) || mode != PAGE_CUR_LE); |
| 1147 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(low_match != uint16_t(~0U) || mode != PAGE_CUR_LE); |
| 1148 | ++cxx . . $ ib_counter_t#operator++(6bf6242aaae3b6b0).btr_cur_n_seacxx . . $ btr_cur_n_sea.; |
| 1149 | |
| 1150 | return DB_SUCCESScxx . . $ DB_SUCCESS.; |
| 1151 | } |
| 1152 | else |
| 1153 | ++cxx . . $ ib_counter_t#operator++(6bf6242aaae3b6b0).btr_cur_n_non_seacxx . . $ btr_cur_n_non_sea.; |
| 1154 | # endif |
| 1155 | #endif |
| 1156 | |
| 1157 | /* If the hash search did not succeed, do binary search down the |
| 1158 | tree */ |
| 1159 | |
| 1160 | /* Store the position of the tree latch we push to mtr so that we |
| 1161 | know how to release it when we have latched leaf node(s) */ |
| 1162 | |
| 1163 | const ulintcxx . . $ ulint# savepoint= mtr->get_savepointcxx . . $ mtr_t#get_savepoint(fe4d2d262d4164a8).(); |
| 1164 | |
| 1165 | ulintcxx . . $ ulint# node_ptr_max_size= 0, compress_limit= 0; |
| 1166 | rw_lock_type_tcxx . . $ rw_lock_type_t# rw_latch= RW_S_LATCHcxx . . $ RW_S_LATCH.; |
| 1167 | |
| 1168 | switch (latch_mode) { |
| 1169 | case BTR_MODIFY_TREEcxx . . $ BTR_MODIFY_TREE.: |
| 1170 | rw_latch= RW_X_LATCHcxx . . $ RW_X_LATCH.; |
| 1171 | node_ptr_max_size= btr_node_ptr_max_sizecxx . . $ btr_node_ptr_max_size(67f37f56c055bd3e).(indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).()); |
| 1172 | if (latch_by_caller) |
| 1173 | { |
| 1174 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mtr->memo_contains_flagged(&index()->lock, MTR_MEMO_X_LOCK)); |
| 1175 | break; |
| 1176 | } |
| 1177 | if (lock_intention == BTR_INTENTION_DELETEcxx . . $ BTR_INTENTION_DELETE.) |
| 1178 | { |
| 1179 | compress_limit= BTR_CUR_PAGE_COMPRESS_LIMITcxx . . $ `storage/innobase/include/btr0cur.h:616:9`!(index()); |
| 1180 | if (os_aio_pending_reads_approxcxx . . $ os_aio_pending_reads_approx(cee159cc271e827).() && |
| 1181 | trx_syscxx . . $ trx_sys..history_size_approxcxx . . $ trx_sys_t#history_size_approx(fe4d2d262d4164a8).() > BTR_CUR_FINE_HISTORY_LENGTHcxx . . $ `storage/innobase/btr/btr0cur.cc:87:9`!) |
| 1182 | { |
| 1183 | /* Most delete-intended operations are due to the purge of history. |
| 1184 | Prioritize them when the history list is growing huge. */ |
| 1185 | mtr_x_lock_indexcxx . . $ `storage/innobase/include/mtr0mtr.h:46:10`!(index(), mtr); |
| 1186 | break; |
| 1187 | } |
| 1188 | } |
| 1189 | mtr_sx_lock_indexcxx . . $ `storage/innobase/include/mtr0mtr.h:47:10`!(index(), mtr); |
| 1190 | break; |
| 1191 | #ifdef UNIV_DEBUG |
| 1192 | case BTR_CONT_MODIFY_TREE: |
| 1193 | ut_ad("invalid mode" == 0); |
| 1194 | break; |
| 1195 | #endif |
| 1196 | case BTR_MODIFY_ROOT_AND_LEAFcxx . . $ BTR_MODIFY_ROOT_AND_LEAF.: |
| 1197 | rw_latch= RW_SX_LATCHcxx . . $ RW_SX_LATCH.; |
| 1198 | /* fall through */ |
| 1199 | default: |
| 1200 | if (!latch_by_caller) |
| 1201 | mtr_s_lock_indexcxx . . $ `storage/innobase/include/mtr0mtr.h:45:10`!(index(), mtr); |
| 1202 | } |
| 1203 | |
| 1204 | dberr_tcxx . . $ dberr_t# err; |
| 1205 | |
| 1206 | if (!indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).()->tablecxx . . $ dict_index_t#table.->spacecxx . . $ dict_table_t#space.) |
| 1207 | { |
| 1208 | corrupted: |
| 1209 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!("corrupted" == 0); // FIXME: remove this |
| 1210 | err= DB_CORRUPTIONcxx . . $ DB_CORRUPTION.; |
| 1211 | func_exit: |
| 1212 | if (UNIV_LIKELY_NULLcxx . . $ `storage/innobase/include/univ.i:393:10`!(heap)) |
| 1213 | mem_heap_freecxx . . $ mem_heap_free(5231cf397463bfab).(heap); |
| 1214 | return err; |
| 1215 | } |
| 1216 | |
| 1217 | const ulintcxx . . $ ulint# zip_size= indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).()->tablecxx . . $ dict_index_t#table.->spacecxx . . $ dict_table_t#space.->zip_sizecxx . . $ fil_space_t#zip_size(d22c8608b6eae7b5).(); |
| 1218 | |
| 1219 | /* Start with the root page. */ |
| 1220 | page_id_tcxx . . $ page_id_t# page_idcxx . . $ page_id_t#page_id_t(b4d55b1286ff73e8).(indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).()->tablecxx . . $ dict_index_t#table.->space_idcxx . . $ dict_table_t#space_id., indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).()->pagecxx . . $ dict_index_t#page.); |
| 1221 | |
| 1222 | const page_cur_mode_tcxx . . $ page_cur_mode_t# page_mode= btr_cur_nonleaf_modecxx . . $ btr_cur_nonleaf_mode(61e4b25c51d635cf).(mode); |
| 1223 | ulintcxx . . $ ulint# height= ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!; |
| 1224 | up_matchcxx . . $ btr_cur_t#up_match.= 0; |
| 1225 | up_bytescxx . . $ btr_cur_t#up_bytes.= 0; |
| 1226 | low_matchcxx . . $ btr_cur_t#low_match.= 0; |
| 1227 | low_bytescxx . . $ btr_cur_t#low_bytes.= 0; |
| 1228 | search_loop: |
| 1229 | auto block_savepoint= mtr->get_savepointcxx . . $ mtr_t#get_savepoint(fe4d2d262d4164a8).(); |
| 1230 | buf_block_tcxx . . $ buf_block_t# *block= |
| 1231 | buf_page_get_gencxx . . $ buf_page_get_gen(4cc82125c68d4d05).(page_id, zip_size, rw_latch, guess, BUF_GETcxx . . $ `storage/innobase/include/buf0buf.h:53:9`!, mtr, &err); |
| 1232 | if (!block) |
| 1233 | { |
| 1234 | btr_read_failedcxx . . $ btr_read_failed(5cd27334cb9550f7).(err, *indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).()); |
| 1235 | goto func_exit; |
| 1236 | } |
| 1237 | |
| 1238 | btr_search_drop_page_hash_indexcxx . . $ btr_search_drop_page_hash_index(33307f3566ecc1a8).(block, indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).()); |
| 1239 | |
| 1240 | if (!!page_is_compcxx . . $ page_is_comp(f3688bc2ee54ea05).(block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.) != indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).()->tablecxx . . $ dict_index_t#table.->not_redundantcxx . . $ dict_table_t#not_redundant(50ce9a9e25b4a850).() || |
| 1241 | btr_page_get_index_idcxx . . $ btr_page_get_index_id(b191ace3c5bffbd9).(block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.) != indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).()->idcxx . . $ dict_index_t#id. || |
| 1242 | fil_page_get_typecxx . . $ fil_page_get_type(422f7ec86fa2a2fb).(block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.) == FIL_PAGE_RTREEcxx . . $ FIL_PAGE_RTREE. || |
| 1243 | !fil_page_index_page_checkcxx . . $ `storage/innobase/include/fil0fil.h:1357:9`!(block->page.frame)) |
| 1244 | goto corrupted; |
| 1245 | |
| 1246 | page_curcxx . . $ btr_cur_t#page_cur..blockcxx . . $ page_cur_t#block.= block; |
| 1247 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(block == mtr->at_savepoint(block_savepoint)); |
| 1248 | const bool not_first_access{buf_page_make_young_if_neededcxx . . $ buf_page_make_young_if_needed(12ea16e51c748147).(&block->pagecxx . . $ buf_block_t#page.)}; |
| 1249 | #ifdef UNIV_ZIP_DEBUG |
| 1250 | if (const page_zip_des_t *page_zip= buf_block_get_page_zip(block)) |
| 1251 | ut_a(page_zip_validate(page_zip, block->page.frame, index())); |
| 1252 | #endif /* UNIV_ZIP_DEBUG */ |
| 1253 | |
| 1254 | uint32_tcxx . . $ uint32_t# page_level= btr_page_get_levelcxx . . $ btr_page_get_level(469dcb4e54b221a8).(block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.); |
| 1255 | |
| 1256 | if (height == ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!) |
| 1257 | { |
| 1258 | /* We are in the B-tree index root page. */ |
| 1259 | #ifdef BTR_CUR_ADAPTcxx . . $ `<built-in>:480:9`! |
| 1260 | info->root_guesscxx . . $ dict_index_t#ahi#root_guess.= block; |
| 1261 | #endif |
| 1262 | reached_root: |
| 1263 | height= page_level; |
| 1264 | tree_heightcxx . . $ btr_cur_t#tree_height.= height + 1; |
| 1265 | |
| 1266 | if (!height) |
| 1267 | { |
| 1268 | /* The root page is also a leaf page. |
| 1269 | We may have to reacquire the page latch in a different mode. */ |
| 1270 | switch (rw_latch) { |
| 1271 | case RW_S_LATCHcxx . . $ RW_S_LATCH.: |
| 1272 | if (!(latch_mode & BTR_SEARCH_LEAFcxx . . $ BTR_SEARCH_LEAF.)) |
| 1273 | { |
| 1274 | rw_latch= RW_X_LATCHcxx . . $ RW_X_LATCH.; |
| 1275 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rw_lock_type_t(latch_mode & ~12) == RW_X_LATCH); |
| 1276 | mtr->lock_registercxx . . $ mtr_t#lock_register(9cd57bca12b7bf30).(block_savepoint, MTR_MEMO_PAGE_X_FIXcxx . . $ MTR_MEMO_PAGE_X_FIX.); |
| 1277 | if (!block->pagecxx . . $ buf_block_t#page..lockcxx . . $ buf_page_t#lock..s_x_upgrade_trycxx . . $ sux_lock#s_x_upgrade_try(c9857a73d68e59ba).()) |
| 1278 | { |
| 1279 | block->pagecxx . . $ buf_block_t#page..lockcxx . . $ buf_page_t#lock..s_unlockcxx . . $ sux_lock#s_unlock(49f6e7a06ebc5aa8).(); |
| 1280 | block->pagecxx . . $ buf_block_t#page..lockcxx . . $ buf_page_t#lock..x_lockcxx . . $ sux_lock#x_lock(b45ddcbc8423892c).(); |
| 1281 | /* Dropping the index tree (and freeing the root page) |
| 1282 | should be impossible while we hold index()->lock. */ |
| 1283 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!block->page.is_freed()); |
| 1284 | page_level= btr_page_get_levelcxx . . $ btr_page_get_level(469dcb4e54b221a8).(block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.); |
| 1285 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(page_level != 0)) |
| 1286 | { |
| 1287 | /* btr_root_raise_and_insert() was executed meanwhile */ |
| 1288 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mtr->memo_contains_flagged(&index()->lock, |
| 1289 | MTR_MEMO_S_LOCK)); |
| 1290 | block->pagecxx . . $ buf_block_t#page..lockcxx . . $ buf_page_t#lock..x_u_downgradecxx . . $ sux_lock#x_u_downgrade(49f6e7a06ebc5aa8).(); |
| 1291 | block->pagecxx . . $ buf_block_t#page..lockcxx . . $ buf_page_t#lock..u_s_downgradecxx . . $ sux_lock#u_s_downgrade(49f6e7a06ebc5aa8).(); |
| 1292 | rw_latch= RW_S_LATCHcxx . . $ RW_S_LATCH.; |
| 1293 | mtr->lock_registercxx . . $ mtr_t#lock_register(9cd57bca12b7bf30).(block_savepoint, MTR_MEMO_PAGE_S_FIXcxx . . $ MTR_MEMO_PAGE_S_FIX.); |
| 1294 | goto reached_root; |
| 1295 | } |
| 1296 | } |
| 1297 | } |
| 1298 | if (rw_latch != RW_S_LATCHcxx . . $ RW_S_LATCH.) |
| 1299 | break; |
| 1300 | if (!latch_by_caller) |
| 1301 | /* Release the tree s-latch */ |
| 1302 | mtr->rollback_to_savepointcxx . . $ mtr_t#rollback_to_savepoint(6714b5f2551eea49).(savepoint, savepoint + 1); |
| 1303 | goto reached_latched_leaf; |
| 1304 | case RW_SX_LATCHcxx . . $ RW_SX_LATCH.: |
| 1305 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(latch_mode == BTR_MODIFY_ROOT_AND_LEAF); |
| 1306 | static_assert(int{BTR_MODIFY_ROOT_AND_LEAFcxx . . $ BTR_MODIFY_ROOT_AND_LEAF.} == int{RW_SX_LATCHcxx . . $ RW_SX_LATCH.}, ""); |
| 1307 | rw_latch= RW_X_LATCHcxx . . $ RW_X_LATCH.; |
| 1308 | mtr->lock_registercxx . . $ mtr_t#lock_register(9cd57bca12b7bf30).(block_savepoint, MTR_MEMO_PAGE_X_FIXcxx . . $ MTR_MEMO_PAGE_X_FIX.); |
| 1309 | block->pagecxx . . $ buf_block_t#page..lockcxx . . $ buf_page_t#lock..u_x_upgradecxx . . $ sux_lock#u_x_upgrade(49f6e7a06ebc5aa8).(); |
| 1310 | break; |
| 1311 | case RW_X_LATCHcxx . . $ RW_X_LATCH.: |
| 1312 | if (latch_mode == BTR_MODIFY_TREEcxx . . $ BTR_MODIFY_TREE.) |
| 1313 | goto reached_index_root_and_leaf; |
| 1314 | break; |
| 1315 | case RW_NO_LATCHcxx . . $ RW_NO_LATCH.: |
| 1316 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(0); |
| 1317 | } |
| 1318 | goto reached_root_and_leaf; |
| 1319 | } |
| 1320 | } |
| 1321 | else if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(height != page_level)) |
| 1322 | goto corrupted; |
| 1323 | else |
| 1324 | switch (latch_mode) { |
| 1325 | case BTR_MODIFY_TREEcxx . . $ BTR_MODIFY_TREE.: |
| 1326 | break; |
| 1327 | case BTR_MODIFY_ROOT_AND_LEAFcxx . . $ BTR_MODIFY_ROOT_AND_LEAF.: |
| 1328 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!((mtr->at_savepoint(block_savepoint - 1)->page.id().page_no() == |
| 1329 | index()->page) == (tree_height <= height + 2)); |
| 1330 | if (tree_heightcxx . . $ btr_cur_t#tree_height. <= height + 2) |
| 1331 | /* Retain the root page latch. */ |
| 1332 | break; |
| 1333 | /* fall through */ |
| 1334 | default: |
| 1335 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(block_savepoint > savepoint); |
| 1336 | mtr->rollback_to_savepointcxx . . $ mtr_t#rollback_to_savepoint(6714b5f2551eea49).(block_savepoint - 1, block_savepoint); |
| 1337 | block_savepoint--; |
| 1338 | } |
| 1339 | |
| 1340 | if (!height) |
| 1341 | { |
| 1342 | /* We reached the leaf level. */ |
| 1343 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(block == mtr->at_savepoint(block_savepoint)); |
| 1344 | |
| 1345 | if (latch_mode == BTR_MODIFY_ROOT_AND_LEAFcxx . . $ BTR_MODIFY_ROOT_AND_LEAF.) |
| 1346 | { |
| 1347 | reached_root_and_leaf: |
| 1348 | if (!latch_by_caller) |
| 1349 | mtr->rollback_to_savepointcxx . . $ mtr_t#rollback_to_savepoint(6714b5f2551eea49).(savepoint, savepoint + 1); |
| 1350 | reached_index_root_and_leaf: |
| 1351 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rw_latch == RW_X_LATCH); |
| 1352 | btr_search_drop_page_hash_indexcxx . . $ btr_search_drop_page_hash_index(33307f3566ecc1a8).(block, indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).()); |
| 1353 | if (page_cur_search_with_matchcxx . . $ page_cur_search_with_match(2a162131057c114d).(tuple, mode, &up_matchcxx . . $ btr_cur_t#up_match., &low_matchcxx . . $ btr_cur_t#low_match., |
| 1354 | &page_curcxx . . $ btr_cur_t#page_cur., nullptr)) |
| 1355 | goto corrupted; |
| 1356 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(up_match != uint16_t(~0U) || mode != PAGE_CUR_GE); |
| 1357 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(up_match != uint16_t(~0U) || mode != PAGE_CUR_LE); |
| 1358 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(low_match != uint16_t(~0U) || mode != PAGE_CUR_LE); |
| 1359 | goto func_exit; |
| 1360 | } |
| 1361 | |
| 1362 | switch (latch_mode) { |
| 1363 | case BTR_SEARCH_PREVcxx . . $ BTR_SEARCH_PREV.: /* btr_pcur_move_to_prev() */ |
| 1364 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!latch_by_caller); |
| 1365 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rw_latch == RW_S_LATCH); |
| 1366 | |
| 1367 | /* latch also siblings from left to right */ |
| 1368 | if (page_has_prevcxx . . $ page_has_prev(190063cf6fb4afb1).(block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.) && |
| 1369 | !btr_latch_prevcxx . . $ btr_latch_prev(d1651efd08c7b088).(rw_latch, page_id, &err, mtr)) |
| 1370 | goto func_exit; |
| 1371 | if (page_has_nextcxx . . $ page_has_next(190063cf6fb4afb1).(block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.) && |
| 1372 | !btr_block_getcxx . . $ btr_block_get(fa2ba45a54fcd0c4).(*indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).(), btr_page_get_nextcxx . . $ btr_page_get_next(ca1608e2c87725e2).(block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.), |
| 1373 | rw_latch, mtr, &err)) |
| 1374 | goto func_exit; |
| 1375 | goto release_tree; |
| 1376 | case BTR_SEARCH_LEAFcxx . . $ BTR_SEARCH_LEAF.: |
| 1377 | case BTR_MODIFY_LEAFcxx . . $ BTR_MODIFY_LEAF.: |
| 1378 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rw_latch == rw_lock_type_t(latch_mode)); |
| 1379 | if (!latch_by_caller) |
| 1380 | { |
| 1381 | release_tree: |
| 1382 | /* Release the tree s-latch */ |
| 1383 | block_savepoint--; |
| 1384 | mtr->rollback_to_savepointcxx . . $ mtr_t#rollback_to_savepoint(6714b5f2551eea49).(savepoint, savepoint + 1); |
| 1385 | } |
| 1386 | /* release upper blocks */ |
| 1387 | if (savepoint < block_savepoint) |
| 1388 | mtr->rollback_to_savepointcxx . . $ mtr_t#rollback_to_savepoint(6714b5f2551eea49).(savepoint, block_savepoint); |
| 1389 | break; |
| 1390 | default: |
| 1391 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(latch_mode == BTR_MODIFY_TREE); |
| 1392 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rw_latch == RW_X_LATCH); |
| 1393 | /* x-latch also siblings from left to right */ |
| 1394 | if (page_has_prevcxx . . $ page_has_prev(190063cf6fb4afb1).(block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.) && |
| 1395 | !btr_latch_prevcxx . . $ btr_latch_prev(d1651efd08c7b088).(rw_latch, page_id, &err, mtr)) |
| 1396 | goto func_exit; |
| 1397 | if (page_has_nextcxx . . $ page_has_next(190063cf6fb4afb1).(block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.) && |
| 1398 | !btr_block_getcxx . . $ btr_block_get(fa2ba45a54fcd0c4).(*indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).(), btr_page_get_nextcxx . . $ btr_page_get_next(ca1608e2c87725e2).(block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.), |
| 1399 | RW_X_LATCHcxx . . $ RW_X_LATCH., mtr, &err)) |
| 1400 | goto func_exit; |
| 1401 | } |
| 1402 | |
| 1403 | reached_latched_leaf: |
| 1404 | if (!(tuple->info_bitscxx . . $ dtuple_t#info_bits. & REC_INFO_MIN_REC_FLAGcxx . . $ `storage/innobase/include/data0type.h:504:9`!)) |
| 1405 | { |
| 1406 | if (page_cur_search_with_match_bytescxx . . $ page_cur_search_with_match_bytes(a185096593c5ab83).(*tuple, mode, &up_matchcxx . . $ btr_cur_t#up_match., &low_matchcxx . . $ btr_cur_t#low_match., |
| 1407 | &page_curcxx . . $ btr_cur_t#page_cur., &up_bytescxx . . $ btr_cur_t#up_bytes., &low_bytescxx . . $ btr_cur_t#low_bytes.)) |
| 1408 | goto corrupted; |
| 1409 | } |
| 1410 | else if (page_cur_search_with_matchcxx . . $ page_cur_search_with_match(2a162131057c114d).(tuple, mode, &up_matchcxx . . $ btr_cur_t#up_match., &low_matchcxx . . $ btr_cur_t#low_match., |
| 1411 | &page_curcxx . . $ btr_cur_t#page_cur., nullptr)) |
| 1412 | goto corrupted; |
| 1413 | |
| 1414 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(up_match != uint16_t(~0U) || mode != PAGE_CUR_GE); |
| 1415 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(up_match != uint16_t(~0U) || mode != PAGE_CUR_LE); |
| 1416 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(low_match != uint16_t(~0U) || mode != PAGE_CUR_LE); |
| 1417 | |
| 1418 | if (latch_mode == BTR_MODIFY_TREEcxx . . $ BTR_MODIFY_TREE. && |
| 1419 | btr_cur_need_opposite_intentioncxx . . $ btr_cur_need_opposite_intention(256c00016b8e20d9).(block->pagecxx . . $ buf_block_t#page., indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).()->is_clustcxx . . $ dict_index_t#is_clust(50ce9a9e25b4a850).(), |
| 1420 | lock_intention, |
| 1421 | node_ptr_max_size, compress_limit, |
| 1422 | page_curcxx . . $ btr_cur_t#page_cur..reccxx . . $ page_cur_t#rec.)) |
| 1423 | goto need_opposite_intention; |
| 1424 | |
| 1425 | #ifdef BTR_CUR_HASH_ADAPTcxx . . $ `<built-in>:481:9`! |
| 1426 | if (flagcxx . . $ btr_cur_t#flag. != BTR_CUR_BINARYcxx . . $ BTR_CUR_BINARY.) |
| 1427 | { |
| 1428 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!(tuple->info_bits & REC_INFO_MIN_REC_FLAG)); |
| 1429 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!index()->table->is_temporary()); |
| 1430 | if (!rec_is_metadatacxx . . $ rec_is_metadata(5dcd923c19b1cb7d).(page_curcxx . . $ btr_cur_t#page_cur..reccxx . . $ page_cur_t#rec., *indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).()) && |
| 1431 | indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).()->search_infocxx . . $ dict_index_t#search_info..hash_analysis_usefulcxx . . $ dict_index_t#ahi#hash_analysis_useful(77ce49a7840d23c7).()) |
| 1432 | search_info_updatecxx . . $ btr_cur_t#search_info_update(a29b2018d437c6ed).(); |
| 1433 | } |
| 1434 | #endif /* BTR_CUR_HASH_ADAPT */ |
| 1435 | |
| 1436 | goto func_exit; |
| 1437 | } |
| 1438 | |
| 1439 | guess= nullptr; |
| 1440 | if (page_cur_search_with_matchcxx . . $ page_cur_search_with_match(2a162131057c114d).(tuple, page_mode, &up_matchcxx . . $ btr_cur_t#up_match., &low_matchcxx . . $ btr_cur_t#low_match., |
| 1441 | &page_curcxx . . $ btr_cur_t#page_cur., nullptr)) |
| 1442 | goto corrupted; |
| 1443 | offsets= rec_get_offsetscxx . . $ `storage/innobase/include/rem0rec.h:475:10`!(page_cur.rec, index(), offsets, 0, ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!, |
| 1444 | &heap); |
| 1445 | |
| 1446 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(block == mtr->at_savepoint(block_savepoint)); |
| 1447 | |
| 1448 | switch (latch_mode) { |
| 1449 | default: |
| 1450 | break; |
| 1451 | case BTR_MODIFY_TREEcxx . . $ BTR_MODIFY_TREE.: |
| 1452 | if (btr_cur_need_opposite_intentioncxx . . $ btr_cur_need_opposite_intention(256c00016b8e20d9).(block->pagecxx . . $ buf_block_t#page., indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).()->is_clustcxx . . $ dict_index_t#is_clust(50ce9a9e25b4a850).(), |
| 1453 | lock_intention, |
| 1454 | node_ptr_max_size, compress_limit, |
| 1455 | page_curcxx . . $ btr_cur_t#page_cur..reccxx . . $ page_cur_t#rec.)) |
| 1456 | /* If the rec is the first or last in the page for pessimistic |
| 1457 | delete intention, it might cause node_ptr insert for the upper |
| 1458 | level. We should change the intention and retry. */ |
| 1459 | need_opposite_intention: |
| 1460 | return pessimistic_search_leafcxx . . $ btr_cur_t#pessimistic_search_leaf(786aa8029f3acc8).(tuple, mode, mtr); |
| 1461 | |
| 1462 | if (detected_same_key_root || lock_intention != BTR_INTENTION_BOTHcxx . . $ BTR_INTENTION_BOTH. || |
| 1463 | indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).()->is_uniquecxx . . $ dict_index_t#is_unique(50ce9a9e25b4a850).() || |
| 1464 | (up_matchcxx . . $ btr_cur_t#up_match. <= rec_offs_n_fieldscxx . . $ rec_offs_n_fields(6fce5c29061b60f9).(offsets) && |
| 1465 | low_matchcxx . . $ btr_cur_t#low_match. <= rec_offs_n_fieldscxx . . $ rec_offs_n_fields(6fce5c29061b60f9).(offsets))) |
| 1466 | break; |
| 1467 | |
| 1468 | /* If the first or the last record of the page or the same key |
| 1469 | value to the first record or last record, then another page might |
| 1470 | be chosen when BTR_CONT_MODIFY_TREE. So, the parent page should |
| 1471 | not released to avoiding deadlock with blocking the another search |
| 1472 | with the same key value. */ |
| 1473 | const rec_tcxx . . $ rec_t# *first= |
| 1474 | page_rec_get_next_constcxx . . $ page_rec_get_next_const(e8dc1f8aea836758).(page_get_infimum_reccxx . . $ `storage/innobase/include/page0page.h:531:9`!(block->page.frame)); |
| 1475 | ulintcxx . . $ ulint# matched_fields; |
| 1476 | |
| 1477 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(!first)) |
| 1478 | goto corrupted; |
| 1479 | if (page_curcxx . . $ btr_cur_t#page_cur..reccxx . . $ page_cur_t#rec. == first || |
| 1480 | page_rec_is_lastcxx . . $ page_rec_is_last(27c8776bc8033bc9).(page_curcxx . . $ btr_cur_t#page_cur..reccxx . . $ page_cur_t#rec., block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.)) |
| 1481 | { |
| 1482 | same_key_root: |
| 1483 | detected_same_key_root= true; |
| 1484 | break; |
| 1485 | } |
| 1486 | |
| 1487 | matched_fields= 0; |
| 1488 | offsets2= rec_get_offsetscxx . . $ `storage/innobase/include/rem0rec.h:475:10`!(first, index(), offsets2, 0, ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!, |
| 1489 | &heap); |
| 1490 | cmp_rec_reccxx . . $ cmp_rec_rec(ead216ea62cda37a).(page_curcxx . . $ btr_cur_t#page_cur..reccxx . . $ page_cur_t#rec., first, offsets, offsets2, indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).(), false, |
| 1491 | &matched_fields); |
| 1492 | if (matched_fields >= rec_offs_n_fieldscxx . . $ rec_offs_n_fields(6fce5c29061b60f9).(offsets) - 1) |
| 1493 | goto same_key_root; |
| 1494 | if (const rec_tcxx . . $ rec_t#* last= |
| 1495 | page_rec_get_prev_constcxx . . $ page_rec_get_prev_const(e8dc1f8aea836758).(page_get_supremum_reccxx . . $ `storage/innobase/include/page0page.h:532:9`!(block->page.frame))) |
| 1496 | { |
| 1497 | matched_fields= 0; |
| 1498 | offsets2= rec_get_offsetscxx . . $ `storage/innobase/include/rem0rec.h:475:10`!(last, index(), offsets2, 0, ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!, |
| 1499 | &heap); |
| 1500 | cmp_rec_reccxx . . $ cmp_rec_rec(ead216ea62cda37a).(page_curcxx . . $ btr_cur_t#page_cur..reccxx . . $ page_cur_t#rec., last, offsets, offsets2, indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).(), false, |
| 1501 | &matched_fields); |
| 1502 | if (matched_fields >= rec_offs_n_fieldscxx . . $ rec_offs_n_fields(6fce5c29061b60f9).(offsets) - 1) |
| 1503 | goto same_key_root; |
| 1504 | } |
| 1505 | else |
| 1506 | goto corrupted; |
| 1507 | |
| 1508 | /* Release the non-root parent page unless it may need to be modified. */ |
| 1509 | if (tree_heightcxx . . $ btr_cur_t#tree_height. > height + 1 && |
| 1510 | !btr_cur_will_modify_treecxx . . $ btr_cur_will_modify_tree(2ced6e53d49ba5b0).(indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).(), block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame., lock_intention, |
| 1511 | page_curcxx . . $ btr_cur_t#page_cur..reccxx . . $ page_cur_t#rec., node_ptr_max_size, |
| 1512 | zip_size, mtr)) |
| 1513 | { |
| 1514 | mtr->rollback_to_savepointcxx . . $ mtr_t#rollback_to_savepoint(6714b5f2551eea49).(block_savepoint - 1, block_savepoint); |
| 1515 | block_savepoint--; |
| 1516 | } |
| 1517 | } |
| 1518 | |
| 1519 | /* Go to the child node */ |
| 1520 | page_id.set_page_nocxx . . $ page_id_t#set_page_no(6bab9b75950d6f3).(btr_node_ptr_get_child_page_nocxx . . $ btr_node_ptr_get_child_page_no(9efe0e53bf5e4c88).(page_curcxx . . $ btr_cur_t#page_cur..reccxx . . $ page_cur_t#rec., offsets)); |
| 1521 | |
| 1522 | if (!--height) |
| 1523 | { |
| 1524 | /* We are about to access the leaf level. */ |
| 1525 | |
| 1526 | switch (latch_mode) { |
| 1527 | case BTR_MODIFY_ROOT_AND_LEAFcxx . . $ BTR_MODIFY_ROOT_AND_LEAF.: |
| 1528 | rw_latch= RW_X_LATCHcxx . . $ RW_X_LATCH.; |
| 1529 | break; |
| 1530 | case BTR_SEARCH_PREVcxx . . $ BTR_SEARCH_PREV.: /* btr_pcur_move_to_prev() */ |
| 1531 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rw_latch == RW_S_LATCH); |
| 1532 | |
| 1533 | if (!not_first_access) |
| 1534 | buf_read_ahead_linearcxx . . $ buf_read_ahead_linear(3269ed12c418f19c).(page_id); |
| 1535 | |
| 1536 | if (page_has_prevcxx . . $ page_has_prev(190063cf6fb4afb1).(block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.) && |
| 1537 | page_rec_is_firstcxx . . $ page_rec_is_first(27c8776bc8033bc9).(page_curcxx . . $ btr_cur_t#page_cur..reccxx . . $ page_cur_t#rec., block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.)) |
| 1538 | { |
| 1539 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(block_savepoint + 1 == mtr->get_savepoint()); |
| 1540 | |
| 1541 | /* Latch the previous page if the node pointer is the leftmost |
| 1542 | of the current page. */ |
| 1543 | int ret= btr_latch_prevcxx . . $ btr_latch_prev(d1651efd08c7b088).(rw_latch, page_id, &err, mtr); |
| 1544 | if (!ret) |
| 1545 | goto func_exit; |
| 1546 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(block_savepoint + 2 == mtr->get_savepoint()); |
| 1547 | if (ret < 0) |
| 1548 | { |
| 1549 | up_matchcxx . . $ btr_cur_t#up_match.= 0, low_matchcxx . . $ btr_cur_t#low_match.= 0, up_bytescxx . . $ btr_cur_t#up_bytes.= 0, low_bytescxx . . $ btr_cur_t#low_bytes.= 0; |
| 1550 | /* While our latch on the level-2 page prevents splits or |
| 1551 | merges of this level-1 block, other threads may have |
| 1552 | modified it due to splitting or merging some level-0 (leaf) |
| 1553 | pages underneath it. Thus, we must search again. */ |
| 1554 | if (page_cur_search_with_matchcxx . . $ page_cur_search_with_match(2a162131057c114d).(tuple, page_mode, |
| 1555 | &up_matchcxx . . $ btr_cur_t#up_match., &low_matchcxx . . $ btr_cur_t#low_match., |
| 1556 | &page_curcxx . . $ btr_cur_t#page_cur., nullptr)) |
| 1557 | goto corrupted; |
| 1558 | offsets= rec_get_offsetscxx . . $ `storage/innobase/include/rem0rec.h:475:10`!(page_cur.rec, index(), offsets, 0, |
| 1559 | ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!, &heap); |
| 1560 | page_id.set_page_nocxx . . $ page_id_t#set_page_no(6bab9b75950d6f3).(btr_node_ptr_get_child_page_nocxx . . $ btr_node_ptr_get_child_page_no(9efe0e53bf5e4c88).(page_curcxx . . $ btr_cur_t#page_cur..reccxx . . $ page_cur_t#rec., |
| 1561 | offsets)); |
| 1562 | } |
| 1563 | } |
| 1564 | rw_latch= rw_lock_type_tcxx . . $ rw_lock_type_t#(latch_mode & (RW_X_LATCHcxx . . $ RW_X_LATCH. | RW_S_LATCHcxx . . $ RW_S_LATCH.)); |
| 1565 | break; |
| 1566 | case BTR_MODIFY_LEAFcxx . . $ BTR_MODIFY_LEAF.: |
| 1567 | case BTR_SEARCH_LEAFcxx . . $ BTR_SEARCH_LEAF.: |
| 1568 | rw_latch= rw_lock_type_tcxx . . $ rw_lock_type_t#(latch_mode); |
| 1569 | if (!not_first_access) |
| 1570 | buf_read_ahead_linearcxx . . $ buf_read_ahead_linear(3269ed12c418f19c).(page_id); |
| 1571 | break; |
| 1572 | case BTR_MODIFY_TREEcxx . . $ BTR_MODIFY_TREE.: |
| 1573 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rw_latch == RW_X_LATCH); |
| 1574 | |
| 1575 | if (lock_intention == BTR_INTENTION_INSERTcxx . . $ BTR_INTENTION_INSERT. && |
| 1576 | page_has_nextcxx . . $ page_has_next(190063cf6fb4afb1).(block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.) && |
| 1577 | page_rec_is_lastcxx . . $ page_rec_is_last(27c8776bc8033bc9).(page_curcxx . . $ btr_cur_t#page_cur..reccxx . . $ page_cur_t#rec., block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.)) |
| 1578 | { |
| 1579 | /* btr_insert_into_right_sibling() might cause deleting node_ptr |
| 1580 | at upper level */ |
| 1581 | mtr->rollback_to_savepointcxx . . $ mtr_t#rollback_to_savepoint(2c44cd906ae4e829).(block_savepoint); |
| 1582 | goto need_opposite_intention; |
| 1583 | } |
| 1584 | break; |
| 1585 | default: |
| 1586 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rw_latch == RW_X_LATCH); |
| 1587 | } |
| 1588 | } |
| 1589 | |
| 1590 | goto search_loop; |
| 1591 | } |
| 1592 | |
| 1593 | ATTRIBUTE_COLDcxx . . $ `include/my_compiler.h:166:10`! void mtr_tcxx . . $ mtr_t#::index_lock_upgradecxx . . $ mtr_t#index_lock_upgrade(49f6e7a06ebc5aa8).() |
| 1594 | { |
| 1595 | auto &slot= m_memocxx . . $ mtr_t#m_memo.[cxx . . $ small_vector#`operator[]`(b18cc97d22f46aed).get_savepointcxx . . $ mtr_t#get_savepoint(fe4d2d262d4164a8).() - 1]; |
| 1596 | if (slot.typecxx . . $ mtr_memo_slot_t#type. == MTR_MEMO_X_LOCKcxx . . $ MTR_MEMO_X_LOCK.) |
| 1597 | return; |
| 1598 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(slot.type == MTR_MEMO_SX_LOCK); |
| 1599 | index_lockcxx . . $ index_lock# *lock= static_cast<index_lockcxx . . $ index_lock#*>(slot.objectcxx . . $ mtr_memo_slot_t#object.); |
| 1600 | lock->u_x_upgradecxx . . $ sux_lock#u_x_upgrade(b51963283f2467a4).(SRW_LOCK_CALLcxx . . $ `storage/innobase/include/srw_lock.h:44:10`!); |
| 1601 | slot.typecxx . . $ mtr_memo_slot_t#type.= MTR_MEMO_X_LOCKcxx . . $ MTR_MEMO_X_LOCK.; |
| 1602 | } |
| 1603 | |
| 1604 | /** Mark a non-leaf page "least recently used", but avoid invoking |
| 1605 | buf_page_t::set_accessed(), because we do not want linear read-ahead */ |
| 1606 | static void btr_cur_nonleaf_make_youngcxx . . $ btr_cur_nonleaf_make_young(39533d69fbc54927).(buf_page_tcxx . . $ buf_page_t# *bpage) |
| 1607 | { |
| 1608 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(buf_page_peek_if_too_old(bpage))) |
| 1609 | buf_page_make_youngcxx . . $ buf_page_make_young(39533d69fbc54927).(bpage); |
| 1610 | } |
| 1611 | |
| 1612 | ATTRIBUTE_COLDcxx . . $ `include/my_compiler.h:166:10`! |
| 1613 | dberr_tcxx . . $ dberr_t# btr_cur_tcxx . . $ btr_cur_t#::pessimistic_search_leafcxx . . $ btr_cur_t#pessimistic_search_leaf(786aa8029f3acc8).(const dtuple_tcxx . . $ dtuple_t# *tuple, |
| 1614 | page_cur_mode_tcxx . . $ page_cur_mode_t# mode, mtr_tcxx . . $ mtr_t# *mtr) |
| 1615 | { |
| 1616 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(index()->is_btree()); |
| 1617 | |
| 1618 | rec_offscxx . . $ rec_offs# offsets_[REC_OFFS_NORMAL_SIZEcxx . . $ REC_OFFS_NORMAL_SIZE.]; |
| 1619 | rec_offscxx . . $ rec_offs#* offsets= offsets_; |
| 1620 | rec_offs_initcxx . . $ `storage/innobase/include/rem0rec.h:844:9`!(offsets_); |
| 1621 | |
| 1622 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(flag == BTR_CUR_BINARY); |
| 1623 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(dict_index_check_search_tuple(index(), tuple)); |
| 1624 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(dtuple_check_typed(tuple)); |
| 1625 | buf_block_tcxx . . $ buf_block_t# *block= mtr->at_savepointcxx . . $ mtr_t#at_savepoint(af74c280cb0dfd96).(1); |
| 1626 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(block->page.id().page_no() == index()->page); |
| 1627 | block->pagecxx . . $ buf_block_t#page..fixcxx . . $ buf_page_t#fix(6e3776fd289463bb).(); |
| 1628 | mtr->rollback_to_savepointcxx . . $ mtr_t#rollback_to_savepoint(2c44cd906ae4e829).(1); |
| 1629 | mtr->index_lock_upgradecxx . . $ mtr_t#index_lock_upgrade(49f6e7a06ebc5aa8).(); |
| 1630 | |
| 1631 | const page_cur_mode_tcxx . . $ page_cur_mode_t# page_mode{btr_cur_nonleaf_modecxx . . $ btr_cur_nonleaf_mode(61e4b25c51d635cf).(mode)}; |
| 1632 | |
| 1633 | mtr->page_lockcxx . . $ mtr_t#page_lock(808a081fc1deebc8).(block, RW_X_LATCHcxx . . $ RW_X_LATCH.); |
| 1634 | btr_search_drop_page_hash_indexcxx . . $ btr_search_drop_page_hash_index(33307f3566ecc1a8).(block, indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).()); |
| 1635 | |
| 1636 | up_matchcxx . . $ btr_cur_t#up_match.= 0; |
| 1637 | up_bytescxx . . $ btr_cur_t#up_bytes.= 0; |
| 1638 | low_matchcxx . . $ btr_cur_t#low_match.= 0; |
| 1639 | low_bytescxx . . $ btr_cur_t#low_bytes.= 0; |
| 1640 | ulintcxx . . $ ulint# height= btr_page_get_levelcxx . . $ btr_page_get_level(469dcb4e54b221a8).(block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.); |
| 1641 | tree_heightcxx . . $ btr_cur_t#tree_height.= height + 1; |
| 1642 | mem_heap_tcxx . . $ mem_heap_t# *heap= nullptr; |
| 1643 | |
| 1644 | search_loop: |
| 1645 | dberr_tcxx . . $ dberr_t# err; |
| 1646 | page_curcxx . . $ btr_cur_t#page_cur..blockcxx . . $ page_cur_t#block.= block; |
| 1647 | |
| 1648 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(!height)) |
| 1649 | { |
| 1650 | if (page_cur_search_with_matchcxx . . $ page_cur_search_with_match(2a162131057c114d).(tuple, mode, &up_matchcxx . . $ btr_cur_t#up_match., &low_matchcxx . . $ btr_cur_t#low_match., |
| 1651 | &page_curcxx . . $ btr_cur_t#page_cur., nullptr)) |
| 1652 | corrupted: |
| 1653 | err= DB_CORRUPTIONcxx . . $ DB_CORRUPTION.; |
| 1654 | else |
| 1655 | { |
| 1656 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(up_match != uint16_t(~0U) || mode != PAGE_CUR_GE); |
| 1657 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(up_match != uint16_t(~0U) || mode != PAGE_CUR_LE); |
| 1658 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(low_match != uint16_t(~0U) || mode != PAGE_CUR_LE); |
| 1659 | |
| 1660 | #ifdef BTR_CUR_HASH_ADAPTcxx . . $ `<built-in>:481:9`! |
| 1661 | /* We do a dirty read of btr_search.enabled here. We will recheck in |
| 1662 | btr_search_build_page_hash_index() before building a page hash |
| 1663 | index, while holding search latch. */ |
| 1664 | if (!btr_searchcxx . . $ btr_search..enabledcxx . . $ btr_sea#enabled.); |
| 1665 | else if (tuple->info_bitscxx . . $ dtuple_t#info_bits. & REC_INFO_MIN_REC_FLAGcxx . . $ `storage/innobase/include/data0type.h:504:9`!) |
| 1666 | /* This may be a search tuple for btr_pcur_t::restore_position(). */ |
| 1667 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(tuple->is_metadata() || |
| 1668 | (tuple->is_metadata(tuple->info_bits ^ REC_STATUS_INSTANT))); |
| 1669 | else if (indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).()->tablecxx . . $ dict_index_t#table.->is_temporarycxx . . $ dict_table_t#is_temporary(50ce9a9e25b4a850).()); |
| 1670 | else if (!rec_is_metadatacxx . . $ rec_is_metadata(5dcd923c19b1cb7d).(page_curcxx . . $ btr_cur_t#page_cur..reccxx . . $ page_cur_t#rec., *indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).()) && |
| 1671 | indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).()->search_infocxx . . $ dict_index_t#search_info..hash_analysis_usefulcxx . . $ dict_index_t#ahi#hash_analysis_useful(77ce49a7840d23c7).()) |
| 1672 | search_info_updatecxx . . $ btr_cur_t#search_info_update(a29b2018d437c6ed).(); |
| 1673 | #endif /* BTR_CUR_HASH_ADAPT */ |
| 1674 | err= DB_SUCCESScxx . . $ DB_SUCCESS.; |
| 1675 | } |
| 1676 | |
| 1677 | func_exit: |
| 1678 | if (UNIV_LIKELY_NULLcxx . . $ `storage/innobase/include/univ.i:393:10`!(heap)) |
| 1679 | mem_heap_freecxx . . $ mem_heap_free(5231cf397463bfab).(heap); |
| 1680 | return err; |
| 1681 | } |
| 1682 | |
| 1683 | if (page_cur_search_with_matchcxx . . $ page_cur_search_with_match(2a162131057c114d).(tuple, page_mode, &up_matchcxx . . $ btr_cur_t#up_match., &low_matchcxx . . $ btr_cur_t#low_match., |
| 1684 | &page_curcxx . . $ btr_cur_t#page_cur., nullptr)) |
| 1685 | goto corrupted; |
| 1686 | |
| 1687 | page_id_tcxx . . $ page_id_t# page_id{block->pagecxx . . $ buf_block_t#page..idcxx . . $ buf_page_t#id(9d40bbb65128eac8).()}; |
| 1688 | |
| 1689 | offsets= rec_get_offsetscxx . . $ `storage/innobase/include/rem0rec.h:475:10`!(page_cur.rec, index(), offsets, 0, ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!, |
| 1690 | &heap); |
| 1691 | /* Go to the child node */ |
| 1692 | page_id.set_page_nocxx . . $ page_id_t#set_page_no(6bab9b75950d6f3).(btr_node_ptr_get_child_page_nocxx . . $ btr_node_ptr_get_child_page_no(9efe0e53bf5e4c88).(page_curcxx . . $ btr_cur_t#page_cur..reccxx . . $ page_cur_t#rec., offsets)); |
| 1693 | |
| 1694 | block= |
| 1695 | buf_page_get_gencxx . . $ buf_page_get_gen(4cc82125c68d4d05).(page_id, block->zip_sizecxx . . $ buf_block_t#zip_size(c9b1e749b64d5edc).(), RW_X_LATCHcxx . . $ RW_X_LATCH., nullptr, BUF_GETcxx . . $ `storage/innobase/include/buf0buf.h:53:9`!, |
| 1696 | mtr, &err); |
| 1697 | |
| 1698 | if (!block) |
| 1699 | { |
| 1700 | btr_read_failedcxx . . $ btr_read_failed(5cd27334cb9550f7).(err, *indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).()); |
| 1701 | goto func_exit; |
| 1702 | } |
| 1703 | |
| 1704 | btr_search_drop_page_hash_indexcxx . . $ btr_search_drop_page_hash_index(33307f3566ecc1a8).(block, indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).()); |
| 1705 | |
| 1706 | if (!!page_is_compcxx . . $ page_is_comp(f3688bc2ee54ea05).(block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.) != indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).()->tablecxx . . $ dict_index_t#table.->not_redundantcxx . . $ dict_table_t#not_redundant(50ce9a9e25b4a850).() || |
| 1707 | btr_page_get_index_idcxx . . $ btr_page_get_index_id(b191ace3c5bffbd9).(block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.) != indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).()->idcxx . . $ dict_index_t#id. || |
| 1708 | fil_page_get_typecxx . . $ fil_page_get_type(422f7ec86fa2a2fb).(block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.) == FIL_PAGE_RTREEcxx . . $ FIL_PAGE_RTREE. || |
| 1709 | !fil_page_index_page_checkcxx . . $ `storage/innobase/include/fil0fil.h:1357:9`!(block->page.frame)) |
| 1710 | goto corrupted; |
| 1711 | |
| 1712 | if (--height != btr_page_get_levelcxx . . $ btr_page_get_level(469dcb4e54b221a8).(block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.)) |
| 1713 | goto corrupted; |
| 1714 | |
| 1715 | btr_cur_nonleaf_make_youngcxx . . $ btr_cur_nonleaf_make_young(39533d69fbc54927).(&block->pagecxx . . $ buf_block_t#page.); |
| 1716 | |
| 1717 | #ifdef UNIV_ZIP_DEBUG |
| 1718 | const page_zip_des_t *page_zip= buf_block_get_page_zip(block); |
| 1719 | ut_a(!page_zip || page_zip_validate(page_zip, block->page.frame, index())); |
| 1720 | #endif /* UNIV_ZIP_DEBUG */ |
| 1721 | |
| 1722 | if (page_has_prevcxx . . $ page_has_prev(190063cf6fb4afb1).(block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.) && |
| 1723 | !btr_latch_prevcxx . . $ btr_latch_prev(d1651efd08c7b088).(RW_X_LATCHcxx . . $ RW_X_LATCH., page_id, &err, mtr)) |
| 1724 | goto func_exit; |
| 1725 | if (page_has_nextcxx . . $ page_has_next(190063cf6fb4afb1).(block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.) && |
| 1726 | !btr_block_getcxx . . $ btr_block_get(fa2ba45a54fcd0c4).(*indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).(), btr_page_get_nextcxx . . $ btr_page_get_next(ca1608e2c87725e2).(block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.), |
| 1727 | RW_X_LATCHcxx . . $ RW_X_LATCH., mtr, &err)) |
| 1728 | goto func_exit; |
| 1729 | goto search_loop; |
| 1730 | } |
| 1731 | |
| 1732 | /********************************************************************//** |
| 1733 | Searches an index tree and positions a tree cursor on a given non-leaf level. |
| 1734 | NOTE: n_fields_cmp in tuple must be set so that it cannot be compared |
| 1735 | to node pointer page number fields on the upper levels of the tree! |
| 1736 | cursor->up_match and cursor->low_match both will have sensible values. |
| 1737 | Cursor is left at the place where an insert of the |
| 1738 | search tuple should be performed in the B-tree. InnoDB does an insert |
| 1739 | immediately after the cursor. Thus, the cursor may end up on a user record, |
| 1740 | or on a page infimum record. |
| 1741 | @param level the tree level of search |
| 1742 | @param tuple data tuple; NOTE: n_fields_cmp in tuple must be set so that |
| 1743 | it cannot get compared to the node ptr page number field! |
| 1744 | @param latch RW_S_LATCH or RW_X_LATCH |
| 1745 | @param cursor tree cursor; the cursor page is s- or x-latched, but see also |
| 1746 | above! |
| 1747 | @param mtr mini-transaction |
| 1748 | @return DB_SUCCESS on success or error code otherwise */ |
| 1749 | dberr_tcxx . . $ dberr_t# btr_cur_search_to_nth_levelcxx . . $ btr_cur_search_to_nth_level(59eb7917f67212e).(ulintcxx . . $ ulint# level, |
| 1750 | const dtuple_tcxx . . $ dtuple_t# *tuple, |
| 1751 | rw_lock_type_tcxx . . $ rw_lock_type_t# rw_latch, |
| 1752 | btr_cur_tcxx . . $ btr_cur_t# *cursor, mtr_tcxx . . $ mtr_t# *mtr) |
| 1753 | { |
| 1754 | dict_index_tcxx . . $ dict_index_t# *const index= cursor->indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).(); |
| 1755 | |
| 1756 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(index->is_btree()); |
| 1757 | mem_heap_tcxx . . $ mem_heap_t# *heap= nullptr; |
| 1758 | rec_offscxx . . $ rec_offs# offsets_[REC_OFFS_NORMAL_SIZEcxx . . $ REC_OFFS_NORMAL_SIZE.]; |
| 1759 | rec_offscxx . . $ rec_offs# *offsets= offsets_; |
| 1760 | rec_offs_initcxx . . $ `storage/innobase/include/rem0rec.h:844:9`!(offsets_); |
| 1761 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(level); |
| 1762 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(dict_index_check_search_tuple(index, tuple)); |
| 1763 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(index->is_btree()); |
| 1764 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(dtuple_check_typed(tuple)); |
| 1765 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(index->page != FIL_NULL); |
| 1766 | |
| 1767 | MEM_UNDEFINEDcxx . . $ `include/my_valgrind.h:67:10`!(&cursor->up_bytes, sizeof cursor->up_bytes); |
| 1768 | MEM_UNDEFINEDcxx . . $ `include/my_valgrind.h:67:10`!(&cursor->low_bytes, sizeof cursor->low_bytes); |
| 1769 | cursor->up_matchcxx . . $ btr_cur_t#up_match.= 0; |
| 1770 | cursor->low_matchcxx . . $ btr_cur_t#low_match.= 0; |
| 1771 | #ifdef BTR_CUR_HASH_ADAPTcxx . . $ `<built-in>:481:9`! |
| 1772 | cursor->flagcxx . . $ btr_cur_t#flag.= BTR_CUR_BINARYcxx . . $ BTR_CUR_BINARY.; |
| 1773 | #endif |
| 1774 | #ifndef BTR_CUR_ADAPTcxx . . $ `<built-in>:480:9`! |
| 1775 | buf_block_t *block= nullptr; |
| 1776 | #else |
| 1777 | buf_block_tcxx . . $ buf_block_t# *block= index->search_infocxx . . $ dict_index_t#search_info..root_guesscxx . . $ dict_index_t#ahi#root_guess.; |
| 1778 | #endif /* BTR_CUR_ADAPT */ |
| 1779 | |
| 1780 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mtr->memo_contains_flagged(&index->lock, |
| 1781 | MTR_MEMO_X_LOCK | MTR_MEMO_SX_LOCK)); |
| 1782 | |
| 1783 | dberr_tcxx . . $ dberr_t# err; |
| 1784 | |
| 1785 | if (!index->tablecxx . . $ dict_index_t#table.->spacecxx . . $ dict_table_t#space.) |
| 1786 | { |
| 1787 | corrupted: |
| 1788 | err= DB_CORRUPTIONcxx . . $ DB_CORRUPTION.; |
| 1789 | func_exit: |
| 1790 | if (UNIV_LIKELY_NULLcxx . . $ `storage/innobase/include/univ.i:393:10`!(heap)) |
| 1791 | mem_heap_freecxx . . $ mem_heap_free(5231cf397463bfab).(heap); |
| 1792 | return err; |
| 1793 | } |
| 1794 | |
| 1795 | const ulintcxx . . $ ulint# zip_size= index->tablecxx . . $ dict_index_t#table.->spacecxx . . $ dict_table_t#space.->zip_sizecxx . . $ fil_space_t#zip_size(d22c8608b6eae7b5).(); |
| 1796 | |
| 1797 | /* Start with the root page. */ |
| 1798 | page_id_tcxx . . $ page_id_t# page_idcxx . . $ page_id_t#page_id_t(b4d55b1286ff73e8).(index->tablecxx . . $ dict_index_t#table.->space_idcxx . . $ dict_table_t#space_id., index->pagecxx . . $ dict_index_t#page.); |
| 1799 | ulintcxx . . $ ulint# height= ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!; |
| 1800 | |
| 1801 | search_loop: |
| 1802 | err= DB_SUCCESScxx . . $ DB_SUCCESS.; |
| 1803 | if (buf_block_tcxx . . $ buf_block_t# *b= |
| 1804 | mtr->get_already_latchedcxx . . $ mtr_t#get_already_latched(c8b94b52f23d581).(page_id, mtr_memo_type_tcxx . . $ mtr_memo_type_t#(rw_latch))) |
| 1805 | block= b; |
| 1806 | else if (!(block= buf_page_get_gencxx . . $ buf_page_get_gen(4cc82125c68d4d05).(page_id, zip_size, rw_latch, |
| 1807 | block, BUF_GETcxx . . $ `storage/innobase/include/buf0buf.h:53:9`!, mtr, &err))) |
| 1808 | { |
| 1809 | btr_read_failedcxx . . $ btr_read_failed(5cd27334cb9550f7).(err, *index); |
| 1810 | goto func_exit; |
| 1811 | } |
| 1812 | else |
| 1813 | { |
| 1814 | btr_search_drop_page_hash_indexcxx . . $ btr_search_drop_page_hash_index(33307f3566ecc1a8).(block, index); |
| 1815 | btr_cur_nonleaf_make_youngcxx . . $ btr_cur_nonleaf_make_young(39533d69fbc54927).(&block->pagecxx . . $ buf_block_t#page.); |
| 1816 | } |
| 1817 | |
| 1818 | #ifdef UNIV_ZIP_DEBUG |
| 1819 | if (const page_zip_des_t *page_zip= buf_block_get_page_zip(block)) |
| 1820 | ut_a(page_zip_validate(page_zip, block->page.frame, index)); |
| 1821 | #endif /* UNIV_ZIP_DEBUG */ |
| 1822 | |
| 1823 | if (!!page_is_compcxx . . $ page_is_comp(f3688bc2ee54ea05).(block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.) != index->tablecxx . . $ dict_index_t#table.->not_redundantcxx . . $ dict_table_t#not_redundant(50ce9a9e25b4a850).() || |
| 1824 | btr_page_get_index_idcxx . . $ btr_page_get_index_id(b191ace3c5bffbd9).(block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.) != index->idcxx . . $ dict_index_t#id. || |
| 1825 | fil_page_get_typecxx . . $ fil_page_get_type(422f7ec86fa2a2fb).(block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.) == FIL_PAGE_RTREEcxx . . $ FIL_PAGE_RTREE. || |
| 1826 | !fil_page_index_page_checkcxx . . $ `storage/innobase/include/fil0fil.h:1357:9`!(block->page.frame)) |
| 1827 | goto corrupted; |
| 1828 | |
| 1829 | const uint32_tcxx . . $ uint32_t# page_level= btr_page_get_levelcxx . . $ btr_page_get_level(469dcb4e54b221a8).(block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.); |
| 1830 | |
| 1831 | if (height == ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!) |
| 1832 | { |
| 1833 | /* We are in the root node */ |
| 1834 | height= page_level; |
| 1835 | if (!height) |
| 1836 | goto corrupted; |
| 1837 | cursor->tree_heightcxx . . $ btr_cur_t#tree_height.= height + 1; |
| 1838 | } |
| 1839 | else if (height != ulintcxx . . $ ulint#{page_level}) |
| 1840 | goto corrupted; |
| 1841 | |
| 1842 | cursor->page_curcxx . . $ btr_cur_t#page_cur..blockcxx . . $ page_cur_t#block.= block; |
| 1843 | |
| 1844 | /* Search for complete index fields. */ |
| 1845 | if (page_cur_search_with_matchcxx . . $ page_cur_search_with_match(2a162131057c114d).(tuple, PAGE_CUR_LEcxx . . $ PAGE_CUR_LE., &cursor->up_matchcxx . . $ btr_cur_t#up_match., |
| 1846 | &cursor->low_matchcxx . . $ btr_cur_t#low_match., &cursor->page_curcxx . . $ btr_cur_t#page_cur., |
| 1847 | nullptr)) |
| 1848 | goto corrupted; |
| 1849 | |
| 1850 | /* If this is the desired level, leave the loop */ |
| 1851 | if (level == height) |
| 1852 | goto func_exit; |
| 1853 | |
| 1854 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(height > level); |
| 1855 | height--; |
| 1856 | |
| 1857 | offsets = rec_get_offsetscxx . . $ `storage/innobase/include/rem0rec.h:475:10`!(cursor->page_cur.rec, index, offsets, 0, |
| 1858 | ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!, &heap); |
| 1859 | /* Go to the child node */ |
| 1860 | page_id.set_page_nocxx . . $ page_id_t#set_page_no(6bab9b75950d6f3).(btr_node_ptr_get_child_page_nocxx . . $ btr_node_ptr_get_child_page_no(9efe0e53bf5e4c88).(cursor->page_curcxx . . $ btr_cur_t#page_cur..reccxx . . $ page_cur_t#rec., |
| 1861 | offsets)); |
| 1862 | block= nullptr; |
| 1863 | goto search_loop; |
| 1864 | } |
| 1865 | |
| 1866 | dberr_tcxx . . $ dberr_t# btr_cur_tcxx . . $ btr_cur_t#::open_leafcxx . . $ btr_cur_t#open_leaf(1d074ecb69eae3b8).(bool first, dict_index_tcxx . . $ dict_index_t# *index, |
| 1867 | btr_latch_modecxx . . $ btr_latch_mode# latch_mode, mtr_tcxx . . $ mtr_t# *mtr) |
| 1868 | { |
| 1869 | ulintcxx . . $ ulint# n_blocks= 0; |
| 1870 | mem_heap_tcxx . . $ mem_heap_t# *heap= nullptr; |
| 1871 | rec_offscxx . . $ rec_offs# offsets_[REC_OFFS_NORMAL_SIZEcxx . . $ REC_OFFS_NORMAL_SIZE.]; |
| 1872 | rec_offscxx . . $ rec_offs# *offsets= offsets_; |
| 1873 | dberr_tcxx . . $ dberr_t# err; |
| 1874 | |
| 1875 | rec_offs_initcxx . . $ `storage/innobase/include/rem0rec.h:844:9`!(offsets_); |
| 1876 | |
| 1877 | const bool latch_by_caller= latch_mode & BTR_ALREADY_S_LATCHEDcxx . . $ BTR_ALREADY_S_LATCHED.; |
| 1878 | latch_mode= btr_latch_modecxx . . $ btr_latch_mode#(latch_mode & ~BTR_ALREADY_S_LATCHEDcxx . . $ BTR_ALREADY_S_LATCHED.); |
| 1879 | |
| 1880 | btr_intention_tcxx . . $ btr_intention_t# lock_intention= btr_cur_get_and_clear_intentioncxx . . $ btr_cur_get_and_clear_intention(7c930369ca6c389e).(&latch_mode); |
| 1881 | |
| 1882 | /* Store the position of the tree latch we push to mtr so that we |
| 1883 | know how to release it when we have latched the leaf node */ |
| 1884 | |
| 1885 | auto savepoint= mtr->get_savepointcxx . . $ mtr_t#get_savepoint(fe4d2d262d4164a8).(); |
| 1886 | |
| 1887 | rw_lock_type_tcxx . . $ rw_lock_type_t# upper_rw_latch= RW_X_LATCHcxx . . $ RW_X_LATCH.; |
| 1888 | ulintcxx . . $ ulint# node_ptr_max_size= 0, compress_limit= 0; |
| 1889 | |
| 1890 | if (latch_mode == BTR_MODIFY_TREEcxx . . $ BTR_MODIFY_TREE.) |
| 1891 | { |
| 1892 | node_ptr_max_size= btr_node_ptr_max_sizecxx . . $ btr_node_ptr_max_size(67f37f56c055bd3e).(index); |
| 1893 | /* Most of delete-intended operations are purging. Free blocks |
| 1894 | and read IO bandwidth should be prioritized for them, when the |
| 1895 | history list is growing huge. */ |
| 1896 | savepoint++; |
| 1897 | if (lock_intention == BTR_INTENTION_DELETEcxx . . $ BTR_INTENTION_DELETE.) |
| 1898 | { |
| 1899 | compress_limit= BTR_CUR_PAGE_COMPRESS_LIMITcxx . . $ `storage/innobase/include/btr0cur.h:616:9`!(index); |
| 1900 | |
| 1901 | if (os_aio_pending_reads_approxcxx . . $ os_aio_pending_reads_approx(cee159cc271e827).() && |
| 1902 | trx_syscxx . . $ trx_sys..history_size_approxcxx . . $ trx_sys_t#history_size_approx(fe4d2d262d4164a8).() > BTR_CUR_FINE_HISTORY_LENGTHcxx . . $ `storage/innobase/btr/btr0cur.cc:87:9`!) |
| 1903 | { |
| 1904 | mtr_x_lock_indexcxx . . $ `storage/innobase/include/mtr0mtr.h:46:10`!(index, mtr); |
| 1905 | goto index_locked; |
| 1906 | } |
| 1907 | } |
| 1908 | mtr_sx_lock_indexcxx . . $ `storage/innobase/include/mtr0mtr.h:47:10`!(index, mtr); |
| 1909 | } |
| 1910 | else |
| 1911 | { |
| 1912 | static_assert(int{BTR_CONT_MODIFY_TREEcxx . . $ BTR_CONT_MODIFY_TREE.} == (12 | BTR_MODIFY_LEAFcxx . . $ BTR_MODIFY_LEAF.), ""); |
| 1913 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!(latch_mode & 8)); |
| 1914 | /* This function doesn't need to lock left page of the leaf page */ |
| 1915 | static_assert(int{BTR_SEARCH_PREVcxx . . $ BTR_SEARCH_PREV.} == (4 | BTR_SEARCH_LEAFcxx . . $ BTR_SEARCH_LEAF.), ""); |
| 1916 | latch_mode= btr_latch_modecxx . . $ btr_latch_mode#(latch_mode & (RW_S_LATCHcxx . . $ RW_S_LATCH. | RW_X_LATCHcxx . . $ RW_X_LATCH.)); |
| 1917 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!latch_by_caller || |
| 1918 | mtr->memo_contains_flagged(&index->lock, |
| 1919 | MTR_MEMO_SX_LOCK | MTR_MEMO_S_LOCK)); |
| 1920 | upper_rw_latch= RW_S_LATCHcxx . . $ RW_S_LATCH.; |
| 1921 | if (!latch_by_caller) |
| 1922 | { |
| 1923 | savepoint++; |
| 1924 | mtr_s_lock_indexcxx . . $ `storage/innobase/include/mtr0mtr.h:45:10`!(index, mtr); |
| 1925 | } |
| 1926 | } |
| 1927 | |
| 1928 | index_locked: |
| 1929 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(savepoint == mtr->get_savepoint()); |
| 1930 | |
| 1931 | const rw_lock_type_tcxx . . $ rw_lock_type_t# root_leaf_rw_latch= |
| 1932 | rw_lock_type_tcxx . . $ rw_lock_type_t#(latch_mode & (RW_S_LATCHcxx . . $ RW_S_LATCH. | RW_X_LATCHcxx . . $ RW_X_LATCH.)); |
| 1933 | |
| 1934 | page_curcxx . . $ btr_cur_t#page_cur..indexcxx . . $ page_cur_t#index. = index; |
| 1935 | |
| 1936 | uint32_tcxx . . $ uint32_t# page= index->pagecxx . . $ dict_index_t#page.; |
| 1937 | |
| 1938 | for (ulintcxx . . $ ulint# height= ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!;;) |
| 1939 | { |
| 1940 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(n_blocks < BTR_MAX_LEVELS); |
| 1941 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(savepoint + n_blocks == mtr->get_savepoint()); |
| 1942 | |
| 1943 | bool first_access= false; |
| 1944 | buf_block_tcxx . . $ buf_block_t#* block= |
| 1945 | btr_block_getcxx . . $ btr_block_get(fa2ba45a54fcd0c4).(*index, page, |
| 1946 | height ? upper_rw_latch : root_leaf_rw_latch, |
| 1947 | mtr, &err, &first_access); |
| 1948 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!block == (err != DB_SUCCESS)); |
| 1949 | |
| 1950 | if (!block) |
| 1951 | break; |
| 1952 | |
| 1953 | if (first) |
| 1954 | page_cur_set_before_firstcxx . . $ page_cur_set_before_first(34f1922d808032bb).(block, &page_curcxx . . $ btr_cur_t#page_cur.); |
| 1955 | else |
| 1956 | page_cur_set_after_lastcxx . . $ page_cur_set_after_last(34f1922d808032bb).(block, &page_curcxx . . $ btr_cur_t#page_cur.); |
| 1957 | |
| 1958 | const uint32_tcxx . . $ uint32_t# l= btr_page_get_levelcxx . . $ btr_page_get_level(469dcb4e54b221a8).(block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.); |
| 1959 | |
| 1960 | if (height == ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!) |
| 1961 | { |
| 1962 | /* We are in the root node */ |
| 1963 | height= l; |
| 1964 | if (height); |
| 1965 | else if (upper_rw_latch != root_leaf_rw_latch) |
| 1966 | { |
| 1967 | /* We should retry to get the page, because the root page |
| 1968 | is latched with different level as a leaf page. */ |
| 1969 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(n_blocks == 0); |
| 1970 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(root_leaf_rw_latch != RW_NO_LATCH); |
| 1971 | upper_rw_latch= root_leaf_rw_latch; |
| 1972 | mtr->rollback_to_savepointcxx . . $ mtr_t#rollback_to_savepoint(2c44cd906ae4e829).(savepoint); |
| 1973 | height= ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!; |
| 1974 | continue; |
| 1975 | } |
| 1976 | else |
| 1977 | { |
| 1978 | reached_leaf: |
| 1979 | const auto leaf_savepoint= mtr->get_savepointcxx . . $ mtr_t#get_savepoint(fe4d2d262d4164a8).(); |
| 1980 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(leaf_savepoint); |
| 1981 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(block == mtr->at_savepoint(leaf_savepoint - 1)); |
| 1982 | |
| 1983 | if (latch_mode == BTR_MODIFY_TREEcxx . . $ BTR_MODIFY_TREE.) |
| 1984 | { |
| 1985 | /* x-latch also siblings from left to right */ |
| 1986 | if (page_has_prevcxx . . $ page_has_prev(190063cf6fb4afb1).(block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.) && |
| 1987 | !btr_latch_prevcxx . . $ btr_latch_prev(d1651efd08c7b088).(RW_X_LATCHcxx . . $ RW_X_LATCH., block->pagecxx . . $ buf_block_t#page..idcxx . . $ buf_page_t#id(9d40bbb65128eac8).(), &err, mtr)) |
| 1988 | break; |
| 1989 | if (page_has_nextcxx . . $ page_has_next(190063cf6fb4afb1).(block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.) && |
| 1990 | !btr_block_getcxx . . $ btr_block_get(fa2ba45a54fcd0c4).(*index, btr_page_get_nextcxx . . $ btr_page_get_next(ca1608e2c87725e2).(block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.), |
| 1991 | RW_X_LATCHcxx . . $ RW_X_LATCH., mtr, &err)) |
| 1992 | break; |
| 1993 | |
| 1994 | if (!index->lockcxx . . $ dict_index_t#lock..have_xcxx . . $ sux_lock#have_x(50ce9a9e25b4a850).() && |
| 1995 | btr_cur_need_opposite_intentioncxx . . $ btr_cur_need_opposite_intention(256c00016b8e20d9).(block->pagecxx . . $ buf_block_t#page., index->is_clustcxx . . $ dict_index_t#is_clust(50ce9a9e25b4a850).(), |
| 1996 | lock_intention, |
| 1997 | node_ptr_max_size, |
| 1998 | compress_limit, page_curcxx . . $ btr_cur_t#page_cur..reccxx . . $ page_cur_t#rec.)) |
| 1999 | goto need_opposite_intention; |
| 2000 | } |
| 2001 | else |
| 2002 | { |
| 2003 | if (latch_mode != BTR_CONT_MODIFY_TREEcxx . . $ BTR_CONT_MODIFY_TREE.) |
| 2004 | { |
| 2005 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(latch_mode == BTR_MODIFY_LEAF || |
| 2006 | latch_mode == BTR_SEARCH_LEAF); |
| 2007 | /* Release index->lock if needed, and the non-leaf pages. */ |
| 2008 | mtr->rollback_to_savepointcxx . . $ mtr_t#rollback_to_savepoint(6714b5f2551eea49).(savepoint - !latch_by_caller, |
| 2009 | leaf_savepoint - 1); |
| 2010 | } |
| 2011 | } |
| 2012 | break; |
| 2013 | } |
| 2014 | } |
| 2015 | else if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(height != l)) |
| 2016 | { |
| 2017 | corrupted: |
| 2018 | err= DB_CORRUPTIONcxx . . $ DB_CORRUPTION.; |
| 2019 | break; |
| 2020 | } |
| 2021 | |
| 2022 | if (!height) |
| 2023 | goto reached_leaf; |
| 2024 | |
| 2025 | height--; |
| 2026 | |
| 2027 | if (first |
| 2028 | ? !page_cur_move_to_nextcxx . . $ page_cur_move_to_next(99e08e4d4839908).(&page_curcxx . . $ btr_cur_t#page_cur.) |
| 2029 | : !page_cur_move_to_prevcxx . . $ page_cur_move_to_prev(99e08e4d4839908).(&page_curcxx . . $ btr_cur_t#page_cur.)) |
| 2030 | goto corrupted; |
| 2031 | |
| 2032 | offsets= rec_get_offsetscxx . . $ `storage/innobase/include/rem0rec.h:475:10`!(page_cur.rec, index, offsets, 0, ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!, |
| 2033 | &heap); |
| 2034 | page= btr_node_ptr_get_child_page_nocxx . . $ btr_node_ptr_get_child_page_no(9efe0e53bf5e4c88).(page_curcxx . . $ btr_cur_t#page_cur..reccxx . . $ page_cur_t#rec., offsets); |
| 2035 | |
| 2036 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(latch_mode != BTR_MODIFY_TREE || upper_rw_latch == RW_X_LATCH); |
| 2037 | |
| 2038 | if (latch_mode != BTR_MODIFY_TREEcxx . . $ BTR_MODIFY_TREE.) |
| 2039 | { |
| 2040 | if (!height && first && first_access) |
| 2041 | buf_read_ahead_linearcxx . . $ buf_read_ahead_linear(3269ed12c418f19c).(page_id_tcxx . . $ page_id_t#page_id_t(b4d55b1286ff73e8).(block->pagecxx . . $ buf_block_t#page..idcxx . . $ buf_page_t#id(9d40bbb65128eac8).().spacecxx . . $ page_id_t#space(d22c8608b6eae7b5).(), page)); |
| 2042 | } |
| 2043 | else if (btr_cur_need_opposite_intentioncxx . . $ btr_cur_need_opposite_intention(256c00016b8e20d9).(block->pagecxx . . $ buf_block_t#page., index->is_clustcxx . . $ dict_index_t#is_clust(50ce9a9e25b4a850).(), |
| 2044 | lock_intention, |
| 2045 | node_ptr_max_size, compress_limit, |
| 2046 | page_curcxx . . $ btr_cur_t#page_cur..reccxx . . $ page_cur_t#rec.)) |
| 2047 | { |
| 2048 | need_opposite_intention: |
| 2049 | /* If the rec is the first or last in the page for pessimistic |
| 2050 | delete intention, it might cause node_ptr insert for the upper |
| 2051 | level. We should change the intention and retry. */ |
| 2052 | |
| 2053 | mtr->rollback_to_savepointcxx . . $ mtr_t#rollback_to_savepoint(2c44cd906ae4e829).(savepoint); |
| 2054 | mtr->index_lock_upgradecxx . . $ mtr_t#index_lock_upgrade(49f6e7a06ebc5aa8).(); |
| 2055 | /* X-latch all pages from now on */ |
| 2056 | latch_mode= BTR_CONT_MODIFY_TREEcxx . . $ BTR_CONT_MODIFY_TREE.; |
| 2057 | page= index->pagecxx . . $ dict_index_t#page.; |
| 2058 | height= ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!; |
| 2059 | n_blocks= 0; |
| 2060 | continue; |
| 2061 | } |
| 2062 | else |
| 2063 | { |
| 2064 | if (!btr_cur_will_modify_treecxx . . $ btr_cur_will_modify_tree(2ced6e53d49ba5b0).(index, block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame., |
| 2065 | lock_intention, page_curcxx . . $ btr_cur_t#page_cur..reccxx . . $ page_cur_t#rec., |
| 2066 | node_ptr_max_size, |
| 2067 | index->tablecxx . . $ dict_index_t#table.->spacecxx . . $ dict_table_t#space.->zip_sizecxx . . $ fil_space_t#zip_size(d22c8608b6eae7b5).(), mtr)) |
| 2068 | { |
| 2069 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(n_blocks); |
| 2070 | /* release buffer-fixes on pages that will not be modified |
| 2071 | (except the root) */ |
| 2072 | if (n_blocks > 1) |
| 2073 | { |
| 2074 | mtr->rollback_to_savepointcxx . . $ mtr_t#rollback_to_savepoint(6714b5f2551eea49).(savepoint + 1, savepoint + n_blocks - 1); |
| 2075 | n_blocks= 1; |
| 2076 | } |
| 2077 | } |
| 2078 | } |
| 2079 | |
| 2080 | /* Go to the child node */ |
| 2081 | n_blocks++; |
| 2082 | } |
| 2083 | |
| 2084 | if (UNIV_LIKELY_NULLcxx . . $ `storage/innobase/include/univ.i:393:10`!(heap)) |
| 2085 | mem_heap_freecxx . . $ mem_heap_free(5231cf397463bfab).(heap); |
| 2086 | |
| 2087 | return err; |
| 2088 | } |
| 2089 | |
| 2090 | /*==================== B-TREE INSERT =========================*/ |
| 2091 | |
| 2092 | /*************************************************************//** |
| 2093 | Inserts a record if there is enough space, or if enough space can |
| 2094 | be freed by reorganizing. Differs from btr_cur_optimistic_insert because |
| 2095 | no heuristics is applied to whether it pays to use CPU time for |
| 2096 | reorganizing the page or not. |
| 2097 | |
| 2098 | @return pointer to inserted record if succeed, else NULL */ |
| 2099 | static MY_ATTRIBUTEcxx . . $ `storage/innobase/include/univ.i:162:11`!((nonnull, warn_unused_result)) |
| 2100 | rec_tcxx . . $ rec_t#* |
| 2101 | btr_cur_insert_if_possiblecxx . . $ btr_cur_insert_if_possible(fd94ef7ff56a20ad).( |
| 2102 | /*=======================*/ |
| 2103 | btr_cur_tcxx . . $ btr_cur_t#* cursor, /*!< in: cursor on page after which to insert; |
| 2104 | cursor stays valid */ |
| 2105 | const dtuple_tcxx . . $ dtuple_t#* tuple, /*!< in: tuple to insert; the size info need not |
| 2106 | have been stored to tuple */ |
| 2107 | rec_offscxx . . $ rec_offs#** offsets,/*!< out: offsets on *rec */ |
| 2108 | mem_heap_tcxx . . $ mem_heap_t#** heap, /*!< in/out: pointer to memory heap, or NULL */ |
| 2109 | ulintcxx . . $ ulint# n_ext, /*!< in: number of externally stored columns */ |
| 2110 | mtr_tcxx . . $ mtr_t#* mtr) /*!< in/out: mini-transaction */ |
| 2111 | { |
| 2112 | page_cur_tcxx . . $ page_cur_t#* page_cursor; |
| 2113 | rec_tcxx . . $ rec_t#* rec; |
| 2114 | |
| 2115 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(dtuple_check_typed(tuple)); |
| 2116 | |
| 2117 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mtr->memo_contains_flagged(btr_cur_get_block(cursor), |
| 2118 | MTR_MEMO_PAGE_X_FIX)); |
| 2119 | page_cursor = btr_cur_get_page_curcxx . . $ `storage/innobase/include/btr0cur.h:62:9`!(cursor); |
| 2120 | |
| 2121 | /* Now, try the insert */ |
| 2122 | rec = page_cur_tuple_insertcxx . . $ page_cur_tuple_insert(20b71dd453d7ef65).(page_cursor, tuple, offsets, heap, n_ext, |
| 2123 | mtr); |
| 2124 | |
| 2125 | /* If the record did not fit, reorganize. |
| 2126 | For compressed pages, page_cur_tuple_insert() |
| 2127 | attempted this already. */ |
| 2128 | if (!rec && !page_cur_get_page_zipcxx . . $ `storage/innobase/include/page0cur.h:56:10`!(page_cursor) |
| 2129 | && btr_page_reorganizecxx . . $ btr_page_reorganize(e4b2ea64c1f14b9e).(page_cursor, mtr) == DB_SUCCESScxx . . $ DB_SUCCESS.) { |
| 2130 | rec = page_cur_tuple_insertcxx . . $ page_cur_tuple_insert(20b71dd453d7ef65).(page_cursor, tuple, offsets, heap, |
| 2131 | n_ext, mtr); |
| 2132 | } |
| 2133 | |
| 2134 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!rec || rec_offs_validate(rec, page_cursor->index, *offsets)); |
| 2135 | return(rec); |
| 2136 | } |
| 2137 | |
| 2138 | /*************************************************************//** |
| 2139 | For an insert, checks the locks and does the undo logging if desired. |
| 2140 | @return DB_SUCCESS, DB_LOCK_WAIT, DB_FAIL, or error number */ |
| 2141 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! MY_ATTRIBUTEcxx . . $ `storage/innobase/include/univ.i:162:11`!((warn_unused_result, nonnull(2,3,5,6))) |
| 2142 | dberr_tcxx . . $ dberr_t# |
| 2143 | btr_cur_ins_lock_and_undocxx . . $ btr_cur_ins_lock_and_undo(3861e9270bf5d316).( |
| 2144 | /*======================*/ |
| 2145 | ulintcxx . . $ ulint# flags, /*!< in: undo logging and locking flags: if |
| 2146 | not zero, the parameters index and thr |
| 2147 | should be specified */ |
| 2148 | btr_cur_tcxx . . $ btr_cur_t#* cursor, /*!< in: cursor on page after which to insert */ |
| 2149 | dtuple_tcxx . . $ dtuple_t#* entry, /*!< in/out: entry to insert */ |
| 2150 | que_thr_tcxx . . $ que_thr_t#* thr, /*!< in: query thread or NULL */ |
| 2151 | mtr_tcxx . . $ mtr_t#* mtr, /*!< in/out: mini-transaction */ |
| 2152 | bool* inherit)/*!< out: true if the inserted new record maybe |
| 2153 | should inherit LOCK_GAP type locks from the |
| 2154 | successor record */ |
| 2155 | { |
| 2156 | if (!(~flags | (BTR_NO_UNDO_LOG_FLAGcxx . . $ BTR_NO_UNDO_LOG_FLAG. | BTR_KEEP_SYS_FLAGcxx . . $ BTR_KEEP_SYS_FLAG.))) { |
| 2157 | return DB_SUCCESScxx . . $ DB_SUCCESS.; |
| 2158 | } |
| 2159 | |
| 2160 | /* Check if we have to wait for a lock: enqueue an explicit lock |
| 2161 | request if yes */ |
| 2162 | |
| 2163 | rec_tcxx . . $ rec_t#* rec = btr_cur_get_reccxx . . $ `storage/innobase/include/btr0cur.h:64:9`!(cursor); |
| 2164 | dict_index_tcxx . . $ dict_index_t#* index = cursor->indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).(); |
| 2165 | |
| 2166 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!dict_index_is_online_ddl(index) |
| 2167 | || dict_index_is_clust(index) |
| 2168 | || (flags & BTR_CREATE_FLAG)); |
| 2169 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!((flags & BTR_NO_UNDO_LOG_FLAG) |
| 2170 | || index->table->skip_alter_undo != dict_table_t::NO_UNDO); |
| 2171 | |
| 2172 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mtr->is_named_space(index->table->space)); |
| 2173 | |
| 2174 | /* Check if there is predicate or GAP lock preventing the insertion */ |
| 2175 | if (!(flags & BTR_NO_LOCKING_FLAGcxx . . $ BTR_NO_LOCKING_FLAG.)) { |
| 2176 | const unsigned type = index->typecxx . . $ dict_index_t#type.; |
| 2177 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(type & DICT_SPATIALcxx . . $ `storage/innobase/include/dict0mem.h:73:9`!)) { |
| 2178 | lock_prdt_tcxx . . $ lock_prdt_t# prdt; |
| 2179 | rtr_mbr_tcxx . . $ rtr_mbr_t# mbr; |
| 2180 | |
| 2181 | rtr_get_mbr_from_tuplecxx . . $ rtr_get_mbr_from_tuple(237e0f1be4830df3).(entry, &mbr); |
| 2182 | |
| 2183 | /* Use on stack MBR variable to test if a lock is |
| 2184 | needed. If so, the predicate (MBR) will be allocated |
| 2185 | from lock heap in lock_prdt_insert_check_and_lock() */ |
| 2186 | lock_init_prdt_from_mbrcxx . . $ lock_init_prdt_from_mbr(784f7963ebb2c1ff).(&prdt, &mbr, 0, nullptr); |
| 2187 | |
| 2188 | if (dberr_tcxx . . $ dberr_t# err = lock_prdt_insert_check_and_lockcxx . . $ lock_prdt_insert_check_and_lock(6c2e87ea42d4d2cd).( |
| 2189 | rec, btr_cur_get_blockcxx . . $ `storage/innobase/include/btr0cur.h:63:9`!(cursor), |
| 2190 | index, thr, mtr, &prdt)) { |
| 2191 | return err; |
| 2192 | } |
| 2193 | *inherit = false; |
| 2194 | } else { |
| 2195 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!dict_index_is_online_ddl(index) |
| 2196 | || index->is_primary() |
| 2197 | || (flags & BTR_CREATE_FLAG)); |
| 2198 | #ifdef WITH_WSREPcxx . . $ `/build/tmp.NxIY9EeyJN/package/build/include/my_config.h:539:9`! |
| 2199 | trx_tcxx . . $ trx_t#* trx= thr_get_trxcxx . . $ thr_get_trx(bce191eb970ff2ca).(thr); |
| 2200 | /* If transaction scanning an unique secondary |
| 2201 | key is wsrep high priority thread (brute |
| 2202 | force) this scanning may involve GAP-locking |
| 2203 | in the index. As this locking happens also |
| 2204 | when applying replication events in high |
| 2205 | priority applier threads, there is a |
| 2206 | probability for lock conflicts between two |
| 2207 | wsrep high priority threads. To avoid this |
| 2208 | GAP-locking we mark that this transaction |
| 2209 | is using unique key scan here. */ |
| 2210 | if ((type & (DICT_CLUSTEREDcxx . . $ `storage/innobase/include/dict0mem.h:65:9`! | DICT_UNIQUEcxx . . $ `storage/innobase/include/dict0mem.h:68:9`!)) == DICT_UNIQUEcxx . . $ `storage/innobase/include/dict0mem.h:68:9`! |
| 2211 | && trx->is_wsrepcxx . . $ trx_t#is_wsrep(50ce9a9e25b4a850).() |
| 2212 | && wsrep_thd_is_BF(trx->mysql_thdcxx . . $ trx_t#mysql_thd., false)) { |
| 2213 | trx->wsrepcxx . . $ trx_t#wsrep. = 3; |
| 2214 | } |
| 2215 | #endif /* WITH_WSREP */ |
| 2216 | if (dberr_tcxx . . $ dberr_t# err = lock_rec_insert_check_and_lockcxx . . $ lock_rec_insert_check_and_lock(b3718d8bef22ae33).( |
| 2217 | rec, btr_cur_get_blockcxx . . $ `storage/innobase/include/btr0cur.h:63:9`!(cursor), |
| 2218 | index, thr, mtr, inherit)) { |
| 2219 | return err; |
| 2220 | } |
| 2221 | } |
| 2222 | } |
| 2223 | |
| 2224 | if (!index->is_primarycxx . . $ dict_index_t#is_primary(50ce9a9e25b4a850).() || !page_is_leafcxx . . $ page_is_leaf(190063cf6fb4afb1).(btr_cur_get_pagecxx . . $ `storage/innobase/include/btr0cur.h:76:9`!(cursor))) { |
| 2225 | return DB_SUCCESScxx . . $ DB_SUCCESS.; |
| 2226 | } |
| 2227 | |
| 2228 | constexpr roll_ptr_tcxx . . $ roll_ptr_t# dummy_roll_ptr = roll_ptr_tcxx . . $ roll_ptr_t#{1} |
| 2229 | << ROLL_PTR_INSERT_FLAG_POScxx . . $ `storage/innobase/include/trx0undo.h:33:9`!; |
| 2230 | roll_ptr_tcxx . . $ roll_ptr_t# roll_ptr = dummy_roll_ptr; |
| 2231 | |
| 2232 | if (!(flags & BTR_NO_UNDO_LOG_FLAGcxx . . $ BTR_NO_UNDO_LOG_FLAG.)) { |
| 2233 | if (dberr_tcxx . . $ dberr_t# err = trx_undo_report_row_operationcxx . . $ trx_undo_report_row_operation(f5c442f0871a0a55).( |
| 2234 | thr, index, entry, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, |
| 2235 | &roll_ptr)) { |
| 2236 | return err; |
| 2237 | } |
| 2238 | |
| 2239 | if (roll_ptr != dummy_roll_ptr) { |
| 2240 | dfield_tcxx . . $ dfield_t#* r = dtuple_get_nth_fieldcxx . . $ dtuple_get_nth_field(71af1a8d94eba0f9).(entry, |
| 2241 | index->db_trx_idcxx . . $ dict_index_t#db_trx_id(72085aa11f4b6e09).()); |
| 2242 | trx_write_trx_idcxx . . $ trx_write_trx_id(6165b45f45ef689c).(static_cast<bytecxx . . $ byte#*>(r->datacxx . . $ dfield_t#data.), |
| 2243 | thr_get_trxcxx . . $ thr_get_trx(bce191eb970ff2ca).(thr)->idcxx . . $ trx_t#id.); |
| 2244 | } |
| 2245 | } |
| 2246 | |
| 2247 | if (!(flags & BTR_KEEP_SYS_FLAGcxx . . $ BTR_KEEP_SYS_FLAG.)) { |
| 2248 | dfield_tcxx . . $ dfield_t#* r = dtuple_get_nth_fieldcxx . . $ dtuple_get_nth_field(71af1a8d94eba0f9).( |
| 2249 | entry, index->db_roll_ptrcxx . . $ dict_index_t#db_roll_ptr(72085aa11f4b6e09).()); |
| 2250 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(r->len == DATA_ROLL_PTR_LEN); |
| 2251 | trx_write_roll_ptrcxx . . $ trx_write_roll_ptr(6165b45f45ef689c).(static_cast<bytecxx . . $ byte#*>(r->datacxx . . $ dfield_t#data.), roll_ptr); |
| 2252 | } |
| 2253 | |
| 2254 | return DB_SUCCESScxx . . $ DB_SUCCESS.; |
| 2255 | } |
| 2256 | |
| 2257 | /** |
| 2258 | Prefetch siblings of the leaf for the pessimistic operation. |
| 2259 | @param block leaf page |
| 2260 | @param index index of the page |
| 2261 | @param trx transaction */ |
| 2262 | static void btr_cur_prefetch_siblingscxx . . $ btr_cur_prefetch_siblings(3d287479f68a2b77).(const buf_block_tcxx . . $ buf_block_t# *block, |
| 2263 | const dict_index_tcxx . . $ dict_index_t# *index, |
| 2264 | trx_tcxx . . $ trx_t# *trx) noexcept |
| 2265 | { |
| 2266 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(page_is_leaf(block->page.frame)); |
| 2267 | |
| 2268 | const page_tcxx . . $ `storage/innobase/include/page0types.h:38:9`! *page= block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.; |
| 2269 | uint32_tcxx . . $ uint32_t# next= mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(my_assume_alignedcxx . . $ my_assume_aligned(5eb18401b0825ee).<4>(page + FIL_PAGE_NEXTcxx . . $ `storage/innobase/include/fil0fil.h:1203:9`!)); |
| 2270 | fil_space_tcxx . . $ fil_space_t# *space= index->tablecxx . . $ dict_index_t#table.->spacecxx . . $ dict_table_t#space.; |
| 2271 | page_id_tcxx . . $ page_id_t# idcxx . . $ page_id_t#page_id_t(b4d55b1286ff73e8).{space->idcxx . . $ fil_space_t#id., |
| 2272 | mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(my_assume_alignedcxx . . $ my_assume_aligned(5eb18401b0825ee).<4>(page + FIL_PAGE_PREVcxx . . $ `storage/innobase/include/fil0fil.h:1196:9`!))}; |
| 2273 | |
| 2274 | if (id.page_nocxx . . $ page_id_t#page_no(d22c8608b6eae7b5).() != FIL_NULLcxx . . $ `storage/innobase/include/fil0fil.h:1175:9`! && space->acquirecxx . . $ fil_space_t#acquire(ad254478a19226f0).()) |
| 2275 | buf_read_page_backgroundcxx . . $ buf_read_page_background(f2eeb3715142f7b2).(id, space, trx); |
| 2276 | |
| 2277 | id.set_page_nocxx . . $ page_id_t#set_page_no(6bab9b75950d6f3).(next); |
| 2278 | |
| 2279 | if (next != FIL_NULLcxx . . $ `storage/innobase/include/fil0fil.h:1175:9`! && space->acquirecxx . . $ fil_space_t#acquire(ad254478a19226f0).()) |
| 2280 | buf_read_page_backgroundcxx . . $ buf_read_page_background(f2eeb3715142f7b2).(id, space, trx); |
| 2281 | } |
| 2282 | |
| 2283 | /*************************************************************//** |
| 2284 | Tries to perform an insert to a page in an index tree, next to cursor. |
| 2285 | It is assumed that mtr holds an x-latch on the page. The operation does |
| 2286 | not succeed if there is too little space on the page. If there is just |
| 2287 | one record on the page, the insert will always succeed; this is to |
| 2288 | prevent trying to split a page with just one record. |
| 2289 | @return DB_SUCCESS, DB_LOCK_WAIT, DB_FAIL, or error number */ |
| 2290 | dberr_tcxx . . $ dberr_t# |
| 2291 | btr_cur_optimistic_insertcxx . . $ btr_cur_optimistic_insert(608ae1f6b838559e).( |
| 2292 | /*======================*/ |
| 2293 | ulintcxx . . $ ulint# flags, /*!< in: undo logging and locking flags: if not |
| 2294 | zero, the parameters index and thr should be |
| 2295 | specified */ |
| 2296 | btr_cur_tcxx . . $ btr_cur_t#* cursor, /*!< in: cursor on page after which to insert; |
| 2297 | cursor stays valid */ |
| 2298 | rec_offscxx . . $ rec_offs#** offsets,/*!< out: offsets on *rec */ |
| 2299 | mem_heap_tcxx . . $ mem_heap_t#** heap, /*!< in/out: pointer to memory heap */ |
| 2300 | dtuple_tcxx . . $ dtuple_t#* entry, /*!< in/out: entry to insert */ |
| 2301 | rec_tcxx . . $ rec_t#** rec, /*!< out: pointer to inserted record if |
| 2302 | succeed */ |
| 2303 | big_rec_tcxx . . $ big_rec_t#** big_rec,/*!< out: big rec vector whose fields have to |
| 2304 | be stored externally by the caller */ |
| 2305 | ulintcxx . . $ ulint# n_ext, /*!< in: number of externally stored columns */ |
| 2306 | que_thr_tcxx . . $ que_thr_t#* thr, /*!< in/out: query thread; can be NULL if |
| 2307 | !(~flags |
| 2308 | & (BTR_NO_LOCKING_FLAG |
| 2309 | | BTR_NO_UNDO_LOG_FLAG)) */ |
| 2310 | mtr_tcxx . . $ mtr_t#* mtr) /*!< in/out: mini-transaction; |
| 2311 | if this function returns DB_SUCCESS on |
| 2312 | a leaf page of a secondary index in a |
| 2313 | compressed tablespace, the caller must |
| 2314 | mtr_commit(mtr) before latching |
| 2315 | any further pages */ |
| 2316 | { |
| 2317 | big_rec_tcxx . . $ big_rec_t#* big_rec_vec = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 2318 | dict_index_tcxx . . $ dict_index_t#* index; |
| 2319 | page_cur_tcxx . . $ page_cur_t#* page_cursor; |
| 2320 | buf_block_tcxx . . $ buf_block_t#* block; |
| 2321 | page_tcxx . . $ `storage/innobase/include/page0types.h:38:9`!* page; |
| 2322 | rec_tcxx . . $ rec_t#* dummy; |
| 2323 | bool leaf; |
| 2324 | bool reorg __attribute__((unused)); |
| 2325 | bool inherit = true; |
| 2326 | ulintcxx . . $ ulint# rec_size; |
| 2327 | dberr_tcxx . . $ dberr_t# err; |
| 2328 | |
| 2329 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(thr || !(~flags & (BTR_NO_LOCKING_FLAG | BTR_NO_UNDO_LOG_FLAG))); |
| 2330 | *big_rec = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 2331 | |
| 2332 | block = btr_cur_get_blockcxx . . $ `storage/innobase/include/btr0cur.h:63:9`!(cursor); |
| 2333 | page = buf_block_get_framecxx . . $ `storage/innobase/include/buf0buf.h:385:9`!(block); |
| 2334 | index = cursor->indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).(); |
| 2335 | |
| 2336 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mtr->memo_contains_flagged(block, MTR_MEMO_PAGE_X_FIX)); |
| 2337 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!dict_index_is_online_ddl(index) |
| 2338 | || dict_index_is_clust(index) |
| 2339 | || (flags & BTR_CREATE_FLAG)); |
| 2340 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(dtuple_check_typed(entry)); |
| 2341 | |
| 2342 | #ifdef HAVE_valgrind |
| 2343 | if (block->page.zip.data) { |
| 2344 | MEM_CHECK_DEFINED(page, srv_page_size); |
| 2345 | MEM_CHECK_DEFINED(block->page.zip.data, block->zip_size()); |
| 2346 | } |
| 2347 | #endif /* HAVE_valgrind */ |
| 2348 | |
| 2349 | leaf = page_is_leafcxx . . $ page_is_leaf(190063cf6fb4afb1).(page); |
| 2350 | |
| 2351 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(entry->is_alter_metadata())) { |
| 2352 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(leaf); |
| 2353 | goto convert_big_rec; |
| 2354 | } |
| 2355 | |
| 2356 | /* Calculate the record size when entry is converted to a record */ |
| 2357 | rec_size = rec_get_converted_sizecxx . . $ rec_get_converted_size(65a2a1c1835c6045).(index, entry, n_ext); |
| 2358 | |
| 2359 | if (page_zip_rec_needs_extcxx . . $ page_zip_rec_needs_ext(ca07b99eee158bc2).(rec_size, page_is_compcxx . . $ page_is_comp(f3688bc2ee54ea05).(page), |
| 2360 | dtuple_get_n_fieldscxx . . $ dtuple_get_n_fields(3106ade7d958747e).(entry), |
| 2361 | block->zip_sizecxx . . $ buf_block_t#zip_size(c9b1e749b64d5edc).())) { |
| 2362 | convert_big_rec: |
| 2363 | /* The record is so big that we have to store some fields |
| 2364 | externally on separate database pages */ |
| 2365 | big_rec_vec = dtuple_convert_big_reccxx . . $ dtuple_convert_big_rec(470f4bee431791a6).(index, 0, entry, &n_ext); |
| 2366 | |
| 2367 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(big_rec_vec == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)) { |
| 2368 | |
| 2369 | return(DB_TOO_BIG_RECORDcxx . . $ DB_TOO_BIG_RECORD.); |
| 2370 | } |
| 2371 | |
| 2372 | rec_size = rec_get_converted_sizecxx . . $ rec_get_converted_size(65a2a1c1835c6045).(index, entry, n_ext); |
| 2373 | } |
| 2374 | |
| 2375 | if (block->pagecxx . . $ buf_block_t#page..zipcxx . . $ buf_page_t#zip..datacxx . . $ page_zip_des_t#data. && page_zip_is_too_bigcxx . . $ page_zip_is_too_big(ffbc8782ebc52193).(index, entry)) { |
| 2376 | if (big_rec_vec != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { |
| 2377 | dtuple_convert_back_big_reccxx . . $ dtuple_convert_back_big_rec(4f5e1bce9a5c5d93).(index, entry, big_rec_vec); |
| 2378 | } |
| 2379 | |
| 2380 | return(DB_TOO_BIG_RECORDcxx . . $ DB_TOO_BIG_RECORD.); |
| 2381 | } |
| 2382 | |
| 2383 | LIMIT_OPTIMISTIC_INSERT_DEBUGcxx . . $ `storage/innobase/include/btr0cur.inl:36:10`!(page_get_n_recs(page), goto fail); |
| 2384 | |
| 2385 | if (block->pagecxx . . $ buf_block_t#page..zipcxx . . $ buf_page_t#zip..datacxx . . $ page_zip_des_t#data. && leaf |
| 2386 | && (page_get_data_sizecxx . . $ page_get_data_size(469dcb4e54b221a8).(page) + rec_size |
| 2387 | >= dict_index_zip_pad_optimal_page_sizecxx . . $ dict_index_zip_pad_optimal_page_size(2e6d4b3eeae69f8c).(index))) { |
| 2388 | /* If compression padding tells us that insertion will |
| 2389 | result in too packed up page i.e.: which is likely to |
| 2390 | cause compression failure then don't do an optimistic |
| 2391 | insertion. */ |
| 2392 | fail: |
| 2393 | err = DB_FAILcxx . . $ DB_FAIL.; |
| 2394 | |
| 2395 | /* prefetch siblings of the leaf for the pessimistic |
| 2396 | operation, if the page is leaf. */ |
| 2397 | if (leaf) { |
| 2398 | btr_cur_prefetch_siblingscxx . . $ btr_cur_prefetch_siblings(3d287479f68a2b77).(block, index, mtr->trxcxx . . $ mtr_t#trx.); |
| 2399 | } |
| 2400 | fail_err: |
| 2401 | |
| 2402 | if (big_rec_vec) { |
| 2403 | dtuple_convert_back_big_reccxx . . $ dtuple_convert_back_big_rec(4f5e1bce9a5c5d93).(index, entry, big_rec_vec); |
| 2404 | } |
| 2405 | |
| 2406 | return(err); |
| 2407 | } |
| 2408 | |
| 2409 | ulintcxx . . $ ulint# max_size = page_get_max_insert_size_after_reorganizecxx . . $ page_get_max_insert_size_after_reorganize(4adc7973d4c4f159).(page, 1); |
| 2410 | if (max_size < rec_size) { |
| 2411 | goto fail; |
| 2412 | } |
| 2413 | |
| 2414 | const ulintcxx . . $ ulint# n_recs = page_get_n_recscxx . . $ page_get_n_recs(469dcb4e54b221a8).(page); |
| 2415 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(n_recs >= 8189)) { |
| 2416 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(srv_page_size == 65536); |
| 2417 | goto fail; |
| 2418 | } |
| 2419 | |
| 2420 | if (page_has_garbagecxx . . $ page_has_garbage(190063cf6fb4afb1).(page)) { |
| 2421 | if (max_size < BTR_CUR_PAGE_REORGANIZE_LIMITcxx . . $ `storage/innobase/btr/btr0cur.cc:112:9`! |
| 2422 | && n_recs > 1 |
| 2423 | && page_get_max_insert_sizecxx . . $ page_get_max_insert_size(4adc7973d4c4f159).(page, 1) < rec_size) { |
| 2424 | |
| 2425 | goto fail; |
| 2426 | } |
| 2427 | } |
| 2428 | |
| 2429 | /* If there have been many consecutive inserts to the |
| 2430 | clustered index leaf page of an uncompressed table, check if |
| 2431 | we have to split the page to reserve enough free space for |
| 2432 | future updates of records. */ |
| 2433 | |
| 2434 | if (leaf && !block->pagecxx . . $ buf_block_t#page..zipcxx . . $ buf_page_t#zip..datacxx . . $ page_zip_des_t#data. && dict_index_is_clustcxx . . $ `storage/innobase/include/dict0dict.h:617:9`!(index) |
| 2435 | && page_get_n_recscxx . . $ page_get_n_recs(469dcb4e54b221a8).(page) >= 2 |
| 2436 | && dict_index_get_space_reservecxx . . $ dict_index_get_space_reserve(f708dce9a8856c70).() + rec_size > max_size |
| 2437 | && (btr_page_get_split_rec_to_rightcxx . . $ btr_page_get_split_rec_to_right(f07a715fb6186f94).(cursor, &dummy) |
| 2438 | || btr_page_get_split_rec_to_leftcxx . . $ btr_page_get_split_rec_to_left(15754bd857ff87f9).(cursor))) { |
| 2439 | goto fail; |
| 2440 | } |
| 2441 | |
| 2442 | page_cursor = btr_cur_get_page_curcxx . . $ `storage/innobase/include/btr0cur.h:62:9`!(cursor); |
| 2443 | |
| 2444 | DBUG_LOGcxx . . $ `include/my_dbug.h:235:11`!("ib_cur", |
| 2445 | "insert " << index->name << " (" << index->id << ") by " |
| 2446 | << ib::hex(thr ? thr->graph->trx->id : 0) |
| 2447 | << ' ' << rec_printer(entry).str()); |
| 2448 | DBUG_EXECUTE_IFcxx . . $ `include/my_dbug.h:172:9`!("do_page_reorganize", |
| 2449 | ut_a(!n_recs || btr_page_reorganize(page_cursor, mtr) |
| 2450 | == DB_SUCCESS);); |
| 2451 | |
| 2452 | /* Now, try the insert */ |
| 2453 | { |
| 2454 | const rec_tcxx . . $ rec_t#* page_cursor_rec = page_cur_get_reccxx . . $ `storage/innobase/include/page0cur.h:57:10`!(page_cursor); |
| 2455 | |
| 2456 | /* Check locks and write to the undo log, |
| 2457 | if specified */ |
| 2458 | err = btr_cur_ins_lock_and_undocxx . . $ btr_cur_ins_lock_and_undo(3861e9270bf5d316).(flags, cursor, entry, |
| 2459 | thr, mtr, &inherit); |
| 2460 | if (err != DB_SUCCESScxx . . $ DB_SUCCESS.) { |
| 2461 | goto fail_err; |
| 2462 | } |
| 2463 | |
| 2464 | #ifdef UNIV_DEBUG |
| 2465 | if (!(flags & BTR_CREATE_FLAG) |
| 2466 | && leaf && index->is_primary()) { |
| 2467 | const dfield_t* trx_id = dtuple_get_nth_field( |
| 2468 | entry, dict_col_get_clust_pos( |
| 2469 | dict_table_get_sys_col(index->table, |
| 2470 | DATA_TRX_ID), |
| 2471 | index)); |
| 2472 | |
| 2473 | ut_ad(trx_id->len == DATA_TRX_ID_LEN); |
| 2474 | ut_ad(trx_id[1].len == DATA_ROLL_PTR_LEN); |
| 2475 | ut_ad(*static_cast<const byte*> |
| 2476 | (trx_id[1].data) & 0x80); |
| 2477 | if (flags & BTR_NO_UNDO_LOG_FLAG) { |
| 2478 | ut_ad(!memcmp(trx_id->data, reset_trx_id, |
| 2479 | DATA_TRX_ID_LEN)); |
| 2480 | } else { |
| 2481 | ut_ad(thr->graph->trx->id); |
| 2482 | ut_ad(thr->graph->trx->bulk_insert |
| 2483 | || thr->graph->trx->id |
| 2484 | == trx_read_trx_id( |
| 2485 | static_cast<const byte*>( |
| 2486 | trx_id->data)) |
| 2487 | || index->table->is_temporary()); |
| 2488 | } |
| 2489 | } |
| 2490 | #endif |
| 2491 | |
| 2492 | *rec = page_cur_tuple_insertcxx . . $ page_cur_tuple_insert(20b71dd453d7ef65).(page_cursor, entry, offsets, heap, |
| 2493 | n_ext, mtr); |
| 2494 | |
| 2495 | reorg = page_cursor_rec != page_cur_get_reccxx . . $ `storage/innobase/include/page0cur.h:57:10`!(page_cursor); |
| 2496 | } |
| 2497 | |
| 2498 | if (*rec) { |
| 2499 | } else if (block->pagecxx . . $ buf_block_t#page..zipcxx . . $ buf_page_t#zip..datacxx . . $ page_zip_des_t#data.) { |
| 2500 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!index->table->is_temporary()); |
| 2501 | goto fail; |
| 2502 | } else { |
| 2503 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!reorg); |
| 2504 | reorg = true; |
| 2505 | |
| 2506 | /* If the record did not fit, reorganize */ |
| 2507 | err = btr_page_reorganizecxx . . $ btr_page_reorganize(e4b2ea64c1f14b9e).(page_cursor, mtr); |
| 2508 | if (err != DB_SUCCESScxx . . $ DB_SUCCESS. |
| 2509 | || page_get_max_insert_sizecxx . . $ page_get_max_insert_size(4adc7973d4c4f159).(page, 1) != max_size |
| 2510 | || !(*rec = page_cur_tuple_insertcxx . . $ page_cur_tuple_insert(20b71dd453d7ef65).(page_cursor, entry, |
| 2511 | offsets, heap, n_ext, |
| 2512 | mtr))) { |
| 2513 | err = DB_CORRUPTIONcxx . . $ DB_CORRUPTION.; |
| 2514 | goto fail_err; |
| 2515 | } |
| 2516 | } |
| 2517 | |
| 2518 | #ifdef BTR_CUR_HASH_ADAPTcxx . . $ `<built-in>:481:9`! |
| 2519 | if (!leaf) { |
| 2520 | } else if (entry->info_bitscxx . . $ dtuple_t#info_bits. & REC_INFO_MIN_REC_FLAGcxx . . $ `storage/innobase/include/data0type.h:504:9`!) { |
| 2521 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(entry->is_metadata()); |
| 2522 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(index->is_instant()); |
| 2523 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(flags == BTR_NO_LOCKING_FLAG); |
| 2524 | } else if (!index->tablecxx . . $ dict_index_t#table.->is_temporarycxx . . $ dict_table_t#is_temporary(50ce9a9e25b4a850).()) { |
| 2525 | btr_search_update_hash_on_insertcxx . . $ btr_search_update_hash_on_insert(2127997ef63bd150).(cursor, reorg); |
| 2526 | } |
| 2527 | #endif /* BTR_CUR_HASH_ADAPT */ |
| 2528 | |
| 2529 | if (!(flags & BTR_NO_LOCKING_FLAGcxx . . $ BTR_NO_LOCKING_FLAG.) && inherit) { |
| 2530 | |
| 2531 | lock_update_insertcxx . . $ lock_update_insert(8215f79b77a41d69).(block, *rec); |
| 2532 | } |
| 2533 | |
| 2534 | *big_rec = big_rec_vec; |
| 2535 | |
| 2536 | return(DB_SUCCESScxx . . $ DB_SUCCESS.); |
| 2537 | } |
| 2538 | |
| 2539 | /*************************************************************//** |
| 2540 | Performs an insert on a page of an index tree. It is assumed that mtr |
| 2541 | holds an x-latch on the tree and on the cursor page. If the insert is |
| 2542 | made on the leaf level, to avoid deadlocks, mtr must also own x-latches |
| 2543 | to brothers of page, if those brothers exist. |
| 2544 | @return DB_SUCCESS or error number */ |
| 2545 | dberr_tcxx . . $ dberr_t# |
| 2546 | btr_cur_pessimistic_insertcxx . . $ btr_cur_pessimistic_insert(608ae1f6b838559e).( |
| 2547 | /*=======================*/ |
| 2548 | ulintcxx . . $ ulint# flags, /*!< in: undo logging and locking flags: if not |
| 2549 | zero, the parameter thr should be |
| 2550 | specified; if no undo logging is specified, |
| 2551 | then the caller must have reserved enough |
| 2552 | free extents in the file space so that the |
| 2553 | insertion will certainly succeed */ |
| 2554 | btr_cur_tcxx . . $ btr_cur_t#* cursor, /*!< in: cursor after which to insert; |
| 2555 | cursor stays valid */ |
| 2556 | rec_offscxx . . $ rec_offs#** offsets,/*!< out: offsets on *rec */ |
| 2557 | mem_heap_tcxx . . $ mem_heap_t#** heap, /*!< in/out: pointer to memory heap |
| 2558 | that can be emptied */ |
| 2559 | dtuple_tcxx . . $ dtuple_t#* entry, /*!< in/out: entry to insert */ |
| 2560 | rec_tcxx . . $ rec_t#** rec, /*!< out: pointer to inserted record if |
| 2561 | succeed */ |
| 2562 | big_rec_tcxx . . $ big_rec_t#** big_rec,/*!< out: big rec vector whose fields have to |
| 2563 | be stored externally by the caller */ |
| 2564 | ulintcxx . . $ ulint# n_ext, /*!< in: number of externally stored columns */ |
| 2565 | que_thr_tcxx . . $ que_thr_t#* thr, /*!< in/out: query thread; can be NULL if |
| 2566 | !(~flags |
| 2567 | & (BTR_NO_LOCKING_FLAG |
| 2568 | | BTR_NO_UNDO_LOG_FLAG)) */ |
| 2569 | mtr_tcxx . . $ mtr_t#* mtr) /*!< in/out: mini-transaction */ |
| 2570 | { |
| 2571 | dict_index_tcxx . . $ dict_index_t#* index = cursor->indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).(); |
| 2572 | big_rec_tcxx . . $ big_rec_t#* big_rec_vec = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 2573 | bool inherit = false; |
| 2574 | uint32_tcxx . . $ uint32_t# n_reserved = 0; |
| 2575 | |
| 2576 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(dtuple_check_typed(entry)); |
| 2577 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(thr || !(~flags & (BTR_NO_LOCKING_FLAG | BTR_NO_UNDO_LOG_FLAG))); |
| 2578 | |
| 2579 | *big_rec = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 2580 | |
| 2581 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mtr->memo_contains_flagged(&index->lock, MTR_MEMO_X_LOCK |
| 2582 | | MTR_MEMO_SX_LOCK)); |
| 2583 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mtr->memo_contains_flagged(btr_cur_get_block(cursor), |
| 2584 | MTR_MEMO_PAGE_X_FIX)); |
| 2585 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!dict_index_is_online_ddl(index) |
| 2586 | || dict_index_is_clust(index) |
| 2587 | || (flags & BTR_CREATE_FLAG)); |
| 2588 | |
| 2589 | #ifdef BTR_CUR_HASH_ADAPTcxx . . $ `<built-in>:481:9`! |
| 2590 | cursor->flagcxx . . $ btr_cur_t#flag. = BTR_CUR_BINARYcxx . . $ BTR_CUR_BINARY.; |
| 2591 | #endif |
| 2592 | |
| 2593 | /* Check locks and write to undo log, if specified */ |
| 2594 | |
| 2595 | dberr_tcxx . . $ dberr_t# err = btr_cur_ins_lock_and_undocxx . . $ btr_cur_ins_lock_and_undo(3861e9270bf5d316).(flags, cursor, entry, |
| 2596 | thr, mtr, &inherit); |
| 2597 | |
| 2598 | if (err != DB_SUCCESScxx . . $ DB_SUCCESS.) { |
| 2599 | return(err); |
| 2600 | } |
| 2601 | |
| 2602 | /* First reserve enough free space for the file segments of |
| 2603 | the index tree, so that the insert will not fail because of |
| 2604 | lack of space */ |
| 2605 | |
| 2606 | err = fsp_reserve_free_extentscxx . . $ fsp_reserve_free_extents(ff8909883dc21fea).(&n_reserved, index->tablecxx . . $ dict_index_t#table.->spacecxx . . $ dict_table_t#space., |
| 2607 | uint32_tcxx . . $ uint32_t#(cursor->tree_heightcxx . . $ btr_cur_t#tree_height. / 16 + 3), |
| 2608 | FSP_NORMALcxx . . $ FSP_NORMAL., mtr); |
| 2609 | if (err != DB_SUCCESScxx . . $ DB_SUCCESS.) { |
| 2610 | return err; |
| 2611 | } |
| 2612 | |
| 2613 | if (page_zip_rec_needs_extcxx . . $ page_zip_rec_needs_ext(ca07b99eee158bc2).(rec_get_converted_sizecxx . . $ rec_get_converted_size(65a2a1c1835c6045).(index, entry, n_ext), |
| 2614 | index->tablecxx . . $ dict_index_t#table.->not_redundantcxx . . $ dict_table_t#not_redundant(50ce9a9e25b4a850).(), |
| 2615 | dtuple_get_n_fieldscxx . . $ dtuple_get_n_fields(3106ade7d958747e).(entry), |
| 2616 | btr_cur_get_blockcxx . . $ `storage/innobase/include/btr0cur.h:63:9`!(cursor)->zip_sizecxx . . $ buf_block_t#zip_size(c9b1e749b64d5edc).()) |
| 2617 | || UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(entry->is_alter_metadata() |
| 2618 | && !dfield_is_ext( |
| 2619 | dtuple_get_nth_field( |
| 2620 | entry, |
| 2621 | index->first_user_field())))) { |
| 2622 | /* The record is so big that we have to store some fields |
| 2623 | externally on separate database pages */ |
| 2624 | |
| 2625 | if (UNIV_LIKELY_NULLcxx . . $ `storage/innobase/include/univ.i:393:10`!(big_rec_vec)) { |
| 2626 | /* This should never happen, but we handle |
| 2627 | the situation in a robust manner. */ |
| 2628 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(0); |
| 2629 | dtuple_convert_back_big_reccxx . . $ dtuple_convert_back_big_rec(4f5e1bce9a5c5d93).(index, entry, big_rec_vec); |
| 2630 | } |
| 2631 | |
| 2632 | big_rec_vec = dtuple_convert_big_reccxx . . $ dtuple_convert_big_rec(470f4bee431791a6).(index, 0, entry, &n_ext); |
| 2633 | |
| 2634 | if (big_rec_vec == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { |
| 2635 | |
| 2636 | index->tablecxx . . $ dict_index_t#table.->spacecxx . . $ dict_table_t#space.->release_free_extentscxx . . $ fil_space_t#release_free_extents(6bab9b75950d6f3).(n_reserved); |
| 2637 | return(DB_TOO_BIG_RECORDcxx . . $ DB_TOO_BIG_RECORD.); |
| 2638 | } |
| 2639 | } |
| 2640 | |
| 2641 | if (index->pagecxx . . $ dict_index_t#page. == btr_cur_get_blockcxx . . $ `storage/innobase/include/btr0cur.h:63:9`!(cursor)->pagecxx . . $ buf_block_t#page..idcxx . . $ buf_page_t#id(9d40bbb65128eac8).().page_nocxx . . $ page_id_t#page_no(d22c8608b6eae7b5).()) { |
| 2642 | *rec = index->is_spatialcxx . . $ dict_index_t#is_spatial(50ce9a9e25b4a850).() |
| 2643 | ? rtr_root_raise_and_insertcxx . . $ rtr_root_raise_and_insert(3297259feb0ea9a0).(flags, cursor, offsets, |
| 2644 | heap, entry, n_ext, mtr, |
| 2645 | &err, thr) |
| 2646 | : btr_root_raise_and_insertcxx . . $ btr_root_raise_and_insert(705431d322c9a50a).(flags, cursor, offsets, |
| 2647 | heap, entry, n_ext, mtr, |
| 2648 | &err); |
| 2649 | } else if (index->is_spatialcxx . . $ dict_index_t#is_spatial(50ce9a9e25b4a850).()) { |
| 2650 | *rec = rtr_page_split_and_insertcxx . . $ rtr_page_split_and_insert(3297259feb0ea9a0).(flags, cursor, offsets, heap, |
| 2651 | entry, n_ext, mtr, &err, thr); |
| 2652 | } else { |
| 2653 | *rec = btr_page_split_and_insertcxx . . $ btr_page_split_and_insert(705431d322c9a50a).(flags, cursor, offsets, heap, |
| 2654 | entry, n_ext, mtr, &err); |
| 2655 | } |
| 2656 | |
| 2657 | if (!*rec) { |
| 2658 | goto func_exit; |
| 2659 | } |
| 2660 | |
| 2661 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(page_rec_get_next(btr_cur_get_rec(cursor)) == *rec |
| 2662 | || dict_index_is_spatial(index)); |
| 2663 | |
| 2664 | if (!(flags & BTR_NO_LOCKING_FLAGcxx . . $ BTR_NO_LOCKING_FLAG.)) { |
| 2665 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!index->table->is_temporary()); |
| 2666 | if (dict_index_is_spatialcxx . . $ `storage/innobase/include/dict0dict.h:620:9`!(index)) { |
| 2667 | /* Do nothing */ |
| 2668 | } else { |
| 2669 | /* The cursor might be moved to the other page |
| 2670 | and the max trx id field should be updated after |
| 2671 | the cursor was fixed. */ |
| 2672 | if (!dict_index_is_clustcxx . . $ `storage/innobase/include/dict0dict.h:617:9`!(index)) { |
| 2673 | page_update_max_trx_idcxx . . $ page_update_max_trx_id(7ff4fec4cd653b55).( |
| 2674 | btr_cur_get_blockcxx . . $ `storage/innobase/include/btr0cur.h:63:9`!(cursor), |
| 2675 | btr_cur_get_page_zipcxx . . $ btr_cur_get_page_zip(25879e64d517f276).(cursor), |
| 2676 | thr_get_trxcxx . . $ thr_get_trx(bce191eb970ff2ca).(thr)->idcxx . . $ trx_t#id., mtr); |
| 2677 | } |
| 2678 | |
| 2679 | if (!page_rec_is_infimumcxx . . $ page_rec_is_infimum(190063cf6fb4afb1).(btr_cur_get_reccxx . . $ `storage/innobase/include/btr0cur.h:64:9`!(cursor)) |
| 2680 | || !page_has_prevcxx . . $ page_has_prev(190063cf6fb4afb1).(btr_cur_get_pagecxx . . $ `storage/innobase/include/btr0cur.h:76:9`!(cursor))) { |
| 2681 | /* split and inserted need to call |
| 2682 | lock_update_insert() always. */ |
| 2683 | inherit = true; |
| 2684 | } |
| 2685 | } |
| 2686 | } |
| 2687 | |
| 2688 | if (!page_is_leafcxx . . $ page_is_leaf(190063cf6fb4afb1).(btr_cur_get_pagecxx . . $ `storage/innobase/include/btr0cur.h:76:9`!(cursor))) { |
| 2689 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!big_rec_vec); |
| 2690 | } else { |
| 2691 | #ifdef BTR_CUR_HASH_ADAPTcxx . . $ `<built-in>:481:9`! |
| 2692 | if (entry->info_bitscxx . . $ dtuple_t#info_bits. & REC_INFO_MIN_REC_FLAGcxx . . $ `storage/innobase/include/data0type.h:504:9`!) { |
| 2693 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(entry->is_metadata()); |
| 2694 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(index->is_instant()); |
| 2695 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(flags & BTR_NO_LOCKING_FLAG); |
| 2696 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!(flags & BTR_CREATE_FLAG)); |
| 2697 | } else if (!index->tablecxx . . $ dict_index_t#table.->is_temporarycxx . . $ dict_table_t#is_temporary(50ce9a9e25b4a850).()) { |
| 2698 | btr_search_update_hash_on_insertcxx . . $ btr_search_update_hash_on_insert(2127997ef63bd150).(cursor, false); |
| 2699 | } |
| 2700 | #endif /* BTR_CUR_HASH_ADAPT */ |
| 2701 | if (inherit && !(flags & BTR_NO_LOCKING_FLAGcxx . . $ BTR_NO_LOCKING_FLAG.)) { |
| 2702 | |
| 2703 | lock_update_insertcxx . . $ lock_update_insert(8215f79b77a41d69).(btr_cur_get_blockcxx . . $ `storage/innobase/include/btr0cur.h:63:9`!(cursor), *rec); |
| 2704 | } |
| 2705 | } |
| 2706 | |
| 2707 | err = DB_SUCCESScxx . . $ DB_SUCCESS.; |
| 2708 | func_exit: |
| 2709 | index->tablecxx . . $ dict_index_t#table.->spacecxx . . $ dict_table_t#space.->release_free_extentscxx . . $ fil_space_t#release_free_extents(6bab9b75950d6f3).(n_reserved); |
| 2710 | *big_rec = big_rec_vec; |
| 2711 | |
| 2712 | return err; |
| 2713 | } |
| 2714 | |
| 2715 | /*==================== B-TREE UPDATE =========================*/ |
| 2716 | |
| 2717 | /*************************************************************//** |
| 2718 | For an update, checks the locks and does the undo logging. |
| 2719 | @return DB_SUCCESS, DB_LOCK_WAIT, or error number */ |
| 2720 | UNIV_INLINEcxx . . $ `storage/innobase/include/univ.i:168:9`! MY_ATTRIBUTEcxx . . $ `storage/innobase/include/univ.i:162:11`!((warn_unused_result)) |
| 2721 | dberr_tcxx . . $ dberr_t# |
| 2722 | btr_cur_upd_lock_and_undocxx . . $ btr_cur_upd_lock_and_undo(7bb56c7fd0c4544e).( |
| 2723 | /*======================*/ |
| 2724 | ulintcxx . . $ ulint# flags, /*!< in: undo logging and locking flags */ |
| 2725 | btr_cur_tcxx . . $ btr_cur_t#* cursor, /*!< in: cursor on record to update */ |
| 2726 | const rec_offscxx . . $ rec_offs#* offsets,/*!< in: rec_get_offsets() on cursor */ |
| 2727 | const upd_tcxx . . $ upd_t#* update, /*!< in: update vector */ |
| 2728 | ulintcxx . . $ ulint# cmpl_info,/*!< in: compiler info on secondary index |
| 2729 | updates */ |
| 2730 | que_thr_tcxx . . $ que_thr_t#* thr, /*!< in: query thread |
| 2731 | (can be NULL if BTR_NO_LOCKING_FLAG) */ |
| 2732 | mtr_tcxx . . $ mtr_t#* mtr, /*!< in/out: mini-transaction */ |
| 2733 | roll_ptr_tcxx . . $ roll_ptr_t#* roll_ptr)/*!< out: roll pointer */ |
| 2734 | { |
| 2735 | dict_index_tcxx . . $ dict_index_t#* index; |
| 2736 | const rec_tcxx . . $ rec_t#* rec; |
| 2737 | dberr_tcxx . . $ dberr_t# err; |
| 2738 | |
| 2739 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!((thr != NULL) || (flags & BTR_NO_LOCKING_FLAG)); |
| 2740 | |
| 2741 | rec = btr_cur_get_reccxx . . $ `storage/innobase/include/btr0cur.h:64:9`!(cursor); |
| 2742 | index = cursor->indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).(); |
| 2743 | |
| 2744 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rec_offs_validate(rec, index, offsets)); |
| 2745 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mtr->is_named_space(index->table->space)); |
| 2746 | |
| 2747 | if (!dict_index_is_clustcxx . . $ `storage/innobase/include/dict0dict.h:617:9`!(index)) { |
| 2748 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(dict_index_is_online_ddl(index) |
| 2749 | == !!(flags & BTR_CREATE_FLAG)); |
| 2750 | |
| 2751 | /* We do undo logging only when we update a clustered index |
| 2752 | record */ |
| 2753 | return(lock_sec_rec_modify_check_and_lockcxx . . $ lock_sec_rec_modify_check_and_lock(9b90b058c64879e3).( |
| 2754 | flags, btr_cur_get_blockcxx . . $ `storage/innobase/include/btr0cur.h:63:9`!(cursor), rec, |
| 2755 | index, thr, mtr)); |
| 2756 | } |
| 2757 | |
| 2758 | /* Check if we have to wait for a lock: enqueue an explicit lock |
| 2759 | request if yes */ |
| 2760 | |
| 2761 | if (!(flags & BTR_NO_LOCKING_FLAGcxx . . $ BTR_NO_LOCKING_FLAG.)) { |
| 2762 | err = lock_clust_rec_modify_check_and_lockcxx . . $ lock_clust_rec_modify_check_and_lock(dc19d26c70f2a5c1).( |
| 2763 | btr_cur_get_blockcxx . . $ `storage/innobase/include/btr0cur.h:63:9`!(cursor), rec, index, |
| 2764 | offsets, thr); |
| 2765 | if (err != DB_SUCCESScxx . . $ DB_SUCCESS.) { |
| 2766 | return(err); |
| 2767 | } |
| 2768 | } |
| 2769 | |
| 2770 | /* Append the info about the update in the undo log */ |
| 2771 | |
| 2772 | return((flags & BTR_NO_UNDO_LOG_FLAGcxx . . $ BTR_NO_UNDO_LOG_FLAG.) |
| 2773 | ? DB_SUCCESScxx . . $ DB_SUCCESS. |
| 2774 | : trx_undo_report_row_operationcxx . . $ trx_undo_report_row_operation(f5c442f0871a0a55).( |
| 2775 | thr, index, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, update, |
| 2776 | cmpl_info, rec, offsets, roll_ptr)); |
| 2777 | } |
| 2778 | |
| 2779 | /** Write DB_TRX_ID,DB_ROLL_PTR to a clustered index entry. |
| 2780 | @param[in,out] entry clustered index entry |
| 2781 | @param[in] index clustered index |
| 2782 | @param[in] trx_id DB_TRX_ID |
| 2783 | @param[in] roll_ptr DB_ROLL_PTR */ |
| 2784 | static void btr_cur_write_syscxx . . $ btr_cur_write_sys(b297a728581d7399).( |
| 2785 | dtuple_tcxx . . $ dtuple_t#* entry, |
| 2786 | const dict_index_tcxx . . $ dict_index_t#* index, |
| 2787 | trx_id_tcxx . . $ trx_id_t# trx_id, |
| 2788 | roll_ptr_tcxx . . $ roll_ptr_t# roll_ptr) |
| 2789 | { |
| 2790 | dfield_tcxx . . $ dfield_t#* t = dtuple_get_nth_fieldcxx . . $ dtuple_get_nth_field(71af1a8d94eba0f9).(entry, index->db_trx_idcxx . . $ dict_index_t#db_trx_id(72085aa11f4b6e09).()); |
| 2791 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(t->len == DATA_TRX_ID_LEN); |
| 2792 | trx_write_trx_idcxx . . $ trx_write_trx_id(6165b45f45ef689c).(static_cast<bytecxx . . $ byte#*>(t->datacxx . . $ dfield_t#data.), trx_id); |
| 2793 | dfield_tcxx . . $ dfield_t#* r = dtuple_get_nth_fieldcxx . . $ dtuple_get_nth_field(71af1a8d94eba0f9).(entry, index->db_roll_ptrcxx . . $ dict_index_t#db_roll_ptr(72085aa11f4b6e09).()); |
| 2794 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(r->len == DATA_ROLL_PTR_LEN); |
| 2795 | trx_write_roll_ptrcxx . . $ trx_write_roll_ptr(6165b45f45ef689c).(static_cast<bytecxx . . $ byte#*>(r->datacxx . . $ dfield_t#data.), roll_ptr); |
| 2796 | } |
| 2797 | |
| 2798 | MY_ATTRIBUTEcxx . . $ `storage/innobase/include/univ.i:162:11`!((warn_unused_result)) |
| 2799 | /** Update DB_TRX_ID, DB_ROLL_PTR in a clustered index record. |
| 2800 | @param[in,out] block clustered index leaf page |
| 2801 | @param[in,out] rec clustered index record |
| 2802 | @param[in] index clustered index |
| 2803 | @param[in] offsets rec_get_offsets(rec, index) |
| 2804 | @param[in] trx transaction |
| 2805 | @param[in] roll_ptr DB_ROLL_PTR value |
| 2806 | @param[in,out] mtr mini-transaction |
| 2807 | @return error code */ |
| 2808 | static dberr_tcxx . . $ dberr_t# btr_cur_upd_rec_syscxx . . $ btr_cur_upd_rec_sys(e2b18affefdcc973).(buf_block_tcxx . . $ buf_block_t# *block, rec_tcxx . . $ rec_t# *rec, |
| 2809 | dict_index_tcxx . . $ dict_index_t# *index, const rec_offscxx . . $ rec_offs# *offsets, |
| 2810 | const trx_tcxx . . $ trx_t# *trx, roll_ptr_tcxx . . $ roll_ptr_t# roll_ptr, |
| 2811 | mtr_tcxx . . $ mtr_t# *mtr) |
| 2812 | { |
| 2813 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(index->is_primary()); |
| 2814 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rec_offs_validate(rec, index, offsets)); |
| 2815 | |
| 2816 | if (UNIV_LIKELY_NULLcxx . . $ `storage/innobase/include/univ.i:393:10`!(block->page.zip.data)) |
| 2817 | { |
| 2818 | page_zip_write_trx_id_and_roll_ptrcxx . . $ page_zip_write_trx_id_and_roll_ptr(ae05c1ec80a1617c).(block, rec, offsets, index->db_trx_idcxx . . $ dict_index_t#db_trx_id(72085aa11f4b6e09).(), |
| 2819 | trx->idcxx . . $ trx_t#id., roll_ptr, mtr); |
| 2820 | return DB_SUCCESScxx . . $ DB_SUCCESS.; |
| 2821 | } |
| 2822 | |
| 2823 | ulintcxx . . $ ulint# offset= index->trx_id_offsetcxx . . $ dict_index_t#trx_id_offset.; |
| 2824 | |
| 2825 | if (!offset) |
| 2826 | offset= row_get_trx_id_offsetcxx . . $ row_get_trx_id_offset(81d21ff965fadd7c).(index, offsets); |
| 2827 | |
| 2828 | compile_time_assertcxx . . $ `include/my_global.h:377:9`!(DATA_TRX_IDcxx . . $ `storage/innobase/include/data0type.h:155:9`! + 1 == DATA_ROLL_PTRcxx . . $ `storage/innobase/include/data0type.h:158:9`!); |
| 2829 | |
| 2830 | /* During IMPORT the trx id in the record can be in the future, if |
| 2831 | the .ibd file is being imported from another instance. During IMPORT |
| 2832 | roll_ptr will be 0. */ |
| 2833 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(roll_ptr == 0 || |
| 2834 | lock_check_trx_id_sanity(trx_read_trx_id(rec + offset), |
| 2835 | rec, index, offsets)); |
| 2836 | |
| 2837 | bytecxx . . $ byte# sys[DATA_TRX_ID_LENcxx . . $ `storage/innobase/include/data0type.h:156:9`! + DATA_ROLL_PTR_LENcxx . . $ `storage/innobase/include/data0type.h:159:9`!]; |
| 2838 | |
| 2839 | trx_write_trx_idcxx . . $ trx_write_trx_id(6165b45f45ef689c).(sys, trx->idcxx . . $ trx_t#id.); |
| 2840 | trx_write_roll_ptrcxx . . $ trx_write_roll_ptr(6165b45f45ef689c).(sys + DATA_TRX_ID_LENcxx . . $ `storage/innobase/include/data0type.h:156:9`!, roll_ptr); |
| 2841 | |
| 2842 | ulintcxx . . $ ulint# d= 0; |
| 2843 | const bytecxx . . $ byte# *src= nullptr; |
| 2844 | bytecxx . . $ byte# *dest= rec + offset; |
| 2845 | ulintcxx . . $ ulint# len= DATA_TRX_ID_LENcxx . . $ `storage/innobase/include/data0type.h:156:9`! + DATA_ROLL_PTR_LENcxx . . $ `storage/innobase/include/data0type.h:159:9`!; |
| 2846 | |
| 2847 | if (UNIV_LIKELYcxx . . $ `storage/innobase/include/univ.i:437:9`!(index->trx_id_offset)) |
| 2848 | { |
| 2849 | const rec_tcxx . . $ rec_t# *prev= page_rec_get_prev_constcxx . . $ page_rec_get_prev_const(e8dc1f8aea836758).(rec); |
| 2850 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(!prev || prev == rec)) |
| 2851 | return DB_CORRUPTIONcxx . . $ DB_CORRUPTION.; |
| 2852 | else if (page_rec_is_infimumcxx . . $ page_rec_is_infimum(190063cf6fb4afb1).(prev)); |
| 2853 | else |
| 2854 | for (src= prev + offset; d < DATA_TRX_ID_LENcxx . . $ `storage/innobase/include/data0type.h:156:9`! + DATA_ROLL_PTR_LENcxx . . $ `storage/innobase/include/data0type.h:159:9`!; d++) |
| 2855 | if (src[d] != sys[d]) |
| 2856 | break; |
| 2857 | if (d > 6 && memcmp(dest, sys, d)) |
| 2858 | { |
| 2859 | /* We save space by replacing a single record |
| 2860 | |
| 2861 | WRITE,page_offset(dest),byte[13] |
| 2862 | |
| 2863 | with two records: |
| 2864 | |
| 2865 | MEMMOVE,page_offset(dest),d(1 byte),offset(1..3 bytes), |
| 2866 | WRITE|0x80,0,byte[13-d] |
| 2867 | |
| 2868 | The single WRITE record would be x+13 bytes long, with x>2. |
| 2869 | The MEMMOVE record would be up to x+1+3 = x+4 bytes, and the |
| 2870 | second WRITE would be 1+1+13-d = 15-d bytes. |
| 2871 | |
| 2872 | The total size is: x+13 versus x+4+15-d = x+19-d bytes. |
| 2873 | To save space, we must have d>6, that is, the complete DB_TRX_ID and |
| 2874 | the first byte(s) of DB_ROLL_PTR must match the previous record. */ |
| 2875 | memcpy(dest, src, d); |
| 2876 | mtr->memmovecxx . . $ mtr_t#memmove(6b3ae618754b5d9e).(*block, dest - block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame., src - block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame., |
| 2877 | d); |
| 2878 | dest+= d; |
| 2879 | len-= d; |
| 2880 | /* DB_TRX_ID,DB_ROLL_PTR must be unique in each record when |
| 2881 | DB_TRX_ID refers to an active transaction. */ |
| 2882 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(len); |
| 2883 | } |
| 2884 | else |
| 2885 | d= 0; |
| 2886 | } |
| 2887 | |
| 2888 | if (UNIV_LIKELYcxx . . $ `storage/innobase/include/univ.i:437:9`!(len)) /* extra safety, to avoid corrupting the log */ |
| 2889 | mtr->memcpycxx . . $ mtr_t#memcpy(cacdda589782ca45).<mtr_tcxx . . $ mtr_t#::MAYBE_NOPcxx . . $ mtr_t#MAYBE_NOP.>(*block, dest, sys + d, len); |
| 2890 | |
| 2891 | return DB_SUCCESScxx . . $ DB_SUCCESS.; |
| 2892 | } |
| 2893 | |
| 2894 | /*************************************************************//** |
| 2895 | See if there is enough place in the page modification log to log |
| 2896 | an update-in-place. |
| 2897 | |
| 2898 | @retval false if out of space |
| 2899 | @retval true if enough place */ |
| 2900 | bool |
| 2901 | btr_cur_update_alloc_zip_funccxx . . $ btr_cur_update_alloc_zip_func(fe79a5d14f09e0af).( |
| 2902 | /*==========================*/ |
| 2903 | page_zip_des_tcxx . . $ page_zip_des_t#* page_zip,/*!< in/out: compressed page */ |
| 2904 | page_cur_tcxx . . $ page_cur_t#* cursor, /*!< in/out: B-tree page cursor */ |
| 2905 | #ifdef UNIV_DEBUG |
| 2906 | rec_offs* offsets,/*!< in/out: offsets of the cursor record */ |
| 2907 | #endif /* UNIV_DEBUG */ |
| 2908 | ulintcxx . . $ ulint# length, /*!< in: size needed */ |
| 2909 | bool create, /*!< in: true=delete-and-insert, |
| 2910 | false=update-in-place */ |
| 2911 | mtr_tcxx . . $ mtr_t#* mtr) /*!< in/out: mini-transaction */ |
| 2912 | { |
| 2913 | dict_index_tcxx . . $ dict_index_t#* index = cursor->indexcxx . . $ page_cur_t#index.; |
| 2914 | |
| 2915 | /* Have a local copy of the variables as these can change |
| 2916 | dynamically. */ |
| 2917 | const page_tcxx . . $ `storage/innobase/include/page0types.h:38:9`!* page = page_cur_get_pagecxx . . $ `storage/innobase/include/page0cur.h:59:9`!(cursor); |
| 2918 | |
| 2919 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(page_zip == page_cur_get_page_zip(cursor)); |
| 2920 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rec_offs_validate(page_cur_get_rec(cursor), index, offsets)); |
| 2921 | |
| 2922 | if (page_zip_availablecxx . . $ page_zip_available(b51f516ccf7dc7b1).(page_zip, dict_index_is_clustcxx . . $ `storage/innobase/include/dict0dict.h:617:9`!(index), |
| 2923 | length, create)) { |
| 2924 | return(true); |
| 2925 | } |
| 2926 | |
| 2927 | if (!page_zip->m_nonemptycxx . . $ page_zip_des_t#m_nonempty. && !page_has_garbagecxx . . $ page_has_garbage(190063cf6fb4afb1).(page)) { |
| 2928 | /* The page has been freshly compressed, so |
| 2929 | reorganizing it will not help. */ |
| 2930 | return(false); |
| 2931 | } |
| 2932 | |
| 2933 | if (create && page_is_leafcxx . . $ page_is_leaf(190063cf6fb4afb1).(page) |
| 2934 | && (length + page_get_data_sizecxx . . $ page_get_data_size(469dcb4e54b221a8).(page) |
| 2935 | >= dict_index_zip_pad_optimal_page_sizecxx . . $ dict_index_zip_pad_optimal_page_size(2e6d4b3eeae69f8c).(index))) { |
| 2936 | return(false); |
| 2937 | } |
| 2938 | |
| 2939 | if (btr_page_reorganizecxx . . $ btr_page_reorganize(e4b2ea64c1f14b9e).(cursor, mtr) == DB_SUCCESScxx . . $ DB_SUCCESS.) { |
| 2940 | rec_offs_make_validcxx . . $ `storage/innobase/include/rem0rec.h:520:10`!(page_cur_get_rec(cursor), index, |
| 2941 | page_is_leaf(page), offsets); |
| 2942 | |
| 2943 | return page_zip_availablecxx . . $ page_zip_available(b51f516ccf7dc7b1).(page_zip, dict_index_is_clustcxx . . $ `storage/innobase/include/dict0dict.h:617:9`!(index), |
| 2944 | length, create); |
| 2945 | } |
| 2946 | |
| 2947 | return(false); |
| 2948 | } |
| 2949 | |
| 2950 | /** Apply an update vector to a record. No field size changes are allowed. |
| 2951 | |
| 2952 | This is usually invoked on a clustered index. The only use case for a |
| 2953 | secondary index is row_ins_sec_index_entry_by_modify() or its |
| 2954 | counterpart in ibuf_insert_to_index_page(). |
| 2955 | @param[in,out] rec index record |
| 2956 | @param[in] index the index of the record |
| 2957 | @param[in] offsets rec_get_offsets(rec, index) |
| 2958 | @param[in] update update vector |
| 2959 | @param[in,out] block index page |
| 2960 | @param[in,out] mtr mini-transaction */ |
| 2961 | void btr_cur_upd_rec_in_placecxx . . $ btr_cur_upd_rec_in_place(44ce334ad98f1616).(rec_tcxx . . $ rec_t# *rec, const dict_index_tcxx . . $ dict_index_t# *index, |
| 2962 | const rec_offscxx . . $ rec_offs# *offsets, const upd_tcxx . . $ upd_t# *update, |
| 2963 | buf_block_tcxx . . $ buf_block_t# *block, mtr_tcxx . . $ mtr_t# *mtr) |
| 2964 | { |
| 2965 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rec_offs_validate(rec, index, offsets)); |
| 2966 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!index->table->skip_alter_undo); |
| 2967 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!block->page.zip.data || index->table->not_redundant()); |
| 2968 | |
| 2969 | #ifdef UNIV_DEBUG |
| 2970 | if (rec_offs_comp(offsets)) { |
| 2971 | switch (rec_get_status(rec)) { |
| 2972 | case REC_STATUS_ORDINARY: |
| 2973 | break; |
| 2974 | case REC_STATUS_INSTANT: |
| 2975 | ut_ad(index->is_instant()); |
| 2976 | break; |
| 2977 | case REC_STATUS_NODE_PTR: |
| 2978 | case REC_STATUS_INFIMUM: |
| 2979 | case REC_STATUS_SUPREMUM: |
| 2980 | ut_ad("wrong record status in update" == 0); |
| 2981 | } |
| 2982 | } |
| 2983 | #endif /* UNIV_DEBUG */ |
| 2984 | |
| 2985 | static_assert(REC_INFO_BITS_SHIFTcxx . . $ `storage/innobase/include/rem0rec.inl:108:9`! == 0, "compatibility"); |
| 2986 | if (UNIV_LIKELY_NULLcxx . . $ `storage/innobase/include/univ.i:393:10`!(block->page.zip.data)) { |
| 2987 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rec_offs_comp(offsets)); |
| 2988 | bytecxx . . $ byte#* info_bits = &rec[-REC_NEW_INFO_BITScxx . . $ `storage/innobase/include/rem0rec.inl:106:9`!]; |
| 2989 | const bool flip_del_mark = (*info_bits ^ update->info_bitscxx . . $ upd_t#info_bits.) |
| 2990 | & REC_INFO_DELETED_FLAGcxx . . $ `storage/innobase/include/data0type.h:506:9`!; |
| 2991 | *info_bits &= bytecxx . . $ byte#(~REC_INFO_BITS_MASKcxx . . $ `storage/innobase/include/rem0rec.inl:107:9`!); |
| 2992 | *info_bits |= update->info_bitscxx . . $ upd_t#info_bits.; |
| 2993 | |
| 2994 | if (flip_del_mark) { |
| 2995 | page_zip_rec_set_deletedcxx . . $ page_zip_rec_set_deleted(470ecb4dfb7c5acf).(block, rec, update->info_bitscxx . . $ upd_t#info_bits. |
| 2996 | & REC_INFO_DELETED_FLAGcxx . . $ `storage/innobase/include/data0type.h:506:9`!, mtr); |
| 2997 | } |
| 2998 | } else { |
| 2999 | bytecxx . . $ byte#* info_bits = &rec[rec_offs_compcxx . . $ rec_offs_comp(6fce5c29061b60f9).(offsets) |
| 3000 | ? -REC_NEW_INFO_BITScxx . . $ `storage/innobase/include/rem0rec.inl:106:9`! |
| 3001 | : -REC_OLD_INFO_BITScxx . . $ `storage/innobase/include/rem0rec.inl:105:9`!]; |
| 3002 | |
| 3003 | mtr->writecxx . . $ mtr_t#write(4888ddbfa94c5eeb).<1,mtr_tcxx . . $ mtr_t#::MAYBE_NOPcxx . . $ mtr_t#MAYBE_NOP.>(*block, info_bits, |
| 3004 | (*info_bits |
| 3005 | & ~REC_INFO_BITS_MASKcxx . . $ `storage/innobase/include/rem0rec.inl:107:9`!) |
| 3006 | | update->info_bitscxx . . $ upd_t#info_bits.); |
| 3007 | } |
| 3008 | |
| 3009 | for (ulintcxx . . $ ulint# i = 0; i < update->n_fieldscxx . . $ upd_t#n_fields.; i++) { |
| 3010 | const upd_field_tcxx . . $ upd_field_t#* uf = upd_get_nth_fieldcxx . . $ `storage/innobase/include/row0upd.h:68:10`!(update, i); |
| 3011 | if (upd_fld_is_virtual_colcxx . . $ `storage/innobase/include/row0upd.h:321:9`!(uf) && !index->has_virtualcxx . . $ dict_index_t#has_virtual(50ce9a9e25b4a850).()) { |
| 3012 | continue; |
| 3013 | } |
| 3014 | const ulintcxx . . $ ulint# n = uf->field_nocxx . . $ upd_field_t#field_no.; |
| 3015 | |
| 3016 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!dfield_is_ext(&uf->new_val) |
| 3017 | == !rec_offs_nth_extern(offsets, n)); |
| 3018 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!rec_offs_nth_default(offsets, n)); |
| 3019 | |
| 3020 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(dfield_is_null(&uf->new_val))) { |
| 3021 | if (rec_offs_nth_sql_nullcxx . . $ rec_offs_nth_sql_null(878e7dc5509530f1).(offsets, n)) { |
| 3022 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(index->table->is_instant()); |
| 3023 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(n >= index->n_core_fields); |
| 3024 | continue; |
| 3025 | } |
| 3026 | |
| 3027 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!index->table->not_redundant()); |
| 3028 | switch (ulintcxx . . $ ulint# size = rec_get_nth_field_sizecxx . . $ rec_get_nth_field_size(4adc7973d4c4f159).(rec, n)) { |
| 3029 | case 0: |
| 3030 | break; |
| 3031 | case 1: |
| 3032 | mtr->writecxx . . $ mtr_t#write(4888ddbfa94c5eeb).<1,mtr_tcxx . . $ mtr_t#::MAYBE_NOPcxx . . $ mtr_t#MAYBE_NOP.>( |
| 3033 | *block, |
| 3034 | rec_get_field_start_offscxx . . $ rec_get_field_start_offs(4adc7973d4c4f159).(rec, n) + rec, |
| 3035 | 0U); |
| 3036 | break; |
| 3037 | default: |
| 3038 | mtr->memsetcxx . . $ mtr_t#memset(514fd140d769d0f8).( |
| 3039 | block, |
| 3040 | rec_get_field_start_offscxx . . $ rec_get_field_start_offs(4adc7973d4c4f159).(rec, n) + rec |
| 3041 | - block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame., |
| 3042 | size, 0); |
| 3043 | } |
| 3044 | ulintcxx . . $ ulint# l = rec_get_1byte_offs_flagcxx . . $ rec_get_1byte_offs_flag(b191ace3c5bffbd9).(rec) |
| 3045 | ? (n + 1) : (n + 1) * 2; |
| 3046 | bytecxx . . $ byte#* b = rec - REC_N_OLD_EXTRA_BYTEScxx . . $ `storage/innobase/include/rem0rec.h:43:9`! - l; |
| 3047 | compile_time_assertcxx . . $ `include/my_global.h:377:9`!(REC_1BYTE_SQL_NULL_MASK << 8 |
| 3048 | == REC_2BYTE_SQL_NULL_MASK); |
| 3049 | mtr->writecxx . . $ mtr_t#write(4888ddbfa94c5eeb).<1>(*block, b, |
| 3050 | bytecxx . . $ byte#(*b | REC_1BYTE_SQL_NULL_MASKcxx . . $ REC_1BYTE_SQL_NULL_MASK.)); |
| 3051 | continue; |
| 3052 | } |
| 3053 | |
| 3054 | ulintcxx . . $ ulint# len; |
| 3055 | bytecxx . . $ byte#* data = rec_get_nth_fieldcxx . . $ `storage/innobase/include/rem0rec.h:562:9`!(rec, offsets, n, &len); |
| 3056 | if (UNIV_LIKELY_NULLcxx . . $ `storage/innobase/include/univ.i:393:10`!(block->page.zip.data)) { |
| 3057 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(len == uf->new_val.len); |
| 3058 | memcpy(data, uf->new_valcxx . . $ upd_field_t#new_val..datacxx . . $ dfield_t#data., len); |
| 3059 | continue; |
| 3060 | } |
| 3061 | |
| 3062 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(len != uf->new_val.len)) { |
| 3063 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(len == UNIV_SQL_NULL); |
| 3064 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!rec_offs_comp(offsets)); |
| 3065 | len = uf->new_valcxx . . $ upd_field_t#new_val..lencxx . . $ dfield_t#len.; |
| 3066 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(len == rec_get_nth_field_size(rec, n)); |
| 3067 | ulintcxx . . $ ulint# l = rec_get_1byte_offs_flagcxx . . $ rec_get_1byte_offs_flag(b191ace3c5bffbd9).(rec) |
| 3068 | ? (n + 1) : (n + 1) * 2; |
| 3069 | bytecxx . . $ byte#* b = rec - REC_N_OLD_EXTRA_BYTEScxx . . $ `storage/innobase/include/rem0rec.h:43:9`! - l; |
| 3070 | compile_time_assertcxx . . $ `include/my_global.h:377:9`!(REC_1BYTE_SQL_NULL_MASK << 8 |
| 3071 | == REC_2BYTE_SQL_NULL_MASK); |
| 3072 | mtr->writecxx . . $ mtr_t#write(4888ddbfa94c5eeb).<1>(*block, b, |
| 3073 | bytecxx . . $ byte#(*b & ~REC_1BYTE_SQL_NULL_MASKcxx . . $ REC_1BYTE_SQL_NULL_MASK.)); |
| 3074 | } |
| 3075 | |
| 3076 | if (len) { |
| 3077 | mtr->memcpycxx . . $ mtr_t#memcpy(cacdda589782ca45).<mtr_tcxx . . $ mtr_t#::MAYBE_NOPcxx . . $ mtr_t#MAYBE_NOP.>(*block, data, |
| 3078 | uf->new_valcxx . . $ upd_field_t#new_val..datacxx . . $ dfield_t#data., len); |
| 3079 | } |
| 3080 | } |
| 3081 | |
| 3082 | if (UNIV_LIKELYcxx . . $ `storage/innobase/include/univ.i:437:9`!(!block->page.zip.data)) { |
| 3083 | return; |
| 3084 | } |
| 3085 | |
| 3086 | switch (update->n_fieldscxx . . $ upd_t#n_fields.) { |
| 3087 | case 0: |
| 3088 | /* We only changed the delete-mark flag. */ |
| 3089 | return; |
| 3090 | case 1: |
| 3091 | if (!index->is_clustcxx . . $ dict_index_t#is_clust(50ce9a9e25b4a850).() |
| 3092 | || update->fieldscxx . . $ upd_t#fields.[0].field_nocxx . . $ upd_field_t#field_no. != index->db_roll_ptrcxx . . $ dict_index_t#db_roll_ptr(72085aa11f4b6e09).()) { |
| 3093 | break; |
| 3094 | } |
| 3095 | goto update_sys; |
| 3096 | case 2: |
| 3097 | if (!index->is_clustcxx . . $ dict_index_t#is_clust(50ce9a9e25b4a850).() |
| 3098 | || update->fieldscxx . . $ upd_t#fields.[0].field_nocxx . . $ upd_field_t#field_no. != index->db_trx_idcxx . . $ dict_index_t#db_trx_id(72085aa11f4b6e09).() |
| 3099 | || update->fieldscxx . . $ upd_t#fields.[1].field_nocxx . . $ upd_field_t#field_no. != index->db_roll_ptrcxx . . $ dict_index_t#db_roll_ptr(72085aa11f4b6e09).()) { |
| 3100 | break; |
| 3101 | } |
| 3102 | update_sys: |
| 3103 | ulintcxx . . $ ulint# len; |
| 3104 | const bytecxx . . $ byte#* sys = rec_get_nth_fieldcxx . . $ `storage/innobase/include/rem0rec.h:562:9`!(rec, offsets, |
| 3105 | index->db_trx_id(), &len); |
| 3106 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(len == DATA_TRX_ID_LEN); |
| 3107 | page_zip_write_trx_id_and_roll_ptrcxx . . $ page_zip_write_trx_id_and_roll_ptr(ae05c1ec80a1617c).( |
| 3108 | block, rec, offsets, index->db_trx_idcxx . . $ dict_index_t#db_trx_id(72085aa11f4b6e09).(), |
| 3109 | trx_read_trx_idcxx . . $ trx_read_trx_id(b191ace3c5bffbd9).(sys), |
| 3110 | trx_read_roll_ptrcxx . . $ trx_read_roll_ptr(b191ace3c5bffbd9).(sys + DATA_TRX_ID_LENcxx . . $ `storage/innobase/include/data0type.h:156:9`!), mtr); |
| 3111 | return; |
| 3112 | } |
| 3113 | |
| 3114 | page_zip_write_reccxx . . $ page_zip_write_rec(a146ada4f6a0173d).(block, rec, index, offsets, 0, mtr); |
| 3115 | } |
| 3116 | |
| 3117 | /** Check if a ROW_FORMAT=COMPRESSED page can be updated in place |
| 3118 | @param cur cursor pointing to ROW_FORMAT=COMPRESSED page |
| 3119 | @param offsets rec_get_offsets(btr_cur_get_rec(cur)) |
| 3120 | @param update index fields being updated |
| 3121 | @param mtr mini-transaction |
| 3122 | @return the record in the ROW_FORMAT=COMPRESSED page |
| 3123 | @retval nullptr if the page cannot be updated in place */ |
| 3124 | ATTRIBUTE_COLDcxx . . $ `include/my_compiler.h:166:10`! static |
| 3125 | rec_tcxx . . $ rec_t# *btr_cur_update_in_place_zip_checkcxx . . $ btr_cur_update_in_place_zip_check(a8c7a42f7ac7052).(btr_cur_tcxx . . $ btr_cur_t# *cur, rec_offscxx . . $ rec_offs# *offsets, |
| 3126 | const upd_tcxx . . $ upd_t#& update, mtr_tcxx . . $ mtr_t# *mtr) |
| 3127 | { |
| 3128 | dict_index_tcxx . . $ dict_index_t# *index= cur->indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).(); |
| 3129 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!index->table->is_temporary()); |
| 3130 | |
| 3131 | switch (update.n_fieldscxx . . $ upd_t#n_fields.) { |
| 3132 | case 0: |
| 3133 | /* We are only changing the delete-mark flag. */ |
| 3134 | break; |
| 3135 | case 1: |
| 3136 | if (!index->is_clustcxx . . $ dict_index_t#is_clust(50ce9a9e25b4a850).() || |
| 3137 | update.fieldscxx . . $ upd_t#fields.[0].field_nocxx . . $ upd_field_t#field_no. != index->db_roll_ptrcxx . . $ dict_index_t#db_roll_ptr(72085aa11f4b6e09).()) |
| 3138 | goto check_for_overflow; |
| 3139 | /* We are only changing the delete-mark flag and DB_ROLL_PTR. */ |
| 3140 | break; |
| 3141 | case 2: |
| 3142 | if (!index->is_clustcxx . . $ dict_index_t#is_clust(50ce9a9e25b4a850).() || |
| 3143 | update.fieldscxx . . $ upd_t#fields.[0].field_nocxx . . $ upd_field_t#field_no. != index->db_trx_idcxx . . $ dict_index_t#db_trx_id(72085aa11f4b6e09).() || |
| 3144 | update.fieldscxx . . $ upd_t#fields.[1].field_nocxx . . $ upd_field_t#field_no. != index->db_roll_ptrcxx . . $ dict_index_t#db_roll_ptr(72085aa11f4b6e09).()) |
| 3145 | goto check_for_overflow; |
| 3146 | /* We are only changing DB_TRX_ID, DB_ROLL_PTR, and the delete-mark. |
| 3147 | They can be updated in place in the uncompressed part of the |
| 3148 | ROW_FORMAT=COMPRESSED page. */ |
| 3149 | break; |
| 3150 | check_for_overflow: |
| 3151 | default: |
| 3152 | if (!btr_cur_update_alloc_zipcxx . . $ `storage/innobase/include/btr0cur.h:225:10`!(btr_cur_get_page_zip(cur), |
| 3153 | btr_cur_get_page_curcxx . . $ `storage/innobase/include/btr0cur.h:62:9`!(cur), |
| 3154 | offsets, rec_offs_size(offsets), |
| 3155 | false, mtr)) |
| 3156 | return nullptr; |
| 3157 | } |
| 3158 | |
| 3159 | return btr_cur_get_reccxx . . $ `storage/innobase/include/btr0cur.h:64:9`!(cur); |
| 3160 | } |
| 3161 | |
| 3162 | /*************************************************************//** |
| 3163 | Updates a record when the update causes no size changes in its fields. |
| 3164 | We assume here that the ordering fields of the record do not change. |
| 3165 | @return locking or undo log related error code, or |
| 3166 | @retval DB_SUCCESS on success |
| 3167 | @retval DB_ZIP_OVERFLOW if there is not enough space left |
| 3168 | on a ROW_FORMAT=COMPRESSED page */ |
| 3169 | dberr_tcxx . . $ dberr_t# |
| 3170 | btr_cur_update_in_placecxx . . $ btr_cur_update_in_place(5d689aab8a84140f).( |
| 3171 | /*====================*/ |
| 3172 | ulintcxx . . $ ulint# flags, /*!< in: undo logging and locking flags */ |
| 3173 | btr_cur_tcxx . . $ btr_cur_t#* cursor, /*!< in: cursor on the record to update; |
| 3174 | cursor stays valid and positioned on the |
| 3175 | same record */ |
| 3176 | rec_offscxx . . $ rec_offs#* offsets,/*!< in/out: offsets on cursor->page_cur.rec */ |
| 3177 | const upd_tcxx . . $ upd_t#* update, /*!< in: update vector */ |
| 3178 | ulintcxx . . $ ulint# cmpl_info,/*!< in: compiler info on secondary index |
| 3179 | updates */ |
| 3180 | que_thr_tcxx . . $ que_thr_t#* thr, /*!< in: query thread */ |
| 3181 | trx_id_tcxx . . $ trx_id_t# trx_id, /*!< in: transaction id */ |
| 3182 | mtr_tcxx . . $ mtr_t#* mtr) /*!< in/out: mini-transaction; if this |
| 3183 | is a secondary index, the caller must |
| 3184 | mtr_commit(mtr) before latching any |
| 3185 | further pages */ |
| 3186 | { |
| 3187 | dict_index_tcxx . . $ dict_index_t#* index; |
| 3188 | rec_tcxx . . $ rec_t#* rec; |
| 3189 | roll_ptr_tcxx . . $ roll_ptr_t# roll_ptr = 0; |
| 3190 | ulintcxx . . $ ulint# was_delete_marked; |
| 3191 | |
| 3192 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(page_is_leaf(cursor->page_cur.block->page.frame)); |
| 3193 | rec = btr_cur_get_reccxx . . $ `storage/innobase/include/btr0cur.h:64:9`!(cursor); |
| 3194 | index = cursor->indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).(); |
| 3195 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rec_offs_validate(rec, index, offsets)); |
| 3196 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!!page_rec_is_comp(rec) == dict_table_is_comp(index->table)); |
| 3197 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(trx_id > 0 || (flags & BTR_KEEP_SYS_FLAG) |
| 3198 | || index->table->is_temporary()); |
| 3199 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(dict_index_is_online_ddl(index) == !!(flags & BTR_CREATE_FLAG) |
| 3200 | || index->is_primary()); |
| 3201 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(thr_get_trx(thr)->id == trx_id |
| 3202 | || (flags & ulint(~BTR_KEEP_POS_FLAG)) |
| 3203 | == (BTR_NO_UNDO_LOG_FLAG | BTR_NO_LOCKING_FLAG |
| 3204 | | BTR_CREATE_FLAG | BTR_KEEP_SYS_FLAG)); |
| 3205 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(fil_page_index_page_check(btr_cur_get_page(cursor))); |
| 3206 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(btr_page_get_index_id(btr_cur_get_page(cursor)) == index->id); |
| 3207 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!(update->info_bits & REC_INFO_MIN_REC_FLAG)); |
| 3208 | |
| 3209 | DBUG_LOGcxx . . $ `include/my_dbug.h:235:11`!("ib_cur", |
| 3210 | "update-in-place " << index->name << " (" << index->id |
| 3211 | << ") by " << ib::hex(trx_id) << ": " |
| 3212 | << rec_printer(rec, offsets).str()); |
| 3213 | |
| 3214 | buf_block_tcxx . . $ buf_block_t#* block = btr_cur_get_blockcxx . . $ `storage/innobase/include/btr0cur.h:63:9`!(cursor); |
| 3215 | page_zip_des_tcxx . . $ page_zip_des_t#* page_zip = buf_block_get_page_zipcxx . . $ `storage/innobase/include/buf0buf.h:390:9`!(block); |
| 3216 | |
| 3217 | /* Check that enough space is available on the compressed page. */ |
| 3218 | if (UNIV_LIKELY_NULLcxx . . $ `storage/innobase/include/univ.i:393:10`!(page_zip) |
| 3219 | && !(rec = btr_cur_update_in_place_zip_checkcxx . . $ btr_cur_update_in_place_zip_check(a8c7a42f7ac7052).( |
| 3220 | cursor, offsets, *update, mtr))) { |
| 3221 | return DB_ZIP_OVERFLOWcxx . . $ DB_ZIP_OVERFLOW.; |
| 3222 | } |
| 3223 | |
| 3224 | /* Do lock checking and undo logging */ |
| 3225 | if (dberr_tcxx . . $ dberr_t# err = btr_cur_upd_lock_and_undocxx . . $ btr_cur_upd_lock_and_undo(7bb56c7fd0c4544e).(flags, cursor, offsets, |
| 3226 | update, cmpl_info, |
| 3227 | thr, mtr, &roll_ptr)) { |
| 3228 | return err; |
| 3229 | } |
| 3230 | |
| 3231 | if (flags & BTR_KEEP_SYS_FLAGcxx . . $ BTR_KEEP_SYS_FLAG.) { |
| 3232 | } else if (dberr_tcxx . . $ dberr_t# err = btr_cur_upd_rec_syscxx . . $ btr_cur_upd_rec_sys(e2b18affefdcc973).(block, rec, index, offsets, |
| 3233 | thr_get_trxcxx . . $ thr_get_trx(bce191eb970ff2ca).(thr), |
| 3234 | roll_ptr, mtr)) { |
| 3235 | return err; |
| 3236 | } |
| 3237 | |
| 3238 | was_delete_marked = rec_get_deleted_flagcxx . . $ rec_get_deleted_flag(4adc7973d4c4f159).( |
| 3239 | rec, page_is_compcxx . . $ page_is_comp(f3688bc2ee54ea05).(buf_block_get_framecxx . . $ `storage/innobase/include/buf0buf.h:385:9`!(block))); |
| 3240 | /* In delete-marked records, DB_TRX_ID must always refer to an |
| 3241 | existing undo log record. */ |
| 3242 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!was_delete_marked |
| 3243 | || !dict_index_is_clust(index) |
| 3244 | || row_get_rec_trx_id(rec, index, offsets)); |
| 3245 | |
| 3246 | #ifdef BTR_CUR_HASH_ADAPTcxx . . $ `<built-in>:481:9`! |
| 3247 | { |
| 3248 | auto part = block->indexcxx . . $ buf_block_t#index. |
| 3249 | ? &btr_searchcxx . . $ btr_search..get_partcxx . . $ btr_sea#get_part(85b9523d50af32eb).(*index) : nullptr; |
| 3250 | if (part) { |
| 3251 | /* TO DO: Can we skip this if none of the fields |
| 3252 | index->search_info->curr_n_fields |
| 3253 | are being updated? */ |
| 3254 | |
| 3255 | /* The function row_upd_changes_ord_field_binary |
| 3256 | does not work on a secondary index. */ |
| 3257 | |
| 3258 | if (!dict_index_is_clustcxx . . $ `storage/innobase/include/dict0dict.h:617:9`!(index) |
| 3259 | || row_upd_changes_ord_field_binarycxx . . $ `storage/innobase/include/row0upd.h:257:10`!( |
| 3260 | index, update, thr, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)) { |
| 3261 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!(update->info_bits |
| 3262 | & REC_INFO_MIN_REC_FLAG)); |
| 3263 | /* Remove possible hash index pointer |
| 3264 | to this record */ |
| 3265 | btr_search_update_hash_on_deletecxx . . $ btr_search_update_hash_on_delete(c309ee090c231893).(cursor); |
| 3266 | } |
| 3267 | |
| 3268 | part->latchcxx . . $ btr_sea#partition#latch..wr_lockcxx . . $ srw_lock_impl#wr_lock(9bb8261ff8654062).(SRW_LOCK_CALLcxx . . $ `storage/innobase/include/srw_lock.h:44:10`!); |
| 3269 | } |
| 3270 | |
| 3271 | assert_block_ahi_validcxx . . $ `storage/innobase/include/buf0buf.h:881:11`!(block); |
| 3272 | #endif /* BTR_CUR_HASH_ADAPT */ |
| 3273 | |
| 3274 | btr_cur_upd_rec_in_placecxx . . $ btr_cur_upd_rec_in_place(44ce334ad98f1616).(rec, index, offsets, update, block, |
| 3275 | mtr); |
| 3276 | |
| 3277 | #ifdef BTR_CUR_HASH_ADAPTcxx . . $ `<built-in>:481:9`! |
| 3278 | if (part) { |
| 3279 | part->latchcxx . . $ btr_sea#partition#latch..wr_unlockcxx . . $ srw_lock_impl#wr_unlock(ced63f7c635d850d).(); |
| 3280 | } |
| 3281 | } |
| 3282 | #endif /* BTR_CUR_HASH_ADAPT */ |
| 3283 | |
| 3284 | if (was_delete_marked |
| 3285 | && !rec_get_deleted_flagcxx . . $ rec_get_deleted_flag(4adc7973d4c4f159).( |
| 3286 | rec, page_is_compcxx . . $ page_is_comp(f3688bc2ee54ea05).(buf_block_get_framecxx . . $ `storage/innobase/include/buf0buf.h:385:9`!(block)))) { |
| 3287 | /* The new updated record owns its possible externally |
| 3288 | stored fields */ |
| 3289 | |
| 3290 | btr_cur_unmark_extern_fieldscxx . . $ btr_cur_unmark_extern_fields(2a7528bc66954456).(block, rec, index, offsets, mtr); |
| 3291 | } |
| 3292 | |
| 3293 | return DB_SUCCESScxx . . $ DB_SUCCESS.; |
| 3294 | } |
| 3295 | |
| 3296 | /** Trim a metadata record during the rollback of instant ALTER TABLE. |
| 3297 | @param[in] entry metadata tuple |
| 3298 | @param[in] index primary key |
| 3299 | @param[in] update update vector for the rollback |
| 3300 | @param[in,out] trx transaction */ |
| 3301 | ATTRIBUTE_COLDcxx . . $ `include/my_compiler.h:166:10`! |
| 3302 | static void btr_cur_trim_alter_metadatacxx . . $ btr_cur_trim_alter_metadata(5c47bdbfdc21b71c).(dtuple_tcxx . . $ dtuple_t#* entry, |
| 3303 | const dict_index_tcxx . . $ dict_index_t#* index, |
| 3304 | const upd_tcxx . . $ upd_t#* update, trx_tcxx . . $ trx_t# *trx) |
| 3305 | { |
| 3306 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(index->is_instant()); |
| 3307 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(update->is_alter_metadata()); |
| 3308 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(entry->is_alter_metadata()); |
| 3309 | |
| 3310 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(update->fields[0].field_no == index->first_user_field()); |
| 3311 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(update->fields[0].new_val.ext); |
| 3312 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(update->fields[0].new_val.len == FIELD_REF_SIZE); |
| 3313 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(entry->n_fields - 1 == index->n_fields); |
| 3314 | |
| 3315 | const bytecxx . . $ byte#* ptr = static_cast<const bytecxx . . $ byte#*>( |
| 3316 | update->fieldscxx . . $ upd_t#fields.[0].new_valcxx . . $ upd_field_t#new_val..datacxx . . $ dfield_t#data.); |
| 3317 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!mach_read_from_4(ptr + BTR_EXTERN_LEN)); |
| 3318 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mach_read_from_4(ptr + BTR_EXTERN_LEN + 4) > 4); |
| 3319 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mach_read_from_4(ptr + BTR_EXTERN_OFFSET) == FIL_PAGE_DATA); |
| 3320 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mach_read_from_4(ptr + BTR_EXTERN_SPACE_ID) |
| 3321 | == index->table->space->id); |
| 3322 | |
| 3323 | ulintcxx . . $ ulint# n_fields = update->fieldscxx . . $ upd_t#fields.[1].field_nocxx . . $ upd_field_t#field_no.; |
| 3324 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(n_fields <= index->n_fields); |
| 3325 | if (n_fields != index->n_uniqcxx . . $ dict_index_t#n_uniq.) { |
| 3326 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(n_fields |
| 3327 | >= index->n_core_fields); |
| 3328 | entry->n_fieldscxx . . $ dtuple_t#n_fields. = uint16_tcxx . . $ uint16_t#(n_fields); |
| 3329 | return; |
| 3330 | } |
| 3331 | |
| 3332 | /* This is based on dict_table_t::deserialise_columns() |
| 3333 | and btr_cur_instant_init_low(). */ |
| 3334 | mtr_tcxx . . $ mtr_t# mtrcxx . . $ mtr_t#mtr_t(a6968fd0d8f26912).{trx}; |
| 3335 | mtr.startcxx . . $ mtr_t#start(49f6e7a06ebc5aa8).(); |
| 3336 | buf_block_tcxx . . $ buf_block_t#* block = buf_page_getcxx . . $ `storage/innobase/include/buf0buf.h:149:10`!( |
| 3337 | page_id_t(index->table->space->id, |
| 3338 | mach_read_from_4(ptr + BTR_EXTERN_PAGE_NOcxx . . $ `storage/innobase/include/btr0cur.h:794:9`!)), |
| 3339 | 0, RW_S_LATCH, &mtr); |
| 3340 | if (!block) { |
| 3341 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!("corruption" == 0); |
| 3342 | mtr.commitcxx . . $ mtr_t#commit(49f6e7a06ebc5aa8).(); |
| 3343 | return; |
| 3344 | } |
| 3345 | |
| 3346 | btr_search_drop_page_hash_indexcxx . . $ btr_search_drop_page_hash_index(33307f3566ecc1a8).(block, index); |
| 3347 | |
| 3348 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(fil_page_get_type(block->page.frame) == FIL_PAGE_TYPE_BLOB); |
| 3349 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mach_read_from_4(&block->page.frame |
| 3350 | [FIL_PAGE_DATA + BTR_BLOB_HDR_NEXT_PAGE_NO]) |
| 3351 | == FIL_NULL); |
| 3352 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mach_read_from_4(&block->page.frame |
| 3353 | [FIL_PAGE_DATA + BTR_BLOB_HDR_PART_LEN]) |
| 3354 | == mach_read_from_4(ptr + BTR_EXTERN_LEN + 4)); |
| 3355 | n_fields = mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).( |
| 3356 | &block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.[FIL_PAGE_DATAcxx . . $ `storage/innobase/include/fil0fil.h:1249:9`! + BTR_BLOB_HDR_SIZEcxx . . $ `storage/innobase/btr/btr0cur.cc:122:9`!]) |
| 3357 | + index->first_user_fieldcxx . . $ dict_index_t#first_user_field(72085aa11f4b6e09).(); |
| 3358 | /* Rollback should not increase the number of fields. */ |
| 3359 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(n_fields <= index->n_fields); |
| 3360 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(n_fields + 1 <= entry->n_fields); |
| 3361 | /* dict_index_t::clear_instant_alter() cannot be invoked while |
| 3362 | rollback of an instant ALTER TABLE transaction is in progress |
| 3363 | for an is_alter_metadata() record. */ |
| 3364 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(n_fields >= index->n_core_fields); |
| 3365 | |
| 3366 | mtr.commitcxx . . $ mtr_t#commit(49f6e7a06ebc5aa8).(); |
| 3367 | entry->n_fieldscxx . . $ dtuple_t#n_fields. = uint16_tcxx . . $ uint16_t#(n_fields + 1); |
| 3368 | } |
| 3369 | |
| 3370 | /** Trim an update tuple due to instant ADD COLUMN, if needed. |
| 3371 | For normal records, the trailing instantly added fields that match |
| 3372 | the initial default values are omitted. |
| 3373 | |
| 3374 | For the special metadata record on a table on which instant |
| 3375 | ADD COLUMN has already been executed, both ADD COLUMN and the |
| 3376 | rollback of ADD COLUMN need to be handled specially. |
| 3377 | |
| 3378 | @param[in,out] entry index entry |
| 3379 | @param[in] index index |
| 3380 | @param[in] update update vector |
| 3381 | @param[in] thr execution thread */ |
| 3382 | static inline |
| 3383 | void |
| 3384 | btr_cur_trimcxx . . $ btr_cur_trim(442d30e0ddec5d33).( |
| 3385 | dtuple_tcxx . . $ dtuple_t#* entry, |
| 3386 | const dict_index_tcxx . . $ dict_index_t#* index, |
| 3387 | const upd_tcxx . . $ upd_t#* update, |
| 3388 | const que_thr_tcxx . . $ que_thr_t#* thr) |
| 3389 | { |
| 3390 | if (!index->is_instantcxx . . $ dict_index_t#is_instant(50ce9a9e25b4a850).()) { |
| 3391 | } else if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(update->is_metadata())) { |
| 3392 | /* We are either updating a metadata record |
| 3393 | (instant ALTER TABLE on a table where instant ALTER was |
| 3394 | already executed) or rolling back such an operation. */ |
| 3395 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!upd_get_nth_field(update, 0)->orig_len); |
| 3396 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(entry->is_metadata()); |
| 3397 | trx_tcxx . . $ trx_t#* const trx{thr->graphcxx . . $ que_thr_t#graph.->trxcxx . . $ que_fork_t#trx.}; |
| 3398 | |
| 3399 | if (trx->in_rollbackcxx . . $ trx_t#in_rollback.) { |
| 3400 | /* This rollback can occur either as part of |
| 3401 | ha_innobase::commit_inplace_alter_table() rolling |
| 3402 | back after a failed innobase_add_instant_try(), |
| 3403 | or as part of crash recovery. Either way, the |
| 3404 | table will be in the data dictionary cache, with |
| 3405 | the instantly added columns going to be removed |
| 3406 | later in the rollback. */ |
| 3407 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(index->table->cached); |
| 3408 | /* The DB_TRX_ID,DB_ROLL_PTR are always last, |
| 3409 | and there should be some change to roll back. |
| 3410 | The first field in the update vector is the |
| 3411 | first instantly added column logged by |
| 3412 | innobase_add_instant_try(). */ |
| 3413 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(update->n_fields > 2); |
| 3414 | if (update->is_alter_metadatacxx . . $ upd_t#is_alter_metadata(50ce9a9e25b4a850).()) { |
| 3415 | btr_cur_trim_alter_metadatacxx . . $ btr_cur_trim_alter_metadata(5c47bdbfdc21b71c).( |
| 3416 | entry, index, update, trx); |
| 3417 | return; |
| 3418 | } |
| 3419 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!entry->is_alter_metadata()); |
| 3420 | |
| 3421 | ulintcxx . . $ ulint# n_fields = upd_get_nth_fieldcxx . . $ `storage/innobase/include/row0upd.h:68:10`!(update, 0) |
| 3422 | ->field_nocxx . . $ upd_field_t#field_no.; |
| 3423 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(n_fields + 1 >= entry->n_fields); |
| 3424 | entry->n_fieldscxx . . $ dtuple_t#n_fields. = uint16_tcxx . . $ uint16_t#(n_fields); |
| 3425 | } |
| 3426 | } else { |
| 3427 | entry->trimcxx . . $ dtuple_t#trim(2d597176275c4795).(*index); |
| 3428 | } |
| 3429 | } |
| 3430 | |
| 3431 | /*************************************************************//** |
| 3432 | Tries to update a record on a page in an index tree. It is assumed that mtr |
| 3433 | holds an x-latch on the page. The operation does not succeed if there is too |
| 3434 | little space on the page or if the update would result in too empty a page, |
| 3435 | so that tree compression is recommended. We assume here that the ordering |
| 3436 | fields of the record do not change. |
| 3437 | @return error code, including |
| 3438 | @retval DB_SUCCESS on success |
| 3439 | @retval DB_OVERFLOW if the updated record does not fit |
| 3440 | @retval DB_UNDERFLOW if the page would become too empty |
| 3441 | @retval DB_ZIP_OVERFLOW if there is not enough space left |
| 3442 | on a ROW_FORMAT=COMPRESSED page */ |
| 3443 | dberr_tcxx . . $ dberr_t# |
| 3444 | btr_cur_optimistic_updatecxx . . $ btr_cur_optimistic_update(c5dbdb1e1dfafe63).( |
| 3445 | /*======================*/ |
| 3446 | ulintcxx . . $ ulint# flags, /*!< in: undo logging and locking flags */ |
| 3447 | btr_cur_tcxx . . $ btr_cur_t#* cursor, /*!< in: cursor on the record to update; |
| 3448 | cursor stays valid and positioned on the |
| 3449 | same record */ |
| 3450 | rec_offscxx . . $ rec_offs#** offsets,/*!< out: offsets on cursor->page_cur.rec */ |
| 3451 | mem_heap_tcxx . . $ mem_heap_t#** heap, /*!< in/out: pointer to NULL or memory heap */ |
| 3452 | const upd_tcxx . . $ upd_t#* update, /*!< in: update vector; this must also |
| 3453 | contain trx id and roll ptr fields */ |
| 3454 | ulintcxx . . $ ulint# cmpl_info,/*!< in: compiler info on secondary index |
| 3455 | updates */ |
| 3456 | que_thr_tcxx . . $ que_thr_t#* thr, /*!< in: query thread */ |
| 3457 | trx_id_tcxx . . $ trx_id_t# trx_id, /*!< in: transaction id */ |
| 3458 | mtr_tcxx . . $ mtr_t#* mtr) /*!< in/out: mini-transaction; if this |
| 3459 | is a secondary index, the caller must |
| 3460 | mtr_commit(mtr) before latching any |
| 3461 | further pages */ |
| 3462 | { |
| 3463 | dict_index_tcxx . . $ dict_index_t#* index; |
| 3464 | page_cur_tcxx . . $ page_cur_t#* page_cursor; |
| 3465 | dberr_tcxx . . $ dberr_t# err; |
| 3466 | buf_block_tcxx . . $ buf_block_t#* block; |
| 3467 | page_tcxx . . $ `storage/innobase/include/page0types.h:38:9`!* page; |
| 3468 | page_zip_des_tcxx . . $ page_zip_des_t#* page_zip; |
| 3469 | rec_tcxx . . $ rec_t#* rec; |
| 3470 | ulintcxx . . $ ulint# max_size; |
| 3471 | ulintcxx . . $ ulint# new_rec_size; |
| 3472 | ulintcxx . . $ ulint# old_rec_size; |
| 3473 | dtuple_tcxx . . $ dtuple_t#* new_entry; |
| 3474 | roll_ptr_tcxx . . $ roll_ptr_t# roll_ptr; |
| 3475 | ulintcxx . . $ ulint# i; |
| 3476 | |
| 3477 | block = btr_cur_get_blockcxx . . $ `storage/innobase/include/btr0cur.h:63:9`!(cursor); |
| 3478 | page = buf_block_get_framecxx . . $ `storage/innobase/include/buf0buf.h:385:9`!(block); |
| 3479 | rec = btr_cur_get_reccxx . . $ `storage/innobase/include/btr0cur.h:64:9`!(cursor); |
| 3480 | index = cursor->indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).(); |
| 3481 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(trx_id > 0 || (flags & BTR_KEEP_SYS_FLAG) |
| 3482 | || index->table->is_temporary()); |
| 3483 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!!page_rec_is_comp(rec) == dict_table_is_comp(index->table)); |
| 3484 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mtr->memo_contains_flagged(block, MTR_MEMO_PAGE_X_FIX)); |
| 3485 | /* This is intended only for leaf page updates */ |
| 3486 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(page_is_leaf(page)); |
| 3487 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(dict_index_is_online_ddl(index) == !!(flags & BTR_CREATE_FLAG) |
| 3488 | || dict_index_is_clust(index)); |
| 3489 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(thr_get_trx(thr)->id == trx_id |
| 3490 | || (flags & ulint(~BTR_KEEP_POS_FLAG)) |
| 3491 | == (BTR_NO_UNDO_LOG_FLAG | BTR_NO_LOCKING_FLAG |
| 3492 | | BTR_CREATE_FLAG | BTR_KEEP_SYS_FLAG)); |
| 3493 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(fil_page_index_page_check(page)); |
| 3494 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(btr_page_get_index_id(page) == index->id); |
| 3495 | |
| 3496 | *offsets = rec_get_offsetscxx . . $ `storage/innobase/include/rem0rec.h:475:10`!(rec, index, *offsets, index->n_core_fields, |
| 3497 | ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!, heap); |
| 3498 | #if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG |
| 3499 | /* Blob pointer can be null if InnoDB was killed or |
| 3500 | ran out of space while allocating a page. */ |
| 3501 | ut_a(!rec_offs_any_null_extern(rec, *offsets) |
| 3502 | || thr_get_trx(thr)->in_rollback); |
| 3503 | #endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */ |
| 3504 | |
| 3505 | if (UNIV_LIKELYcxx . . $ `storage/innobase/include/univ.i:437:9`!(!update->is_metadata()) |
| 3506 | && !row_upd_changes_field_size_or_externalcxx . . $ row_upd_changes_field_size_or_external(fd32628fcf491594).(index, *offsets, |
| 3507 | update)) { |
| 3508 | |
| 3509 | /* The simplest and the most common case: the update does not |
| 3510 | change the size of any field and none of the updated fields is |
| 3511 | externally stored in rec or update, and there is enough space |
| 3512 | on the compressed page to log the update. */ |
| 3513 | |
| 3514 | return(btr_cur_update_in_placecxx . . $ btr_cur_update_in_place(5d689aab8a84140f).( |
| 3515 | flags, cursor, *offsets, update, |
| 3516 | cmpl_info, thr, trx_id, mtr)); |
| 3517 | } |
| 3518 | |
| 3519 | if (rec_offs_any_externcxx . . $ rec_offs_any_extern(ca762aca731138fc).(*offsets)) { |
| 3520 | any_extern: |
| 3521 | /* Externally stored fields are treated in pessimistic |
| 3522 | update */ |
| 3523 | |
| 3524 | /* prefetch siblings of the leaf for the pessimistic |
| 3525 | operation. */ |
| 3526 | btr_cur_prefetch_siblingscxx . . $ btr_cur_prefetch_siblings(3d287479f68a2b77).(block, index, mtr->trxcxx . . $ mtr_t#trx.); |
| 3527 | |
| 3528 | return(DB_OVERFLOWcxx . . $ DB_OVERFLOW.); |
| 3529 | } |
| 3530 | |
| 3531 | if (rec_is_metadatacxx . . $ rec_is_metadata(5dcd923c19b1cb7d).(rec, *index) && index->tablecxx . . $ dict_index_t#table.->instantcxx . . $ dict_table_t#instant.) { |
| 3532 | goto any_extern; |
| 3533 | } |
| 3534 | |
| 3535 | for (i = 0; i < upd_get_n_fieldscxx . . $ upd_get_n_fields(c9dccea53ab13a00).(update); i++) { |
| 3536 | if (dfield_is_extcxx . . $ dfield_is_ext(421b5b1f6d6093e7).(&upd_get_nth_fieldcxx . . $ `storage/innobase/include/row0upd.h:68:10`!(update, i)->new_valcxx . . $ upd_field_t#new_val.)) { |
| 3537 | |
| 3538 | goto any_extern; |
| 3539 | } |
| 3540 | } |
| 3541 | |
| 3542 | DBUG_LOGcxx . . $ `include/my_dbug.h:235:11`!("ib_cur", |
| 3543 | "update " << index->name << " (" << index->id << ") by " |
| 3544 | << ib::hex(trx_id) << ": " |
| 3545 | << rec_printer(rec, *offsets).str()); |
| 3546 | |
| 3547 | page_cursor = btr_cur_get_page_curcxx . . $ `storage/innobase/include/btr0cur.h:62:9`!(cursor); |
| 3548 | |
| 3549 | if (!*heap) { |
| 3550 | *heap = mem_heap_createcxx . . $ `storage/innobase/include/mem0mem.h:85:10`!( |
| 3551 | rec_offs_size(*offsets) |
| 3552 | + DTUPLE_EST_ALLOCcxx . . $ `storage/innobase/include/data0data.h:214:9`!(rec_offs_n_fields(*offsets))); |
| 3553 | } |
| 3554 | |
| 3555 | new_entry = row_rec_to_index_entrycxx . . $ row_rec_to_index_entry(906df6b920478360).(rec, index, *offsets, *heap); |
| 3556 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!dtuple_get_n_ext(new_entry)); |
| 3557 | |
| 3558 | /* The page containing the clustered index record |
| 3559 | corresponding to new_entry is latched in mtr. |
| 3560 | Thus the following call is safe. */ |
| 3561 | row_upd_index_replace_new_col_vals_index_poscxx . . $ row_upd_index_replace_new_col_vals_index_pos(e4301329e7674fe3).(new_entry, index, update, |
| 3562 | *heap); |
| 3563 | btr_cur_trimcxx . . $ btr_cur_trim(442d30e0ddec5d33).(new_entry, index, update, thr); |
| 3564 | old_rec_size = rec_offs_sizecxx . . $ rec_offs_size(6fce5c29061b60f9).(*offsets); |
| 3565 | new_rec_size = rec_get_converted_sizecxx . . $ rec_get_converted_size(65a2a1c1835c6045).(index, new_entry, 0); |
| 3566 | |
| 3567 | page_zip = buf_block_get_page_zipcxx . . $ `storage/innobase/include/buf0buf.h:390:9`!(block); |
| 3568 | #ifdef UNIV_ZIP_DEBUG |
| 3569 | ut_a(!page_zip || page_zip_validate(page_zip, page, index)); |
| 3570 | #endif /* UNIV_ZIP_DEBUG */ |
| 3571 | |
| 3572 | if (page_zip) { |
| 3573 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!index->table->is_temporary()); |
| 3574 | |
| 3575 | if (page_zip_rec_needs_extcxx . . $ page_zip_rec_needs_ext(ca07b99eee158bc2).(new_rec_size, page_is_compcxx . . $ page_is_comp(f3688bc2ee54ea05).(page), |
| 3576 | dict_index_get_n_fieldscxx . . $ dict_index_get_n_fields(40995254b96f8651).(index), |
| 3577 | block->zip_sizecxx . . $ buf_block_t#zip_size(c9b1e749b64d5edc).())) { |
| 3578 | goto any_extern; |
| 3579 | } |
| 3580 | |
| 3581 | if (!btr_cur_update_alloc_zipcxx . . $ `storage/innobase/include/btr0cur.h:225:10`!( |
| 3582 | page_zip, page_cursor, *offsets, |
| 3583 | new_rec_size, true, mtr)) { |
| 3584 | return(DB_ZIP_OVERFLOWcxx . . $ DB_ZIP_OVERFLOW.); |
| 3585 | } |
| 3586 | |
| 3587 | rec = page_cur_get_reccxx . . $ `storage/innobase/include/page0cur.h:57:10`!(page_cursor); |
| 3588 | } |
| 3589 | |
| 3590 | /* We limit max record size to 16k even for 64k page size. */ |
| 3591 | if (new_rec_size >= COMPRESSED_REC_MAX_DATA_SIZEcxx . . $ `storage/innobase/include/rem0rec.h:1261:9`! || |
| 3592 | (!dict_table_is_compcxx . . $ `storage/innobase/include/dict0dict.h:776:9`!(index->table) |
| 3593 | && new_rec_size >= REDUNDANT_REC_MAX_DATA_SIZEcxx . . $ `storage/innobase/include/rem0rec.h:1256:9`!)) { |
| 3594 | err = DB_OVERFLOWcxx . . $ DB_OVERFLOW.; |
| 3595 | goto func_exit; |
| 3596 | } |
| 3597 | |
| 3598 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(new_rec_size |
| 3599 | >= (page_get_free_space_of_empty(page_is_comp(page)) |
| 3600 | / 2))) { |
| 3601 | err = DB_OVERFLOWcxx . . $ DB_OVERFLOW.; |
| 3602 | goto func_exit; |
| 3603 | } |
| 3604 | |
| 3605 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(page_get_data_size(page) |
| 3606 | - old_rec_size + new_rec_size |
| 3607 | < BTR_CUR_PAGE_COMPRESS_LIMITcxx . . $ `storage/innobase/include/btr0cur.h:616:9`!(index))) { |
| 3608 | /* The page would become too empty */ |
| 3609 | err = DB_UNDERFLOWcxx . . $ DB_UNDERFLOW.; |
| 3610 | goto func_exit; |
| 3611 | } |
| 3612 | |
| 3613 | /* We do not attempt to reorganize if the page is compressed. |
| 3614 | This is because the page may fail to compress after reorganization. */ |
| 3615 | max_size = page_zip |
| 3616 | ? page_get_max_insert_sizecxx . . $ page_get_max_insert_size(4adc7973d4c4f159).(page, 1) |
| 3617 | : (old_rec_size |
| 3618 | + page_get_max_insert_size_after_reorganizecxx . . $ page_get_max_insert_size_after_reorganize(4adc7973d4c4f159).(page, 1)); |
| 3619 | |
| 3620 | if (!(((max_size >= BTR_CUR_PAGE_REORGANIZE_LIMITcxx . . $ `storage/innobase/btr/btr0cur.cc:112:9`!) |
| 3621 | && (max_size >= new_rec_size)) |
| 3622 | || (page_get_n_recscxx . . $ page_get_n_recs(469dcb4e54b221a8).(page) <= 1))) { |
| 3623 | /* There was not enough space, or it did not pay to |
| 3624 | reorganize: for simplicity, we decide what to do assuming a |
| 3625 | reorganization is needed, though it might not be necessary */ |
| 3626 | |
| 3627 | err = DB_OVERFLOWcxx . . $ DB_OVERFLOW.; |
| 3628 | goto func_exit; |
| 3629 | } |
| 3630 | |
| 3631 | /* Do lock checking and undo logging */ |
| 3632 | err = btr_cur_upd_lock_and_undocxx . . $ btr_cur_upd_lock_and_undo(7bb56c7fd0c4544e).(flags, cursor, *offsets, |
| 3633 | update, cmpl_info, |
| 3634 | thr, mtr, &roll_ptr); |
| 3635 | if (err != DB_SUCCESScxx . . $ DB_SUCCESS.) { |
| 3636 | goto func_exit; |
| 3637 | } |
| 3638 | |
| 3639 | /* Ok, we may do the replacement. Store on the page infimum the |
| 3640 | explicit locks on rec, before deleting rec (see the comment in |
| 3641 | btr_cur_pessimistic_update). */ |
| 3642 | if (index->has_lockingcxx . . $ dict_index_t#has_locking(c9857a73d68e59ba).()) { |
| 3643 | lock_rec_store_on_page_infimumcxx . . $ lock_rec_store_on_page_infimum(8215f79b77a41d69).(block, rec); |
| 3644 | } |
| 3645 | |
| 3646 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(update->is_metadata())) { |
| 3647 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(new_entry->is_metadata()); |
| 3648 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(index->is_instant()); |
| 3649 | /* This can be innobase_add_instant_try() performing a |
| 3650 | subsequent instant ADD COLUMN, or its rollback by |
| 3651 | row_undo_mod_clust_low(). */ |
| 3652 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(flags & BTR_NO_LOCKING_FLAG); |
| 3653 | } else { |
| 3654 | btr_search_update_hash_on_deletecxx . . $ btr_search_update_hash_on_delete(c309ee090c231893).(cursor); |
| 3655 | } |
| 3656 | |
| 3657 | page_cur_delete_reccxx . . $ page_cur_delete_rec(236e529d3b285e57).(page_cursor, *offsets, mtr); |
| 3658 | |
| 3659 | if (!page_cur_move_to_prevcxx . . $ page_cur_move_to_prev(99e08e4d4839908).(page_cursor)) { |
| 3660 | return DB_CORRUPTIONcxx . . $ DB_CORRUPTION.; |
| 3661 | } |
| 3662 | |
| 3663 | if (!(flags & BTR_KEEP_SYS_FLAGcxx . . $ BTR_KEEP_SYS_FLAG.)) { |
| 3664 | btr_cur_write_syscxx . . $ btr_cur_write_sys(b297a728581d7399).(new_entry, index, trx_id, roll_ptr); |
| 3665 | } |
| 3666 | |
| 3667 | rec = btr_cur_insert_if_possiblecxx . . $ btr_cur_insert_if_possible(fd94ef7ff56a20ad).(cursor, new_entry, offsets, heap, |
| 3668 | 0/*n_ext*/, mtr); |
| 3669 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(!rec)) { |
| 3670 | goto corrupted; |
| 3671 | } |
| 3672 | |
| 3673 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(update->is_metadata())) { |
| 3674 | /* We must empty the PAGE_FREE list, because if this |
| 3675 | was a rollback, the shortened metadata record |
| 3676 | would have too many fields, and we would be unable to |
| 3677 | know the size of the freed record. */ |
| 3678 | err = btr_page_reorganizecxx . . $ btr_page_reorganize(e4b2ea64c1f14b9e).(page_cursor, mtr); |
| 3679 | if (err != DB_SUCCESScxx . . $ DB_SUCCESS.) { |
| 3680 | goto func_exit; |
| 3681 | } |
| 3682 | } else { |
| 3683 | /* Restore the old explicit lock state on the record */ |
| 3684 | lock_rec_restore_from_page_infimumcxx . . $ lock_rec_restore_from_page_infimum(5b2823c106408d46).(*block, rec, |
| 3685 | block->pagecxx . . $ buf_block_t#page..idcxx . . $ buf_page_t#id(9d40bbb65128eac8).()); |
| 3686 | } |
| 3687 | |
| 3688 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(err == DB_SUCCESS); |
| 3689 | if (!page_cur_move_to_nextcxx . . $ page_cur_move_to_next(99e08e4d4839908).(page_cursor)) { |
| 3690 | corrupted: |
| 3691 | return DB_CORRUPTIONcxx . . $ DB_CORRUPTION.; |
| 3692 | } |
| 3693 | |
| 3694 | if (err != DB_SUCCESScxx . . $ DB_SUCCESS.) { |
| 3695 | func_exit: |
| 3696 | /* prefetch siblings of the leaf for the pessimistic |
| 3697 | operation. */ |
| 3698 | btr_cur_prefetch_siblingscxx . . $ btr_cur_prefetch_siblings(3d287479f68a2b77).(block, index, mtr->trxcxx . . $ mtr_t#trx.); |
| 3699 | } |
| 3700 | |
| 3701 | return(err); |
| 3702 | } |
| 3703 | |
| 3704 | /*************************************************************//** |
| 3705 | If, in a split, a new supremum record was created as the predecessor of the |
| 3706 | updated record, the supremum record must inherit exactly the locks on the |
| 3707 | updated record. In the split it may have inherited locks from the successor |
| 3708 | of the updated record, which is not correct. This function restores the |
| 3709 | right locks for the new supremum. */ |
| 3710 | static |
| 3711 | dberr_tcxx . . $ dberr_t# |
| 3712 | btr_cur_pess_upd_restore_supremumcxx . . $ btr_cur_pess_upd_restore_supremum(492f6da4fab9b254).( |
| 3713 | /*==============================*/ |
| 3714 | buf_block_tcxx . . $ buf_block_t#* block, /*!< in: buffer block of rec */ |
| 3715 | const rec_tcxx . . $ rec_t#* rec, /*!< in: updated record */ |
| 3716 | mtr_tcxx . . $ mtr_t#* mtr) /*!< in: mtr */ |
| 3717 | { |
| 3718 | page_tcxx . . $ `storage/innobase/include/page0types.h:38:9`!* page; |
| 3719 | |
| 3720 | page = buf_block_get_framecxx . . $ `storage/innobase/include/buf0buf.h:385:9`!(block); |
| 3721 | |
| 3722 | if (page_rec_get_nextcxx . . $ page_rec_get_next(adcd832f8377c3d8).(page_get_infimum_reccxx . . $ `storage/innobase/include/page0page.h:531:9`!(page)) != rec) { |
| 3723 | /* Updated record is not the first user record on its page */ |
| 3724 | return DB_SUCCESScxx . . $ DB_SUCCESS.; |
| 3725 | } |
| 3726 | |
| 3727 | const uint32_tcxx . . $ uint32_t# prev_page_no = btr_page_get_prevcxx . . $ btr_page_get_prev(ca1608e2c87725e2).(page); |
| 3728 | |
| 3729 | const page_id_tcxx . . $ page_id_t# block_id{block->pagecxx . . $ buf_block_t#page..idcxx . . $ buf_page_t#id(9d40bbb65128eac8).()}; |
| 3730 | const page_id_tcxx . . $ page_id_t# prev_idcxx . . $ page_id_t#page_id_t(b4d55b1286ff73e8).(block_id.spacecxx . . $ page_id_t#space(d22c8608b6eae7b5).(), prev_page_no); |
| 3731 | buf_block_tcxx . . $ buf_block_t#* prev_block |
| 3732 | = mtr->get_already_latchedcxx . . $ mtr_t#get_already_latched(c8b94b52f23d581).(prev_id, MTR_MEMO_PAGE_X_FIXcxx . . $ MTR_MEMO_PAGE_X_FIX.); |
| 3733 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(!prev_block)) { |
| 3734 | return DB_CORRUPTIONcxx . . $ DB_CORRUPTION.; |
| 3735 | } |
| 3736 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!memcmp_aligned<4>(prev_block->page.frame + FIL_PAGE_NEXT, |
| 3737 | block->page.frame + FIL_PAGE_OFFSET, 4)); |
| 3738 | |
| 3739 | lock_rec_reset_and_inherit_gap_lockscxx . . $ lock_rec_reset_and_inherit_gap_locks(8701183d10523dfa).(*prev_block, block_id, |
| 3740 | PAGE_HEAP_NO_SUPREMUMcxx . . $ `storage/innobase/include/page0page.h:154:9`!, |
| 3741 | page_is_compcxx . . $ page_is_comp(f3688bc2ee54ea05).(page) |
| 3742 | ? rec_get_heap_no_newcxx . . $ rec_get_heap_no_new(469dcb4e54b221a8).(rec) |
| 3743 | : rec_get_heap_no_oldcxx . . $ rec_get_heap_no_old(469dcb4e54b221a8).(rec)); |
| 3744 | return DB_SUCCESScxx . . $ DB_SUCCESS.; |
| 3745 | } |
| 3746 | |
| 3747 | /*************************************************************//** |
| 3748 | Performs an update of a record on a page of a tree. It is assumed |
| 3749 | that mtr holds an x-latch on the tree and on the cursor page. If the |
| 3750 | update is made on the leaf level, to avoid deadlocks, mtr must also |
| 3751 | own x-latches to brothers of page, if those brothers exist. We assume |
| 3752 | here that the ordering fields of the record do not change. |
| 3753 | @return DB_SUCCESS or error code */ |
| 3754 | dberr_tcxx . . $ dberr_t# |
| 3755 | btr_cur_pessimistic_updatecxx . . $ btr_cur_pessimistic_update(9764464e87ddac3d).( |
| 3756 | /*=======================*/ |
| 3757 | ulintcxx . . $ ulint# flags, /*!< in: undo logging, locking, and rollback |
| 3758 | flags */ |
| 3759 | btr_cur_tcxx . . $ btr_cur_t#* cursor, /*!< in/out: cursor on the record to update; |
| 3760 | cursor may become invalid if *big_rec == NULL |
| 3761 | || !(flags & BTR_KEEP_POS_FLAG) */ |
| 3762 | rec_offscxx . . $ rec_offs#** offsets,/*!< out: offsets on cursor->page_cur.rec */ |
| 3763 | mem_heap_tcxx . . $ mem_heap_t#** offsets_heap, |
| 3764 | /*!< in/out: pointer to memory heap |
| 3765 | that can be emptied */ |
| 3766 | mem_heap_tcxx . . $ mem_heap_t#* entry_heap, |
| 3767 | /*!< in/out: memory heap for allocating |
| 3768 | big_rec and the index tuple */ |
| 3769 | big_rec_tcxx . . $ big_rec_t#** big_rec,/*!< out: big rec vector whose fields have to |
| 3770 | be stored externally by the caller */ |
| 3771 | upd_tcxx . . $ upd_t#* update, /*!< in/out: update vector; this is allowed to |
| 3772 | also contain trx id and roll ptr fields. |
| 3773 | Non-updated columns that are moved offpage will |
| 3774 | be appended to this. */ |
| 3775 | ulintcxx . . $ ulint# cmpl_info,/*!< in: compiler info on secondary index |
| 3776 | updates */ |
| 3777 | que_thr_tcxx . . $ que_thr_t#* thr, /*!< in: query thread */ |
| 3778 | trx_id_tcxx . . $ trx_id_t# trx_id, /*!< in: transaction id */ |
| 3779 | mtr_tcxx . . $ mtr_t#* mtr) /*!< in/out: mini-transaction; must be |
| 3780 | committed before latching any further pages */ |
| 3781 | { |
| 3782 | big_rec_tcxx . . $ big_rec_t#* big_rec_vec = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 3783 | big_rec_tcxx . . $ big_rec_t#* dummy_big_rec; |
| 3784 | dict_index_tcxx . . $ dict_index_t#* index; |
| 3785 | buf_block_tcxx . . $ buf_block_t#* block; |
| 3786 | rec_tcxx . . $ rec_t#* rec; |
| 3787 | page_cur_tcxx . . $ page_cur_t#* page_cursor; |
| 3788 | dberr_tcxx . . $ dberr_t# err; |
| 3789 | dberr_tcxx . . $ dberr_t# optim_err; |
| 3790 | roll_ptr_tcxx . . $ roll_ptr_t# roll_ptr; |
| 3791 | bool was_first; |
| 3792 | uint32_tcxx . . $ uint32_t# n_reserved = 0; |
| 3793 | |
| 3794 | *offsets = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 3795 | *big_rec = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 3796 | |
| 3797 | block = btr_cur_get_blockcxx . . $ `storage/innobase/include/btr0cur.h:63:9`!(cursor); |
| 3798 | index = cursor->indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).(); |
| 3799 | |
| 3800 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mtr->memo_contains_flagged(&index->lock, MTR_MEMO_X_LOCK | |
| 3801 | MTR_MEMO_SX_LOCK)); |
| 3802 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mtr->memo_contains_flagged(block, MTR_MEMO_PAGE_X_FIX)); |
| 3803 | #if defined UNIV_ZIP_DEBUG || defined UNIV_DEBUG |
| 3804 | page_zip_des_t* page_zip = buf_block_get_page_zip(block); |
| 3805 | #endif |
| 3806 | #ifdef UNIV_ZIP_DEBUG |
| 3807 | ut_a(!page_zip |
| 3808 | || page_zip_validate(page_zip, block->page.frame, index)); |
| 3809 | #endif /* UNIV_ZIP_DEBUG */ |
| 3810 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!page_zip || !index->table->is_temporary()); |
| 3811 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(trx_id > 0 || (flags & BTR_KEEP_SYS_FLAG) |
| 3812 | || index->table->is_temporary()); |
| 3813 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(dict_index_is_online_ddl(index) == !!(flags & BTR_CREATE_FLAG) |
| 3814 | || dict_index_is_clust(index)); |
| 3815 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(thr_get_trx(thr)->id == trx_id |
| 3816 | || (flags & ulint(~BTR_KEEP_POS_FLAG)) |
| 3817 | == (BTR_NO_UNDO_LOG_FLAG | BTR_NO_LOCKING_FLAG |
| 3818 | | BTR_CREATE_FLAG | BTR_KEEP_SYS_FLAG)); |
| 3819 | |
| 3820 | err = optim_err = btr_cur_optimistic_updatecxx . . $ btr_cur_optimistic_update(c5dbdb1e1dfafe63).( |
| 3821 | flags, |
| 3822 | cursor, offsets, offsets_heap, update, |
| 3823 | cmpl_info, thr, trx_id, mtr); |
| 3824 | |
| 3825 | switch (err) { |
| 3826 | case DB_ZIP_OVERFLOWcxx . . $ DB_ZIP_OVERFLOW.: |
| 3827 | case DB_UNDERFLOWcxx . . $ DB_UNDERFLOW.: |
| 3828 | case DB_OVERFLOWcxx . . $ DB_OVERFLOW.: |
| 3829 | break; |
| 3830 | default: |
| 3831 | err_exit: |
| 3832 | if (big_rec_vec != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { |
| 3833 | dtuple_big_rec_freecxx . . $ dtuple_big_rec_free(3eb68053a3a1fd25).(big_rec_vec); |
| 3834 | } |
| 3835 | |
| 3836 | return(err); |
| 3837 | } |
| 3838 | |
| 3839 | rec = btr_cur_get_reccxx . . $ `storage/innobase/include/btr0cur.h:64:9`!(cursor); |
| 3840 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rec_offs_validate(rec, index, *offsets)); |
| 3841 | |
| 3842 | dtuple_tcxx . . $ dtuple_t#* new_entry; |
| 3843 | |
| 3844 | const bool is_metadata = rec_is_metadatacxx . . $ rec_is_metadata(5dcd923c19b1cb7d).(rec, *index); |
| 3845 | |
| 3846 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(is_metadata)) { |
| 3847 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(update->is_metadata()); |
| 3848 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(flags & BTR_NO_LOCKING_FLAG); |
| 3849 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(index->is_instant()); |
| 3850 | new_entry = row_metadata_to_tuplecxx . . $ row_metadata_to_tuple(5a85727e2991d8b9).( |
| 3851 | rec, index, *offsets, entry_heap, |
| 3852 | update->info_bitscxx . . $ upd_t#info_bits., !thr_get_trxcxx . . $ thr_get_trx(bce191eb970ff2ca).(thr)->in_rollbackcxx . . $ trx_t#in_rollback.); |
| 3853 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(new_entry->n_fields |
| 3854 | == ulint(index->n_fields) |
| 3855 | + update->is_alter_metadata()); |
| 3856 | } else { |
| 3857 | new_entry = row_rec_to_index_entrycxx . . $ row_rec_to_index_entry(906df6b920478360).(rec, index, *offsets, |
| 3858 | entry_heap); |
| 3859 | } |
| 3860 | |
| 3861 | /* The page containing the clustered index record |
| 3862 | corresponding to new_entry is latched in mtr. If the |
| 3863 | clustered index record is delete-marked, then its externally |
| 3864 | stored fields cannot have been purged yet, because then the |
| 3865 | purge would also have removed the clustered index record |
| 3866 | itself. Thus the following call is safe. */ |
| 3867 | row_upd_index_replace_new_col_vals_index_poscxx . . $ row_upd_index_replace_new_col_vals_index_pos(e4301329e7674fe3).(new_entry, index, update, |
| 3868 | entry_heap); |
| 3869 | btr_cur_trimcxx . . $ btr_cur_trim(442d30e0ddec5d33).(new_entry, index, update, thr); |
| 3870 | |
| 3871 | /* We have to set appropriate extern storage bits in the new |
| 3872 | record to be inserted: we have to remember which fields were such */ |
| 3873 | |
| 3874 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!page_is_comp(block->page.frame) || !rec_get_node_ptr_flag(rec)); |
| 3875 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rec_offs_validate(rec, index, *offsets)); |
| 3876 | |
| 3877 | if ((flags & BTR_NO_UNDO_LOG_FLAGcxx . . $ BTR_NO_UNDO_LOG_FLAG.) |
| 3878 | && rec_offs_any_externcxx . . $ rec_offs_any_extern(ca762aca731138fc).(*offsets)) { |
| 3879 | /* We are in a transaction rollback undoing a row |
| 3880 | update: we must free possible externally stored fields |
| 3881 | which got new values in the update, if they are not |
| 3882 | inherited values. They can be inherited if we have |
| 3883 | updated the primary key to another value, and then |
| 3884 | update it back again. */ |
| 3885 | |
| 3886 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(big_rec_vec == NULL); |
| 3887 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(dict_index_is_clust(index)); |
| 3888 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(thr_get_trx(thr)->in_rollback); |
| 3889 | |
| 3890 | DEBUG_SYNC_Ccxx . . $ `include/mysql/service_debug_sync.h:355:9`!("blob_rollback_middle"); |
| 3891 | |
| 3892 | btr_rec_free_updated_extern_fieldscxx . . $ btr_rec_free_updated_extern_fields(1e02f8a3eb9379da).( |
| 3893 | index, rec, block, *offsets, update, true, mtr); |
| 3894 | } |
| 3895 | |
| 3896 | ulintcxx . . $ ulint# n_ext = index->is_primarycxx . . $ dict_index_t#is_primary(50ce9a9e25b4a850).() ? dtuple_get_n_extcxx . . $ dtuple_get_n_ext(b99d8fb98adb3238).(new_entry) : 0; |
| 3897 | |
| 3898 | if (page_zip_rec_needs_extcxx . . $ page_zip_rec_needs_ext(ca07b99eee158bc2).( |
| 3899 | rec_get_converted_sizecxx . . $ rec_get_converted_size(65a2a1c1835c6045).(index, new_entry, n_ext), |
| 3900 | page_is_compcxx . . $ page_is_comp(f3688bc2ee54ea05).(block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.), |
| 3901 | dict_index_get_n_fieldscxx . . $ dict_index_get_n_fields(40995254b96f8651).(index), |
| 3902 | block->zip_sizecxx . . $ buf_block_t#zip_size(c9b1e749b64d5edc).()) |
| 3903 | || (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(update->is_alter_metadata()) |
| 3904 | && !dfield_is_extcxx . . $ dfield_is_ext(421b5b1f6d6093e7).(dtuple_get_nth_fieldcxx . . $ dtuple_get_nth_field(71af1a8d94eba0f9).( |
| 3905 | new_entry, |
| 3906 | index->first_user_fieldcxx . . $ dict_index_t#first_user_field(72085aa11f4b6e09).())))) { |
| 3907 | big_rec_vec = dtuple_convert_big_reccxx . . $ dtuple_convert_big_rec(470f4bee431791a6).(index, update, new_entry, &n_ext); |
| 3908 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(big_rec_vec == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)) { |
| 3909 | #ifdef UNIV_ZIP_DEBUG |
| 3910 | ut_a(!page_zip |
| 3911 | || page_zip_validate(page_zip, block->page.frame, |
| 3912 | index)); |
| 3913 | #endif /* UNIV_ZIP_DEBUG */ |
| 3914 | index->tablecxx . . $ dict_index_t#table.->spacecxx . . $ dict_table_t#space.->release_free_extentscxx . . $ fil_space_t#release_free_extents(6bab9b75950d6f3).(n_reserved); |
| 3915 | err = DB_TOO_BIG_RECORDcxx . . $ DB_TOO_BIG_RECORD.; |
| 3916 | goto err_exit; |
| 3917 | } |
| 3918 | |
| 3919 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(page_is_leaf(block->page.frame)); |
| 3920 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(dict_index_is_clust(index)); |
| 3921 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(!(flags & BTR_KEEP_POS_FLAG))) { |
| 3922 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(page_zip != NULL); |
| 3923 | dtuple_convert_back_big_reccxx . . $ dtuple_convert_back_big_rec(4f5e1bce9a5c5d93).(index, new_entry, |
| 3924 | big_rec_vec); |
| 3925 | big_rec_vec = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 3926 | n_ext = dtuple_get_n_extcxx . . $ dtuple_get_n_ext(b99d8fb98adb3238).(new_entry); |
| 3927 | } |
| 3928 | } |
| 3929 | |
| 3930 | /* Do lock checking and undo logging */ |
| 3931 | err = btr_cur_upd_lock_and_undocxx . . $ btr_cur_upd_lock_and_undo(7bb56c7fd0c4544e).(flags, cursor, *offsets, |
| 3932 | update, cmpl_info, |
| 3933 | thr, mtr, &roll_ptr); |
| 3934 | if (err != DB_SUCCESScxx . . $ DB_SUCCESS.) { |
| 3935 | goto err_exit; |
| 3936 | } |
| 3937 | |
| 3938 | if (optim_err == DB_OVERFLOWcxx . . $ DB_OVERFLOW.) { |
| 3939 | /* First reserve enough free space for the file segments |
| 3940 | of the index tree, so that the update will not fail because |
| 3941 | of lack of space */ |
| 3942 | |
| 3943 | err = fsp_reserve_free_extentscxx . . $ fsp_reserve_free_extents(ff8909883dc21fea).( |
| 3944 | &n_reserved, index->tablecxx . . $ dict_index_t#table.->spacecxx . . $ dict_table_t#space., |
| 3945 | uint32_tcxx . . $ uint32_t#(cursor->tree_heightcxx . . $ btr_cur_t#tree_height. / 16 + 3), |
| 3946 | flags & BTR_NO_UNDO_LOG_FLAGcxx . . $ BTR_NO_UNDO_LOG_FLAG. |
| 3947 | ? FSP_CLEANINGcxx . . $ FSP_CLEANING. : FSP_NORMALcxx . . $ FSP_NORMAL., |
| 3948 | mtr); |
| 3949 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(err != DB_SUCCESS)) { |
| 3950 | err = DB_OUT_OF_FILE_SPACEcxx . . $ DB_OUT_OF_FILE_SPACE.; |
| 3951 | goto err_exit; |
| 3952 | } |
| 3953 | } |
| 3954 | |
| 3955 | if (!(flags & BTR_KEEP_SYS_FLAGcxx . . $ BTR_KEEP_SYS_FLAG.)) { |
| 3956 | btr_cur_write_syscxx . . $ btr_cur_write_sys(b297a728581d7399).(new_entry, index, trx_id, roll_ptr); |
| 3957 | } |
| 3958 | |
| 3959 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(is_metadata)) { |
| 3960 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(new_entry->is_metadata()); |
| 3961 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(index->is_instant()); |
| 3962 | /* This can be innobase_add_instant_try() performing a |
| 3963 | subsequent instant ALTER TABLE, or its rollback by |
| 3964 | row_undo_mod_clust_low(). */ |
| 3965 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(flags & BTR_NO_LOCKING_FLAG); |
| 3966 | } else { |
| 3967 | btr_search_update_hash_on_deletecxx . . $ btr_search_update_hash_on_delete(c309ee090c231893).(cursor); |
| 3968 | |
| 3969 | /* Store state of explicit locks on rec on the page |
| 3970 | infimum record, before deleting rec. The page infimum |
| 3971 | acts as a dummy carrier of the locks, taking care also |
| 3972 | of lock releases, before we can move the locks back on |
| 3973 | the actual record. There is a special case: if we are |
| 3974 | inserting on the root page and the insert causes a |
| 3975 | call of btr_root_raise_and_insert. Therefore we cannot |
| 3976 | in the lock system delete the lock structs set on the |
| 3977 | root page even if the root page carries just node |
| 3978 | pointers. */ |
| 3979 | lock_rec_store_on_page_infimumcxx . . $ lock_rec_store_on_page_infimum(8215f79b77a41d69).(block, rec); |
| 3980 | } |
| 3981 | |
| 3982 | #ifdef UNIV_ZIP_DEBUG |
| 3983 | ut_a(!page_zip |
| 3984 | || page_zip_validate(page_zip, block->page.frame, index)); |
| 3985 | #endif /* UNIV_ZIP_DEBUG */ |
| 3986 | page_cursor = btr_cur_get_page_curcxx . . $ `storage/innobase/include/btr0cur.h:62:9`!(cursor); |
| 3987 | |
| 3988 | page_cur_delete_reccxx . . $ page_cur_delete_rec(236e529d3b285e57).(page_cursor, *offsets, mtr); |
| 3989 | |
| 3990 | if (!page_cur_move_to_prevcxx . . $ page_cur_move_to_prev(99e08e4d4839908).(page_cursor)) { |
| 3991 | err = DB_CORRUPTIONcxx . . $ DB_CORRUPTION.; |
| 3992 | goto return_after_reservations; |
| 3993 | } |
| 3994 | |
| 3995 | rec = btr_cur_insert_if_possiblecxx . . $ btr_cur_insert_if_possible(fd94ef7ff56a20ad).(cursor, new_entry, |
| 3996 | offsets, offsets_heap, n_ext, mtr); |
| 3997 | |
| 3998 | if (rec) { |
| 3999 | page_cursor->reccxx . . $ page_cur_t#rec. = rec; |
| 4000 | |
| 4001 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(is_metadata)) { |
| 4002 | /* We must empty the PAGE_FREE list, because if this |
| 4003 | was a rollback, the shortened metadata record |
| 4004 | would have too many fields, and we would be unable to |
| 4005 | know the size of the freed record. */ |
| 4006 | err = btr_page_reorganizecxx . . $ btr_page_reorganize(e4b2ea64c1f14b9e).(page_cursor, mtr); |
| 4007 | if (err != DB_SUCCESScxx . . $ DB_SUCCESS.) { |
| 4008 | goto return_after_reservations; |
| 4009 | } |
| 4010 | rec = page_cursor->reccxx . . $ page_cur_t#rec.; |
| 4011 | rec_offs_make_validcxx . . $ `storage/innobase/include/rem0rec.h:520:10`!(rec, index, true, *offsets); |
| 4012 | if (page_cursor->blockcxx . . $ page_cur_t#block.->pagecxx . . $ buf_block_t#page..idcxx . . $ buf_page_t#id(9d40bbb65128eac8).().page_nocxx . . $ page_id_t#page_no(d22c8608b6eae7b5).() |
| 4013 | == index->pagecxx . . $ dict_index_t#page.) { |
| 4014 | btr_set_instantcxx . . $ btr_set_instant(c781c825a451f33b).(page_cursor->blockcxx . . $ page_cur_t#block., *index, |
| 4015 | mtr); |
| 4016 | } |
| 4017 | } else { |
| 4018 | lock_rec_restore_from_page_infimumcxx . . $ lock_rec_restore_from_page_infimum(5b2823c106408d46).( |
| 4019 | *btr_cur_get_blockcxx . . $ `storage/innobase/include/btr0cur.h:63:9`!(cursor), rec, |
| 4020 | block->pagecxx . . $ buf_block_t#page..idcxx . . $ buf_page_t#id(9d40bbb65128eac8).()); |
| 4021 | } |
| 4022 | |
| 4023 | if (!rec_get_deleted_flagcxx . . $ rec_get_deleted_flag(4adc7973d4c4f159).(rec, rec_offs_compcxx . . $ rec_offs_comp(6fce5c29061b60f9).(*offsets)) |
| 4024 | || rec_is_alter_metadatacxx . . $ rec_is_alter_metadata(5dcd923c19b1cb7d).(rec, *index)) { |
| 4025 | /* The new inserted record owns its possible externally |
| 4026 | stored fields */ |
| 4027 | btr_cur_unmark_extern_fieldscxx . . $ btr_cur_unmark_extern_fields(2a7528bc66954456).(btr_cur_get_blockcxx . . $ `storage/innobase/include/btr0cur.h:63:9`!(cursor), |
| 4028 | rec, index, *offsets, mtr); |
| 4029 | } else { |
| 4030 | /* In delete-marked records, DB_TRX_ID must |
| 4031 | always refer to an existing undo log record. */ |
| 4032 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(row_get_rec_trx_id(rec, index, *offsets)); |
| 4033 | } |
| 4034 | |
| 4035 | bool adjust = big_rec_vec && (flags & BTR_KEEP_POS_FLAGcxx . . $ BTR_KEEP_POS_FLAG.); |
| 4036 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!adjust || page_is_leaf(block->page.frame)); |
| 4037 | |
| 4038 | if (btr_cur_compress_if_usefulcxx . . $ btr_cur_compress_if_useful(c0ed7dbe459c1b6c).(cursor, adjust, mtr)) { |
| 4039 | if (adjust) { |
| 4040 | rec_offs_make_validcxx . . $ `storage/innobase/include/rem0rec.h:520:10`!(page_cursor->rec, index, |
| 4041 | true, *offsets); |
| 4042 | } |
| 4043 | } |
| 4044 | |
| 4045 | #if 0 // FIXME: this used to be a no-op, and will cause trouble if enabled |
| 4046 | if (!big_rec_vec |
| 4047 | && page_is_leaf(block->page.frame) |
| 4048 | && !dict_index_is_online_ddl(index)) { |
| 4049 | mtr->release(index->lock); |
| 4050 | /* NOTE: We cannot release root block latch here, because it |
| 4051 | has segment header and already modified in most of cases.*/ |
| 4052 | } |
| 4053 | #endif |
| 4054 | |
| 4055 | err = DB_SUCCESScxx . . $ DB_SUCCESS.; |
| 4056 | goto return_after_reservations; |
| 4057 | } else { |
| 4058 | /* If the page is compressed and it initially |
| 4059 | compresses very well, and there is a subsequent insert |
| 4060 | of a badly-compressing record, it is possible for |
| 4061 | btr_cur_optimistic_update() to return DB_UNDERFLOW and |
| 4062 | btr_cur_insert_if_possible() to return FALSE. */ |
| 4063 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(page_zip || optim_err != DB_UNDERFLOW); |
| 4064 | } |
| 4065 | |
| 4066 | if (big_rec_vec != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { |
| 4067 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(page_is_leaf(block->page.frame)); |
| 4068 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(dict_index_is_clust(index)); |
| 4069 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(flags & BTR_KEEP_POS_FLAG); |
| 4070 | |
| 4071 | /* btr_page_split_and_insert() in |
| 4072 | btr_cur_pessimistic_insert() invokes |
| 4073 | mtr->release(index->lock). |
| 4074 | We must keep the index->lock when we created a |
| 4075 | big_rec, so that row_upd_clust_rec() can store the |
| 4076 | big_rec in the same mini-transaction. */ |
| 4077 | |
| 4078 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mtr->memo_contains_flagged(&index->lock, MTR_MEMO_X_LOCK |
| 4079 | | MTR_MEMO_SX_LOCK)); |
| 4080 | mtr_sx_lock_indexcxx . . $ `storage/innobase/include/mtr0mtr.h:47:10`!(index, mtr); |
| 4081 | } |
| 4082 | |
| 4083 | /* Was the record to be updated positioned as the first user |
| 4084 | record on its page? */ |
| 4085 | was_first = page_cur_is_before_firstcxx . . $ page_cur_is_before_first(95964a7af755c14).(page_cursor); |
| 4086 | |
| 4087 | /* Lock checks and undo logging were already performed by |
| 4088 | btr_cur_upd_lock_and_undo(). We do not try |
| 4089 | btr_cur_optimistic_insert() because |
| 4090 | btr_cur_insert_if_possible() already failed above. */ |
| 4091 | |
| 4092 | err = btr_cur_pessimistic_insertcxx . . $ btr_cur_pessimistic_insert(608ae1f6b838559e).(BTR_NO_UNDO_LOG_FLAGcxx . . $ BTR_NO_UNDO_LOG_FLAG. |
| 4093 | | BTR_NO_LOCKING_FLAGcxx . . $ BTR_NO_LOCKING_FLAG. |
| 4094 | | BTR_KEEP_SYS_FLAGcxx . . $ BTR_KEEP_SYS_FLAG., |
| 4095 | cursor, offsets, offsets_heap, |
| 4096 | new_entry, &rec, |
| 4097 | &dummy_big_rec, n_ext, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, mtr); |
| 4098 | if (err) { |
| 4099 | /* This should happen when InnoDB tries to extend the |
| 4100 | tablespace */ |
| 4101 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(err == DB_OUT_OF_FILE_SPACE); |
| 4102 | return err; |
| 4103 | } |
| 4104 | ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(rec); |
| 4105 | ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(dummy_big_rec == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 4106 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rec_offs_validate(rec, cursor->index(), *offsets)); |
| 4107 | page_cursor->reccxx . . $ page_cur_t#rec. = rec; |
| 4108 | |
| 4109 | /* Multiple transactions cannot simultaneously operate on the |
| 4110 | same temp-table in parallel. |
| 4111 | max_trx_id is ignored for temp tables because it not required |
| 4112 | for MVCC. */ |
| 4113 | if (!index->is_primarycxx . . $ dict_index_t#is_primary(50ce9a9e25b4a850).() && !index->tablecxx . . $ dict_index_t#table.->is_temporarycxx . . $ dict_table_t#is_temporary(50ce9a9e25b4a850).()) { |
| 4114 | /* Update PAGE_MAX_TRX_ID in the index page header. |
| 4115 | It was not updated by btr_cur_pessimistic_insert() |
| 4116 | because of BTR_NO_LOCKING_FLAG. */ |
| 4117 | page_update_max_trx_idcxx . . $ page_update_max_trx_id(7ff4fec4cd653b55).(btr_cur_get_blockcxx . . $ `storage/innobase/include/btr0cur.h:63:9`!(cursor), |
| 4118 | btr_cur_get_page_zipcxx . . $ btr_cur_get_page_zip(25879e64d517f276).(cursor), |
| 4119 | trx_id, mtr); |
| 4120 | } |
| 4121 | |
| 4122 | if (!rec_get_deleted_flagcxx . . $ rec_get_deleted_flag(4adc7973d4c4f159).(rec, rec_offs_compcxx . . $ rec_offs_comp(6fce5c29061b60f9).(*offsets))) { |
| 4123 | /* The new inserted record owns its possible externally |
| 4124 | stored fields */ |
| 4125 | #ifdef UNIV_ZIP_DEBUG |
| 4126 | ut_a(!page_zip |
| 4127 | || page_zip_validate(page_zip, block->page.frame, index)); |
| 4128 | #endif /* UNIV_ZIP_DEBUG */ |
| 4129 | btr_cur_unmark_extern_fieldscxx . . $ btr_cur_unmark_extern_fields(2a7528bc66954456).(btr_cur_get_blockcxx . . $ `storage/innobase/include/btr0cur.h:63:9`!(cursor), rec, |
| 4130 | index, *offsets, mtr); |
| 4131 | } else { |
| 4132 | /* In delete-marked records, DB_TRX_ID must |
| 4133 | always refer to an existing undo log record. */ |
| 4134 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(row_get_rec_trx_id(rec, index, *offsets)); |
| 4135 | } |
| 4136 | |
| 4137 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(is_metadata)) { |
| 4138 | /* We must empty the PAGE_FREE list, because if this |
| 4139 | was a rollback, the shortened metadata record |
| 4140 | would have too many fields, and we would be unable to |
| 4141 | know the size of the freed record. */ |
| 4142 | err = btr_page_reorganizecxx . . $ btr_page_reorganize(e4b2ea64c1f14b9e).(page_cursor, mtr); |
| 4143 | if (err != DB_SUCCESScxx . . $ DB_SUCCESS.) { |
| 4144 | goto return_after_reservations; |
| 4145 | } |
| 4146 | rec = page_cursor->reccxx . . $ page_cur_t#rec.; |
| 4147 | } else { |
| 4148 | lock_rec_restore_from_page_infimumcxx . . $ lock_rec_restore_from_page_infimum(5b2823c106408d46).( |
| 4149 | *btr_cur_get_blockcxx . . $ `storage/innobase/include/btr0cur.h:63:9`!(cursor), rec, block->pagecxx . . $ buf_block_t#page..idcxx . . $ buf_page_t#id(9d40bbb65128eac8).()); |
| 4150 | } |
| 4151 | |
| 4152 | /* If necessary, restore also the correct lock state for a new, |
| 4153 | preceding supremum record created in a page split. While the old |
| 4154 | record was nonexistent, the supremum might have inherited its locks |
| 4155 | from a wrong record. */ |
| 4156 | |
| 4157 | if (!was_first) { |
| 4158 | err = btr_cur_pess_upd_restore_supremumcxx . . $ btr_cur_pess_upd_restore_supremum(492f6da4fab9b254).( |
| 4159 | btr_cur_get_blockcxx . . $ `storage/innobase/include/btr0cur.h:63:9`!(cursor), rec, mtr); |
| 4160 | } |
| 4161 | |
| 4162 | return_after_reservations: |
| 4163 | #ifdef UNIV_ZIP_DEBUG |
| 4164 | ut_a(err || |
| 4165 | !page_zip || page_zip_validate(btr_cur_get_page_zip(cursor), |
| 4166 | btr_cur_get_page(cursor), index)); |
| 4167 | #endif /* UNIV_ZIP_DEBUG */ |
| 4168 | |
| 4169 | index->tablecxx . . $ dict_index_t#table.->spacecxx . . $ dict_table_t#space.->release_free_extentscxx . . $ fil_space_t#release_free_extents(6bab9b75950d6f3).(n_reserved); |
| 4170 | *big_rec = big_rec_vec; |
| 4171 | return(err); |
| 4172 | } |
| 4173 | |
| 4174 | /*==================== B-TREE DELETE MARK AND UNMARK ===============*/ |
| 4175 | |
| 4176 | /** Modify the delete-mark flag of a record. |
| 4177 | @tparam flag the value of the delete-mark flag |
| 4178 | @param[in,out] block buffer block |
| 4179 | @param[in,out] rec record on a physical index page |
| 4180 | @param[in,out] mtr mini-transaction */ |
| 4181 | template<bool flag> |
| 4182 | void btr_rec_set_deletedcxx . . $ btr_rec_set_deleted(8f409c4cbc0b0c0a).(buf_block_tcxx . . $ buf_block_t# *block, rec_tcxx . . $ rec_t# *rec, mtr_tcxx . . $ mtr_t# *mtr) |
| 4183 | { |
| 4184 | if (UNIV_LIKELYcxx . . $ `storage/innobase/include/univ.i:437:9`!(page_is_comp(block->page.frame) != 0)) |
| 4185 | { |
| 4186 | bytecxx . . $ byte# *b= &rec[-REC_NEW_INFO_BITScxx . . $ `storage/innobase/include/rem0rec.inl:106:9`!]; |
| 4187 | const bytecxx . . $ byte# v= flag |
| 4188 | ? (*b | REC_INFO_DELETED_FLAGcxx . . $ `storage/innobase/include/data0type.h:506:9`!) |
| 4189 | : (*b & bytecxx . . $ byte#(~REC_INFO_DELETED_FLAGcxx . . $ `storage/innobase/include/data0type.h:506:9`!)); |
| 4190 | if (*b == v); |
| 4191 | else if (UNIV_LIKELY_NULLcxx . . $ `storage/innobase/include/univ.i:393:10`!(block->page.zip.data)) |
| 4192 | { |
| 4193 | *b= v; |
| 4194 | page_zip_rec_set_deletedcxx . . $ page_zip_rec_set_deleted(470ecb4dfb7c5acf).(block, rec, flag, mtr); |
| 4195 | } |
| 4196 | else |
| 4197 | mtr->writecxx . . $ mtr_t#write(4888ddbfa94c5eeb).<1>(*block, b, v); |
| 4198 | } |
| 4199 | else |
| 4200 | { |
| 4201 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!block->page.zip.data); |
| 4202 | bytecxx . . $ byte# *b= &rec[-REC_OLD_INFO_BITScxx . . $ `storage/innobase/include/rem0rec.inl:105:9`!]; |
| 4203 | const bytecxx . . $ byte# v = flag |
| 4204 | ? (*b | REC_INFO_DELETED_FLAGcxx . . $ `storage/innobase/include/data0type.h:506:9`!) |
| 4205 | : (*b & bytecxx . . $ byte#(~REC_INFO_DELETED_FLAGcxx . . $ `storage/innobase/include/data0type.h:506:9`!)); |
| 4206 | mtr->writecxx . . $ mtr_t#write(4888ddbfa94c5eeb).<1,mtr_tcxx . . $ mtr_t#::MAYBE_NOPcxx . . $ mtr_t#MAYBE_NOP.>(*block, b, v); |
| 4207 | } |
| 4208 | } |
| 4209 | |
| 4210 | template void btr_rec_set_deleted<false>(buf_block_t *, rec_t *, mtr_t *); |
| 4211 | template void btr_rec_set_deleted<true>(buf_block_t *, rec_t *, mtr_t *); |
| 4212 | |
| 4213 | /***********************************************************//** |
| 4214 | Marks a clustered index record deleted. Writes an undo log record to |
| 4215 | undo log on this delete marking. Writes in the trx id field the id |
| 4216 | of the deleting transaction, and in the roll ptr field pointer to the |
| 4217 | undo log record created. |
| 4218 | @return DB_SUCCESS, DB_LOCK_WAIT, or error number */ |
| 4219 | dberr_tcxx . . $ dberr_t# |
| 4220 | btr_cur_del_mark_set_clust_reccxx . . $ btr_cur_del_mark_set_clust_rec(cd1e7da0643eae5a).( |
| 4221 | /*===========================*/ |
| 4222 | buf_block_tcxx . . $ buf_block_t#* block, /*!< in/out: buffer block of the record */ |
| 4223 | rec_tcxx . . $ rec_t#* rec, /*!< in/out: record */ |
| 4224 | dict_index_tcxx . . $ dict_index_t#* index, /*!< in: clustered index of the record */ |
| 4225 | const rec_offscxx . . $ rec_offs#* offsets,/*!< in: rec_get_offsets(rec) */ |
| 4226 | que_thr_tcxx . . $ que_thr_t#* thr, /*!< in: query thread */ |
| 4227 | const dtuple_tcxx . . $ dtuple_t#* entry, /*!< in: dtuple for the deleting record, also |
| 4228 | contains the virtual cols if there are any */ |
| 4229 | mtr_tcxx . . $ mtr_t#* mtr) /*!< in/out: mini-transaction */ |
| 4230 | { |
| 4231 | roll_ptr_tcxx . . $ roll_ptr_t# roll_ptr; |
| 4232 | dberr_tcxx . . $ dberr_t# err; |
| 4233 | trx_tcxx . . $ trx_t#* trx; |
| 4234 | |
| 4235 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(dict_index_is_clust(index)); |
| 4236 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rec_offs_validate(rec, index, offsets)); |
| 4237 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!!page_rec_is_comp(rec) == dict_table_is_comp(index->table)); |
| 4238 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(buf_block_get_frame(block) == page_align(rec)); |
| 4239 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(page_rec_is_leaf(rec)); |
| 4240 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mtr->is_named_space(index->table->space)); |
| 4241 | |
| 4242 | if (rec_get_deleted_flagcxx . . $ rec_get_deleted_flag(4adc7973d4c4f159).(rec, rec_offs_compcxx . . $ rec_offs_comp(6fce5c29061b60f9).(offsets))) { |
| 4243 | /* We may already have delete-marked this record |
| 4244 | when executing an ON DELETE CASCADE operation. */ |
| 4245 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(row_get_rec_trx_id(rec, index, offsets) |
| 4246 | == thr_get_trx(thr)->id); |
| 4247 | return(DB_SUCCESScxx . . $ DB_SUCCESS.); |
| 4248 | } |
| 4249 | |
| 4250 | err = trx_undo_report_row_operationcxx . . $ trx_undo_report_row_operation(f5c442f0871a0a55).(thr, index, |
| 4251 | entry, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 0, rec, offsets, |
| 4252 | &roll_ptr); |
| 4253 | if (err != DB_SUCCESScxx . . $ DB_SUCCESS.) { |
| 4254 | |
| 4255 | return(err); |
| 4256 | } |
| 4257 | |
| 4258 | /* The search latch is not needed here, because |
| 4259 | the adaptive hash index does not depend on the delete-mark |
| 4260 | and the delete-mark is being updated in place. */ |
| 4261 | |
| 4262 | btr_rec_set_deletedcxx . . $ btr_rec_set_deleted(8f409c4cbc0b0c0a).<true>(block, rec, mtr); |
| 4263 | |
| 4264 | trx = thr_get_trxcxx . . $ thr_get_trx(bce191eb970ff2ca).(thr); |
| 4265 | |
| 4266 | DBUG_LOGcxx . . $ `include/my_dbug.h:235:11`!("ib_cur", |
| 4267 | "delete-mark clust " << index->table->name |
| 4268 | << " (" << index->id << ") by " |
| 4269 | << ib::hex(trx->id) << ": " |
| 4270 | << rec_printer(rec, offsets).str()); |
| 4271 | |
| 4272 | return btr_cur_upd_rec_syscxx . . $ btr_cur_upd_rec_sys(e2b18affefdcc973).(block, rec, index, offsets, trx, roll_ptr, |
| 4273 | mtr); |
| 4274 | } |
| 4275 | |
| 4276 | /*==================== B-TREE RECORD REMOVE =========================*/ |
| 4277 | |
| 4278 | /*************************************************************//** |
| 4279 | Tries to compress a page of the tree if it seems useful. It is assumed |
| 4280 | that mtr holds an x-latch on the tree and on the cursor page. To avoid |
| 4281 | deadlocks, mtr must also own x-latches to brothers of page, if those |
| 4282 | brothers exist. NOTE: it is assumed that the caller has reserved enough |
| 4283 | free extents so that the compression will always succeed if done! |
| 4284 | @return whether compression occurred */ |
| 4285 | bool |
| 4286 | btr_cur_compress_if_usefulcxx . . $ btr_cur_compress_if_useful(c0ed7dbe459c1b6c).( |
| 4287 | /*=======================*/ |
| 4288 | btr_cur_tcxx . . $ btr_cur_t#* cursor, /*!< in/out: cursor on the page to compress; |
| 4289 | cursor does not stay valid if !adjust and |
| 4290 | compression occurs */ |
| 4291 | bool adjust, /*!< in: whether the cursor position should be |
| 4292 | adjusted even when compression occurs */ |
| 4293 | mtr_tcxx . . $ mtr_t#* mtr) /*!< in/out: mini-transaction */ |
| 4294 | { |
| 4295 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mtr->memo_contains_flagged(&cursor->index()->lock, |
| 4296 | MTR_MEMO_X_LOCK | MTR_MEMO_SX_LOCK)); |
| 4297 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mtr->memo_contains_flagged(btr_cur_get_block(cursor), |
| 4298 | MTR_MEMO_PAGE_X_FIX)); |
| 4299 | |
| 4300 | if (cursor->indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).()->is_spatialcxx . . $ dict_index_t#is_spatial(50ce9a9e25b4a850).()) { |
| 4301 | const trx_tcxx . . $ trx_t#* trx = cursor->rtr_infocxx . . $ btr_cur_t#rtr_info.->thrcxx . . $ rtr_info#thr. |
| 4302 | ? thr_get_trxcxx . . $ thr_get_trx(bce191eb970ff2ca).(cursor->rtr_infocxx . . $ btr_cur_t#rtr_info.->thrcxx . . $ rtr_info#thr.) |
| 4303 | : NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 4304 | const buf_block_tcxx . . $ buf_block_t#* block = btr_cur_get_blockcxx . . $ `storage/innobase/include/btr0cur.h:63:9`!(cursor); |
| 4305 | |
| 4306 | /* Check whether page lock prevents the compression */ |
| 4307 | if (!lock_test_prdt_page_lockcxx . . $ lock_test_prdt_page_lock(d21ec259cc96fe00).(trx, block->pagecxx . . $ buf_block_t#page..idcxx . . $ buf_page_t#id(9d40bbb65128eac8).())) { |
| 4308 | return(false); |
| 4309 | } |
| 4310 | } |
| 4311 | |
| 4312 | return btr_cur_compress_recommendationcxx . . $ btr_cur_compress_recommendation(82f858bc4e1f6dfd).(cursor, mtr) |
| 4313 | && btr_compresscxx . . $ btr_compress(23f7ab79088ffd00).(cursor, adjust, mtr) == DB_SUCCESScxx . . $ DB_SUCCESS.; |
| 4314 | } |
| 4315 | |
| 4316 | /*******************************************************//** |
| 4317 | Removes the record on which the tree cursor is positioned on a leaf page. |
| 4318 | It is assumed that the mtr has an x-latch on the page where the cursor is |
| 4319 | positioned, but no latch on the whole tree. |
| 4320 | @return error code |
| 4321 | @retval DB_FAIL if the page would become too empty */ |
| 4322 | dberr_tcxx . . $ dberr_t# |
| 4323 | btr_cur_optimistic_deletecxx . . $ btr_cur_optimistic_delete(5923638ae82be759).( |
| 4324 | /*======================*/ |
| 4325 | btr_cur_tcxx . . $ btr_cur_t#* cursor, /*!< in: cursor on leaf page, on the record to |
| 4326 | delete; cursor stays valid: if deletion |
| 4327 | succeeds, on function exit it points to the |
| 4328 | successor of the deleted record */ |
| 4329 | ulintcxx . . $ ulint# flags, /*!< in: BTR_CREATE_FLAG or 0 */ |
| 4330 | mtr_tcxx . . $ mtr_t#* mtr) /*!< in: mtr; if this function returns |
| 4331 | TRUE on a leaf page of a secondary |
| 4332 | index, the mtr must be committed |
| 4333 | before latching any further pages */ |
| 4334 | { |
| 4335 | buf_block_tcxx . . $ buf_block_t#* block; |
| 4336 | rec_tcxx . . $ rec_t#* rec; |
| 4337 | mem_heap_tcxx . . $ mem_heap_t#* heap = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 4338 | rec_offscxx . . $ rec_offs# offsets_[REC_OFFS_NORMAL_SIZEcxx . . $ REC_OFFS_NORMAL_SIZE.]; |
| 4339 | rec_offscxx . . $ rec_offs#* offsets = offsets_; |
| 4340 | rec_offs_initcxx . . $ `storage/innobase/include/rem0rec.h:844:9`!(offsets_); |
| 4341 | |
| 4342 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(flags == 0 || flags == BTR_CREATE_FLAG); |
| 4343 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mtr->memo_contains_flagged(btr_cur_get_block(cursor), |
| 4344 | MTR_MEMO_PAGE_X_FIX)); |
| 4345 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mtr->is_named_space(cursor->index()->table->space)); |
| 4346 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!cursor->index()->is_dummy); |
| 4347 | |
| 4348 | /* This is intended only for leaf page deletions */ |
| 4349 | |
| 4350 | block = btr_cur_get_blockcxx . . $ `storage/innobase/include/btr0cur.h:63:9`!(cursor); |
| 4351 | |
| 4352 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(block->page.id().space() == cursor->index()->table->space->id); |
| 4353 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(page_is_leaf(buf_block_get_frame(block))); |
| 4354 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!dict_index_is_online_ddl(cursor->index()) |
| 4355 | || cursor->index()->is_clust() |
| 4356 | || (flags & BTR_CREATE_FLAG)); |
| 4357 | |
| 4358 | rec = btr_cur_get_reccxx . . $ `storage/innobase/include/btr0cur.h:64:9`!(cursor); |
| 4359 | |
| 4360 | offsets = rec_get_offsetscxx . . $ `storage/innobase/include/rem0rec.h:475:10`!(rec, cursor->index(), offsets, |
| 4361 | cursor->index()->n_core_fields, |
| 4362 | ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!, &heap); |
| 4363 | |
| 4364 | dberr_tcxx . . $ dberr_t# err = DB_SUCCESScxx . . $ DB_SUCCESS.; |
| 4365 | DBUG_EXECUTE_IFcxx . . $ `include/my_dbug.h:172:9`!("btr_force_pessimistic_delete", |
| 4366 | err = DB_FAIL; goto func_exit;); |
| 4367 | |
| 4368 | if (rec_offs_any_externcxx . . $ rec_offs_any_extern(ca762aca731138fc).(offsets) |
| 4369 | || !btr_cur_can_delete_without_compresscxx . . $ btr_cur_can_delete_without_compress(eb7ec0e77beb17fb).(cursor, |
| 4370 | rec_offs_sizecxx . . $ rec_offs_size(6fce5c29061b60f9).(offsets), |
| 4371 | mtr)) { |
| 4372 | /* prefetch siblings of the leaf for the pessimistic |
| 4373 | operation. */ |
| 4374 | btr_cur_prefetch_siblingscxx . . $ btr_cur_prefetch_siblings(3d287479f68a2b77).(block, cursor->indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).(), mtr->trxcxx . . $ mtr_t#trx.); |
| 4375 | err = DB_FAILcxx . . $ DB_FAIL.; |
| 4376 | goto func_exit; |
| 4377 | } |
| 4378 | |
| 4379 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(block->page.id().page_no() == cursor->index()->page |
| 4380 | && page_get_n_recs(block->page.frame) == 1 |
| 4381 | + (cursor->index()->is_instant() |
| 4382 | && !rec_is_metadata(rec, *cursor->index())) |
| 4383 | && !cursor->index() |
| 4384 | ->must_avoid_clear_instant_add())) { |
| 4385 | /* The whole index (and table) becomes logically empty. |
| 4386 | Empty the whole page. That is, if we are deleting the |
| 4387 | only user record, also delete the metadata record |
| 4388 | if one exists for instant ADD COLUMN (not generic ALTER TABLE). |
| 4389 | If we are deleting the metadata record and the |
| 4390 | table becomes empty, clean up the whole page. */ |
| 4391 | dict_index_tcxx . . $ dict_index_t#* index = cursor->indexcxx . . $ btr_cur_t#index(4ab6b9797a912635).(); |
| 4392 | const rec_tcxx . . $ rec_t#* first_rec = page_rec_get_next_constcxx . . $ page_rec_get_next_const(e8dc1f8aea836758).( |
| 4393 | page_get_infimum_reccxx . . $ `storage/innobase/include/page0page.h:531:9`!(block->page.frame)); |
| 4394 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(!first_rec)) { |
| 4395 | err = DB_CORRUPTIONcxx . . $ DB_CORRUPTION.; |
| 4396 | goto func_exit; |
| 4397 | } |
| 4398 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!index->is_instant() |
| 4399 | || rec_is_metadata(first_rec, *index)); |
| 4400 | const bool is_metadata = rec_is_metadatacxx . . $ rec_is_metadata(5dcd923c19b1cb7d).(rec, *index); |
| 4401 | /* We can remove the metadata when rolling back an |
| 4402 | instant ALTER TABLE operation, or when deleting the |
| 4403 | last user record on the page such that only metadata for |
| 4404 | instant ADD COLUMN (not generic ALTER TABLE) remains. */ |
| 4405 | const bool empty_table = is_metadata |
| 4406 | || !index->is_instantcxx . . $ dict_index_t#is_instant(50ce9a9e25b4a850).() |
| 4407 | || (first_rec != rec |
| 4408 | && rec_is_add_metadatacxx . . $ rec_is_add_metadata(5dcd923c19b1cb7d).(first_rec, *index)); |
| 4409 | if (UNIV_LIKELYcxx . . $ `storage/innobase/include/univ.i:437:9`!(empty_table)) { |
| 4410 | if (UNIV_LIKELYcxx . . $ `storage/innobase/include/univ.i:437:9`!(!is_metadata && !flags)) { |
| 4411 | lock_update_deletecxx . . $ lock_update_delete(8215f79b77a41d69).(block, rec); |
| 4412 | } |
| 4413 | btr_page_emptycxx . . $ btr_page_empty(403ca5985fa24f33).(block, buf_block_get_page_zipcxx . . $ `storage/innobase/include/buf0buf.h:390:9`!(block), |
| 4414 | index, 0, mtr); |
| 4415 | if (index->is_instantcxx . . $ dict_index_t#is_instant(50ce9a9e25b4a850).()) { |
| 4416 | /* MDEV-17383: free metadata BLOBs! */ |
| 4417 | index->clear_instant_altercxx . . $ dict_index_t#clear_instant_alter(49f6e7a06ebc5aa8).(); |
| 4418 | } |
| 4419 | |
| 4420 | page_cur_set_after_lastcxx . . $ page_cur_set_after_last(34f1922d808032bb).(block, |
| 4421 | btr_cur_get_page_curcxx . . $ `storage/innobase/include/btr0cur.h:62:9`!(cursor)); |
| 4422 | goto func_exit; |
| 4423 | } |
| 4424 | } |
| 4425 | |
| 4426 | { |
| 4427 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(rec_get_info_bits(rec, page_is_comp( |
| 4428 | block->page.frame)) |
| 4429 | & REC_INFO_MIN_REC_FLAGcxx . . $ `storage/innobase/include/data0type.h:504:9`!)) { |
| 4430 | /* This should be rolling back instant ADD COLUMN. |
| 4431 | If this is a recovered transaction, then |
| 4432 | index->is_instant() will hold until the |
| 4433 | insert into SYS_COLUMNS is rolled back. */ |
| 4434 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(cursor->index()->table->supports_instant()); |
| 4435 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(cursor->index()->is_primary()); |
| 4436 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!buf_block_get_page_zip(block)); |
| 4437 | page_cur_delete_reccxx . . $ page_cur_delete_rec(236e529d3b285e57).(btr_cur_get_page_curcxx . . $ `storage/innobase/include/btr0cur.h:62:9`!(cursor), |
| 4438 | offsets, mtr); |
| 4439 | /* We must empty the PAGE_FREE list, because |
| 4440 | after rollback, this deleted metadata record |
| 4441 | would have too many fields, and we would be |
| 4442 | unable to know the size of the freed record. */ |
| 4443 | err = btr_page_reorganizecxx . . $ btr_page_reorganize(e4b2ea64c1f14b9e).(btr_cur_get_page_curcxx . . $ `storage/innobase/include/btr0cur.h:62:9`!(cursor), |
| 4444 | mtr); |
| 4445 | goto func_exit; |
| 4446 | } else { |
| 4447 | if (!flags) { |
| 4448 | lock_update_deletecxx . . $ lock_update_delete(8215f79b77a41d69).(block, rec); |
| 4449 | } |
| 4450 | |
| 4451 | btr_search_update_hash_on_deletecxx . . $ btr_search_update_hash_on_delete(c309ee090c231893).(cursor); |
| 4452 | } |
| 4453 | |
| 4454 | page_cur_delete_reccxx . . $ page_cur_delete_rec(236e529d3b285e57).(btr_cur_get_page_curcxx . . $ `storage/innobase/include/btr0cur.h:62:9`!(cursor), |
| 4455 | offsets, mtr); |
| 4456 | } |
| 4457 | |
| 4458 | func_exit: |
| 4459 | if (UNIV_LIKELY_NULLcxx . . $ `storage/innobase/include/univ.i:393:10`!(heap)) { |
| 4460 | mem_heap_freecxx . . $ mem_heap_free(5231cf397463bfab).(heap); |
| 4461 | } |
| 4462 | |
| 4463 | return err; |
| 4464 | } |
| 4465 | |
| 4466 | /*************************************************************//** |
| 4467 | Removes the record on which the tree cursor is positioned. Tries |
| 4468 | to compress the page if its fillfactor drops below a threshold |
| 4469 | or if it is the only page on the level. It is assumed that mtr holds |
| 4470 | an x-latch on the tree and on the cursor page. To avoid deadlocks, |
| 4471 | mtr must also own x-latches to brothers of page, if those brothers |
| 4472 | exist. |
| 4473 | @return TRUE if compression occurred and FALSE if not or something |
| 4474 | wrong. */ |
| 4475 | iboolcxx . . $ `storage/innobase/include/univ.i:355:9`! |
| 4476 | btr_cur_pessimistic_deletecxx . . $ btr_cur_pessimistic_delete(8e234601f90ce98f).( |
| 4477 | /*=======================*/ |
| 4478 | dberr_tcxx . . $ dberr_t#* err, /*!< out: DB_SUCCESS or DB_OUT_OF_FILE_SPACE; |
| 4479 | the latter may occur because we may have |
| 4480 | to update node pointers on upper levels, |
| 4481 | and in the case of variable length keys |
| 4482 | these may actually grow in size */ |
| 4483 | iboolcxx . . $ `storage/innobase/include/univ.i:355:9`! has_reserved_extents, /*!< in: TRUE if the |
| 4484 | caller has already reserved enough free |
| 4485 | extents so that he knows that the operation |
| 4486 | will succeed */ |
| 4487 | btr_cur_tcxx . . $ btr_cur_t#* cursor, /*!< in: cursor on the record to delete; |
| 4488 | if compression does not occur, the cursor |
| 4489 | stays valid: it points to successor of |
| 4490 | deleted record on function exit */ |
| 4491 | ulintcxx . . $ ulint# flags, /*!< in: BTR_CREATE_FLAG or 0 */ |
| 4492 | bool rollback,/*!< in: performing rollback? */ |
| 4493 | mtr_tcxx . . $ mtr_t#* mtr) /*!< in: mtr */ |
| 4494 | { |
| 4495 | buf_block_tcxx . . $ buf_block_t#* block; |
| 4496 | page_tcxx . . $ `storage/innobase/include/page0types.h:38:9`!* page; |
| 4497 | page_zip_des_tcxx . . $ page_zip_des_t#* page_zip; |
| 4498 | dict_index_tcxx . . $ dict_index_t#* index; |
| 4499 | rec_tcxx . . $ rec_t#* rec; |
| 4500 | uint32_tcxx . . $ uint32_t# n_reserved = 0; |
| 4501 | iboolcxx . . $ `storage/innobase/include/univ.i:355:9`! ret = FALSEcxx . . $ `include/my_global.h:477:9`!; |
| 4502 | mem_heap_tcxx . . $ mem_heap_t#* heap; |
| 4503 | rec_offscxx . . $ rec_offs#* offsets; |
| 4504 | #ifdef UNIV_DEBUG |
| 4505 | bool parent_latched = false; |
| 4506 | #endif /* UNIV_DEBUG */ |
| 4507 | |
| 4508 | block = btr_cur_get_blockcxx . . $ `storage/innobase/include/btr0cur.h:63:9`!(cursor); |
| 4509 | page = buf_block_get_framecxx . . $ `storage/innobase/include/buf0buf.h:385:9`!(block); |
| 4510 | index = btr_cur_get_indexcxx . . $ `storage/innobase/include/btr0cur.h:82:9`!(cursor); |
| 4511 | |
| 4512 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(flags == 0 || flags == BTR_CREATE_FLAG); |
| 4513 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!dict_index_is_online_ddl(index) |
| 4514 | || dict_index_is_clust(index) |
| 4515 | || (flags & BTR_CREATE_FLAG)); |
| 4516 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mtr->memo_contains_flagged(&index->lock, MTR_MEMO_X_LOCK |
| 4517 | | MTR_MEMO_SX_LOCK)); |
| 4518 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mtr->memo_contains_flagged(block, MTR_MEMO_PAGE_X_FIX)); |
| 4519 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mtr->is_named_space(index->table->space)); |
| 4520 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!index->is_dummy); |
| 4521 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(block->page.id().space() == index->table->space->id); |
| 4522 | |
| 4523 | if (!has_reserved_extents) { |
| 4524 | /* First reserve enough free space for the file segments |
| 4525 | of the index tree, so that the node pointer updates will |
| 4526 | not fail because of lack of space */ |
| 4527 | |
| 4528 | uint32_tcxx . . $ uint32_t# n_extents = uint32_tcxx . . $ uint32_t#(cursor->tree_heightcxx . . $ btr_cur_t#tree_height. / 32 + 1); |
| 4529 | |
| 4530 | *err = fsp_reserve_free_extentscxx . . $ fsp_reserve_free_extents(ff8909883dc21fea).(&n_reserved, |
| 4531 | index->tablecxx . . $ dict_index_t#table.->spacecxx . . $ dict_table_t#space., |
| 4532 | n_extents, |
| 4533 | FSP_CLEANINGcxx . . $ FSP_CLEANING., mtr); |
| 4534 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(*err != DB_SUCCESS)) { |
| 4535 | return(FALSEcxx . . $ `include/my_global.h:477:9`!); |
| 4536 | } |
| 4537 | } |
| 4538 | |
| 4539 | heap = mem_heap_createcxx . . $ `storage/innobase/include/mem0mem.h:85:10`!(1024); |
| 4540 | rec = btr_cur_get_reccxx . . $ `storage/innobase/include/btr0cur.h:64:9`!(cursor); |
| 4541 | page_zip = buf_block_get_page_zipcxx . . $ `storage/innobase/include/buf0buf.h:390:9`!(block); |
| 4542 | #ifdef UNIV_ZIP_DEBUG |
| 4543 | ut_a(!page_zip || page_zip_validate(page_zip, page, index)); |
| 4544 | #endif /* UNIV_ZIP_DEBUG */ |
| 4545 | |
| 4546 | offsets = rec_get_offsetscxx . . $ `storage/innobase/include/rem0rec.h:475:10`!(rec, index, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, page_is_leaf(page) |
| 4547 | ? index->n_core_fields : 0, |
| 4548 | ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!, &heap); |
| 4549 | |
| 4550 | if (rec_offs_any_externcxx . . $ rec_offs_any_extern(ca762aca731138fc).(offsets)) { |
| 4551 | btr_rec_free_externally_stored_fieldscxx . . $ btr_rec_free_externally_stored_fields(e4c61c0bfa48221b).(index, |
| 4552 | rec, offsets, block, |
| 4553 | rollback, mtr); |
| 4554 | #ifdef UNIV_ZIP_DEBUG |
| 4555 | ut_a(!page_zip || page_zip_validate(page_zip, page, index)); |
| 4556 | #endif /* UNIV_ZIP_DEBUG */ |
| 4557 | } |
| 4558 | |
| 4559 | rec_tcxx . . $ rec_t#* next_rec = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 4560 | bool min_mark_next_rec = false; |
| 4561 | |
| 4562 | if (page_is_leafcxx . . $ page_is_leaf(190063cf6fb4afb1).(page)) { |
| 4563 | const bool is_metadata = rec_is_metadatacxx . . $ rec_is_metadata(3a706fe4966174d9).( |
| 4564 | rec, page_is_compcxx . . $ page_is_comp(f3688bc2ee54ea05).(block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.)); |
| 4565 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(is_metadata)) { |
| 4566 | /* This should be rolling back instant ALTER TABLE. |
| 4567 | If this is a recovered transaction, then |
| 4568 | index->is_instant() will hold until the |
| 4569 | insert into SYS_COLUMNS is rolled back. */ |
| 4570 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rollback); |
| 4571 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(index->table->supports_instant()); |
| 4572 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(index->is_primary()); |
| 4573 | } else if (flags == 0) { |
| 4574 | lock_update_deletecxx . . $ lock_update_delete(8215f79b77a41d69).(block, rec); |
| 4575 | } |
| 4576 | |
| 4577 | if (block->pagecxx . . $ buf_block_t#page..idcxx . . $ buf_page_t#id(9d40bbb65128eac8).().page_nocxx . . $ page_id_t#page_no(d22c8608b6eae7b5).() != index->pagecxx . . $ dict_index_t#page.) { |
| 4578 | if (page_get_n_recscxx . . $ page_get_n_recs(469dcb4e54b221a8).(page) < 2) { |
| 4579 | goto discard_page; |
| 4580 | } |
| 4581 | } else if (page_get_n_recscxx . . $ page_get_n_recs(469dcb4e54b221a8).(page) == 1 |
| 4582 | + (index->is_instantcxx . . $ dict_index_t#is_instant(50ce9a9e25b4a850).() && !is_metadata) |
| 4583 | && !index->must_avoid_clear_instant_addcxx . . $ dict_index_t#must_avoid_clear_instant_add(50ce9a9e25b4a850).()) { |
| 4584 | /* The whole index (and table) becomes logically empty. |
| 4585 | Empty the whole page. That is, if we are deleting the |
| 4586 | only user record, also delete the metadata record |
| 4587 | if one exists for instant ADD COLUMN |
| 4588 | (not generic ALTER TABLE). |
| 4589 | If we are deleting the metadata record |
| 4590 | (in the rollback of instant ALTER TABLE) and the |
| 4591 | table becomes empty, clean up the whole page. */ |
| 4592 | |
| 4593 | const rec_tcxx . . $ rec_t#* first_rec = page_rec_get_next_constcxx . . $ page_rec_get_next_const(e8dc1f8aea836758).( |
| 4594 | page_get_infimum_reccxx . . $ `storage/innobase/include/page0page.h:531:9`!(page)); |
| 4595 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(!first_rec)) { |
| 4596 | *err = DB_CORRUPTIONcxx . . $ DB_CORRUPTION.; |
| 4597 | goto err_exit; |
| 4598 | } |
| 4599 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!index->is_instant() |
| 4600 | || rec_is_metadata(first_rec, *index)); |
| 4601 | if (is_metadata || !index->is_instantcxx . . $ dict_index_t#is_instant(50ce9a9e25b4a850).() |
| 4602 | || (first_rec != rec |
| 4603 | && rec_is_add_metadatacxx . . $ rec_is_add_metadata(5dcd923c19b1cb7d).(first_rec, *index))) { |
| 4604 | btr_page_emptycxx . . $ btr_page_empty(403ca5985fa24f33).(block, page_zip, index, 0, mtr); |
| 4605 | if (index->is_instantcxx . . $ dict_index_t#is_instant(50ce9a9e25b4a850).()) { |
| 4606 | /* MDEV-17383: free metadata BLOBs! */ |
| 4607 | index->clear_instant_altercxx . . $ dict_index_t#clear_instant_alter(49f6e7a06ebc5aa8).(); |
| 4608 | } |
| 4609 | |
| 4610 | page_cur_set_after_lastcxx . . $ page_cur_set_after_last(34f1922d808032bb).( |
| 4611 | block, |
| 4612 | btr_cur_get_page_curcxx . . $ `storage/innobase/include/btr0cur.h:62:9`!(cursor)); |
| 4613 | ret = TRUEcxx . . $ `include/my_global.h:476:9`!; |
| 4614 | goto return_after_reservations; |
| 4615 | } |
| 4616 | } |
| 4617 | |
| 4618 | if (UNIV_LIKELYcxx . . $ `storage/innobase/include/univ.i:437:9`!(!is_metadata)) { |
| 4619 | btr_search_update_hash_on_deletecxx . . $ btr_search_update_hash_on_delete(c309ee090c231893).(cursor); |
| 4620 | } else { |
| 4621 | page_cur_delete_reccxx . . $ page_cur_delete_rec(236e529d3b285e57).(btr_cur_get_page_curcxx . . $ `storage/innobase/include/btr0cur.h:62:9`!(cursor), |
| 4622 | offsets, mtr); |
| 4623 | /* We must empty the PAGE_FREE list, because |
| 4624 | after rollback, this deleted metadata record |
| 4625 | would carry too many fields, and we would be |
| 4626 | unable to know the size of the freed record. */ |
| 4627 | *err = btr_page_reorganizecxx . . $ btr_page_reorganize(e4b2ea64c1f14b9e).(btr_cur_get_page_curcxx . . $ `storage/innobase/include/btr0cur.h:62:9`!(cursor), |
| 4628 | mtr); |
| 4629 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!ret); |
| 4630 | goto err_exit; |
| 4631 | } |
| 4632 | } else if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(page_rec_is_first(rec, page))) { |
| 4633 | if (page_rec_is_lastcxx . . $ page_rec_is_last(27c8776bc8033bc9).(rec, page)) { |
| 4634 | discard_page: |
| 4635 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(page_get_n_recs(page) == 1); |
| 4636 | /* If there is only one record, drop |
| 4637 | the whole page. */ |
| 4638 | |
| 4639 | btr_discard_pagecxx . . $ btr_discard_page(b94baeb28a69884e).(cursor, mtr); |
| 4640 | |
| 4641 | ret = TRUEcxx . . $ `include/my_global.h:476:9`!; |
| 4642 | goto return_after_reservations; |
| 4643 | } |
| 4644 | |
| 4645 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(!(next_rec = page_rec_get_next(rec)))) { |
| 4646 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!ret); |
| 4647 | *err = DB_CORRUPTIONcxx . . $ DB_CORRUPTION.; |
| 4648 | goto err_exit; |
| 4649 | } |
| 4650 | |
| 4651 | btr_cur_tcxx . . $ btr_cur_t# curcxx . . $ btr_cur_t#btr_cur_t(49f6e7a06ebc5aa8).; |
| 4652 | cur.page_curcxx . . $ btr_cur_t#page_cur..indexcxx . . $ page_cur_t#index. = index; |
| 4653 | cur.page_curcxx . . $ btr_cur_t#page_cur..blockcxx . . $ page_cur_t#block. = block; |
| 4654 | |
| 4655 | if (!page_has_prevcxx . . $ page_has_prev(190063cf6fb4afb1).(page)) { |
| 4656 | /* If we delete the leftmost node pointer on a |
| 4657 | non-leaf level, we must mark the new leftmost node |
| 4658 | pointer as the predefined minimum record */ |
| 4659 | |
| 4660 | min_mark_next_rec = true; |
| 4661 | } else if (index->is_spatialcxx . . $ dict_index_t#is_spatial(50ce9a9e25b4a850).()) { |
| 4662 | /* For rtree, if delete the leftmost node pointer, |
| 4663 | we need to update parent page. */ |
| 4664 | rtr_mbr_tcxx . . $ rtr_mbr_t# father_mbr; |
| 4665 | rec_tcxx . . $ rec_t#* father_rec; |
| 4666 | rec_offscxx . . $ rec_offs#* offsets; |
| 4667 | ulintcxx . . $ ulint# len; |
| 4668 | |
| 4669 | rtr_page_get_father_blockcxx . . $ rtr_page_get_father_block(11147704a133bbed).(nullptr, heap, nullptr, |
| 4670 | &cur, |
| 4671 | cursor->rtr_infocxx . . $ btr_cur_t#rtr_info.->thrcxx . . $ rtr_info#thr., mtr); |
| 4672 | father_rec = btr_cur_get_reccxx . . $ `storage/innobase/include/btr0cur.h:64:9`!(&cur); |
| 4673 | offsets = rec_get_offsetscxx . . $ `storage/innobase/include/rem0rec.h:475:10`!(father_rec, index, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, |
| 4674 | 0, ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!, &heap); |
| 4675 | |
| 4676 | rtr_read_mbrcxx . . $ rtr_read_mbr(6f8069964988d1d0).(rec_get_nth_fieldcxx . . $ `storage/innobase/include/rem0rec.h:562:9`!( |
| 4677 | father_rec, offsets, 0, &len), &father_mbr); |
| 4678 | |
| 4679 | rtr_update_mbr_fieldcxx . . $ rtr_update_mbr_field(1a4fe7edb6924cd8).(&cur, offsets, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, |
| 4680 | page, &father_mbr, next_rec, mtr); |
| 4681 | ut_dcxx . . $ `storage/innobase/include/ut0dbg.h:68:9`!(parent_latched = true); |
| 4682 | } else { |
| 4683 | /* Otherwise, if we delete the leftmost node pointer |
| 4684 | on a page, we have to change the parent node pointer |
| 4685 | so that it is equal to the new leftmost node pointer |
| 4686 | on the page */ |
| 4687 | ret = btr_page_get_fathercxx . . $ btr_page_get_father(ef799a93ae7a666b).(mtr, &cur); |
| 4688 | if (!ret) { |
| 4689 | *err = DB_CORRUPTIONcxx . . $ DB_CORRUPTION.; |
| 4690 | goto err_exit; |
| 4691 | } |
| 4692 | *err = btr_cur_node_ptr_deletecxx . . $ btr_cur_node_ptr_delete(b94baeb28a69884e).(&cur, mtr); |
| 4693 | if (*err != DB_SUCCESScxx . . $ DB_SUCCESS.) { |
| 4694 | got_err: |
| 4695 | ret = FALSEcxx . . $ `include/my_global.h:477:9`!; |
| 4696 | goto err_exit; |
| 4697 | } |
| 4698 | |
| 4699 | const ulintcxx . . $ ulint# level = btr_page_get_levelcxx . . $ btr_page_get_level(469dcb4e54b221a8).(page); |
| 4700 | // FIXME: reuse the node_ptr from above |
| 4701 | dtuple_tcxx . . $ dtuple_t#* node_ptr = dict_index_build_node_ptrcxx . . $ dict_index_build_node_ptr(21b5a4827c82add7).( |
| 4702 | index, next_rec, block->pagecxx . . $ buf_block_t#page..idcxx . . $ buf_page_t#id(9d40bbb65128eac8).().page_nocxx . . $ page_id_t#page_no(d22c8608b6eae7b5).(), |
| 4703 | heap, level); |
| 4704 | |
| 4705 | *err = btr_insert_on_non_leaf_levelcxx . . $ btr_insert_on_non_leaf_level(3adb5c2757e97672).( |
| 4706 | flags, index, level + 1, node_ptr, mtr); |
| 4707 | if (*err != DB_SUCCESScxx . . $ DB_SUCCESS.) { |
| 4708 | ret = FALSEcxx . . $ `include/my_global.h:477:9`!; |
| 4709 | goto got_err; |
| 4710 | } |
| 4711 | |
| 4712 | ut_dcxx . . $ `storage/innobase/include/ut0dbg.h:68:9`!(parent_latched = true); |
| 4713 | } |
| 4714 | } |
| 4715 | |
| 4716 | /* SPATIAL INDEX never use U locks; we can allow page merges |
| 4717 | while holding X lock on the spatial index tree. |
| 4718 | Do not allow merges of non-leaf B-tree pages unless it is |
| 4719 | safe to do so. */ |
| 4720 | { |
| 4721 | const bool allow_merge = page_is_leafcxx . . $ page_is_leaf(190063cf6fb4afb1).(page) |
| 4722 | || dict_index_is_spatialcxx . . $ `storage/innobase/include/dict0dict.h:620:9`!(index) |
| 4723 | || btr_cur_will_modify_treecxx . . $ btr_cur_will_modify_tree(2ced6e53d49ba5b0).( |
| 4724 | index, page, BTR_INTENTION_DELETEcxx . . $ BTR_INTENTION_DELETE., rec, |
| 4725 | btr_node_ptr_max_sizecxx . . $ btr_node_ptr_max_size(67f37f56c055bd3e).(index), |
| 4726 | block->zip_sizecxx . . $ buf_block_t#zip_size(c9b1e749b64d5edc).(), mtr); |
| 4727 | page_cur_delete_reccxx . . $ page_cur_delete_rec(236e529d3b285e57).(btr_cur_get_page_curcxx . . $ `storage/innobase/include/btr0cur.h:62:9`!(cursor), |
| 4728 | offsets, mtr); |
| 4729 | |
| 4730 | if (min_mark_next_rec) { |
| 4731 | btr_set_min_rec_markcxx . . $ btr_set_min_rec_mark(2be009421920b45e).(next_rec, *block, mtr); |
| 4732 | } |
| 4733 | |
| 4734 | #ifdef UNIV_ZIP_DEBUG |
| 4735 | ut_a(!page_zip || page_zip_validate(page_zip, page, index)); |
| 4736 | #endif /* UNIV_ZIP_DEBUG */ |
| 4737 | |
| 4738 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!parent_latched |
| 4739 | || btr_check_node_ptr(index, block, |
| 4740 | cursor->rtr_info |
| 4741 | ? cursor->rtr_info->thr |
| 4742 | : nullptr, mtr)); |
| 4743 | |
| 4744 | if (!ret && btr_cur_compress_recommendationcxx . . $ btr_cur_compress_recommendation(82f858bc4e1f6dfd).(cursor, mtr)) { |
| 4745 | if (UNIV_LIKELYcxx . . $ `storage/innobase/include/univ.i:437:9`!(allow_merge)) { |
| 4746 | ret = btr_cur_compress_if_usefulcxx . . $ btr_cur_compress_if_useful(c0ed7dbe459c1b6c).( |
| 4747 | cursor, FALSEcxx . . $ `include/my_global.h:477:9`!, mtr); |
| 4748 | } else { |
| 4749 | ibcxx . . $ ib/::warncxx . . $ ib/warn#() <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). "Not merging page " |
| 4750 | <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). block->pagecxx . . $ buf_block_t#page..idcxx . . $ buf_page_t#id(9d40bbb65128eac8).() |
| 4751 | <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). " in index " <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). index->namecxx . . $ dict_index_t#name. |
| 4752 | <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). " of " <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). index->tablecxx . . $ dict_index_t#table.->namecxx . . $ dict_table_t#name.; |
| 4753 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!("MDEV-14637" == 0); |
| 4754 | } |
| 4755 | } |
| 4756 | } |
| 4757 | |
| 4758 | return_after_reservations: |
| 4759 | *err = DB_SUCCESScxx . . $ DB_SUCCESS.; |
| 4760 | err_exit: |
| 4761 | mem_heap_freecxx . . $ mem_heap_free(5231cf397463bfab).(heap); |
| 4762 | |
| 4763 | #if 0 // FIXME: this used to be a no-op, and will cause trouble if enabled |
| 4764 | if (page_is_leaf(page) |
| 4765 | && !dict_index_is_online_ddl(index)) { |
| 4766 | mtr->release(index->lock); |
| 4767 | /* NOTE: We cannot release root block latch here, because it |
| 4768 | has segment header and already modified in most of cases.*/ |
| 4769 | } |
| 4770 | #endif |
| 4771 | |
| 4772 | index->tablecxx . . $ dict_index_t#table.->spacecxx . . $ dict_table_t#space.->release_free_extentscxx . . $ fil_space_t#release_free_extents(6bab9b75950d6f3).(n_reserved); |
| 4773 | return(ret); |
| 4774 | } |
| 4775 | |
| 4776 | /** Delete the node pointer in a parent page. |
| 4777 | @param[in,out] parent cursor pointing to parent record |
| 4778 | @param[in,out] mtr mini-transaction */ |
| 4779 | dberr_tcxx . . $ dberr_t# btr_cur_node_ptr_deletecxx . . $ btr_cur_node_ptr_delete(b94baeb28a69884e).(btr_cur_tcxx . . $ btr_cur_t#* parent, mtr_tcxx . . $ mtr_t#* mtr) |
| 4780 | { |
| 4781 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mtr->memo_contains_flagged(btr_cur_get_block(parent), |
| 4782 | MTR_MEMO_PAGE_X_FIX)); |
| 4783 | dberr_tcxx . . $ dberr_t# err; |
| 4784 | iboolcxx . . $ `storage/innobase/include/univ.i:355:9`! compressed = btr_cur_pessimistic_deletecxx . . $ btr_cur_pessimistic_delete(8e234601f90ce98f).(&err, TRUEcxx . . $ `include/my_global.h:476:9`!, parent, |
| 4785 | BTR_CREATE_FLAGcxx . . $ BTR_CREATE_FLAG., false, |
| 4786 | mtr); |
| 4787 | if (err == DB_SUCCESScxx . . $ DB_SUCCESS. && !compressed) { |
| 4788 | btr_cur_compress_if_usefulcxx . . $ btr_cur_compress_if_useful(c0ed7dbe459c1b6c).(parent, FALSEcxx . . $ `include/my_global.h:477:9`!, mtr); |
| 4789 | } |
| 4790 | |
| 4791 | return err; |
| 4792 | } |
| 4793 | |
| 4794 | /** Represents the cursor for the number of rows estimation. The |
| 4795 | content is used for level-by-level diving and estimation the number of rows |
| 4796 | on each level. */ |
| 4797 | class btr_est_cur_tcxx . . $ btr_est_cur_t# |
| 4798 | { |
| 4799 | /* Assume a page like: |
| 4800 | records: (inf, a, b, c, d, sup) |
| 4801 | index of the record: 0, 1, 2, 3, 4, 5 |
| 4802 | */ |
| 4803 | |
| 4804 | /** Index of the record where the page cursor stopped on this level |
| 4805 | (index in alphabetical order). In the above example, if the search stopped on |
| 4806 | record 'c', then nth_rec will be 3. */ |
| 4807 | ulintcxx . . $ ulint# m_nth_reccxx . . $ btr_est_cur_t#m_nth_rec.; |
| 4808 | |
| 4809 | /** Number of the records on the page, not counting inf and sup. |
| 4810 | In the above example n_recs will be 4. */ |
| 4811 | ulintcxx . . $ ulint# m_n_recscxx . . $ btr_est_cur_t#m_n_recs.; |
| 4812 | |
| 4813 | /** Search tuple */ |
| 4814 | const dtuple_tcxx . . $ dtuple_t# &m_tuplecxx . . $ btr_est_cur_t#m_tuple.; |
| 4815 | /** Cursor search mode */ |
| 4816 | page_cur_mode_tcxx . . $ page_cur_mode_t# m_modecxx . . $ btr_est_cur_t#m_mode.; |
| 4817 | /** Page cursor which is used for search */ |
| 4818 | page_cur_tcxx . . $ page_cur_t# m_page_curcxx . . $ btr_est_cur_t#m_page_cur.; |
| 4819 | /** Page id of the page to get on level down, can differ from |
| 4820 | m_block->page.id at the moment when the child's page id is already found, but |
| 4821 | the child's block has not fetched yet */ |
| 4822 | page_id_tcxx . . $ page_id_t# m_page_idcxx . . $ btr_est_cur_t#m_page_id.; |
| 4823 | /** Current block */ |
| 4824 | buf_block_tcxx . . $ buf_block_t# *m_blockcxx . . $ btr_est_cur_t#m_block.; |
| 4825 | /** Page search mode, can differ from m_mode for non-leaf pages, see c-tor |
| 4826 | comments for details */ |
| 4827 | page_cur_mode_tcxx . . $ page_cur_mode_t# m_page_modecxx . . $ btr_est_cur_t#m_page_mode.; |
| 4828 | |
| 4829 | /** Matched fields and bytes which are used for on-page search, see |
| 4830 | btr_cur_t::(up|low)_(match|bytes) comments for details */ |
| 4831 | uint16_tcxx . . $ uint16_t# m_up_matchcxx . . $ btr_est_cur_t#m_up_match.= 0; |
| 4832 | uint16_tcxx . . $ uint16_t# m_up_bytescxx . . $ btr_est_cur_t#m_up_bytes.= 0; |
| 4833 | uint16_tcxx . . $ uint16_t# m_low_matchcxx . . $ btr_est_cur_t#m_low_match.= 0; |
| 4834 | uint16_tcxx . . $ uint16_t# m_low_bytescxx . . $ btr_est_cur_t#m_low_bytes.= 0; |
| 4835 | |
| 4836 | public: |
| 4837 | btr_est_cur_tcxx . . $ btr_est_cur_t#btr_est_cur_t(a7241808cc5497e4).(dict_index_tcxx . . $ dict_index_t# *index, const dtuple_tcxx . . $ dtuple_t# &tuple, |
| 4838 | page_cur_mode_tcxx . . $ page_cur_mode_t# mode) |
| 4839 | : m_tuplecxx . . $ btr_est_cur_t#m_tuple.(tuple), m_modecxx . . $ btr_est_cur_t#m_mode.(mode), |
| 4840 | m_page_idcxx . . $ btr_est_cur_t#m_page_id.(index->tablecxx . . $ dict_index_t#table.->space_idcxx . . $ dict_table_t#space_id., index->pagecxx . . $ dict_index_t#page.), m_blockcxx . . $ btr_est_cur_t#m_block.(nullptr) |
| 4841 | { |
| 4842 | |
| 4843 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(dict_index_check_search_tuple(index, &tuple)); |
| 4844 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(dtuple_check_typed(&tuple)); |
| 4845 | |
| 4846 | m_page_curcxx . . $ btr_est_cur_t#m_page_cur..indexcxx . . $ page_cur_t#index. = index; |
| 4847 | /* We use these modified search modes on non-leaf levels of the B-tree. |
| 4848 | These let us end up in the right B-tree leaf. In that leaf we use the |
| 4849 | original search mode. */ |
| 4850 | switch (mode) { |
| 4851 | case PAGE_CUR_GEcxx . . $ PAGE_CUR_GE.: |
| 4852 | m_page_modecxx . . $ btr_est_cur_t#m_page_mode.= PAGE_CUR_Lcxx . . $ PAGE_CUR_L.; |
| 4853 | break; |
| 4854 | case PAGE_CUR_Gcxx . . $ PAGE_CUR_G.: |
| 4855 | m_page_modecxx . . $ btr_est_cur_t#m_page_mode.= PAGE_CUR_LEcxx . . $ PAGE_CUR_LE.; |
| 4856 | break; |
| 4857 | default: |
| 4858 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mode == PAGE_CUR_L || mode == PAGE_CUR_LE); |
| 4859 | m_page_modecxx . . $ btr_est_cur_t#m_page_mode.= mode; |
| 4860 | break; |
| 4861 | } |
| 4862 | } |
| 4863 | |
| 4864 | /** Retrieve block with m_page_id, release the previously gotten block |
| 4865 | if necessary. If this is a left border block cursor and both left and right |
| 4866 | border blocks have the same parent, don't unlatch the parent, as it must be |
| 4867 | latched to get the right block, and will be unlatched after the right block |
| 4868 | is fetched. |
| 4869 | @param level distance from the leaf page level; ULINT_UNDEFINED when |
| 4870 | fetching the root page |
| 4871 | @param mtr mtr |
| 4872 | @param right_parent right border block parent, nullptr if the function |
| 4873 | is called for the right block itself |
| 4874 | @return true on success or false otherwise. */ |
| 4875 | bool fetch_childcxx . . $ btr_est_cur_t#fetch_child(c1df0f5eb492ca26).(ulintcxx . . $ ulint# level, mtr_tcxx . . $ mtr_t# &mtr, const buf_block_tcxx . . $ buf_block_t# *right_parent) |
| 4876 | { |
| 4877 | buf_block_tcxx . . $ buf_block_t# *parent_block= m_blockcxx . . $ btr_est_cur_t#m_block.; |
| 4878 | |
| 4879 | m_blockcxx . . $ btr_est_cur_t#m_block.= btr_block_getcxx . . $ btr_block_get(fa2ba45a54fcd0c4).(*indexcxx . . $ btr_est_cur_t#index(2cd16ccfe5c0b43a).(), m_page_idcxx . . $ btr_est_cur_t#m_page_id..page_nocxx . . $ page_id_t#page_no(d22c8608b6eae7b5).(), RW_S_LATCHcxx . . $ RW_S_LATCH., |
| 4880 | &mtr, nullptr); |
| 4881 | if (!m_blockcxx . . $ btr_est_cur_t#m_block.) |
| 4882 | return false; |
| 4883 | |
| 4884 | if (parent_block && parent_block != right_parent) |
| 4885 | { |
| 4886 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mtr.get_savepoint() >= 2); |
| 4887 | mtr.rollback_to_savepointcxx . . $ mtr_t#rollback_to_savepoint(6714b5f2551eea49).(1, 2); |
| 4888 | } |
| 4889 | |
| 4890 | return level == ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`! || |
| 4891 | btr_page_get_levelcxx . . $ btr_page_get_level(469dcb4e54b221a8).(m_blockcxx . . $ btr_est_cur_t#m_block.->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.) == level; |
| 4892 | } |
| 4893 | |
| 4894 | /** Sets page mode for leaves */ |
| 4895 | void set_page_mode_for_leavescxx . . $ btr_est_cur_t#set_page_mode_for_leaves(49f6e7a06ebc5aa8).() { m_page_modecxx . . $ btr_est_cur_t#m_page_mode.= m_modecxx . . $ btr_est_cur_t#m_mode.; } |
| 4896 | |
| 4897 | /** Does search on the current page. If there is no border in m_tuple, then |
| 4898 | just move the cursor to the most left or right record. |
| 4899 | @param level current level on tree. |
| 4900 | @param root_height root height |
| 4901 | @param left true if this is left border, false otherwise. |
| 4902 | @return true on success, false otherwise. */ |
| 4903 | bool search_on_pagecxx . . $ btr_est_cur_t#search_on_page(4af46f8da2c629f3).(ulintcxx . . $ ulint# level, ulintcxx . . $ ulint# root_height, bool left) |
| 4904 | { |
| 4905 | if (level != btr_page_get_levelcxx . . $ btr_page_get_level(469dcb4e54b221a8).(m_blockcxx . . $ btr_est_cur_t#m_block.->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.)) |
| 4906 | return false; |
| 4907 | |
| 4908 | m_n_recscxx . . $ btr_est_cur_t#m_n_recs.= page_get_n_recscxx . . $ page_get_n_recs(469dcb4e54b221a8).(m_blockcxx . . $ btr_est_cur_t#m_block.->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.); |
| 4909 | |
| 4910 | if (dtuple_get_n_fieldscxx . . $ dtuple_get_n_fields(3106ade7d958747e).(&m_tuplecxx . . $ btr_est_cur_t#m_tuple.) > 0) |
| 4911 | { |
| 4912 | m_up_bytescxx . . $ btr_est_cur_t#m_up_bytes.= m_low_bytescxx . . $ btr_est_cur_t#m_low_bytes.= 0; |
| 4913 | m_page_curcxx . . $ btr_est_cur_t#m_page_cur..blockcxx . . $ page_cur_t#block.= m_blockcxx . . $ btr_est_cur_t#m_block.; |
| 4914 | if (page_cur_search_with_matchcxx . . $ page_cur_search_with_match(2a162131057c114d).(&m_tuplecxx . . $ btr_est_cur_t#m_tuple., m_page_modecxx . . $ btr_est_cur_t#m_page_mode., |
| 4915 | &m_up_matchcxx . . $ btr_est_cur_t#m_up_match., &m_low_matchcxx . . $ btr_est_cur_t#m_low_match., &m_page_curcxx . . $ btr_est_cur_t#m_page_cur., |
| 4916 | nullptr)) |
| 4917 | return false; |
| 4918 | m_nth_reccxx . . $ btr_est_cur_t#m_nth_rec.= page_rec_get_n_recs_beforecxx . . $ page_rec_get_n_recs_before(b191ace3c5bffbd9).(page_cur_get_reccxx . . $ `storage/innobase/include/page0cur.h:57:10`!(&m_page_cur)); |
| 4919 | } |
| 4920 | else if (left) |
| 4921 | { |
| 4922 | page_cur_set_before_firstcxx . . $ page_cur_set_before_first(34f1922d808032bb).(m_blockcxx . . $ btr_est_cur_t#m_block., &m_page_curcxx . . $ btr_est_cur_t#m_page_cur.); |
| 4923 | if (level) |
| 4924 | { |
| 4925 | if (!page_cur_move_to_nextcxx . . $ page_cur_move_to_next(99e08e4d4839908).(&m_page_curcxx . . $ btr_est_cur_t#m_page_cur.)) |
| 4926 | return false; |
| 4927 | m_nth_reccxx . . $ btr_est_cur_t#m_nth_rec.= 1; |
| 4928 | } |
| 4929 | else |
| 4930 | m_nth_reccxx . . $ btr_est_cur_t#m_nth_rec.= 0; |
| 4931 | } |
| 4932 | else |
| 4933 | { |
| 4934 | m_nth_reccxx . . $ btr_est_cur_t#m_nth_rec.= m_n_recscxx . . $ btr_est_cur_t#m_n_recs.; |
| 4935 | if (!level) |
| 4936 | { |
| 4937 | page_cur_set_after_lastcxx . . $ page_cur_set_after_last(34f1922d808032bb).(m_blockcxx . . $ btr_est_cur_t#m_block., &m_page_curcxx . . $ btr_est_cur_t#m_page_cur.); |
| 4938 | ++m_nth_reccxx . . $ btr_est_cur_t#m_nth_rec.; |
| 4939 | } |
| 4940 | else |
| 4941 | { |
| 4942 | m_page_curcxx . . $ btr_est_cur_t#m_page_cur..blockcxx . . $ page_cur_t#block.= m_blockcxx . . $ btr_est_cur_t#m_block.; |
| 4943 | m_page_curcxx . . $ btr_est_cur_t#m_page_cur..reccxx . . $ page_cur_t#rec.= page_rec_get_nthcxx . . $ page_rec_get_nth(7ccb9c26b1180419).(m_blockcxx . . $ btr_est_cur_t#m_block.->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame., m_nth_reccxx . . $ btr_est_cur_t#m_nth_rec.); |
| 4944 | } |
| 4945 | } |
| 4946 | |
| 4947 | return true; |
| 4948 | } |
| 4949 | |
| 4950 | /** Read page id of the current record child. |
| 4951 | @param offsets offsets array. |
| 4952 | @param heap heap for offsets array */ |
| 4953 | void read_child_page_idcxx . . $ btr_est_cur_t#read_child_page_id(667519cbefc2e584).(rec_offscxx . . $ rec_offs# **offsets, mem_heap_tcxx . . $ mem_heap_t# **heap) |
| 4954 | { |
| 4955 | const rec_tcxx . . $ rec_t# *node_ptr= page_cur_get_reccxx . . $ `storage/innobase/include/page0cur.h:57:10`!(&m_page_cur); |
| 4956 | |
| 4957 | /* FIXME: get the child page number directly without computing offsets */ |
| 4958 | *offsets= rec_get_offsetscxx . . $ `storage/innobase/include/rem0rec.h:475:10`!(node_ptr, index(), *offsets, 0, ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!, |
| 4959 | heap); |
| 4960 | |
| 4961 | /* Go to the child node */ |
| 4962 | m_page_idcxx . . $ btr_est_cur_t#m_page_id..set_page_nocxx . . $ page_id_t#set_page_no(6bab9b75950d6f3).(btr_node_ptr_get_child_page_nocxx . . $ btr_node_ptr_get_child_page_no(9efe0e53bf5e4c88).(node_ptr, *offsets)); |
| 4963 | } |
| 4964 | |
| 4965 | /** @return true if left border should be counted */ |
| 4966 | bool should_count_the_left_bordercxx . . $ btr_est_cur_t#should_count_the_left_border(50ce9a9e25b4a850).() const |
| 4967 | { |
| 4968 | if (dtuple_get_n_fieldscxx . . $ dtuple_get_n_fields(3106ade7d958747e).(&m_tuplecxx . . $ btr_est_cur_t#m_tuple.) > 0) |
| 4969 | { |
| 4970 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!page_rec_is_infimum(page_cur_get_rec(&m_page_cur))); |
| 4971 | return !page_rec_is_supremumcxx . . $ page_rec_is_supremum(190063cf6fb4afb1).(page_cur_get_reccxx . . $ `storage/innobase/include/page0cur.h:57:10`!(&m_page_cur)); |
| 4972 | } |
| 4973 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(page_rec_is_infimum(page_cur_get_rec(&m_page_cur))); |
| 4974 | return false; |
| 4975 | } |
| 4976 | |
| 4977 | /** @return true if right border should be counted */ |
| 4978 | bool should_count_the_right_bordercxx . . $ btr_est_cur_t#should_count_the_right_border(50ce9a9e25b4a850).() const |
| 4979 | { |
| 4980 | if (dtuple_get_n_fieldscxx . . $ dtuple_get_n_fields(3106ade7d958747e).(&m_tuplecxx . . $ btr_est_cur_t#m_tuple.) > 0) |
| 4981 | { |
| 4982 | const rec_tcxx . . $ rec_t# *rec= page_cur_get_reccxx . . $ `storage/innobase/include/page0cur.h:57:10`!(&m_page_cur); |
| 4983 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!(m_mode == PAGE_CUR_L && page_rec_is_supremum(rec))); |
| 4984 | |
| 4985 | return (m_modecxx . . $ btr_est_cur_t#m_mode. == PAGE_CUR_LEcxx . . $ PAGE_CUR_LE. /* if the range is '<=' */ |
| 4986 | /* and the record was found */ |
| 4987 | && m_low_matchcxx . . $ btr_est_cur_t#m_low_match. >= dtuple_get_n_fieldscxx . . $ dtuple_get_n_fields(3106ade7d958747e).(&m_tuplecxx . . $ btr_est_cur_t#m_tuple.)) || |
| 4988 | (m_modecxx . . $ btr_est_cur_t#m_mode. == PAGE_CUR_Lcxx . . $ PAGE_CUR_L. /* or if the range is '<' */ |
| 4989 | /* and there are any records to match the criteria, i.e. if the |
| 4990 | minimum record on the tree is 5 and x < 7 is specified then the |
| 4991 | cursor will be positioned at 5 and we should count the border, |
| 4992 | but if x < 2 is specified, then the cursor will be positioned at |
| 4993 | 'inf' and we should not count the border */ |
| 4994 | && !page_rec_is_infimumcxx . . $ page_rec_is_infimum(190063cf6fb4afb1).(rec)); |
| 4995 | /* Notice that for "WHERE col <= 'foo'" the server passes to |
| 4996 | ha_innobase::records_in_range(): min_key=NULL (left-unbounded) which is |
| 4997 | expected max_key='foo' flag=HA_READ_AFTER_KEY (PAGE_CUR_G), which is |
| 4998 | unexpected - one would expect flag=HA_READ_KEY_OR_PREV (PAGE_CUR_LE). In |
| 4999 | this case the cursor will be positioned on the first record to the right |
| 5000 | of the requested one (can also be positioned on the 'sup') and we should |
| 5001 | not count the right border. */ |
| 5002 | } |
| 5003 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(page_rec_is_supremum(page_cur_get_rec(&m_page_cur))); |
| 5004 | |
| 5005 | /* The range specified is without a right border, just 'x > 123' |
| 5006 | or 'x >= 123' and search_on_page() positioned the cursor on the |
| 5007 | supremum record on the rightmost page, which must not be counted. */ |
| 5008 | return false; |
| 5009 | } |
| 5010 | |
| 5011 | /** @return index */ |
| 5012 | const dict_index_tcxx . . $ dict_index_t# *indexcxx . . $ btr_est_cur_t#index(2cd16ccfe5c0b43a).() const { return m_page_curcxx . . $ btr_est_cur_t#m_page_cur..indexcxx . . $ page_cur_t#index.; } |
| 5013 | |
| 5014 | /** @return current block */ |
| 5015 | const buf_block_tcxx . . $ buf_block_t# *blockcxx . . $ btr_est_cur_t#block(c285edb5a15fa64f).() const { return m_blockcxx . . $ btr_est_cur_t#m_block.; } |
| 5016 | |
| 5017 | /** @return current page id */ |
| 5018 | page_id_tcxx . . $ page_id_t# page_idcxx . . $ btr_est_cur_t#page_id(bf57bd4462354dd6).() const { return m_page_idcxx . . $ btr_est_cur_t#m_page_id.; } |
| 5019 | |
| 5020 | /** Copies block pointer and savepoint from another btr_est_cur_t in the case |
| 5021 | if both left and right border cursors point to the same block. |
| 5022 | @param o reference to the other btr_est_cur_t object. */ |
| 5023 | void set_blockcxx . . $ btr_est_cur_t#set_block(c0a6df1f9c4660d3).(const btr_est_cur_tcxx . . $ btr_est_cur_t# &o) { m_blockcxx . . $ btr_est_cur_t#m_block.= o.m_blockcxx . . $ btr_est_cur_t#m_block.; } |
| 5024 | |
| 5025 | /** @return current record number. */ |
| 5026 | ulintcxx . . $ ulint# nth_reccxx . . $ btr_est_cur_t#nth_rec(fe4d2d262d4164a8).() const { return m_nth_reccxx . . $ btr_est_cur_t#m_nth_rec.; } |
| 5027 | |
| 5028 | /** @return number of records in the current page. */ |
| 5029 | ulintcxx . . $ ulint# n_recscxx . . $ btr_est_cur_t#n_recs(fe4d2d262d4164a8).() const { return m_n_recscxx . . $ btr_est_cur_t#m_n_recs.; } |
| 5030 | }; |
| 5031 | |
| 5032 | /** Estimate the number of rows between the left record of the path and the |
| 5033 | right one(non-inclusive) for the certain level on a B-tree. This function |
| 5034 | starts from the page next to the left page and reads a few pages to the right, |
| 5035 | counting their records. If we reach the right page quickly then we know exactly |
| 5036 | how many records there are between left and right records and we set |
| 5037 | is_n_rows_exact to true. After some page is latched, the previous page is |
| 5038 | unlatched. If we cannot reach the right page quickly then we calculate the |
| 5039 | average number of records in the pages scanned so far and assume that all pages |
| 5040 | that we did not scan up to the right page contain the same number of records, |
| 5041 | then we multiply that average to the number of pages between right and left |
| 5042 | records (which is n_rows_on_prev_level). In this case we set is_n_rows_exact to |
| 5043 | false. |
| 5044 | @param level current level. |
| 5045 | @param left_cur the cursor of the left page. |
| 5046 | @param right_page_no right page number. |
| 5047 | @param n_rows_on_prev_level number of rows on the previous level. |
| 5048 | @param[out] is_n_rows_exact true if exact rows number is returned. |
| 5049 | @param[in,out] mtr mtr, |
| 5050 | @return number of rows, not including the borders (exact or estimated). */ |
| 5051 | static ha_rowscxx . . $ ha_rows# btr_estimate_n_rows_in_range_on_levelcxx . . $ btr_estimate_n_rows_in_range_on_level(30bd8256ad012b66).( |
| 5052 | ulintcxx . . $ ulint# level, btr_est_cur_tcxx . . $ btr_est_cur_t# &left_cur, uint32_tcxx . . $ uint32_t# right_page_no, |
| 5053 | ha_rowscxx . . $ ha_rows# n_rows_on_prev_level, bool &is_n_rows_exact, mtr_tcxx . . $ mtr_t# &mtr) |
| 5054 | { |
| 5055 | ha_rowscxx . . $ ha_rows# n_rows= 0; |
| 5056 | uint n_pages_read= 0; |
| 5057 | /* Do not read more than this number of pages in order not to hurt |
| 5058 | performance with this code which is just an estimation. If we read this many |
| 5059 | pages before reaching right_page_no, then we estimate the average from the |
| 5060 | pages scanned so far. */ |
| 5061 | static constexpr uint n_pages_read_limit= 9; |
| 5062 | buf_block_tcxx . . $ buf_block_t# *block= nullptr; |
| 5063 | const dict_index_tcxx . . $ dict_index_t# *index= left_cur.indexcxx . . $ btr_est_cur_t#index(2cd16ccfe5c0b43a).(); |
| 5064 | |
| 5065 | /* Assume by default that we will scan all pages between left and right(non |
| 5066 | inclusive) pages */ |
| 5067 | is_n_rows_exact= true; |
| 5068 | |
| 5069 | /* Add records from the left page which are to the right of the record which |
| 5070 | serves as a left border of the range, if any (we don't include the record |
| 5071 | itself in this count). */ |
| 5072 | if (left_cur.nth_reccxx . . $ btr_est_cur_t#nth_rec(fe4d2d262d4164a8).() <= left_cur.n_recscxx . . $ btr_est_cur_t#n_recs(fe4d2d262d4164a8).()) |
| 5073 | { |
| 5074 | n_rows+= left_cur.n_recscxx . . $ btr_est_cur_t#n_recs(fe4d2d262d4164a8).() - left_cur.nth_reccxx . . $ btr_est_cur_t#nth_rec(fe4d2d262d4164a8).(); |
| 5075 | } |
| 5076 | |
| 5077 | /* Count the records in the pages between left and right (non inclusive) |
| 5078 | pages */ |
| 5079 | |
| 5080 | const fil_space_tcxx . . $ fil_space_t# *space= index->tablecxx . . $ dict_index_t#table.->spacecxx . . $ dict_table_t#space.; |
| 5081 | page_id_tcxx . . $ page_id_t# page_idcxx . . $ page_id_t#page_id_t(b4d55b1286ff73e8).(space->idcxx . . $ fil_space_t#id., |
| 5082 | btr_page_get_nextcxx . . $ btr_page_get_next(ca1608e2c87725e2).(buf_block_get_framecxx . . $ `storage/innobase/include/buf0buf.h:385:9`!(left_cur.block()))); |
| 5083 | |
| 5084 | if (page_id.page_nocxx . . $ page_id_t#page_no(d22c8608b6eae7b5).() == FIL_NULLcxx . . $ `storage/innobase/include/fil0fil.h:1175:9`!) |
| 5085 | goto inexact; |
| 5086 | |
| 5087 | do |
| 5088 | { |
| 5089 | page_tcxx . . $ `storage/innobase/include/page0types.h:38:9`! *page; |
| 5090 | buf_block_tcxx . . $ buf_block_t# *prev_block= block; |
| 5091 | |
| 5092 | /* Fetch the page. */ |
| 5093 | block= btr_block_getcxx . . $ btr_block_get(fa2ba45a54fcd0c4).(*index, page_id.page_nocxx . . $ page_id_t#page_no(d22c8608b6eae7b5).(), RW_S_LATCHcxx . . $ RW_S_LATCH., &mtr, nullptr); |
| 5094 | |
| 5095 | if (prev_block) |
| 5096 | { |
| 5097 | ulintcxx . . $ ulint# savepoint = mtr.get_savepointcxx . . $ mtr_t#get_savepoint(fe4d2d262d4164a8).(); |
| 5098 | /* Index s-lock, p1, p2 latches, can also be p1 and p2 parent latch if |
| 5099 | they are not diverged */ |
| 5100 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(savepoint >= 3); |
| 5101 | mtr.rollback_to_savepointcxx . . $ mtr_t#rollback_to_savepoint(6714b5f2551eea49).(savepoint - 2, savepoint - 1); |
| 5102 | } |
| 5103 | |
| 5104 | if (!block || btr_page_get_levelcxx . . $ btr_page_get_level(469dcb4e54b221a8).(buf_block_get_framecxx . . $ `storage/innobase/include/buf0buf.h:385:9`!(block)) != level) |
| 5105 | goto inexact; |
| 5106 | |
| 5107 | page= buf_block_get_framecxx . . $ `storage/innobase/include/buf0buf.h:385:9`!(block); |
| 5108 | |
| 5109 | /* It is possible but highly unlikely that the page was originally written |
| 5110 | by an old version of InnoDB that did not initialize FIL_PAGE_TYPE on other |
| 5111 | than B-tree pages. For example, this could be an almost-empty BLOB page |
| 5112 | that happens to contain the magic values in the fields |
| 5113 | that we checked above. */ |
| 5114 | |
| 5115 | n_pages_read++; |
| 5116 | |
| 5117 | n_rows+= page_get_n_recscxx . . $ page_get_n_recs(469dcb4e54b221a8).(page); |
| 5118 | |
| 5119 | page_id.set_page_nocxx . . $ page_id_t#set_page_no(6bab9b75950d6f3).(btr_page_get_nextcxx . . $ btr_page_get_next(ca1608e2c87725e2).(page)); |
| 5120 | |
| 5121 | if (n_pages_read == n_pages_read_limit) |
| 5122 | { |
| 5123 | /* We read too many pages or we reached the end of the level |
| 5124 | without passing through right_page_no. */ |
| 5125 | goto inexact; |
| 5126 | } |
| 5127 | |
| 5128 | } while (page_id.page_nocxx . . $ page_id_t#page_no(d22c8608b6eae7b5).() != right_page_no); |
| 5129 | |
| 5130 | if (block) |
| 5131 | { |
| 5132 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(block == mtr.at_savepoint(mtr.get_savepoint() - 1)); |
| 5133 | mtr.rollback_to_savepointcxx . . $ mtr_t#rollback_to_savepoint(2c44cd906ae4e829).(mtr.get_savepointcxx . . $ mtr_t#get_savepoint(fe4d2d262d4164a8).() - 1); |
| 5134 | } |
| 5135 | |
| 5136 | return (n_rows); |
| 5137 | |
| 5138 | inexact: |
| 5139 | |
| 5140 | if (block) |
| 5141 | { |
| 5142 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(block == mtr.at_savepoint(mtr.get_savepoint() - 1)); |
| 5143 | mtr.rollback_to_savepointcxx . . $ mtr_t#rollback_to_savepoint(2c44cd906ae4e829).(mtr.get_savepointcxx . . $ mtr_t#get_savepoint(fe4d2d262d4164a8).() - 1); |
| 5144 | } |
| 5145 | |
| 5146 | is_n_rows_exact= false; |
| 5147 | |
| 5148 | /* We did interrupt before reaching right page */ |
| 5149 | |
| 5150 | if (n_pages_read > 0) |
| 5151 | { |
| 5152 | /* The number of pages on this level is |
| 5153 | n_rows_on_prev_level, multiply it by the |
| 5154 | average number of recs per page so far */ |
| 5155 | n_rows= n_rows_on_prev_level * n_rows / n_pages_read; |
| 5156 | } |
| 5157 | else |
| 5158 | { |
| 5159 | n_rows= 10; |
| 5160 | } |
| 5161 | |
| 5162 | return (n_rows); |
| 5163 | } |
| 5164 | |
| 5165 | /** Estimates the number of rows in a given index range. Do search in the |
| 5166 | left page, then if there are pages between left and right ones, read a few |
| 5167 | pages to the right, if the right page is reached, fetch it and count the exact |
| 5168 | number of rows, otherwise count the estimated(see |
| 5169 | btr_estimate_n_rows_in_range_on_level() for details) number if rows, and |
| 5170 | fetch the right page. If leaves are reached, unlatch non-leaf pages except |
| 5171 | the right leaf parent. After the right leaf page is fetched, commit mtr. |
| 5172 | @param trx transaction |
| 5173 | @param index B-tree |
| 5174 | @param range_start first key |
| 5175 | @param range_end last key |
| 5176 | @return estimated number of rows; */ |
| 5177 | ha_rowscxx . . $ ha_rows# btr_estimate_n_rows_in_rangecxx . . $ btr_estimate_n_rows_in_range(b04eafb1a47924cb).(trx_tcxx . . $ trx_t# *trx, dict_index_tcxx . . $ dict_index_t# *index, |
| 5178 | btr_pos_tcxx . . $ btr_pos_t# *range_start, |
| 5179 | btr_pos_tcxx . . $ btr_pos_t# *range_end) |
| 5180 | { |
| 5181 | DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("btr_estimate_n_rows_in_range"); |
| 5182 | |
| 5183 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(index->page == FIL_NULLcxx . . $ `storage/innobase/include/fil0fil.h:1175:9`! || index->is_corrupted())) |
| 5184 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(0); |
| 5185 | |
| 5186 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(index->is_btree()); |
| 5187 | |
| 5188 | mtr_tcxx . . $ mtr_t# mtrcxx . . $ mtr_t#mtr_t(a6968fd0d8f26912).{trx}; |
| 5189 | btr_est_cur_tcxx . . $ btr_est_cur_t# p1cxx . . $ btr_est_cur_t#btr_est_cur_t(a7241808cc5497e4).(index, *range_start->tuplecxx . . $ btr_pos_t#tuple., range_start->modecxx . . $ btr_pos_t#mode.); |
| 5190 | btr_est_cur_tcxx . . $ btr_est_cur_t# p2cxx . . $ btr_est_cur_t#btr_est_cur_t(a7241808cc5497e4).(index, *range_end->tuplecxx . . $ btr_pos_t#tuple., range_end->modecxx . . $ btr_pos_t#mode.); |
| 5191 | |
| 5192 | ulintcxx . . $ ulint# height; |
| 5193 | ulintcxx . . $ ulint# root_height= 0; /* remove warning */ |
| 5194 | |
| 5195 | mem_heap_tcxx . . $ mem_heap_t# *heap= NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 5196 | rec_offscxx . . $ rec_offs# offsets_[REC_OFFS_NORMAL_SIZEcxx . . $ REC_OFFS_NORMAL_SIZE.]; |
| 5197 | rec_offscxx . . $ rec_offs# *offsets= offsets_; |
| 5198 | rec_offs_initcxx . . $ `storage/innobase/include/rem0rec.h:844:9`!(offsets_); |
| 5199 | |
| 5200 | mtr.startcxx . . $ mtr_t#start(49f6e7a06ebc5aa8).(); |
| 5201 | |
| 5202 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mtr.get_savepoint() == 0); |
| 5203 | mtr_s_lock_indexcxx . . $ `storage/innobase/include/mtr0mtr.h:45:10`!(index, &mtr); |
| 5204 | |
| 5205 | ha_rowscxx . . $ ha_rows# table_n_rows= dict_table_get_n_rowscxx . . $ dict_table_get_n_rows(8b7f25d2756988c8).(index->tablecxx . . $ dict_index_t#table.); |
| 5206 | |
| 5207 | height= ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!; |
| 5208 | |
| 5209 | /* This becomes true when the two paths do not pass through the same pages |
| 5210 | anymore. */ |
| 5211 | bool diverged= false; |
| 5212 | /* This is the height, i.e. the number of levels from the root, where paths |
| 5213 | are not the same or adjacent any more. */ |
| 5214 | ulintcxx . . $ ulint# divergence_height= ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!; |
| 5215 | bool should_count_the_left_border= true; |
| 5216 | bool should_count_the_right_border= true; |
| 5217 | bool is_n_rows_exact= true; |
| 5218 | ha_rowscxx . . $ ha_rows# n_rows= 0; |
| 5219 | |
| 5220 | /* Loop and search until we arrive at the desired level. */ |
| 5221 | search_loop: |
| 5222 | if (!p1.fetch_childcxx . . $ btr_est_cur_t#fetch_child(c1df0f5eb492ca26).(height, mtr, p2.blockcxx . . $ btr_est_cur_t#block(c285edb5a15fa64f).())) |
| 5223 | goto error; |
| 5224 | |
| 5225 | if (height == ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!) |
| 5226 | { |
| 5227 | /* We are in the root node */ |
| 5228 | height= btr_page_get_levelcxx . . $ btr_page_get_level(469dcb4e54b221a8).(buf_block_get_framecxx . . $ `storage/innobase/include/buf0buf.h:385:9`!(p1.block())); |
| 5229 | root_height= height; |
| 5230 | } |
| 5231 | |
| 5232 | if (!height) |
| 5233 | { |
| 5234 | p1.set_page_mode_for_leavescxx . . $ btr_est_cur_t#set_page_mode_for_leaves(49f6e7a06ebc5aa8).(); |
| 5235 | p2.set_page_mode_for_leavescxx . . $ btr_est_cur_t#set_page_mode_for_leaves(49f6e7a06ebc5aa8).(); |
| 5236 | } |
| 5237 | |
| 5238 | if (p1.page_idcxx . . $ btr_est_cur_t#page_id(bf57bd4462354dd6).() ==cxx . . $ page_id_t#`operator==`(d789d526a826a185). p2.page_idcxx . . $ btr_est_cur_t#page_id(bf57bd4462354dd6).()) |
| 5239 | p2.set_blockcxx . . $ btr_est_cur_t#set_block(c0a6df1f9c4660d3).(p1); |
| 5240 | else |
| 5241 | { |
| 5242 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(diverged); |
| 5243 | if (divergence_height != ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!) { |
| 5244 | /* We need to call p1.search_on_page() here as |
| 5245 | btr_estimate_n_rows_in_range_on_level() uses p1.m_n_recs and |
| 5246 | p1.m_nth_rec. */ |
| 5247 | if (!p1.search_on_pagecxx . . $ btr_est_cur_t#search_on_page(4af46f8da2c629f3).(height, root_height, true)) |
| 5248 | goto error; |
| 5249 | n_rows= btr_estimate_n_rows_in_range_on_levelcxx . . $ btr_estimate_n_rows_in_range_on_level(30bd8256ad012b66).( |
| 5250 | height, p1, p2.page_idcxx . . $ btr_est_cur_t#page_id(bf57bd4462354dd6).().page_nocxx . . $ page_id_t#page_no(d22c8608b6eae7b5).(), n_rows, is_n_rows_exact, mtr); |
| 5251 | } |
| 5252 | if (!p2.fetch_childcxx . . $ btr_est_cur_t#fetch_child(c1df0f5eb492ca26).(height, mtr, nullptr)) |
| 5253 | goto error; |
| 5254 | } |
| 5255 | |
| 5256 | if (height == 0) |
| 5257 | /* There is no need to release non-leaf pages here as they must already be |
| 5258 | unlatched in btr_est_cur_t::fetch_child(). Try to search on pages after |
| 5259 | releasing the index latch, to decrease contention. */ |
| 5260 | mtr.rollback_to_savepointcxx . . $ mtr_t#rollback_to_savepoint(6714b5f2551eea49).(0, 1); |
| 5261 | |
| 5262 | /* There is no need to search on left page if |
| 5263 | divergence_height != ULINT_UNDEFINED, as it was already searched before |
| 5264 | btr_estimate_n_rows_in_range_on_level() call */ |
| 5265 | if (divergence_height == ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`! && |
| 5266 | !p1.search_on_pagecxx . . $ btr_est_cur_t#search_on_page(4af46f8da2c629f3).(height, root_height, true)) |
| 5267 | goto error; |
| 5268 | |
| 5269 | if (!p2.search_on_pagecxx . . $ btr_est_cur_t#search_on_page(4af46f8da2c629f3).(height, root_height, false)) |
| 5270 | goto error; |
| 5271 | |
| 5272 | if (!diverged && (p1.nth_reccxx . . $ btr_est_cur_t#nth_rec(fe4d2d262d4164a8).() != p2.nth_reccxx . . $ btr_est_cur_t#nth_rec(fe4d2d262d4164a8).())) |
| 5273 | { |
| 5274 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(p1.page_id() == p2.page_id()); |
| 5275 | diverged= true; |
| 5276 | if (p1.nth_reccxx . . $ btr_est_cur_t#nth_rec(fe4d2d262d4164a8).() < p2.nth_reccxx . . $ btr_est_cur_t#nth_rec(fe4d2d262d4164a8).()) |
| 5277 | { |
| 5278 | /* We do not count the borders (nor the left nor the right one), thus |
| 5279 | "- 1". */ |
| 5280 | n_rows= p2.nth_reccxx . . $ btr_est_cur_t#nth_rec(fe4d2d262d4164a8).() - p1.nth_reccxx . . $ btr_est_cur_t#nth_rec(fe4d2d262d4164a8).() - 1; |
| 5281 | |
| 5282 | if (n_rows > 0) |
| 5283 | { |
| 5284 | /* There is at least one row between the two borders pointed to by p1 |
| 5285 | and p2, so on the level below the slots will point to non-adjacent |
| 5286 | pages. */ |
| 5287 | divergence_height= root_height - height; |
| 5288 | } |
| 5289 | } |
| 5290 | else |
| 5291 | { |
| 5292 | /* It is possible that p1->nth_rec > p2->nth_rec if, for example, we have |
| 5293 | a single page tree which contains (inf, 5, 6, supr) and we select where x |
| 5294 | > 20 and x < 30; in this case p1->nth_rec will point to the supr record |
| 5295 | and p2->nth_rec will point to 6. */ |
| 5296 | n_rows= 0; |
| 5297 | should_count_the_left_border= false; |
| 5298 | should_count_the_right_border= false; |
| 5299 | } |
| 5300 | } |
| 5301 | else if (diverged && divergence_height == ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!) |
| 5302 | { |
| 5303 | |
| 5304 | if (p1.nth_reccxx . . $ btr_est_cur_t#nth_rec(fe4d2d262d4164a8).() < p1.n_recscxx . . $ btr_est_cur_t#n_recs(fe4d2d262d4164a8).() || p2.nth_reccxx . . $ btr_est_cur_t#nth_rec(fe4d2d262d4164a8).() > 1) |
| 5305 | { |
| 5306 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(p1.page_id() != p2.page_id()); |
| 5307 | divergence_height= root_height - height; |
| 5308 | |
| 5309 | n_rows= 0; |
| 5310 | |
| 5311 | if (p1.nth_reccxx . . $ btr_est_cur_t#nth_rec(fe4d2d262d4164a8).() < p1.n_recscxx . . $ btr_est_cur_t#n_recs(fe4d2d262d4164a8).()) |
| 5312 | { |
| 5313 | n_rows+= p1.n_recscxx . . $ btr_est_cur_t#n_recs(fe4d2d262d4164a8).() - p1.nth_reccxx . . $ btr_est_cur_t#nth_rec(fe4d2d262d4164a8).(); |
| 5314 | } |
| 5315 | |
| 5316 | if (p2.nth_reccxx . . $ btr_est_cur_t#nth_rec(fe4d2d262d4164a8).() > 1) |
| 5317 | { |
| 5318 | n_rows+= p2.nth_reccxx . . $ btr_est_cur_t#nth_rec(fe4d2d262d4164a8).() - 1; |
| 5319 | } |
| 5320 | } |
| 5321 | } |
| 5322 | else if (divergence_height != ULINT_UNDEFINEDcxx . . $ `storage/innobase/include/univ.i:329:9`!) |
| 5323 | { |
| 5324 | /* All records before the right page was already counted. Add records from |
| 5325 | p2->page_no which are to the left of the record which servers as a right |
| 5326 | border of the range, if any (we don't include the record itself in this |
| 5327 | count). */ |
| 5328 | if (p2.nth_reccxx . . $ btr_est_cur_t#nth_rec(fe4d2d262d4164a8).() > 1) |
| 5329 | n_rows+= p2.nth_reccxx . . $ btr_est_cur_t#nth_rec(fe4d2d262d4164a8).() - 1; |
| 5330 | } |
| 5331 | |
| 5332 | if (height) |
| 5333 | { |
| 5334 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(height > 0); |
| 5335 | height--; |
| 5336 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mtr.memo_contains(p1.index()->lock, MTR_MEMO_S_LOCK)); |
| 5337 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mtr.memo_contains_flagged(p1.block(), MTR_MEMO_PAGE_S_FIX)); |
| 5338 | p1.read_child_page_idcxx . . $ btr_est_cur_t#read_child_page_id(667519cbefc2e584).(&offsets, &heap); |
| 5339 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mtr.memo_contains(p2.index()->lock, MTR_MEMO_S_LOCK)); |
| 5340 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mtr.memo_contains_flagged(p2.block(), MTR_MEMO_PAGE_S_FIX)); |
| 5341 | p2.read_child_page_idcxx . . $ btr_est_cur_t#read_child_page_id(667519cbefc2e584).(&offsets, &heap); |
| 5342 | goto search_loop; |
| 5343 | } |
| 5344 | |
| 5345 | should_count_the_left_border= |
| 5346 | should_count_the_left_border && p1.should_count_the_left_bordercxx . . $ btr_est_cur_t#should_count_the_left_border(50ce9a9e25b4a850).(); |
| 5347 | should_count_the_right_border= |
| 5348 | should_count_the_right_border && p2.should_count_the_right_bordercxx . . $ btr_est_cur_t#should_count_the_right_border(50ce9a9e25b4a850).(); |
| 5349 | |
| 5350 | mtr.commitcxx . . $ mtr_t#commit(49f6e7a06ebc5aa8).(); |
| 5351 | if (UNIV_LIKELY_NULLcxx . . $ `storage/innobase/include/univ.i:393:10`!(heap)) |
| 5352 | mem_heap_freecxx . . $ mem_heap_free(5231cf397463bfab).(heap); |
| 5353 | |
| 5354 | |
| 5355 | range_start->page_idcxx . . $ btr_pos_t#page_id.=cxx . . $ page_id_t#`operator=`(c12b003cf52832b6). p1.page_idcxx . . $ btr_est_cur_t#page_id(bf57bd4462354dd6).(); |
| 5356 | range_end->page_idcxx . . $ btr_pos_t#page_id.=cxx . . $ page_id_t#`operator=`(c12b003cf52832b6). p2.page_idcxx . . $ btr_est_cur_t#page_id(bf57bd4462354dd6).(); |
| 5357 | |
| 5358 | /* Here none of the borders were counted. For example, if on the leaf level |
| 5359 | we descended to: |
| 5360 | (inf, a, b, c, d, e, f, sup) |
| 5361 | ^ ^ |
| 5362 | path1 path2 |
| 5363 | then n_rows will be 2 (c and d). */ |
| 5364 | |
| 5365 | if (is_n_rows_exact) |
| 5366 | { |
| 5367 | /* Only fiddle to adjust this off-by-one if the number is exact, otherwise |
| 5368 | we do much grosser adjustments below. */ |
| 5369 | |
| 5370 | /* If both paths end up on the same record on the leaf level. */ |
| 5371 | if (p1.page_idcxx . . $ btr_est_cur_t#page_id(bf57bd4462354dd6).() ==cxx . . $ page_id_t#`operator==`(d789d526a826a185). p2.page_idcxx . . $ btr_est_cur_t#page_id(bf57bd4462354dd6).() && p1.nth_reccxx . . $ btr_est_cur_t#nth_rec(fe4d2d262d4164a8).() == p2.nth_reccxx . . $ btr_est_cur_t#nth_rec(fe4d2d262d4164a8).()) |
| 5372 | { |
| 5373 | |
| 5374 | /* n_rows can be > 0 here if the paths were first different and then |
| 5375 | converged to the same record on the leaf level. |
| 5376 | For example: |
| 5377 | SELECT ... LIKE 'wait/synch/rwlock%' |
| 5378 | mode1=PAGE_CUR_GE, |
| 5379 | tuple1="wait/synch/rwlock" |
| 5380 | path1[0]={nth_rec=58, n_recs=58, |
| 5381 | page_no=3, page_level=1} |
| 5382 | path1[1]={nth_rec=56, n_recs=55, |
| 5383 | page_no=119, page_level=0} |
| 5384 | |
| 5385 | mode2=PAGE_CUR_G |
| 5386 | tuple2="wait/synch/rwlock" |
| 5387 | path2[0]={nth_rec=57, n_recs=57, |
| 5388 | page_no=3, page_level=1} |
| 5389 | path2[1]={nth_rec=56, n_recs=55, |
| 5390 | page_no=119, page_level=0} */ |
| 5391 | |
| 5392 | /* If the range is such that we should count both borders, then avoid |
| 5393 | counting that record twice - once as a left border and once as a right |
| 5394 | border. Some of the borders should not be counted, e.g. [3,3). */ |
| 5395 | n_rows= should_count_the_left_border && should_count_the_right_border; |
| 5396 | } |
| 5397 | else |
| 5398 | n_rows+= should_count_the_left_border + should_count_the_right_border; |
| 5399 | } |
| 5400 | |
| 5401 | if (root_height > divergence_height && !is_n_rows_exact) |
| 5402 | /* In trees whose height is > 1 our algorithm tends to underestimate: |
| 5403 | multiply the estimate by 2: */ |
| 5404 | n_rows*= 2; |
| 5405 | |
| 5406 | DBUG_EXECUTE_IFcxx . . $ `include/my_dbug.h:172:9`!("bug14007649", DBUG_RETURN(n_rows);); |
| 5407 | |
| 5408 | #ifdef NOT_USED |
| 5409 | /* Do not estimate the number of rows in the range to over 1 / 2 of the |
| 5410 | estimated rows in the whole table */ |
| 5411 | |
| 5412 | if (n_rows > table_n_rows / 2 && !is_n_rows_exact) |
| 5413 | { |
| 5414 | |
| 5415 | n_rows= table_n_rows / 2; |
| 5416 | |
| 5417 | /* If there are just 0 or 1 rows in the table, then we estimate all rows |
| 5418 | are in the range */ |
| 5419 | |
| 5420 | if (n_rows == 0) |
| 5421 | n_rows= table_n_rows; |
| 5422 | } |
| 5423 | #else |
| 5424 | if (n_rows > table_n_rows) |
| 5425 | n_rows= table_n_rows; |
| 5426 | #endif |
| 5427 | |
| 5428 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(n_rows); |
| 5429 | |
| 5430 | error: |
| 5431 | mtr.commitcxx . . $ mtr_t#commit(49f6e7a06ebc5aa8).(); |
| 5432 | if (UNIV_LIKELY_NULLcxx . . $ `storage/innobase/include/univ.i:393:10`!(heap)) |
| 5433 | mem_heap_freecxx . . $ mem_heap_free(5231cf397463bfab).(heap); |
| 5434 | |
| 5435 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(0); |
| 5436 | } |
| 5437 | |
| 5438 | /*================== EXTERNAL STORAGE OF BIG FIELDS ===================*/ |
| 5439 | |
| 5440 | /***********************************************************//** |
| 5441 | Gets the offset of the pointer to the externally stored part of a field. |
| 5442 | @return offset of the pointer to the externally stored part */ |
| 5443 | static |
| 5444 | ulintcxx . . $ ulint# |
| 5445 | btr_rec_get_field_ref_offscxx . . $ btr_rec_get_field_ref_offs(878e7dc5509530f1).( |
| 5446 | /*=======================*/ |
| 5447 | const rec_offscxx . . $ rec_offs#* offsets,/*!< in: array returned by rec_get_offsets() */ |
| 5448 | ulintcxx . . $ ulint# n) /*!< in: index of the external field */ |
| 5449 | { |
| 5450 | ulintcxx . . $ ulint# field_ref_offs; |
| 5451 | ulintcxx . . $ ulint# local_len; |
| 5452 | |
| 5453 | ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(rec_offs_nth_extern(offsets, n)); |
| 5454 | field_ref_offs = rec_get_nth_field_offscxx . . $ rec_get_nth_field_offs(70b61031fb25acea).(offsets, n, &local_len); |
| 5455 | ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(len_is_storedcxx . . $ `storage/innobase/include/data0type.h:34:9`!(local_len)); |
| 5456 | ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(local_len >= BTR_EXTERN_FIELD_REF_SIZEcxx . . $ `storage/innobase/include/btr0types.h:41:9`!); |
| 5457 | |
| 5458 | return(field_ref_offs + local_len - BTR_EXTERN_FIELD_REF_SIZEcxx . . $ `storage/innobase/include/btr0types.h:41:9`!); |
| 5459 | } |
| 5460 | |
| 5461 | /** Gets a pointer to the externally stored part of a field. |
| 5462 | @param rec record |
| 5463 | @param offsets rec_get_offsets(rec) |
| 5464 | @param n index of the externally stored field |
| 5465 | @return pointer to the externally stored part */ |
| 5466 | #define btr_rec_get_field_refcxx . . $ `storage/innobase/btr/btr0cur.cc:5466:9`!(rec, offsets, n) \ |
| 5467 | ((rec) + btr_rec_get_field_ref_offs(offsets, n)) |
| 5468 | |
| 5469 | /** Gets the externally stored size of a record, in units of a database page. |
| 5470 | @param[in] rec record |
| 5471 | @param[in] offsets array returned by rec_get_offsets() |
| 5472 | @return externally stored part, in units of a database page */ |
| 5473 | ulintcxx . . $ ulint# |
| 5474 | btr_rec_get_externally_stored_lencxx . . $ btr_rec_get_externally_stored_len(5a6c2a4dffbff345).( |
| 5475 | const rec_tcxx . . $ rec_t#* rec, |
| 5476 | const rec_offscxx . . $ rec_offs#* offsets) |
| 5477 | { |
| 5478 | ulintcxx . . $ ulint# n_fields; |
| 5479 | ulintcxx . . $ ulint# total_extern_len = 0; |
| 5480 | ulintcxx . . $ ulint# i; |
| 5481 | |
| 5482 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!rec_offs_comp(offsets) || !rec_get_node_ptr_flag(rec)); |
| 5483 | |
| 5484 | if (!rec_offs_any_externcxx . . $ rec_offs_any_extern(ca762aca731138fc).(offsets)) { |
| 5485 | return(0); |
| 5486 | } |
| 5487 | |
| 5488 | n_fields = rec_offs_n_fieldscxx . . $ rec_offs_n_fields(6fce5c29061b60f9).(offsets); |
| 5489 | |
| 5490 | for (i = 0; i < n_fields; i++) { |
| 5491 | if (rec_offs_nth_externcxx . . $ rec_offs_nth_extern(878e7dc5509530f1).(offsets, i)) { |
| 5492 | |
| 5493 | ulintcxx . . $ ulint# extern_len = mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).( |
| 5494 | btr_rec_get_field_refcxx . . $ `storage/innobase/btr/btr0cur.cc:5466:9`!(rec, offsets, i) |
| 5495 | + BTR_EXTERN_LENcxx . . $ `storage/innobase/include/btr0cur.h:797:9`! + 4); |
| 5496 | |
| 5497 | total_extern_len += ut_calc_aligncxx . . $ ut_calc_align(f80f7d6260b3ee3a).( |
| 5498 | extern_len, ulintcxx . . $ ulint#(srv_page_sizecxx . . $ srv_page_size.)); |
| 5499 | } |
| 5500 | } |
| 5501 | |
| 5502 | return total_extern_len >> srv_page_size_shiftcxx . . $ srv_page_size_shift.; |
| 5503 | } |
| 5504 | |
| 5505 | /*******************************************************************//** |
| 5506 | Sets the ownership bit of an externally stored field in a record. */ |
| 5507 | static |
| 5508 | void |
| 5509 | btr_cur_set_ownership_of_extern_fieldcxx . . $ btr_cur_set_ownership_of_extern_field(b424d242e4d3c435).( |
| 5510 | /*==================================*/ |
| 5511 | buf_block_tcxx . . $ buf_block_t#* block, /*!< in/out: index page */ |
| 5512 | rec_tcxx . . $ rec_t#* rec, /*!< in/out: clustered index record */ |
| 5513 | dict_index_tcxx . . $ dict_index_t#* index, /*!< in: index of the page */ |
| 5514 | const rec_offscxx . . $ rec_offs#* offsets,/*!< in: array returned by rec_get_offsets() */ |
| 5515 | ulintcxx . . $ ulint# i, /*!< in: field number */ |
| 5516 | bool val, /*!< in: value to set */ |
| 5517 | mtr_tcxx . . $ mtr_t#* mtr) /*!< in: mtr, or NULL if not logged */ |
| 5518 | { |
| 5519 | bytecxx . . $ byte#* data; |
| 5520 | ulintcxx . . $ ulint# local_len; |
| 5521 | ulintcxx . . $ ulint# byte_val; |
| 5522 | |
| 5523 | data = rec_get_nth_fieldcxx . . $ `storage/innobase/include/rem0rec.h:562:9`!(rec, offsets, i, &local_len); |
| 5524 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rec_offs_nth_extern(offsets, i)); |
| 5525 | ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(local_len >= BTR_EXTERN_FIELD_REF_SIZEcxx . . $ `storage/innobase/include/btr0types.h:41:9`!); |
| 5526 | |
| 5527 | local_len -= BTR_EXTERN_FIELD_REF_SIZEcxx . . $ `storage/innobase/include/btr0types.h:41:9`!; |
| 5528 | |
| 5529 | byte_val = mach_read_from_1cxx . . $ mach_read_from_1(f3688bc2ee54ea05).(data + local_len + BTR_EXTERN_LENcxx . . $ `storage/innobase/include/btr0cur.h:797:9`!); |
| 5530 | |
| 5531 | if (val) { |
| 5532 | byte_val &= ~BTR_EXTERN_OWNER_FLAGcxx . . $ `storage/innobase/include/btr0cur.h:809:9`!; |
| 5533 | } else { |
| 5534 | #if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG |
| 5535 | ut_a(!(byte_val & BTR_EXTERN_OWNER_FLAG)); |
| 5536 | #endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */ |
| 5537 | byte_val |= BTR_EXTERN_OWNER_FLAGcxx . . $ `storage/innobase/include/btr0cur.h:809:9`!; |
| 5538 | } |
| 5539 | |
| 5540 | if (UNIV_LIKELY_NULLcxx . . $ `storage/innobase/include/univ.i:393:10`!(block->page.zip.data)) { |
| 5541 | mach_write_to_1cxx . . $ mach_write_to_1(6165b45f45ef689c).(data + local_len + BTR_EXTERN_LENcxx . . $ `storage/innobase/include/btr0cur.h:797:9`!, byte_val); |
| 5542 | page_zip_write_blob_ptrcxx . . $ page_zip_write_blob_ptr(a51fb08fa125d8c1).(block, rec, index, offsets, i, mtr); |
| 5543 | } else { |
| 5544 | mtr->writecxx . . $ mtr_t#write(4888ddbfa94c5eeb).<1,mtr_tcxx . . $ mtr_t#::MAYBE_NOPcxx . . $ mtr_t#MAYBE_NOP.>(*block, data + local_len |
| 5545 | + BTR_EXTERN_LENcxx . . $ `storage/innobase/include/btr0cur.h:797:9`!, byte_val); |
| 5546 | } |
| 5547 | } |
| 5548 | |
| 5549 | /*******************************************************************//** |
| 5550 | Marks non-updated off-page fields as disowned by this record. The ownership |
| 5551 | must be transferred to the updated record which is inserted elsewhere in the |
| 5552 | index tree. In purge only the owner of externally stored field is allowed |
| 5553 | to free the field. */ |
| 5554 | void |
| 5555 | btr_cur_disown_inherited_fieldscxx . . $ btr_cur_disown_inherited_fields(22c17273502d4844).( |
| 5556 | /*============================*/ |
| 5557 | buf_block_tcxx . . $ buf_block_t#* block, /*!< in/out: index page */ |
| 5558 | rec_tcxx . . $ rec_t#* rec, /*!< in/out: record in a clustered index */ |
| 5559 | dict_index_tcxx . . $ dict_index_t#* index, /*!< in: index of the page */ |
| 5560 | const rec_offscxx . . $ rec_offs#* offsets,/*!< in: array returned by rec_get_offsets() */ |
| 5561 | const upd_tcxx . . $ upd_t#* update, /*!< in: update vector */ |
| 5562 | mtr_tcxx . . $ mtr_t#* mtr) /*!< in/out: mini-transaction */ |
| 5563 | { |
| 5564 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rec_offs_validate(rec, index, offsets)); |
| 5565 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!rec_offs_comp(offsets) || !rec_get_node_ptr_flag(rec)); |
| 5566 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rec_offs_any_extern(offsets)); |
| 5567 | |
| 5568 | for (uint16_tcxx . . $ uint16_t# i = 0; i < rec_offs_n_fieldscxx . . $ rec_offs_n_fields(6fce5c29061b60f9).(offsets); i++) { |
| 5569 | if (rec_offs_nth_externcxx . . $ rec_offs_nth_extern(878e7dc5509530f1).(offsets, i) |
| 5570 | && !upd_get_field_by_field_nocxx . . $ upd_get_field_by_field_no(9753c34970181a9d).(update, i, false)) { |
| 5571 | btr_cur_set_ownership_of_extern_fieldcxx . . $ btr_cur_set_ownership_of_extern_field(b424d242e4d3c435).( |
| 5572 | block, rec, index, offsets, i, false, mtr); |
| 5573 | } |
| 5574 | } |
| 5575 | } |
| 5576 | |
| 5577 | /*******************************************************************//** |
| 5578 | Marks all extern fields in a record as owned by the record. This function |
| 5579 | should be called if the delete mark of a record is removed: a not delete |
| 5580 | marked record always owns all its extern fields. */ |
| 5581 | static |
| 5582 | void |
| 5583 | btr_cur_unmark_extern_fieldscxx . . $ btr_cur_unmark_extern_fields(2a7528bc66954456).( |
| 5584 | /*=========================*/ |
| 5585 | buf_block_tcxx . . $ buf_block_t#* block, /*!< in/out: index page */ |
| 5586 | rec_tcxx . . $ rec_t#* rec, /*!< in/out: record in a clustered index */ |
| 5587 | dict_index_tcxx . . $ dict_index_t#* index, /*!< in: index of the page */ |
| 5588 | const rec_offscxx . . $ rec_offs#* offsets,/*!< in: array returned by rec_get_offsets() */ |
| 5589 | mtr_tcxx . . $ mtr_t#* mtr) /*!< in: mtr, or NULL if not logged */ |
| 5590 | { |
| 5591 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!rec_offs_comp(offsets) || !rec_get_node_ptr_flag(rec)); |
| 5592 | if (!rec_offs_any_externcxx . . $ rec_offs_any_extern(ca762aca731138fc).(offsets)) { |
| 5593 | return; |
| 5594 | } |
| 5595 | |
| 5596 | const ulintcxx . . $ ulint# n = rec_offs_n_fieldscxx . . $ rec_offs_n_fields(6fce5c29061b60f9).(offsets); |
| 5597 | |
| 5598 | for (ulintcxx . . $ ulint# i = 0; i < n; i++) { |
| 5599 | if (rec_offs_nth_externcxx . . $ rec_offs_nth_extern(878e7dc5509530f1).(offsets, i)) { |
| 5600 | btr_cur_set_ownership_of_extern_fieldcxx . . $ btr_cur_set_ownership_of_extern_field(b424d242e4d3c435).( |
| 5601 | block, rec, index, offsets, i, true, mtr); |
| 5602 | } |
| 5603 | } |
| 5604 | } |
| 5605 | |
| 5606 | /*******************************************************************//** |
| 5607 | Returns the length of a BLOB part stored on the header page. |
| 5608 | @return part length */ |
| 5609 | static |
| 5610 | uint32_tcxx . . $ uint32_t# |
| 5611 | btr_blob_get_part_lencxx . . $ btr_blob_get_part_len(ca1608e2c87725e2).( |
| 5612 | /*==================*/ |
| 5613 | const bytecxx . . $ byte#* blob_header) /*!< in: blob header */ |
| 5614 | { |
| 5615 | return(mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(blob_header + BTR_BLOB_HDR_PART_LENcxx . . $ `storage/innobase/btr/btr0cur.cc:117:9`!)); |
| 5616 | } |
| 5617 | |
| 5618 | /*******************************************************************//** |
| 5619 | Returns the page number where the next BLOB part is stored. |
| 5620 | @return page number or FIL_NULL if no more pages */ |
| 5621 | static |
| 5622 | uint32_tcxx . . $ uint32_t# |
| 5623 | btr_blob_get_next_page_nocxx . . $ btr_blob_get_next_page_no(ca1608e2c87725e2).( |
| 5624 | /*======================*/ |
| 5625 | const bytecxx . . $ byte#* blob_header) /*!< in: blob header */ |
| 5626 | { |
| 5627 | return(mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(blob_header + BTR_BLOB_HDR_NEXT_PAGE_NOcxx . . $ `storage/innobase/btr/btr0cur.cc:119:9`!)); |
| 5628 | } |
| 5629 | |
| 5630 | /** Deallocate a buffer block that was reserved for a BLOB part. |
| 5631 | @param block buffer block |
| 5632 | @param all flag whether to remove a ROW_FORMAT=COMPRESSED page |
| 5633 | @param mtr mini-transaction to commit */ |
| 5634 | static void btr_blob_freecxx . . $ btr_blob_free(ef96390c81c5cdc9).(buf_block_tcxx . . $ buf_block_t# *block, bool all, mtr_tcxx . . $ mtr_t# *mtr) |
| 5635 | { |
| 5636 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mtr->memo_contains_flagged(block, MTR_MEMO_PAGE_X_FIX)); |
| 5637 | block->pagecxx . . $ buf_block_t#page..fixcxx . . $ buf_page_t#fix(6e3776fd289463bb).(); |
| 5638 | #ifdef UNIV_DEBUG |
| 5639 | const page_id_t page_id{block->page.id()}; |
| 5640 | buf_pool_t::hash_chain &chain= buf_pool.page_hash.cell_get(page_id.fold()); |
| 5641 | #endif |
| 5642 | mtr->commitcxx . . $ mtr_t#commit(49f6e7a06ebc5aa8).(); |
| 5643 | |
| 5644 | mysql_mutex_lockcxx . . $ `include/mysql/psi/mysql_thread.h:360:11`!(&buf_pool.mutex); |
| 5645 | block->pagecxx . . $ buf_block_t#page..unfixcxx . . $ buf_page_t#unfix(2658d6455debfaef).(); |
| 5646 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(block->page.id() == page_id); |
| 5647 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(&block->page == buf_pool.page_hash.get(page_id, chain)); |
| 5648 | |
| 5649 | if (!buf_LRU_free_pagecxx . . $ buf_LRU_free_page(f635562e56f3996e).(&block->pagecxx . . $ buf_block_t#page., all) && all && block->pagecxx . . $ buf_block_t#page..zipcxx . . $ buf_page_t#zip..datacxx . . $ page_zip_des_t#data.) |
| 5650 | /* Attempt to deallocate the redundant copy of the uncompressed page |
| 5651 | if the whole ROW_FORMAT=COMPRESSED block cannot be deallocted. */ |
| 5652 | buf_LRU_free_pagecxx . . $ buf_LRU_free_page(f635562e56f3996e).(&block->pagecxx . . $ buf_block_t#page., false); |
| 5653 | |
| 5654 | mysql_mutex_unlockcxx . . $ `include/mysql/psi/mysql_thread.h:391:11`!(&buf_pool.mutex); |
| 5655 | } |
| 5656 | |
| 5657 | /** Helper class used while writing blob pages, during insert or update. */ |
| 5658 | struct btr_blob_log_check_tcxx . . $ btr_blob_log_check_t# { |
| 5659 | /** Persistent cursor on a clusterex index record with blobs. */ |
| 5660 | btr_pcur_tcxx . . $ btr_pcur_t#* m_pcurcxx . . $ btr_blob_log_check_t#m_pcur.; |
| 5661 | /** Mini transaction holding the latches for m_pcur */ |
| 5662 | mtr_tcxx . . $ mtr_t#* m_mtrcxx . . $ btr_blob_log_check_t#m_mtr.; |
| 5663 | /** rec_get_offsets(rec, index); offset of clust_rec */ |
| 5664 | const rec_offscxx . . $ rec_offs#* m_offsetscxx . . $ btr_blob_log_check_t#m_offsets.; |
| 5665 | /** The block containing clustered record */ |
| 5666 | buf_block_tcxx . . $ buf_block_t#** m_blockcxx . . $ btr_blob_log_check_t#m_block.; |
| 5667 | /** The clustered record pointer */ |
| 5668 | rec_tcxx . . $ rec_t#** m_reccxx . . $ btr_blob_log_check_t#m_rec.; |
| 5669 | /** The blob operation code */ |
| 5670 | enum blob_opcxx . . $ blob_op# m_opcxx . . $ btr_blob_log_check_t#m_op.; |
| 5671 | |
| 5672 | /** Constructor |
| 5673 | @param[in] pcur persistent cursor on a clustered |
| 5674 | index record with blobs. |
| 5675 | @param[in] mtr mini-transaction holding latches for |
| 5676 | pcur. |
| 5677 | @param[in] offsets offsets of the clust_rec |
| 5678 | @param[in,out] block record block containing pcur record |
| 5679 | @param[in,out] rec the clustered record pointer |
| 5680 | @param[in] op the blob operation code */ |
| 5681 | btr_blob_log_check_tcxx . . $ btr_blob_log_check_t#btr_blob_log_check_t(efd289c5d174bca4).( |
| 5682 | btr_pcur_tcxx . . $ btr_pcur_t#* pcur, |
| 5683 | mtr_tcxx . . $ mtr_t#* mtr, |
| 5684 | const rec_offscxx . . $ rec_offs#* offsets, |
| 5685 | buf_block_tcxx . . $ buf_block_t#** block, |
| 5686 | rec_tcxx . . $ rec_t#** rec, |
| 5687 | enum blob_opcxx . . $ blob_op# op) |
| 5688 | : m_pcurcxx . . $ btr_blob_log_check_t#m_pcur.(pcur), |
| 5689 | m_mtrcxx . . $ btr_blob_log_check_t#m_mtr.(mtr), |
| 5690 | m_offsetscxx . . $ btr_blob_log_check_t#m_offsets.(offsets), |
| 5691 | m_blockcxx . . $ btr_blob_log_check_t#m_block.(block), |
| 5692 | m_reccxx . . $ btr_blob_log_check_t#m_rec.(rec), |
| 5693 | m_opcxx . . $ btr_blob_log_check_t#m_op.(op) |
| 5694 | { |
| 5695 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rec_offs_validate(*m_rec, m_pcur->index(), m_offsets)); |
| 5696 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!((*m_block)->page.frame == page_align(*m_rec)); |
| 5697 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(*m_rec == btr_pcur_get_rec(m_pcur)); |
| 5698 | } |
| 5699 | |
| 5700 | /** Check if there is enough space in log file. Commit and re-start the |
| 5701 | mini transaction. */ |
| 5702 | void checkcxx . . $ btr_blob_log_check_t#check(49f6e7a06ebc5aa8).() |
| 5703 | { |
| 5704 | dict_index_tcxx . . $ dict_index_t#* index = m_pcurcxx . . $ btr_blob_log_check_t#m_pcur.->indexcxx . . $ btr_pcur_t#index(4ab6b9797a912635).(); |
| 5705 | ulintcxx . . $ ulint# offs = 0; |
| 5706 | uint32_tcxx . . $ uint32_t# page_no = FIL_NULLcxx . . $ `storage/innobase/include/fil0fil.h:1175:9`!; |
| 5707 | |
| 5708 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(m_op == BTR_STORE_INSERT_BULK)) { |
| 5709 | offs = *m_reccxx . . $ btr_blob_log_check_t#m_rec. - (*m_blockcxx . . $ btr_blob_log_check_t#m_block.)->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.; |
| 5710 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(offs == page_offset(*m_rec)); |
| 5711 | page_no = (*m_blockcxx . . $ btr_blob_log_check_t#m_block.)->pagecxx . . $ buf_block_t#page..idcxx . . $ buf_page_t#id(9d40bbb65128eac8).().page_nocxx . . $ page_id_t#page_no(d22c8608b6eae7b5).(); |
| 5712 | (*m_blockcxx . . $ btr_blob_log_check_t#m_block.)->pagecxx . . $ buf_block_t#page..fixcxx . . $ buf_page_t#fix(6e3776fd289463bb).(); |
| 5713 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(page_no != FIL_NULL); |
| 5714 | } else { |
| 5715 | btr_pcur_store_positioncxx . . $ btr_pcur_store_position(f723d369374bc0bf).(m_pcurcxx . . $ btr_blob_log_check_t#m_pcur., m_mtrcxx . . $ btr_blob_log_check_t#m_mtr.); |
| 5716 | } |
| 5717 | m_mtrcxx . . $ btr_blob_log_check_t#m_mtr.->commitcxx . . $ mtr_t#commit(49f6e7a06ebc5aa8).(); |
| 5718 | |
| 5719 | DEBUG_SYNC_Ccxx . . $ `include/mysql/service_debug_sync.h:355:9`!("blob_write_middle"); |
| 5720 | |
| 5721 | const mtr_log_tcxx . . $ mtr_log_t# log_mode = m_mtrcxx . . $ btr_blob_log_check_t#m_mtr.->get_log_modecxx . . $ mtr_t#get_log_mode(43738a4ade4f72d4).(); |
| 5722 | m_mtrcxx . . $ btr_blob_log_check_t#m_mtr.->startcxx . . $ mtr_t#start(49f6e7a06ebc5aa8).(); |
| 5723 | m_mtrcxx . . $ btr_blob_log_check_t#m_mtr.->set_log_modecxx . . $ mtr_t#set_log_mode(9fa4fa4ef91bef56).(log_mode); |
| 5724 | index->set_modifiedcxx . . $ dict_index_t#set_modified(6ecce9205e900009).(*m_mtrcxx . . $ btr_blob_log_check_t#m_mtr.); |
| 5725 | |
| 5726 | log_free_checkcxx . . $ log_free_check(ced63f7c635d850d).(); |
| 5727 | |
| 5728 | DEBUG_SYNC_Ccxx . . $ `include/mysql/service_debug_sync.h:355:9`!("blob_write_middle_after_check"); |
| 5729 | |
| 5730 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(page_no != FIL_NULLcxx . . $ `storage/innobase/include/fil0fil.h:1175:9`!)) { |
| 5731 | dberr_tcxx . . $ dberr_t# err; |
| 5732 | if (UNIV_LIKELYcxx . . $ `storage/innobase/include/univ.i:437:9`!(index->page != page_no)) { |
| 5733 | ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(btr_root_block_get(index, RW_SX_LATCH, |
| 5734 | m_mtr, &err)); |
| 5735 | } |
| 5736 | m_pcurcxx . . $ btr_blob_log_check_t#m_pcur.->btr_curcxx . . $ btr_pcur_t#btr_cur..page_curcxx . . $ btr_cur_t#page_cur..blockcxx . . $ page_cur_t#block. = btr_block_getcxx . . $ btr_block_get(fa2ba45a54fcd0c4).( |
| 5737 | *index, page_no, RW_X_LATCHcxx . . $ RW_X_LATCH., m_mtrcxx . . $ btr_blob_log_check_t#m_mtr.); |
| 5738 | /* The page should not be evicted or corrupted while |
| 5739 | we are holding a buffer-fix on it. */ |
| 5740 | m_pcurcxx . . $ btr_blob_log_check_t#m_pcur.->btr_curcxx . . $ btr_pcur_t#btr_cur..page_curcxx . . $ btr_cur_t#page_cur..blockcxx . . $ page_cur_t#block.->pagecxx . . $ buf_block_t#page..unfixcxx . . $ buf_page_t#unfix(2658d6455debfaef).(); |
| 5741 | m_pcurcxx . . $ btr_blob_log_check_t#m_pcur.->btr_curcxx . . $ btr_pcur_t#btr_cur..page_curcxx . . $ btr_cur_t#page_cur..reccxx . . $ page_cur_t#rec. |
| 5742 | = m_pcurcxx . . $ btr_blob_log_check_t#m_pcur.->btr_curcxx . . $ btr_pcur_t#btr_cur..page_curcxx . . $ btr_cur_t#page_cur..blockcxx . . $ page_cur_t#block.->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame. |
| 5743 | + offs; |
| 5744 | } else { |
| 5745 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(m_pcur->rel_pos == BTR_PCUR_ON); |
| 5746 | mtr_sx_lock_indexcxx . . $ `storage/innobase/include/mtr0mtr.h:47:10`!(index, m_mtr); |
| 5747 | ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(m_pcur->restore_position( |
| 5748 | BTR_MODIFY_ROOT_AND_LEAF_ALREADY_LATCHED, |
| 5749 | m_mtr) == btr_pcur_t::SAME_ALL); |
| 5750 | } |
| 5751 | |
| 5752 | *m_blockcxx . . $ btr_blob_log_check_t#m_block. = btr_pcur_get_blockcxx . . $ btr_pcur_get_block(73fb1691f91dfae3).(m_pcurcxx . . $ btr_blob_log_check_t#m_pcur.); |
| 5753 | *m_reccxx . . $ btr_blob_log_check_t#m_rec. = btr_pcur_get_reccxx . . $ btr_pcur_get_rec(759295355ee57c43).(m_pcurcxx . . $ btr_blob_log_check_t#m_pcur.); |
| 5754 | |
| 5755 | rec_offs_make_validcxx . . $ `storage/innobase/include/rem0rec.h:520:10`!(*m_rec, index, true, |
| 5756 | const_cast<rec_offs*>(m_offsets)); |
| 5757 | |
| 5758 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(m_mtr->memo_contains_page_flagged( |
| 5759 | *m_rec, |
| 5760 | MTR_MEMO_PAGE_X_FIX | MTR_MEMO_PAGE_SX_FIX)); |
| 5761 | |
| 5762 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!((m_op == BTR_STORE_INSERT_BULK) |
| 5763 | == !m_mtr->memo_contains_flagged(&index->lock, |
| 5764 | MTR_MEMO_SX_LOCK |
| 5765 | | MTR_MEMO_X_LOCK)); |
| 5766 | } |
| 5767 | }; |
| 5768 | |
| 5769 | /*******************************************************************//** |
| 5770 | Stores the fields in big_rec_vec to the tablespace and puts pointers to |
| 5771 | them in rec. The extern flags in rec will have to be set beforehand. |
| 5772 | The fields are stored on pages allocated from leaf node |
| 5773 | file segment of the index tree. |
| 5774 | |
| 5775 | TODO: If the allocation extends the tablespace, it will not be redo logged, in |
| 5776 | any mini-transaction. Tablespace extension should be redo-logged, so that |
| 5777 | recovery will not fail when the big_rec was written to the extended portion of |
| 5778 | the file, in case the file was somehow truncated in the crash. |
| 5779 | |
| 5780 | @return DB_SUCCESS or DB_OUT_OF_FILE_SPACE */ |
| 5781 | dberr_tcxx . . $ dberr_t# |
| 5782 | btr_store_big_rec_extern_fieldscxx . . $ btr_store_big_rec_extern_fields(1b1e51c0ee61196).( |
| 5783 | /*============================*/ |
| 5784 | btr_pcur_tcxx . . $ btr_pcur_t#* pcur, /*!< in: a persistent cursor */ |
| 5785 | rec_offscxx . . $ rec_offs#* offsets, /*!< in/out: rec_get_offsets() on |
| 5786 | pcur. the "external storage" flags |
| 5787 | in offsets will correctly correspond |
| 5788 | to rec when this function returns */ |
| 5789 | const big_rec_tcxx . . $ big_rec_t#*big_rec_vec, /*!< in: vector containing fields |
| 5790 | to be stored externally */ |
| 5791 | mtr_tcxx . . $ mtr_t#* btr_mtr, /*!< in/out: mtr containing the |
| 5792 | latches to the clustered index. can be |
| 5793 | committed and restarted. */ |
| 5794 | enum blob_opcxx . . $ blob_op# op) /*! in: operation code */ |
| 5795 | { |
| 5796 | bytecxx . . $ byte#* field_ref; |
| 5797 | ulintcxx . . $ ulint# extern_len; |
| 5798 | ulintcxx . . $ ulint# store_len; |
| 5799 | ulintcxx . . $ ulint# i; |
| 5800 | mtr_tcxx . . $ mtr_t# mtrcxx . . $ mtr_t#mtr_t(a6968fd0d8f26912).{btr_mtr->trxcxx . . $ mtr_t#trx.}; |
| 5801 | mem_heap_tcxx . . $ mem_heap_t#* heap = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 5802 | page_zip_des_tcxx . . $ page_zip_des_t#* page_zip; |
| 5803 | z_stream c_stream; |
| 5804 | dberr_tcxx . . $ dberr_t# error = DB_SUCCESScxx . . $ DB_SUCCESS.; |
| 5805 | dict_index_tcxx . . $ dict_index_t#* index = pcur->indexcxx . . $ btr_pcur_t#index(4ab6b9797a912635).(); |
| 5806 | buf_block_tcxx . . $ buf_block_t#* rec_block = btr_pcur_get_blockcxx . . $ btr_pcur_get_block(73fb1691f91dfae3).(pcur); |
| 5807 | rec_tcxx . . $ rec_t#* rec = btr_pcur_get_reccxx . . $ btr_pcur_get_rec(759295355ee57c43).(pcur); |
| 5808 | |
| 5809 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rec_offs_validate(rec, index, offsets)); |
| 5810 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rec_offs_any_extern(offsets)); |
| 5811 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(op == BTR_STORE_INSERT_BULK |
| 5812 | || btr_mtr->memo_contains_flagged(&index->lock, MTR_MEMO_X_LOCK |
| 5813 | | MTR_MEMO_SX_LOCK)); |
| 5814 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(btr_mtr->memo_contains_flagged(rec_block, MTR_MEMO_PAGE_X_FIX)); |
| 5815 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(buf_block_get_frame(rec_block) == page_align(rec)); |
| 5816 | ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(dict_index_is_clustcxx . . $ `storage/innobase/include/dict0dict.h:617:9`!(index)); |
| 5817 | |
| 5818 | if (!fil_page_index_page_checkcxx . . $ `storage/innobase/include/fil0fil.h:1357:9`!(btr_pcur_get_pagecxx . . $ `storage/innobase/include/btr0pcur.h:216:9`!(pcur))) { |
| 5819 | if (op != BTR_STORE_INSERT_BULKcxx . . $ BTR_STORE_INSERT_BULK.) { |
| 5820 | return DB_PAGE_CORRUPTEDcxx . . $ DB_PAGE_CORRUPTED.; |
| 5821 | } |
| 5822 | } |
| 5823 | |
| 5824 | btr_blob_log_check_tcxx . . $ btr_blob_log_check_t# redo_logcxx . . $ btr_blob_log_check_t#btr_blob_log_check_t(efd289c5d174bca4).(pcur, btr_mtr, offsets, &rec_block, |
| 5825 | &rec, op); |
| 5826 | page_zip = buf_block_get_page_zipcxx . . $ `storage/innobase/include/buf0buf.h:390:9`!(rec_block); |
| 5827 | |
| 5828 | if (page_zip) { |
| 5829 | int err; |
| 5830 | |
| 5831 | /* Zlib deflate needs 128 kilobytes for the default |
| 5832 | window size, plus 512 << memLevel, plus a few |
| 5833 | kilobytes for small objects. We use reduced memLevel |
| 5834 | to limit the memory consumption, and preallocate the |
| 5835 | heap, hoping to avoid memory fragmentation. */ |
| 5836 | heap = mem_heap_createcxx . . $ `storage/innobase/include/mem0mem.h:85:10`!(250000); |
| 5837 | page_zip_set_alloccxx . . $ page_zip_set_alloc(4c35a0b4763d0fd5).(&c_stream, heap); |
| 5838 | |
| 5839 | err = deflateInit2cxx . . $ `<external>/8929586433573063152/zlib.h:1936:11`!(&c_stream, int(page_zip_level), |
| 5840 | Z_DEFLATEDcxx . . $ `<external>/8929586433573063152/zlib.h:213:9`!, 15, 7, Z_DEFAULT_STRATEGYcxx . . $ `<external>/8929586433573063152/zlib.h:204:9`!); |
| 5841 | ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(err == Z_OKcxx . . $ `<external>/8929586433573063152/zlib.h:181:9`!); |
| 5842 | } |
| 5843 | |
| 5844 | #if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG |
| 5845 | /* All pointers to externally stored columns in the record |
| 5846 | must either be zero or they must be pointers to inherited |
| 5847 | columns, owned by this record or an earlier record version. */ |
| 5848 | for (i = 0; i < big_rec_vec->n_fields; i++) { |
| 5849 | field_ref = btr_rec_get_field_ref( |
| 5850 | rec, offsets, big_rec_vec->fields[i].field_no); |
| 5851 | |
| 5852 | ut_a(!(field_ref[BTR_EXTERN_LEN] & BTR_EXTERN_OWNER_FLAG)); |
| 5853 | /* Either this must be an update in place, |
| 5854 | or the BLOB must be inherited, or the BLOB pointer |
| 5855 | must be zero (will be written in this function). */ |
| 5856 | ut_a(op == BTR_STORE_UPDATE |
| 5857 | || (field_ref[BTR_EXTERN_LEN] & BTR_EXTERN_INHERITED_FLAG) |
| 5858 | || !memcmp(field_ref, field_ref_zero, |
| 5859 | BTR_EXTERN_FIELD_REF_SIZE)); |
| 5860 | } |
| 5861 | #endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */ |
| 5862 | |
| 5863 | /* Space available in compressed page to carry blob data */ |
| 5864 | const ulintcxx . . $ ulint# payload_size_zip = rec_block->physical_sizecxx . . $ buf_block_t#physical_size(c9b1e749b64d5edc).() |
| 5865 | - FIL_PAGE_DATAcxx . . $ `storage/innobase/include/fil0fil.h:1249:9`!; |
| 5866 | |
| 5867 | /* Space available in uncompressed page to carry blob data */ |
| 5868 | const ulintcxx . . $ ulint# payload_size = payload_size_zip |
| 5869 | - (BTR_BLOB_HDR_SIZEcxx . . $ `storage/innobase/btr/btr0cur.cc:122:9`! + FIL_PAGE_DATA_ENDcxx . . $ `storage/innobase/include/fil0fil.h:1277:9`!); |
| 5870 | |
| 5871 | /* We have to create a file segment to the tablespace |
| 5872 | for each field and put the pointer to the field in rec */ |
| 5873 | |
| 5874 | for (i = 0; i < big_rec_vec->n_fieldscxx . . $ big_rec_t#n_fields.; i++) { |
| 5875 | const ulintcxx . . $ ulint# field_no = big_rec_vec->fieldscxx . . $ big_rec_t#fields.[i].field_nocxx . . $ big_rec_field_t#field_no.; |
| 5876 | |
| 5877 | field_ref = btr_rec_get_field_refcxx . . $ `storage/innobase/btr/btr0cur.cc:5466:9`!(rec, offsets, field_no); |
| 5878 | #if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG |
| 5879 | /* A zero BLOB pointer should have been initially inserted. */ |
| 5880 | ut_a(!memcmp(field_ref, field_ref_zero, |
| 5881 | BTR_EXTERN_FIELD_REF_SIZE)); |
| 5882 | #endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */ |
| 5883 | extern_len = big_rec_vec->fieldscxx . . $ big_rec_t#fields.[i].lencxx . . $ big_rec_field_t#len.; |
| 5884 | MEM_CHECK_DEFINEDcxx . . $ `include/my_valgrind.h:72:10`!(big_rec_vec->fields[i].data, extern_len); |
| 5885 | ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(extern_len > 0); |
| 5886 | |
| 5887 | uint32_tcxx . . $ uint32_t# prev_page_no = FIL_NULLcxx . . $ `storage/innobase/include/fil0fil.h:1175:9`!; |
| 5888 | |
| 5889 | if (page_zip) { |
| 5890 | int err = deflateReset(&c_stream); |
| 5891 | ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(err == Z_OKcxx . . $ `<external>/8929586433573063152/zlib.h:181:9`!); |
| 5892 | |
| 5893 | c_stream.next_in = (Bytefcxx . . $ Bytef#*) |
| 5894 | big_rec_vec->fieldscxx . . $ big_rec_t#fields.[i].datacxx . . $ big_rec_field_t#data.; |
| 5895 | c_stream.avail_in = static_cast<uIntcxx . . $ uInt#>(extern_len); |
| 5896 | } |
| 5897 | |
| 5898 | for (ulintcxx . . $ ulint# blob_npages = 0;; ++blob_npages) { |
| 5899 | buf_block_tcxx . . $ buf_block_t#* block; |
| 5900 | const ulintcxx . . $ ulint# commit_freq = 4; |
| 5901 | |
| 5902 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(page_align(field_ref) == page_align(rec)); |
| 5903 | |
| 5904 | if (!(blob_npages % commit_freq)) { |
| 5905 | |
| 5906 | redo_log.checkcxx . . $ btr_blob_log_check_t#check(49f6e7a06ebc5aa8).(); |
| 5907 | |
| 5908 | field_ref = btr_rec_get_field_refcxx . . $ `storage/innobase/btr/btr0cur.cc:5466:9`!( |
| 5909 | rec, offsets, field_no); |
| 5910 | |
| 5911 | page_zip = buf_block_get_page_zipcxx . . $ `storage/innobase/include/buf0buf.h:390:9`!(rec_block); |
| 5912 | } |
| 5913 | |
| 5914 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(btr_mtr->get_already_latched( |
| 5915 | page_id_t{index->table->space_id, index->page}, |
| 5916 | MTR_MEMO_PAGE_SX_FIX)); |
| 5917 | |
| 5918 | mtr.startcxx . . $ mtr_t#start(49f6e7a06ebc5aa8).(); |
| 5919 | index->set_modifiedcxx . . $ dict_index_t#set_modified(6ecce9205e900009).(mtr); |
| 5920 | mtr.set_log_mode_subcxx . . $ mtr_t#set_log_mode_sub(ee35dd446e10f9ec).(*btr_mtr); |
| 5921 | |
| 5922 | rec_block->pagecxx . . $ buf_block_t#page..fixcxx . . $ buf_page_t#fix(6e3776fd289463bb).(); |
| 5923 | rec_block->pagecxx . . $ buf_block_t#page..lockcxx . . $ buf_page_t#lock..x_lockcxx . . $ sux_lock#x_lock(b45ddcbc8423892c).(); |
| 5924 | |
| 5925 | mtr.memo_pushcxx . . $ mtr_t#memo_push(1e7bab2d46fcb4c1).(rec_block, MTR_MEMO_PAGE_X_FIXcxx . . $ MTR_MEMO_PAGE_X_FIX.); |
| 5926 | #ifdef BTR_CUR_HASH_ADAPTcxx . . $ `<built-in>:481:9`! |
| 5927 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!btr_search_check_marked_free_index(rec_block)); |
| 5928 | #endif |
| 5929 | |
| 5930 | uint32_tcxx . . $ uint32_t# hint_prev = prev_page_no; |
| 5931 | if (hint_prev == FIL_NULLcxx . . $ `storage/innobase/include/fil0fil.h:1175:9`!) { |
| 5932 | hint_prev = rec_block->pagecxx . . $ buf_block_t#page..idcxx . . $ buf_page_t#id(9d40bbb65128eac8).().page_nocxx . . $ page_id_t#page_no(d22c8608b6eae7b5).(); |
| 5933 | } |
| 5934 | |
| 5935 | block = btr_page_alloccxx . . $ btr_page_alloc(97e5958ce206bff9).(index, hint_prev + 1, |
| 5936 | FSP_NO_DIRcxx . . $ `storage/innobase/include/fsp0types.h:55:9`!, 0, &mtr, &mtr, |
| 5937 | &error); |
| 5938 | |
| 5939 | DBUG_EXECUTE_IFcxx . . $ `include/my_dbug.h:172:9`!("btr_page_alloc_fail", |
| 5940 | block= nullptr; |
| 5941 | error= DB_OUT_OF_FILE_SPACE;); |
| 5942 | if (!block) { |
| 5943 | alloc_fail: |
| 5944 | mtr.commitcxx . . $ mtr_t#commit(49f6e7a06ebc5aa8).(); |
| 5945 | goto func_exit; |
| 5946 | } |
| 5947 | |
| 5948 | const uint32_tcxx . . $ uint32_t# space_id = block->pagecxx . . $ buf_block_t#page..idcxx . . $ buf_page_t#id(9d40bbb65128eac8).().spacecxx . . $ page_id_t#space(d22c8608b6eae7b5).(); |
| 5949 | const uint32_tcxx . . $ uint32_t# page_no = block->pagecxx . . $ buf_block_t#page..idcxx . . $ buf_page_t#id(9d40bbb65128eac8).().page_nocxx . . $ page_id_t#page_no(d22c8608b6eae7b5).(); |
| 5950 | |
| 5951 | if (prev_page_no == FIL_NULLcxx . . $ `storage/innobase/include/fil0fil.h:1175:9`!) { |
| 5952 | } else if (buf_block_tcxx . . $ buf_block_t#* prev_block = |
| 5953 | buf_page_get_gencxx . . $ buf_page_get_gen(4cc82125c68d4d05).(page_id_tcxx . . $ page_id_t#page_id_t(b4d55b1286ff73e8).(space_id, |
| 5954 | prev_page_no), |
| 5955 | rec_block->zip_sizecxx . . $ buf_block_t#zip_size(c9b1e749b64d5edc).(), |
| 5956 | RW_X_LATCHcxx . . $ RW_X_LATCH., nullptr, |
| 5957 | BUF_GETcxx . . $ `storage/innobase/include/buf0buf.h:53:9`!, &mtr, &error)) { |
| 5958 | if (page_zip) { |
| 5959 | mtr.writecxx . . $ mtr_t#write(4888ddbfa94c5eeb).<4>(*prev_block, |
| 5960 | prev_block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame. |
| 5961 | + FIL_PAGE_NEXTcxx . . $ `storage/innobase/include/fil0fil.h:1203:9`!, |
| 5962 | page_no); |
| 5963 | memcpy_alignedcxx . . $ memcpy_aligned(cc817cb175f282d).<4>( |
| 5964 | buf_block_get_page_zipcxx . . $ `storage/innobase/include/buf0buf.h:390:9`!( |
| 5965 | prev_block) |
| 5966 | ->datacxx . . $ page_zip_des_t#data. + FIL_PAGE_NEXTcxx . . $ `storage/innobase/include/fil0fil.h:1203:9`!, |
| 5967 | prev_block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame. |
| 5968 | + FIL_PAGE_NEXTcxx . . $ `storage/innobase/include/fil0fil.h:1203:9`!, 4); |
| 5969 | } else { |
| 5970 | mtr.writecxx . . $ mtr_t#write(4888ddbfa94c5eeb).<4>(*prev_block, |
| 5971 | BTR_BLOB_HDR_NEXT_PAGE_NOcxx . . $ `storage/innobase/btr/btr0cur.cc:119:9`! |
| 5972 | + FIL_PAGE_DATAcxx . . $ `storage/innobase/include/fil0fil.h:1249:9`! |
| 5973 | + prev_block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame., |
| 5974 | page_no); |
| 5975 | } |
| 5976 | } else { |
| 5977 | goto alloc_fail; |
| 5978 | } |
| 5979 | |
| 5980 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!page_has_siblings(block->page.frame)); |
| 5981 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!fil_page_get_type(block->page.frame)); |
| 5982 | |
| 5983 | if (page_zip) { |
| 5984 | int err; |
| 5985 | page_zip_des_tcxx . . $ page_zip_des_t#* blob_page_zip; |
| 5986 | |
| 5987 | mtr.writecxx . . $ mtr_t#write(4888ddbfa94c5eeb).<1>(*block, |
| 5988 | FIL_PAGE_TYPEcxx . . $ `storage/innobase/include/fil0fil.h:1215:9`! + 1 |
| 5989 | + block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame., |
| 5990 | prev_page_no == FIL_NULLcxx . . $ `storage/innobase/include/fil0fil.h:1175:9`! |
| 5991 | ? FIL_PAGE_TYPE_ZBLOBcxx . . $ FIL_PAGE_TYPE_ZBLOB. |
| 5992 | : FIL_PAGE_TYPE_ZBLOB2cxx . . $ FIL_PAGE_TYPE_ZBLOB2.); |
| 5993 | block->pagecxx . . $ buf_block_t#page..zipcxx . . $ buf_page_t#zip..datacxx . . $ page_zip_des_t#data.[FIL_PAGE_TYPEcxx . . $ `storage/innobase/include/fil0fil.h:1215:9`! + 1] |
| 5994 | = block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.[FIL_PAGE_TYPEcxx . . $ `storage/innobase/include/fil0fil.h:1215:9`! + 1]; |
| 5995 | |
| 5996 | c_stream.next_out = block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame. |
| 5997 | + FIL_PAGE_DATAcxx . . $ `storage/innobase/include/fil0fil.h:1249:9`!; |
| 5998 | c_stream.avail_out = static_cast<uIntcxx . . $ uInt#>( |
| 5999 | payload_size_zip); |
| 6000 | |
| 6001 | err = deflate(&c_stream, Z_FINISHcxx . . $ `<external>/8929586433573063152/zlib.h:176:9`!); |
| 6002 | ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(err == Z_OKcxx . . $ `<external>/8929586433573063152/zlib.h:181:9`! || err == Z_STREAM_ENDcxx . . $ `<external>/8929586433573063152/zlib.h:182:9`!); |
| 6003 | ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(err == Z_STREAM_ENDcxx . . $ `<external>/8929586433573063152/zlib.h:182:9`! |
| 6004 | || c_stream.avail_out == 0); |
| 6005 | |
| 6006 | mtr.memcpycxx . . $ mtr_t#memcpy(9fdef666e3f18c6c).(*block, |
| 6007 | FIL_PAGE_DATAcxx . . $ `storage/innobase/include/fil0fil.h:1249:9`!, |
| 6008 | page_zip_get_sizecxx . . $ page_zip_get_size(a3b1d3a3537f7de).(page_zip) |
| 6009 | - FIL_PAGE_DATAcxx . . $ `storage/innobase/include/fil0fil.h:1249:9`! |
| 6010 | - c_stream.avail_out); |
| 6011 | /* Copy the page to compressed storage, |
| 6012 | because it will be flushed to disk |
| 6013 | from there. */ |
| 6014 | blob_page_zip = buf_block_get_page_zipcxx . . $ `storage/innobase/include/buf0buf.h:390:9`!(block); |
| 6015 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(blob_page_zip); |
| 6016 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(page_zip_get_size(blob_page_zip) |
| 6017 | == page_zip_get_size(page_zip)); |
| 6018 | memcpy(blob_page_zip->datacxx . . $ page_zip_des_t#data., block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame., |
| 6019 | page_zip_get_sizecxx . . $ page_zip_get_size(a3b1d3a3537f7de).(page_zip)); |
| 6020 | |
| 6021 | if (err == Z_OKcxx . . $ `<external>/8929586433573063152/zlib.h:181:9`! && prev_page_no != FIL_NULLcxx . . $ `storage/innobase/include/fil0fil.h:1175:9`!) { |
| 6022 | |
| 6023 | goto next_zip_page; |
| 6024 | } |
| 6025 | |
| 6026 | if (err == Z_STREAM_ENDcxx . . $ `<external>/8929586433573063152/zlib.h:182:9`!) { |
| 6027 | mach_write_to_4cxx . . $ mach_write_to_4(6165b45f45ef689c).(field_ref |
| 6028 | + BTR_EXTERN_LENcxx . . $ `storage/innobase/include/btr0cur.h:797:9`!, 0); |
| 6029 | mach_write_to_4cxx . . $ mach_write_to_4(6165b45f45ef689c).(field_ref |
| 6030 | + BTR_EXTERN_LENcxx . . $ `storage/innobase/include/btr0cur.h:797:9`! + 4, |
| 6031 | c_stream.total_in); |
| 6032 | } else { |
| 6033 | memset(field_ref + BTR_EXTERN_LENcxx . . $ `storage/innobase/include/btr0cur.h:797:9`!, |
| 6034 | 0, 8); |
| 6035 | } |
| 6036 | |
| 6037 | if (prev_page_no == FIL_NULLcxx . . $ `storage/innobase/include/fil0fil.h:1175:9`!) { |
| 6038 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(blob_npages == 0); |
| 6039 | mach_write_to_4cxx . . $ mach_write_to_4(6165b45f45ef689c).(field_ref |
| 6040 | + BTR_EXTERN_SPACE_IDcxx . . $ `storage/innobase/include/btr0cur.h:793:9`!, |
| 6041 | space_id); |
| 6042 | |
| 6043 | mach_write_to_4cxx . . $ mach_write_to_4(6165b45f45ef689c).(field_ref |
| 6044 | + BTR_EXTERN_PAGE_NOcxx . . $ `storage/innobase/include/btr0cur.h:794:9`!, |
| 6045 | page_no); |
| 6046 | |
| 6047 | mach_write_to_4cxx . . $ mach_write_to_4(6165b45f45ef689c).(field_ref |
| 6048 | + BTR_EXTERN_OFFSETcxx . . $ `storage/innobase/include/btr0cur.h:795:9`!, |
| 6049 | FIL_PAGE_NEXTcxx . . $ `storage/innobase/include/fil0fil.h:1203:9`!); |
| 6050 | } |
| 6051 | |
| 6052 | /* We compress a page when finish bulk insert.*/ |
| 6053 | if (UNIV_LIKELYcxx . . $ `storage/innobase/include/univ.i:437:9`!(op != BTR_STORE_INSERT_BULK)) { |
| 6054 | page_zip_write_blob_ptrcxx . . $ page_zip_write_blob_ptr(a51fb08fa125d8c1).( |
| 6055 | rec_block, rec, index, offsets, |
| 6056 | field_no, &mtr); |
| 6057 | } |
| 6058 | |
| 6059 | next_zip_page: |
| 6060 | prev_page_no = page_no; |
| 6061 | |
| 6062 | /* Commit mtr and release the |
| 6063 | uncompressed page frame to save memory. */ |
| 6064 | btr_blob_freecxx . . $ btr_blob_free(ef96390c81c5cdc9).(block, FALSEcxx . . $ `include/my_global.h:477:9`!, &mtr); |
| 6065 | |
| 6066 | if (err == Z_STREAM_ENDcxx . . $ `<external>/8929586433573063152/zlib.h:182:9`!) { |
| 6067 | break; |
| 6068 | } |
| 6069 | } else { |
| 6070 | mtr.writecxx . . $ mtr_t#write(4888ddbfa94c5eeb).<1>(*block, FIL_PAGE_TYPEcxx . . $ `storage/innobase/include/fil0fil.h:1215:9`! + 1 |
| 6071 | + block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame., |
| 6072 | FIL_PAGE_TYPE_BLOBcxx . . $ FIL_PAGE_TYPE_BLOB.); |
| 6073 | |
| 6074 | if (extern_len > payload_size) { |
| 6075 | store_len = payload_size; |
| 6076 | } else { |
| 6077 | store_len = extern_len; |
| 6078 | } |
| 6079 | |
| 6080 | mtr.memcpycxx . . $ mtr_t#memcpy(cacdda589782ca45).<mtr_tcxx . . $ mtr_t#::MAYBE_NOPcxx . . $ mtr_t#MAYBE_NOP.>( |
| 6081 | *block, |
| 6082 | FIL_PAGE_DATAcxx . . $ `storage/innobase/include/fil0fil.h:1249:9`! + BTR_BLOB_HDR_SIZEcxx . . $ `storage/innobase/btr/btr0cur.cc:122:9`! |
| 6083 | + block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame., |
| 6084 | static_cast<const bytecxx . . $ byte#*> |
| 6085 | (big_rec_vec->fieldscxx . . $ big_rec_t#fields.[i].datacxx . . $ big_rec_field_t#data.) |
| 6086 | + big_rec_vec->fieldscxx . . $ big_rec_t#fields.[i].lencxx . . $ big_rec_field_t#len. |
| 6087 | - extern_len, store_len); |
| 6088 | mtr.writecxx . . $ mtr_t#write(4888ddbfa94c5eeb).<4>(*block, BTR_BLOB_HDR_PART_LENcxx . . $ `storage/innobase/btr/btr0cur.cc:117:9`! |
| 6089 | + FIL_PAGE_DATAcxx . . $ `storage/innobase/include/fil0fil.h:1249:9`! |
| 6090 | + block->pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame., |
| 6091 | store_len); |
| 6092 | compile_time_assertcxx . . $ `include/my_global.h:377:9`!(FIL_NULLcxx . . $ `storage/innobase/include/fil0fil.h:1175:9`! == 0xffffffff); |
| 6093 | mtr.memsetcxx . . $ mtr_t#memset(514fd140d769d0f8).(block, BTR_BLOB_HDR_NEXT_PAGE_NOcxx . . $ `storage/innobase/btr/btr0cur.cc:119:9`! |
| 6094 | + FIL_PAGE_DATAcxx . . $ `storage/innobase/include/fil0fil.h:1249:9`!, 4, 0xff); |
| 6095 | |
| 6096 | extern_len -= store_len; |
| 6097 | |
| 6098 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!mach_read_from_4(BTR_EXTERN_LEN |
| 6099 | + field_ref)); |
| 6100 | mtr.writecxx . . $ mtr_t#write(4888ddbfa94c5eeb).<4>(*rec_block, |
| 6101 | BTR_EXTERN_LENcxx . . $ `storage/innobase/include/btr0cur.h:797:9`! + 4 + field_ref, |
| 6102 | big_rec_vec->fieldscxx . . $ big_rec_t#fields.[i].lencxx . . $ big_rec_field_t#len. |
| 6103 | - extern_len); |
| 6104 | |
| 6105 | if (prev_page_no == FIL_NULLcxx . . $ `storage/innobase/include/fil0fil.h:1175:9`!) { |
| 6106 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(blob_npages == 0); |
| 6107 | mtr.writecxx . . $ mtr_t#write(4888ddbfa94c5eeb).<4,mtr_tcxx . . $ mtr_t#::MAYBE_NOPcxx . . $ mtr_t#MAYBE_NOP.>( |
| 6108 | *rec_block, |
| 6109 | field_ref + BTR_EXTERN_SPACE_IDcxx . . $ `storage/innobase/include/btr0cur.h:793:9`!, |
| 6110 | space_id); |
| 6111 | |
| 6112 | mtr.writecxx . . $ mtr_t#write(4888ddbfa94c5eeb).<4>(*rec_block, field_ref |
| 6113 | + BTR_EXTERN_PAGE_NOcxx . . $ `storage/innobase/include/btr0cur.h:794:9`!, |
| 6114 | page_no); |
| 6115 | |
| 6116 | mtr.writecxx . . $ mtr_t#write(4888ddbfa94c5eeb).<4>(*rec_block, field_ref |
| 6117 | + BTR_EXTERN_OFFSETcxx . . $ `storage/innobase/include/btr0cur.h:795:9`!, |
| 6118 | FIL_PAGE_DATAcxx . . $ `storage/innobase/include/fil0fil.h:1249:9`!); |
| 6119 | } |
| 6120 | |
| 6121 | prev_page_no = page_no; |
| 6122 | |
| 6123 | mtr.commitcxx . . $ mtr_t#commit(49f6e7a06ebc5aa8).(); |
| 6124 | |
| 6125 | if (extern_len == 0) { |
| 6126 | break; |
| 6127 | } |
| 6128 | } |
| 6129 | } |
| 6130 | |
| 6131 | DBUG_EXECUTE_IFcxx . . $ `include/my_dbug.h:172:9`!("btr_store_big_rec_extern", |
| 6132 | error = DB_OUT_OF_FILE_SPACE; |
| 6133 | goto func_exit;); |
| 6134 | |
| 6135 | rec_offs_make_nth_externcxx . . $ rec_offs_make_nth_extern(8bf1e866729cde2b).(offsets, field_no); |
| 6136 | } |
| 6137 | |
| 6138 | func_exit: |
| 6139 | if (page_zip) { |
| 6140 | deflateEnd(&c_stream); |
| 6141 | } |
| 6142 | |
| 6143 | if (heap != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { |
| 6144 | mem_heap_freecxx . . $ mem_heap_free(5231cf397463bfab).(heap); |
| 6145 | } |
| 6146 | |
| 6147 | #if defined UNIV_DEBUG || defined UNIV_BLOB_LIGHT_DEBUG |
| 6148 | /* All pointers to externally stored columns in the record |
| 6149 | must be valid. */ |
| 6150 | for (i = 0; i < rec_offs_n_fields(offsets); i++) { |
| 6151 | if (!rec_offs_nth_extern(offsets, i)) { |
| 6152 | continue; |
| 6153 | } |
| 6154 | |
| 6155 | field_ref = btr_rec_get_field_ref(rec, offsets, i); |
| 6156 | |
| 6157 | /* The pointer must not be zero if the operation |
| 6158 | succeeded. */ |
| 6159 | ut_a(0 != memcmp(field_ref, field_ref_zero, |
| 6160 | BTR_EXTERN_FIELD_REF_SIZE) |
| 6161 | || error != DB_SUCCESS); |
| 6162 | /* The column must not be disowned by this record. */ |
| 6163 | ut_a(!(field_ref[BTR_EXTERN_LEN] & BTR_EXTERN_OWNER_FLAG)); |
| 6164 | } |
| 6165 | #endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */ |
| 6166 | return(error); |
| 6167 | } |
| 6168 | |
| 6169 | /** Check the FIL_PAGE_TYPE on an uncompressed BLOB page. |
| 6170 | @param block uncompressed BLOB page |
| 6171 | @param op operation |
| 6172 | @return whether the type is invalid */ |
| 6173 | static bool btr_check_blob_fil_page_typecxx . . $ btr_check_blob_fil_page_type(887a6c6e58e05fac).(const buf_block_tcxx . . $ buf_block_t#& block, |
| 6174 | const char *op) |
| 6175 | { |
| 6176 | uint16_tcxx . . $ uint16_t# type= fil_page_get_typecxx . . $ fil_page_get_type(422f7ec86fa2a2fb).(block.pagecxx . . $ buf_block_t#page..framecxx . . $ buf_page_t#frame.); |
| 6177 | |
| 6178 | if (UNIV_LIKELYcxx . . $ `storage/innobase/include/univ.i:437:9`!(type == FIL_PAGE_TYPE_BLOB)); |
| 6179 | else if (fil_space_tcxx . . $ fil_space_t# *space= fil_space_tcxx . . $ fil_space_t#::getcxx . . $ fil_space_t#get(fb1f3aca84eadcbc).(block.pagecxx . . $ buf_block_t#page..idcxx . . $ buf_page_t#id(9d40bbb65128eac8).().spacecxx . . $ page_id_t#space(d22c8608b6eae7b5).())) |
| 6180 | { |
| 6181 | /* Old versions of InnoDB did not initialize FIL_PAGE_TYPE on BLOB |
| 6182 | pages. Do not print anything about the type mismatch when reading |
| 6183 | a BLOB page that may be from old versions. */ |
| 6184 | bool fail= space->full_crc32cxx . . $ fil_space_t#full_crc32(3482b152b9333168).() || DICT_TF_HAS_ATOMIC_BLOBScxx . . $ `storage/innobase/include/dict0mem.h:220:9`!(space->flags); |
| 6185 | if (fail) |
| 6186 | sql_print_errorcxx . . $ sql_print_error(326aeb464d16410c).("InnoDB: FIL_PAGE_TYPE=%u on BLOB %s file %s page %u", |
| 6187 | type, op, space->chaincxx . . $ fil_space_t#chain..startcxx . . $ ut_list_base#start.->namecxx . . $ fil_node_t#name., |
| 6188 | block.pagecxx . . $ buf_block_t#page..idcxx . . $ buf_page_t#id(9d40bbb65128eac8).().page_nocxx . . $ page_id_t#page_no(d22c8608b6eae7b5).()); |
| 6189 | space->releasecxx . . $ fil_space_t#release(77ce49a7840d23c7).(); |
| 6190 | return fail; |
| 6191 | } |
| 6192 | return false; |
| 6193 | } |
| 6194 | |
| 6195 | /*******************************************************************//** |
| 6196 | Frees the space in an externally stored field to the file space |
| 6197 | management if the field in data is owned by the externally stored field, |
| 6198 | in a rollback we may have the additional condition that the field must |
| 6199 | not be inherited. */ |
| 6200 | void |
| 6201 | btr_free_externally_stored_fieldcxx . . $ btr_free_externally_stored_field(599858604e27e4ad).( |
| 6202 | /*=============================*/ |
| 6203 | dict_index_tcxx . . $ dict_index_t#* index, /*!< in: index of the data, the index |
| 6204 | tree MUST be X-latched; if the tree |
| 6205 | height is 1, then also the root page |
| 6206 | must be X-latched! (this is relevant |
| 6207 | in the case this function is called |
| 6208 | from purge where 'data' is located on |
| 6209 | an undo log page, not an index |
| 6210 | page) */ |
| 6211 | bytecxx . . $ byte#* field_ref, /*!< in/out: field reference */ |
| 6212 | const rec_tcxx . . $ rec_t#* rec, /*!< in: record containing field_ref, for |
| 6213 | page_zip_write_blob_ptr(), or NULL */ |
| 6214 | const rec_offscxx . . $ rec_offs#* offsets, /*!< in: rec_get_offsets(rec, index), |
| 6215 | or NULL */ |
| 6216 | buf_block_tcxx . . $ buf_block_t#* block, /*!< in/out: page of field_ref */ |
| 6217 | ulintcxx . . $ ulint# i, /*!< in: field number of field_ref; |
| 6218 | ignored if rec == NULL */ |
| 6219 | bool rollback, /*!< in: performing rollback? */ |
| 6220 | mtr_tcxx . . $ mtr_t#* local_mtr) /*!< in: mtr |
| 6221 | containing the latch to data an an |
| 6222 | X-latch to the index tree */ |
| 6223 | { |
| 6224 | const uint32_tcxx . . $ uint32_t# space_id = mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).( |
| 6225 | field_ref + BTR_EXTERN_SPACE_IDcxx . . $ `storage/innobase/include/btr0cur.h:793:9`!); |
| 6226 | |
| 6227 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(index->is_primary()); |
| 6228 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(block->page.lock.have_x()); |
| 6229 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(local_mtr->memo_contains_flagged(&index->lock, MTR_MEMO_X_LOCK |
| 6230 | | MTR_MEMO_SX_LOCK)); |
| 6231 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(local_mtr->memo_contains_page_flagged(field_ref, |
| 6232 | MTR_MEMO_PAGE_X_FIX)); |
| 6233 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!rec || rec_offs_validate(rec, index, offsets)); |
| 6234 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!rec || field_ref == btr_rec_get_field_ref(rec, offsets, i)); |
| 6235 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(index->table->space_id == index->table->space->id); |
| 6236 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(local_mtr->is_named_space(index->table->space)); |
| 6237 | |
| 6238 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(!memcmp(field_ref, field_ref_zero, |
| 6239 | BTR_EXTERN_FIELD_REF_SIZEcxx . . $ `storage/innobase/include/btr0types.h:41:9`!))) { |
| 6240 | /* In the rollback, we may encounter a clustered index |
| 6241 | record with some unwritten off-page columns. There is |
| 6242 | nothing to free then. */ |
| 6243 | ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(rollback); |
| 6244 | return; |
| 6245 | } |
| 6246 | |
| 6247 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!(mach_read_from_4(field_ref + BTR_EXTERN_LEN) |
| 6248 | & ~((BTR_EXTERN_OWNER_FLAG |
| 6249 | | BTR_EXTERN_INHERITED_FLAG) << 24))); |
| 6250 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(space_id == index->table->space_id); |
| 6251 | |
| 6252 | const ulintcxx . . $ ulint# ext_zip_size = index->tablecxx . . $ dict_index_t#table.->spacecxx . . $ dict_table_t#space.->zip_sizecxx . . $ fil_space_t#zip_size(d22c8608b6eae7b5).(); |
| 6253 | /* !rec holds in a call from purge when field_ref is in an undo page */ |
| 6254 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rec || !block->page.zip.data); |
| 6255 | |
| 6256 | for (mtr_tcxx . . $ mtr_t# mtrcxx . . $ mtr_t#mtr_t(a6968fd0d8f26912).{local_mtr->trxcxx . . $ mtr_t#trx.};;) { |
| 6257 | mtr.startcxx . . $ mtr_t#start(49f6e7a06ebc5aa8).(); |
| 6258 | mtr.set_spacescxx . . $ mtr_t#set_spaces(ee35dd446e10f9ec).(*local_mtr); |
| 6259 | mtr.set_log_mode_subcxx . . $ mtr_t#set_log_mode_sub(ee35dd446e10f9ec).(*local_mtr); |
| 6260 | |
| 6261 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!index->table->is_temporary() |
| 6262 | || local_mtr->get_log_mode() == MTR_LOG_NO_REDO); |
| 6263 | |
| 6264 | const uint32_tcxx . . $ uint32_t# page_no = mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).( |
| 6265 | field_ref + BTR_EXTERN_PAGE_NOcxx . . $ `storage/innobase/include/btr0cur.h:794:9`!); |
| 6266 | buf_block_tcxx . . $ buf_block_t#* ext_block; |
| 6267 | |
| 6268 | if (/* There is no external storage data */ |
| 6269 | page_no == FIL_NULLcxx . . $ `storage/innobase/include/fil0fil.h:1175:9`! |
| 6270 | /* This field does not own the externally stored field */ |
| 6271 | || (mach_read_from_1cxx . . $ mach_read_from_1(f3688bc2ee54ea05).(field_ref + BTR_EXTERN_LENcxx . . $ `storage/innobase/include/btr0cur.h:797:9`!) |
| 6272 | & BTR_EXTERN_OWNER_FLAGcxx . . $ `storage/innobase/include/btr0cur.h:809:9`!) |
| 6273 | /* Rollback and inherited field */ |
| 6274 | || (rollback |
| 6275 | && (mach_read_from_1cxx . . $ mach_read_from_1(f3688bc2ee54ea05).(field_ref + BTR_EXTERN_LENcxx . . $ `storage/innobase/include/btr0cur.h:797:9`!) |
| 6276 | & BTR_EXTERN_INHERITED_FLAGcxx . . $ `storage/innobase/include/btr0cur.h:815:9`!))) { |
| 6277 | skip_free: |
| 6278 | /* Do not free */ |
| 6279 | mtr.commitcxx . . $ mtr_t#commit(49f6e7a06ebc5aa8).(); |
| 6280 | |
| 6281 | return; |
| 6282 | } |
| 6283 | |
| 6284 | ext_block = buf_page_getcxx . . $ `storage/innobase/include/buf0buf.h:149:10`!(page_id_t(space_id, page_no), |
| 6285 | ext_zip_size, RW_X_LATCH, &mtr); |
| 6286 | |
| 6287 | if (!ext_block) { |
| 6288 | goto skip_free; |
| 6289 | } |
| 6290 | |
| 6291 | /* The buffer pool block containing the BLOB pointer is |
| 6292 | exclusively latched by local_mtr. To satisfy some design |
| 6293 | constraints, we must recursively latch it in mtr as well. */ |
| 6294 | block->fixcxx . . $ buf_block_t#fix(ced63f7c635d850d).(); |
| 6295 | block->pagecxx . . $ buf_block_t#page..lockcxx . . $ buf_page_t#lock..x_lockcxx . . $ sux_lock#x_lock(b45ddcbc8423892c).(); |
| 6296 | |
| 6297 | mtr.memo_pushcxx . . $ mtr_t#memo_push(1e7bab2d46fcb4c1).(block, MTR_MEMO_PAGE_X_FIXcxx . . $ MTR_MEMO_PAGE_X_FIX.); |
| 6298 | #ifdef BTR_CUR_HASH_ADAPTcxx . . $ `<built-in>:481:9`! |
| 6299 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!btr_search_check_marked_free_index(block)); |
| 6300 | #endif |
| 6301 | |
| 6302 | const page_tcxx . . $ `storage/innobase/include/page0types.h:38:9`!* page = buf_block_get_framecxx . . $ `storage/innobase/include/buf0buf.h:385:9`!(ext_block); |
| 6303 | |
| 6304 | if (ext_zip_size) { |
| 6305 | /* Note that page_zip will be NULL |
| 6306 | in row_purge_upd_exist_or_extern(). */ |
| 6307 | switch (fil_page_get_typecxx . . $ fil_page_get_type(422f7ec86fa2a2fb).(page)) { |
| 6308 | case FIL_PAGE_TYPE_ZBLOBcxx . . $ FIL_PAGE_TYPE_ZBLOB.: |
| 6309 | case FIL_PAGE_TYPE_ZBLOB2cxx . . $ FIL_PAGE_TYPE_ZBLOB2.: |
| 6310 | break; |
| 6311 | default: |
| 6312 | MY_ASSERT_UNREACHABLEcxx . . $ `include/my_compiler.h:51:10`!(); |
| 6313 | } |
| 6314 | const uint32_tcxx . . $ uint32_t# next_page_no = mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).( |
| 6315 | page + FIL_PAGE_NEXTcxx . . $ `storage/innobase/include/fil0fil.h:1203:9`!); |
| 6316 | |
| 6317 | btr_page_freecxx . . $ btr_page_free(afbef3f3f4a891ab).(index, ext_block, &mtr, true, |
| 6318 | local_mtr->memo_containscxx . . $ mtr_t#memo_contains(48c0f5366875f660).( |
| 6319 | *index->tablecxx . . $ dict_index_t#table.->spacecxx . . $ dict_table_t#space.)); |
| 6320 | |
| 6321 | if (UNIV_LIKELY_NULLcxx . . $ `storage/innobase/include/univ.i:393:10`!(block->page.zip.data)) { |
| 6322 | mach_write_to_4cxx . . $ mach_write_to_4(6165b45f45ef689c).(field_ref + BTR_EXTERN_PAGE_NOcxx . . $ `storage/innobase/include/btr0cur.h:794:9`!, |
| 6323 | next_page_no); |
| 6324 | memset(field_ref + BTR_EXTERN_LENcxx . . $ `storage/innobase/include/btr0cur.h:797:9`! + 4, 0, 4); |
| 6325 | page_zip_write_blob_ptrcxx . . $ page_zip_write_blob_ptr(a51fb08fa125d8c1).(block, rec, index, |
| 6326 | offsets, i, &mtr); |
| 6327 | } else { |
| 6328 | mtr.writecxx . . $ mtr_t#write(4888ddbfa94c5eeb).<4>(*block, |
| 6329 | BTR_EXTERN_PAGE_NOcxx . . $ `storage/innobase/include/btr0cur.h:794:9`! + field_ref, |
| 6330 | next_page_no); |
| 6331 | mtr.writecxx . . $ mtr_t#write(4888ddbfa94c5eeb).<4,mtr_tcxx . . $ mtr_t#::MAYBE_NOPcxx . . $ mtr_t#MAYBE_NOP.>(*block, |
| 6332 | BTR_EXTERN_LENcxx . . $ `storage/innobase/include/btr0cur.h:797:9`! |
| 6333 | + 4 + field_ref, |
| 6334 | 0U); |
| 6335 | } |
| 6336 | } else { |
| 6337 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(!block->page.zip.data); |
| 6338 | btr_check_blob_fil_page_typecxx . . $ btr_check_blob_fil_page_type(887a6c6e58e05fac).(*ext_block, "purge"); |
| 6339 | |
| 6340 | const uint32_tcxx . . $ uint32_t# next_page_no = mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).( |
| 6341 | page + FIL_PAGE_DATAcxx . . $ `storage/innobase/include/fil0fil.h:1249:9`! |
| 6342 | + BTR_BLOB_HDR_NEXT_PAGE_NOcxx . . $ `storage/innobase/btr/btr0cur.cc:119:9`!); |
| 6343 | btr_page_freecxx . . $ btr_page_free(afbef3f3f4a891ab).(index, ext_block, &mtr, true, |
| 6344 | local_mtr->memo_containscxx . . $ mtr_t#memo_contains(48c0f5366875f660).( |
| 6345 | *index->tablecxx . . $ dict_index_t#table.->spacecxx . . $ dict_table_t#space.)); |
| 6346 | |
| 6347 | mtr.writecxx . . $ mtr_t#write(4888ddbfa94c5eeb).<4>(*block, BTR_EXTERN_PAGE_NOcxx . . $ `storage/innobase/include/btr0cur.h:794:9`! + field_ref, |
| 6348 | next_page_no); |
| 6349 | /* Zero out the BLOB length. If the server |
| 6350 | crashes during the execution of this function, |
| 6351 | trx_rollback_all_recovered() could |
| 6352 | dereference the half-deleted BLOB, fetching a |
| 6353 | wrong prefix for the BLOB. */ |
| 6354 | mtr.writecxx . . $ mtr_t#write(4888ddbfa94c5eeb).<4,mtr_tcxx . . $ mtr_t#::MAYBE_NOPcxx . . $ mtr_t#MAYBE_NOP.>(*block, |
| 6355 | BTR_EXTERN_LENcxx . . $ `storage/innobase/include/btr0cur.h:797:9`! + 4 |
| 6356 | + field_ref, 0U); |
| 6357 | } |
| 6358 | |
| 6359 | /* Commit mtr and release the BLOB block to save memory. */ |
| 6360 | btr_blob_freecxx . . $ btr_blob_free(ef96390c81c5cdc9).(ext_block, TRUEcxx . . $ `include/my_global.h:476:9`!, &mtr); |
| 6361 | } |
| 6362 | } |
| 6363 | |
| 6364 | /***********************************************************//** |
| 6365 | Frees the externally stored fields for a record. */ |
| 6366 | static |
| 6367 | void |
| 6368 | btr_rec_free_externally_stored_fieldscxx . . $ btr_rec_free_externally_stored_fields(e4c61c0bfa48221b).( |
| 6369 | /*==================================*/ |
| 6370 | dict_index_tcxx . . $ dict_index_t#* index, /*!< in: index of the data, the index |
| 6371 | tree MUST be X-latched */ |
| 6372 | rec_tcxx . . $ rec_t#* rec, /*!< in/out: record */ |
| 6373 | const rec_offscxx . . $ rec_offs#* offsets,/*!< in: rec_get_offsets(rec, index) */ |
| 6374 | buf_block_tcxx . . $ buf_block_t#* block, /*!< in: index page of rec */ |
| 6375 | bool rollback,/*!< in: performing rollback? */ |
| 6376 | mtr_tcxx . . $ mtr_t#* mtr) /*!< in: mini-transaction handle which contains |
| 6377 | an X-latch to record page and to the index |
| 6378 | tree */ |
| 6379 | { |
| 6380 | ulintcxx . . $ ulint# n_fields; |
| 6381 | ulintcxx . . $ ulint# i; |
| 6382 | |
| 6383 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rec_offs_validate(rec, index, offsets)); |
| 6384 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mtr->memo_contains_page_flagged(rec, MTR_MEMO_PAGE_X_FIX)); |
| 6385 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(index->is_primary()); |
| 6386 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(page_rec_is_leaf(rec)); |
| 6387 | /* Free possible externally stored fields in the record */ |
| 6388 | |
| 6389 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(dict_table_is_comp(index->table) == !!rec_offs_comp(offsets)); |
| 6390 | n_fields = rec_offs_n_fieldscxx . . $ rec_offs_n_fields(6fce5c29061b60f9).(offsets); |
| 6391 | |
| 6392 | for (i = 0; i < n_fields; i++) { |
| 6393 | if (rec_offs_nth_externcxx . . $ rec_offs_nth_extern(878e7dc5509530f1).(offsets, i)) { |
| 6394 | btr_free_externally_stored_fieldcxx . . $ btr_free_externally_stored_field(599858604e27e4ad).( |
| 6395 | index, btr_rec_get_field_refcxx . . $ `storage/innobase/btr/btr0cur.cc:5466:9`!(rec, offsets, i), |
| 6396 | rec, offsets, block, i, rollback, mtr); |
| 6397 | } |
| 6398 | } |
| 6399 | } |
| 6400 | |
| 6401 | /***********************************************************//** |
| 6402 | Frees the externally stored fields for a record, if the field is mentioned |
| 6403 | in the update vector. */ |
| 6404 | static |
| 6405 | void |
| 6406 | btr_rec_free_updated_extern_fieldscxx . . $ btr_rec_free_updated_extern_fields(1e02f8a3eb9379da).( |
| 6407 | /*===============================*/ |
| 6408 | dict_index_tcxx . . $ dict_index_t#* index, /*!< in: index of rec; the index tree MUST be |
| 6409 | X-latched */ |
| 6410 | rec_tcxx . . $ rec_t#* rec, /*!< in/out: record */ |
| 6411 | buf_block_tcxx . . $ buf_block_t#* block, /*!< in: index page of rec */ |
| 6412 | const rec_offscxx . . $ rec_offs#* offsets,/*!< in: rec_get_offsets(rec, index) */ |
| 6413 | const upd_tcxx . . $ upd_t#* update, /*!< in: update vector */ |
| 6414 | bool rollback,/*!< in: performing rollback? */ |
| 6415 | mtr_tcxx . . $ mtr_t#* mtr) /*!< in: mini-transaction handle which contains |
| 6416 | an X-latch to record page and to the tree */ |
| 6417 | { |
| 6418 | ulintcxx . . $ ulint# n_fields; |
| 6419 | ulintcxx . . $ ulint# i; |
| 6420 | |
| 6421 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(rec_offs_validate(rec, index, offsets)); |
| 6422 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(mtr->memo_contains_page_flagged(rec, MTR_MEMO_PAGE_X_FIX)); |
| 6423 | |
| 6424 | /* Free possible externally stored fields in the record */ |
| 6425 | |
| 6426 | n_fields = upd_get_n_fieldscxx . . $ upd_get_n_fields(c9dccea53ab13a00).(update); |
| 6427 | |
| 6428 | for (i = 0; i < n_fields; i++) { |
| 6429 | const upd_field_tcxx . . $ upd_field_t#* ufield = upd_get_nth_fieldcxx . . $ `storage/innobase/include/row0upd.h:68:10`!(update, i); |
| 6430 | |
| 6431 | if (rec_offs_nth_externcxx . . $ rec_offs_nth_extern(878e7dc5509530f1).(offsets, ufield->field_nocxx . . $ upd_field_t#field_no.)) { |
| 6432 | ulintcxx . . $ ulint# len; |
| 6433 | bytecxx . . $ byte#* data = rec_get_nth_fieldcxx . . $ `storage/innobase/include/rem0rec.h:562:9`!( |
| 6434 | rec, offsets, ufield->field_no, &len); |
| 6435 | ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(len >= BTR_EXTERN_FIELD_REF_SIZEcxx . . $ `storage/innobase/include/btr0types.h:41:9`!); |
| 6436 | |
| 6437 | btr_free_externally_stored_fieldcxx . . $ btr_free_externally_stored_field(599858604e27e4ad).( |
| 6438 | index, data + len - BTR_EXTERN_FIELD_REF_SIZEcxx . . $ `storage/innobase/include/btr0types.h:41:9`!, |
| 6439 | rec, offsets, block, |
| 6440 | ufield->field_nocxx . . $ upd_field_t#field_no., rollback, mtr); |
| 6441 | } |
| 6442 | } |
| 6443 | } |
| 6444 | |
| 6445 | /*******************************************************************//** |
| 6446 | Copies the prefix of an uncompressed BLOB. The clustered index record |
| 6447 | that points to this BLOB must be protected by a lock or a page latch. |
| 6448 | @return number of bytes written to buf */ |
| 6449 | static |
| 6450 | ulintcxx . . $ ulint# |
| 6451 | btr_copy_blob_prefixcxx . . $ btr_copy_blob_prefix(3e1523d5dbfb0345).( |
| 6452 | /*=================*/ |
| 6453 | bytecxx . . $ byte#* buf, /*!< out: the externally stored part of |
| 6454 | the field, or a prefix of it */ |
| 6455 | uint32_tcxx . . $ uint32_t# len, /*!< in: length of buf, in bytes */ |
| 6456 | page_id_tcxx . . $ page_id_t# id, /*!< in: page identifier of the first BLOB page */ |
| 6457 | uint32_tcxx . . $ uint32_t# offset) /*!< in: offset on the first BLOB page */ |
| 6458 | { |
| 6459 | ulintcxx . . $ ulint# copied_len = 0; |
| 6460 | THDcxx . . $ THD#* thd{current_thdcxx . . $ `sql/mysqld.h:916:9`!}; |
| 6461 | |
| 6462 | for (mtr_tcxx . . $ mtr_t# mtrcxx . . $ mtr_t#mtr_t(a6968fd0d8f26912).{thd ? thd_to_trxcxx . . $ thd_to_trx(76f0d80b3ea02926).(thd) : nullptr};;) { |
| 6463 | buf_block_tcxx . . $ buf_block_t#* block; |
| 6464 | const page_tcxx . . $ `storage/innobase/include/page0types.h:38:9`!* page; |
| 6465 | const bytecxx . . $ byte#* blob_header; |
| 6466 | ulintcxx . . $ ulint# part_len; |
| 6467 | ulintcxx . . $ ulint# copy_len; |
| 6468 | |
| 6469 | mtr_startcxx . . $ `storage/innobase/include/mtr0mtr.h:35:9`!(&mtr); |
| 6470 | |
| 6471 | block = buf_page_getcxx . . $ `storage/innobase/include/buf0buf.h:149:10`!(id, 0, RW_S_LATCH, &mtr); |
| 6472 | if (!block || btr_check_blob_fil_page_typecxx . . $ btr_check_blob_fil_page_type(887a6c6e58e05fac).(*block, "read")) { |
| 6473 | mtr.commitcxx . . $ mtr_t#commit(49f6e7a06ebc5aa8).(); |
| 6474 | return copied_len; |
| 6475 | } |
| 6476 | if (!buf_page_make_young_if_neededcxx . . $ buf_page_make_young_if_needed(12ea16e51c748147).(&block->pagecxx . . $ buf_block_t#page.)) { |
| 6477 | buf_read_ahead_linearcxx . . $ buf_read_ahead_linear(3269ed12c418f19c).(id); |
| 6478 | } |
| 6479 | |
| 6480 | page = buf_block_get_framecxx . . $ `storage/innobase/include/buf0buf.h:385:9`!(block); |
| 6481 | |
| 6482 | blob_header = page + offset; |
| 6483 | part_len = btr_blob_get_part_lencxx . . $ btr_blob_get_part_len(ca1608e2c87725e2).(blob_header); |
| 6484 | copy_len = ut_mincxx . . $ `storage/innobase/include/ut0ut.h:54:9`!(part_len, len - copied_len); |
| 6485 | |
| 6486 | memcpy(buf + copied_len, |
| 6487 | blob_header + BTR_BLOB_HDR_SIZEcxx . . $ `storage/innobase/btr/btr0cur.cc:122:9`!, copy_len); |
| 6488 | copied_len += copy_len; |
| 6489 | |
| 6490 | id.set_page_nocxx . . $ page_id_t#set_page_no(6bab9b75950d6f3).(btr_blob_get_next_page_nocxx . . $ btr_blob_get_next_page_no(ca1608e2c87725e2).(blob_header)); |
| 6491 | |
| 6492 | mtr_commitcxx . . $ `storage/innobase/include/mtr0mtr.h:38:9`!(&mtr); |
| 6493 | |
| 6494 | if (id.page_nocxx . . $ page_id_t#page_no(d22c8608b6eae7b5).() == FIL_NULLcxx . . $ `storage/innobase/include/fil0fil.h:1175:9`! || copy_len != part_len) { |
| 6495 | MEM_CHECK_DEFINEDcxx . . $ `include/my_valgrind.h:72:10`!(buf, copied_len); |
| 6496 | return(copied_len); |
| 6497 | } |
| 6498 | |
| 6499 | /* On other BLOB pages except the first the BLOB header |
| 6500 | always is at the page data start: */ |
| 6501 | |
| 6502 | offset = FIL_PAGE_DATAcxx . . $ `storage/innobase/include/fil0fil.h:1249:9`!; |
| 6503 | |
| 6504 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(copied_len <= len); |
| 6505 | } |
| 6506 | } |
| 6507 | |
| 6508 | /** Copies the prefix of a compressed BLOB. |
| 6509 | The clustered index record that points to this BLOB must be protected |
| 6510 | by a lock or a page latch. |
| 6511 | @param[out] buf the externally stored part of the field, |
| 6512 | or a prefix of it |
| 6513 | @param[in] len length of buf, in bytes |
| 6514 | @param[in] zip_size ROW_FORMAT=COMPRESSED page size |
| 6515 | @param[in] id page identifier of the BLOB pages |
| 6516 | @return number of bytes written to buf */ |
| 6517 | static |
| 6518 | ulintcxx . . $ ulint# |
| 6519 | btr_copy_zblob_prefixcxx . . $ btr_copy_zblob_prefix(15d1ce9494094664).( |
| 6520 | bytecxx . . $ byte#* buf, |
| 6521 | uint32_tcxx . . $ uint32_t# len, |
| 6522 | ulintcxx . . $ ulint# zip_size, |
| 6523 | page_id_tcxx . . $ page_id_t# id, |
| 6524 | uint32_tcxx . . $ uint32_t# offset) |
| 6525 | { |
| 6526 | ulintcxx . . $ ulint# page_type = FIL_PAGE_TYPE_ZBLOBcxx . . $ FIL_PAGE_TYPE_ZBLOB.; |
| 6527 | mem_heap_tcxx . . $ mem_heap_t#* heap; |
| 6528 | int err; |
| 6529 | z_stream d_stream; |
| 6530 | |
| 6531 | d_stream.next_out = buf; |
| 6532 | d_stream.avail_out = static_cast<uIntcxx . . $ uInt#>(len); |
| 6533 | d_stream.next_in = Z_NULLcxx . . $ `<external>/8929586433573063152/zlib.h:216:9`!; |
| 6534 | d_stream.avail_in = 0; |
| 6535 | |
| 6536 | /* Zlib inflate needs 32 kilobytes for the default |
| 6537 | window size, plus a few kilobytes for small objects. */ |
| 6538 | heap = mem_heap_createcxx . . $ `storage/innobase/include/mem0mem.h:85:10`!(40000); |
| 6539 | page_zip_set_alloccxx . . $ page_zip_set_alloc(4c35a0b4763d0fd5).(&d_stream, heap); |
| 6540 | |
| 6541 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(zip_size); |
| 6542 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(ut_is_2pow(zip_size)); |
| 6543 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(id.space()); |
| 6544 | |
| 6545 | err = inflateInitcxx . . $ `<external>/8929586433573063152/zlib.h:1934:11`!(&d_stream); |
| 6546 | ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(err == Z_OKcxx . . $ `<external>/8929586433573063152/zlib.h:181:9`!); |
| 6547 | |
| 6548 | for (;;) { |
| 6549 | buf_page_tcxx . . $ buf_page_t#* bpage; |
| 6550 | uint32_tcxx . . $ uint32_t# next_page_no; |
| 6551 | |
| 6552 | bpage = buf_page_get_zipcxx . . $ buf_page_get_zip(52ad1b78835f3791).(id); |
| 6553 | |
| 6554 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(!bpage)) { |
| 6555 | goto func_exit; |
| 6556 | } |
| 6557 | |
| 6558 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`! |
| 6559 | (fil_page_get_type(bpage->zip.data) != page_type)) { |
| 6560 | |
| 6561 | ibcxx . . $ ib/::errorcxx . . $ ib/error#() <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). "Unexpected type " |
| 6562 | <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). fil_page_get_typecxx . . $ fil_page_get_type(422f7ec86fa2a2fb).(bpage->zipcxx . . $ buf_page_t#zip..datacxx . . $ page_zip_des_t#data.) |
| 6563 | <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). " of compressed BLOB page " <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). id; |
| 6564 | |
| 6565 | ut_adcxx . . $ `storage/innobase/include/ut0dbg.h:62:9`!(0); |
| 6566 | goto end_of_blob; |
| 6567 | } |
| 6568 | |
| 6569 | next_page_no = mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(bpage->zipcxx . . $ buf_page_t#zip..datacxx . . $ page_zip_des_t#data. + offset); |
| 6570 | |
| 6571 | if (UNIV_LIKELYcxx . . $ `storage/innobase/include/univ.i:437:9`!(offset == FIL_PAGE_NEXTcxx . . $ `storage/innobase/include/fil0fil.h:1203:9`!)) { |
| 6572 | /* When the BLOB begins at page header, |
| 6573 | the compressed data payload does not |
| 6574 | immediately follow the next page pointer. */ |
| 6575 | offset = FIL_PAGE_DATAcxx . . $ `storage/innobase/include/fil0fil.h:1249:9`!; |
| 6576 | } else { |
| 6577 | offset += 4; |
| 6578 | } |
| 6579 | |
| 6580 | d_stream.next_in = bpage->zipcxx . . $ buf_page_t#zip..datacxx . . $ page_zip_des_t#data. + offset; |
| 6581 | d_stream.avail_in = uIntcxx . . $ uInt#(zip_size - offset); |
| 6582 | |
| 6583 | err = inflate(&d_stream, Z_NO_FLUSHcxx . . $ `<external>/8929586433573063152/zlib.h:172:9`!); |
| 6584 | switch (err) { |
| 6585 | case Z_OKcxx . . $ `<external>/8929586433573063152/zlib.h:181:9`!: |
| 6586 | if (!d_stream.avail_out) { |
| 6587 | goto end_of_blob; |
| 6588 | } |
| 6589 | break; |
| 6590 | case Z_STREAM_ENDcxx . . $ `<external>/8929586433573063152/zlib.h:182:9`!: |
| 6591 | if (next_page_no == FIL_NULLcxx . . $ `storage/innobase/include/fil0fil.h:1175:9`!) { |
| 6592 | goto end_of_blob; |
| 6593 | } |
| 6594 | /* fall through */ |
| 6595 | default: |
| 6596 | inflate_error: |
| 6597 | ibcxx . . $ ib/::errorcxx . . $ ib/error#() <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). "inflate() of compressed BLOB page " |
| 6598 | <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). id |
| 6599 | <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). " returned " <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). err |
| 6600 | <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). " (" <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). d_stream.msg <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). ")"; |
| 6601 | |
| 6602 | case Z_BUF_ERRORcxx . . $ `<external>/8929586433573063152/zlib.h:188:9`!: |
| 6603 | goto end_of_blob; |
| 6604 | } |
| 6605 | |
| 6606 | if (next_page_no == FIL_NULLcxx . . $ `storage/innobase/include/fil0fil.h:1175:9`!) { |
| 6607 | if (!d_stream.avail_in) { |
| 6608 | ibcxx . . $ ib/::errorcxx . . $ ib/error#() |
| 6609 | <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). "Unexpected end of compressed " |
| 6610 | <<cxx . . $ ib/logger#`operator<<`(dcbc6b5678e2764). "BLOB page " <<cxx . . $ ib/logger#`operator<<`(8dc2c095a0caceff). id; |
| 6611 | } else { |
| 6612 | err = inflate(&d_stream, Z_FINISHcxx . . $ `<external>/8929586433573063152/zlib.h:176:9`!); |
| 6613 | switch (err) { |
| 6614 | case Z_STREAM_ENDcxx . . $ `<external>/8929586433573063152/zlib.h:182:9`!: |
| 6615 | case Z_BUF_ERRORcxx . . $ `<external>/8929586433573063152/zlib.h:188:9`!: |
| 6616 | break; |
| 6617 | default: |
| 6618 | goto inflate_error; |
| 6619 | } |
| 6620 | } |
| 6621 | |
| 6622 | end_of_blob: |
| 6623 | bpage->lockcxx . . $ buf_page_t#lock..s_unlockcxx . . $ sux_lock#s_unlock(49f6e7a06ebc5aa8).(); |
| 6624 | goto func_exit; |
| 6625 | } |
| 6626 | |
| 6627 | bpage->lockcxx . . $ buf_page_t#lock..s_unlockcxx . . $ sux_lock#s_unlock(49f6e7a06ebc5aa8).(); |
| 6628 | |
| 6629 | /* On other BLOB pages except the first |
| 6630 | the BLOB header always is at the page header: */ |
| 6631 | |
| 6632 | id.set_page_nocxx . . $ page_id_t#set_page_no(6bab9b75950d6f3).(next_page_no); |
| 6633 | offset = FIL_PAGE_NEXTcxx . . $ `storage/innobase/include/fil0fil.h:1203:9`!; |
| 6634 | page_type = FIL_PAGE_TYPE_ZBLOB2cxx . . $ FIL_PAGE_TYPE_ZBLOB2.; |
| 6635 | } |
| 6636 | |
| 6637 | func_exit: |
| 6638 | inflateEnd(&d_stream); |
| 6639 | mem_heap_freecxx . . $ mem_heap_free(5231cf397463bfab).(heap); |
| 6640 | MEM_CHECK_DEFINEDcxx . . $ `include/my_valgrind.h:72:10`!(buf, d_stream.total_out); |
| 6641 | return(d_stream.total_out); |
| 6642 | } |
| 6643 | |
| 6644 | /** Copies the prefix of an externally stored field of a record. |
| 6645 | The clustered index record that points to this BLOB must be protected |
| 6646 | by a lock or a page latch. |
| 6647 | @param[out] buf the externally stored part of the |
| 6648 | field, or a prefix of it |
| 6649 | @param[in] len length of buf, in bytes |
| 6650 | @param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 |
| 6651 | @param[in] id page identifier of the first BLOB page |
| 6652 | @param[in] offset offset on the first BLOB page |
| 6653 | @return number of bytes written to buf */ |
| 6654 | static |
| 6655 | ulintcxx . . $ ulint# |
| 6656 | btr_copy_externally_stored_field_prefix_lowcxx . . $ btr_copy_externally_stored_field_prefix_low(15d1ce9494094664).( |
| 6657 | bytecxx . . $ byte#* buf, |
| 6658 | uint32_tcxx . . $ uint32_t# len, |
| 6659 | ulintcxx . . $ ulint# zip_size, |
| 6660 | page_id_tcxx . . $ page_id_t# id, |
| 6661 | uint32_tcxx . . $ uint32_t# offset) |
| 6662 | { |
| 6663 | if (len == 0) |
| 6664 | return 0; |
| 6665 | |
| 6666 | return zip_size |
| 6667 | ? btr_copy_zblob_prefixcxx . . $ btr_copy_zblob_prefix(15d1ce9494094664).(buf, len, zip_size, id, offset) |
| 6668 | : btr_copy_blob_prefixcxx . . $ btr_copy_blob_prefix(3e1523d5dbfb0345).(buf, len, id, offset); |
| 6669 | } |
| 6670 | |
| 6671 | /** Copies the prefix of an externally stored field of a record. |
| 6672 | The clustered index record must be protected by a lock or a page latch. |
| 6673 | @param[out] buf the field, or a prefix of it |
| 6674 | @param[in] len length of buf, in bytes |
| 6675 | @param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 |
| 6676 | @param[in] data 'internally' stored part of the field |
| 6677 | containing also the reference to the external part; must be protected by |
| 6678 | a lock or a page latch |
| 6679 | @param[in] local_len length of data, in bytes |
| 6680 | @return the length of the copied field, or 0 if the column was being |
| 6681 | or has been deleted */ |
| 6682 | ulintcxx . . $ ulint# |
| 6683 | btr_copy_externally_stored_field_prefixcxx . . $ btr_copy_externally_stored_field_prefix(d616716af458c145).( |
| 6684 | bytecxx . . $ byte#* buf, |
| 6685 | ulintcxx . . $ ulint# len, |
| 6686 | ulintcxx . . $ ulint# zip_size, |
| 6687 | const bytecxx . . $ byte#* data, |
| 6688 | ulintcxx . . $ ulint# local_len) |
| 6689 | { |
| 6690 | ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(local_len >= BTR_EXTERN_FIELD_REF_SIZEcxx . . $ `storage/innobase/include/btr0types.h:41:9`!); |
| 6691 | |
| 6692 | local_len -= BTR_EXTERN_FIELD_REF_SIZEcxx . . $ `storage/innobase/include/btr0types.h:41:9`!; |
| 6693 | |
| 6694 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`!(local_len >= len)) { |
| 6695 | memcpy(buf, data, len); |
| 6696 | return(len); |
| 6697 | } |
| 6698 | |
| 6699 | memcpy(buf, data, local_len); |
| 6700 | data += local_len; |
| 6701 | |
| 6702 | ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(memcmp(data, field_ref_zero, BTR_EXTERN_FIELD_REF_SIZEcxx . . $ `storage/innobase/include/btr0types.h:41:9`!)); |
| 6703 | |
| 6704 | if (!mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(data + BTR_EXTERN_LENcxx . . $ `storage/innobase/include/btr0cur.h:797:9`! + 4)) { |
| 6705 | /* The externally stored part of the column has been |
| 6706 | (partially) deleted. Signal the half-deleted BLOB |
| 6707 | to the caller. */ |
| 6708 | |
| 6709 | return(0); |
| 6710 | } |
| 6711 | |
| 6712 | uint32_tcxx . . $ uint32_t# space_id = mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(data + BTR_EXTERN_SPACE_IDcxx . . $ `storage/innobase/include/btr0cur.h:793:9`!); |
| 6713 | uint32_tcxx . . $ uint32_t# page_no = mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(data + BTR_EXTERN_PAGE_NOcxx . . $ `storage/innobase/include/btr0cur.h:794:9`!); |
| 6714 | uint32_tcxx . . $ uint32_t# offset = mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(data + BTR_EXTERN_OFFSETcxx . . $ `storage/innobase/include/btr0cur.h:795:9`!); |
| 6715 | len -= local_len; |
| 6716 | |
| 6717 | return(local_len |
| 6718 | + btr_copy_externally_stored_field_prefix_lowcxx . . $ btr_copy_externally_stored_field_prefix_low(15d1ce9494094664).(buf + local_len, |
| 6719 | uint32_tcxx . . $ uint32_t#(len), |
| 6720 | zip_size, |
| 6721 | page_id_tcxx . . $ page_id_t#page_id_t(b4d55b1286ff73e8).( |
| 6722 | space_id, |
| 6723 | page_no), |
| 6724 | offset)); |
| 6725 | } |
| 6726 | |
| 6727 | /** Copies an externally stored field of a record to mem heap. |
| 6728 | The clustered index record must be protected by a lock or a page latch. |
| 6729 | @param[out] len length of the whole field |
| 6730 | @param[in] data 'internally' stored part of the field |
| 6731 | containing also the reference to the external part; must be protected by |
| 6732 | a lock or a page latch |
| 6733 | @param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 |
| 6734 | @param[in] local_len length of data |
| 6735 | @param[in,out] heap mem heap |
| 6736 | @return the whole field copied to heap */ |
| 6737 | bytecxx . . $ byte#* |
| 6738 | btr_copy_externally_stored_fieldcxx . . $ btr_copy_externally_stored_field(c9f32e0dbefa3c3f).( |
| 6739 | ulintcxx . . $ ulint#* len, |
| 6740 | const bytecxx . . $ byte#* data, |
| 6741 | ulintcxx . . $ ulint# zip_size, |
| 6742 | ulintcxx . . $ ulint# local_len, |
| 6743 | mem_heap_tcxx . . $ mem_heap_t#* heap) |
| 6744 | { |
| 6745 | bytecxx . . $ byte#* buf; |
| 6746 | |
| 6747 | ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(local_len >= BTR_EXTERN_FIELD_REF_SIZEcxx . . $ `storage/innobase/include/btr0types.h:41:9`!); |
| 6748 | |
| 6749 | local_len -= BTR_EXTERN_FIELD_REF_SIZEcxx . . $ `storage/innobase/include/btr0types.h:41:9`!; |
| 6750 | |
| 6751 | uint32_tcxx . . $ uint32_t# space_id = mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(data + local_len |
| 6752 | + BTR_EXTERN_SPACE_IDcxx . . $ `storage/innobase/include/btr0cur.h:793:9`!); |
| 6753 | uint32_tcxx . . $ uint32_t# page_no = mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(data + local_len |
| 6754 | + BTR_EXTERN_PAGE_NOcxx . . $ `storage/innobase/include/btr0cur.h:794:9`!); |
| 6755 | uint32_tcxx . . $ uint32_t# offset = mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(data + local_len |
| 6756 | + BTR_EXTERN_OFFSETcxx . . $ `storage/innobase/include/btr0cur.h:795:9`!); |
| 6757 | |
| 6758 | /* Currently a BLOB cannot be bigger than 4 GB; we |
| 6759 | leave the 4 upper bytes in the length field unused */ |
| 6760 | |
| 6761 | uint32_tcxx . . $ uint32_t# extern_len = mach_read_from_4cxx . . $ mach_read_from_4(ca1608e2c87725e2).(data + local_len |
| 6762 | + BTR_EXTERN_LENcxx . . $ `storage/innobase/include/btr0cur.h:797:9`! + 4); |
| 6763 | |
| 6764 | buf = (bytecxx . . $ byte#*) mem_heap_alloccxx . . $ mem_heap_alloc(3f50e4c8b9ca77c0).(heap, local_len + extern_len); |
| 6765 | |
| 6766 | memcpy(buf, data, local_len); |
| 6767 | *len = local_len |
| 6768 | + btr_copy_externally_stored_field_prefix_lowcxx . . $ btr_copy_externally_stored_field_prefix_low(15d1ce9494094664).(buf + local_len, |
| 6769 | extern_len, |
| 6770 | zip_size, |
| 6771 | page_id_tcxx . . $ page_id_t#page_id_t(b4d55b1286ff73e8).( |
| 6772 | space_id, |
| 6773 | page_no), |
| 6774 | offset); |
| 6775 | |
| 6776 | return(buf); |
| 6777 | } |
| 6778 | |
| 6779 | /** Copies an externally stored field of a record to mem heap. |
| 6780 | @param[in] rec record in a clustered index; must be |
| 6781 | protected by a lock or a page latch |
| 6782 | @param[in] offset array returned by rec_get_offsets() |
| 6783 | @param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 |
| 6784 | @param[in] no field number |
| 6785 | @param[out] len length of the field |
| 6786 | @param[in,out] heap mem heap |
| 6787 | @return the field copied to heap, or NULL if the field is incomplete */ |
| 6788 | bytecxx . . $ byte#* |
| 6789 | btr_rec_copy_externally_stored_fieldcxx . . $ btr_rec_copy_externally_stored_field(7bf20e03f04c2018).( |
| 6790 | const rec_tcxx . . $ rec_t#* rec, |
| 6791 | const rec_offscxx . . $ rec_offs#* offsets, |
| 6792 | ulintcxx . . $ ulint# zip_size, |
| 6793 | ulintcxx . . $ ulint# no, |
| 6794 | ulintcxx . . $ ulint#* len, |
| 6795 | mem_heap_tcxx . . $ mem_heap_t#* heap) |
| 6796 | { |
| 6797 | ulintcxx . . $ ulint# local_len; |
| 6798 | const bytecxx . . $ byte#* data; |
| 6799 | |
| 6800 | ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(rec_offs_nth_extern(offsets, no)); |
| 6801 | |
| 6802 | /* An externally stored field can contain some initial |
| 6803 | data from the field, and in the last 20 bytes it has the |
| 6804 | space id, page number, and offset where the rest of the |
| 6805 | field data is stored, and the data length in addition to |
| 6806 | the data stored locally. We may need to store some data |
| 6807 | locally to get the local record length above the 128 byte |
| 6808 | limit so that field offsets are stored in two bytes, and |
| 6809 | the extern bit is available in those two bytes. */ |
| 6810 | |
| 6811 | data = rec_get_nth_fieldcxx . . $ `storage/innobase/include/rem0rec.h:562:9`!(rec, offsets, no, &local_len); |
| 6812 | |
| 6813 | ut_acxx . . $ `storage/innobase/include/ut0dbg.h:50:9`!(local_len >= BTR_EXTERN_FIELD_REF_SIZEcxx . . $ `storage/innobase/include/btr0types.h:41:9`!); |
| 6814 | |
| 6815 | if (UNIV_UNLIKELYcxx . . $ `storage/innobase/include/univ.i:439:9`! |
| 6816 | (!memcmp(data + local_len - BTR_EXTERN_FIELD_REF_SIZEcxx . . $ `storage/innobase/include/btr0types.h:41:9`!, |
| 6817 | field_ref_zero, BTR_EXTERN_FIELD_REF_SIZEcxx . . $ `storage/innobase/include/btr0types.h:41:9`!))) { |
| 6818 | /* The externally stored field was not written yet. |
| 6819 | This record should only be seen by |
| 6820 | trx_rollback_recovered() or any |
| 6821 | TRX_ISO_READ_UNCOMMITTED transactions. */ |
| 6822 | return(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 6823 | } |
| 6824 | |
| 6825 | return(btr_copy_externally_stored_fieldcxx . . $ btr_copy_externally_stored_field(c9f32e0dbefa3c3f).(len, data, |
| 6826 | zip_size, local_len, heap)); |
| 6827 | } |