MySQL  8.0.19
Source Code Documentation
btr0cur.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (c) 1994, 2019, Oracle and/or its affiliates. All Rights Reserved.
4 
5 This program is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License, version 2.0, as published by the
7 Free Software Foundation.
8 
9 This program is also distributed with certain software (including but not
10 limited to OpenSSL) that is licensed under separate terms, as designated in a
11 particular file or component or in included license documentation. The authors
12 of MySQL hereby grant you an additional permission to link the program and
13 your derivative works with the separately licensed software that they have
14 included with MySQL.
15 
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
19 for more details.
20 
21 You should have received a copy of the GNU General Public License along with
22 this program; if not, write to the Free Software Foundation, Inc.,
23 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 
25 *****************************************************************************/
26 
27 #include <stddef.h>
28 #include <sys/types.h>
29 
30 /** @file include/btr0cur.h
31  The index tree cursor
32 
33  Created 10/16/1994 Heikki Tuuri
34  *******************************************************/
35 
36 #ifndef btr0cur_h
37 #define btr0cur_h
38 
39 #include "btr0types.h"
40 #include "dict0dict.h"
41 #include "gis0type.h"
42 #include "page0cur.h"
43 #include "univ.i"
44 
45 /** Mode flags for btr_cur operations; these can be ORed */
46 enum {
47  /** do no undo logging */
49  /** do no record lock checking */
51  /** sys fields will be found in the update vector or inserted
52  entry */
54  /** btr_cur_pessimistic_update() must keep cursor position
55  when moving columns to big_rec */
57  /** the caller is creating the index or wants to bypass the
58  index->info.online creation log */
60  /** the caller of btr_cur_optimistic_update() or
61  btr_cur_update_in_place() will take care of
62  updating IBUF_BITMAP_FREE */
64 };
65 
66 /* btr_cur_latch_leaves() returns latched blocks and savepoints. */
68  /* left block, target block and right block */
70  ulint savepoints[3];
71 };
72 
73 #ifndef UNIV_HOTBACKUP
74 #include "ha0ha.h"
75 #include "que0types.h"
76 #include "row0types.h"
77 #endif /* !UNIV_HOTBACKUP */
78 
79 #define BTR_CUR_ADAPT
80 #define BTR_CUR_HASH_ADAPT
81 
82 #ifdef UNIV_DEBUG
83 /** Returns the page cursor component of a tree cursor.
84  @return pointer to page cursor component */
85 UNIV_INLINE
87  const btr_cur_t *cursor); /*!< in: tree cursor */
88 /** Returns the buffer block on which the tree cursor is positioned.
89  @return pointer to buffer block */
90 UNIV_INLINE
91 buf_block_t *btr_cur_get_block(const btr_cur_t *cursor); /*!< in: tree cursor */
92 /** Returns the record pointer of a tree cursor.
93  @return pointer to record */
94 UNIV_INLINE
95 rec_t *btr_cur_get_rec(const btr_cur_t *cursor); /*!< in: tree cursor */
96 #else /* UNIV_DEBUG */
97 #define btr_cur_get_page_cur(cursor) (&(cursor)->page_cur)
98 #define btr_cur_get_block(cursor) ((cursor)->page_cur.block)
99 #define btr_cur_get_rec(cursor) ((cursor)->page_cur.rec)
100 #endif /* UNIV_DEBUG */
101 /** Returns the compressed page on which the tree cursor is positioned.
102  @return pointer to compressed page, or NULL if the page is not compressed */
103 UNIV_INLINE
104 page_zip_des_t *btr_cur_get_page_zip(btr_cur_t *cursor); /*!< in: tree cursor */
105 /** Returns the page of a tree cursor.
106  @return pointer to page */
107 UNIV_INLINE
108 page_t *btr_cur_get_page(btr_cur_t *cursor); /*!< in: tree cursor */
109 /** Returns the index of a cursor.
110  @param cursor b-tree cursor
111  @return index */
112 #define btr_cur_get_index(cursor) ((cursor)->index)
113 
114 /** Positions a tree cursor at a given record.
115 @param[in] index index
116 @param[in] rec record in tree
117 @param[in] block buffer block of rec
118 @param[in] cursor cursor */
119 UNIV_INLINE
121  btr_cur_t *cursor);
122 
123 /** Optimistically latches the leaf page or pages requested.
124 @param[in] block guessed buffer block
125 @param[in] modify_clock modify clock value
126 @param[in,out] latch_mode BTR_SEARCH_LEAF, ...
127 @param[in,out] cursor cursor
128 @param[in] file file name
129 @param[in] line line where called
130 @param[in] mtr mini-transaction
131 @return true if success */
133  ib_uint64_t modify_clock,
134  ulint *latch_mode, btr_cur_t *cursor,
135  const char *file, ulint line, mtr_t *mtr);
136 
137 /** Searches an index tree and positions a tree cursor on a given level.
138  NOTE: n_fields_cmp in tuple must be set so that it cannot be compared
139  to node pointer page number fields on the upper levels of the tree!
140  Note that if mode is PAGE_CUR_LE, which is used in inserts, then
141  cursor->up_match and cursor->low_match both will have sensible values.
142  If mode is PAGE_CUR_GE, then up_match will a have a sensible value. */
144  dict_index_t *index, /*!< in: index */
145  ulint level, /*!< in: the tree level of search */
146  const dtuple_t *tuple, /*!< in: data tuple; NOTE: n_fields_cmp in
147  tuple must be set so that it cannot get
148  compared to the node ptr page number field! */
149  page_cur_mode_t mode, /*!< in: PAGE_CUR_L, ...;
150  NOTE that if the search is made using a unique
151  prefix of a record, mode should be PAGE_CUR_LE,
152  not PAGE_CUR_GE, as the latter may end up on
153  the previous page of the record! Inserts
154  should always be made using PAGE_CUR_LE to
155  search the position! */
156  ulint latch_mode, /*!< in: BTR_SEARCH_LEAF, ..., ORed with
157  at most one of BTR_INSERT, BTR_DELETE_MARK,
158  BTR_DELETE, or BTR_ESTIMATE;
159  cursor->left_block is used to store a pointer
160  to the left neighbor page, in the cases
161  BTR_SEARCH_PREV and BTR_MODIFY_PREV;
162  NOTE that if has_search_latch
163  is != 0, we maybe do not have a latch set
164  on the cursor page, we assume
165  the caller uses his search latch
166  to protect the record! */
167  btr_cur_t *cursor, /*!< in/out: tree cursor; the cursor page is
168  s- or x-latched, but see also above! */
169  ulint has_search_latch,
170  /*!< in: latch mode the caller
171  currently has on search system:
172  RW_S_LATCH, or 0 */
173  const char *file, /*!< in: file name */
174  ulint line, /*!< in: line where called */
175  mtr_t *mtr); /*!< in: mtr */
176 
177 /** Searches an index tree and positions a tree cursor on a given level.
178 This function will avoid placing latches the travesal path and so
179 should be used only for cases where-in latching is not needed.
180 
181 @param[in] index index
182 @param[in] level the tree level of search
183 @param[in] tuple data tuple; Note: n_fields_cmp in compared
184  to the node ptr page node field
185 @param[in] mode PAGE_CUR_L, ....
186  Insert should always be made using PAGE_CUR_LE
187  to search the position.
188 @param[in,out] cursor tree cursor; points to record of interest.
189 @param[in] file file name
190 @param[in] line line where called from
191 @param[in,out] mtr mtr
192 @param[in] mark_dirty
193  if true then mark the block as dirty */
195  dict_index_t *index, ulint level, const dtuple_t *tuple,
196  page_cur_mode_t mode, btr_cur_t *cursor, const char *file, ulint line,
197  mtr_t *mtr, bool mark_dirty = true);
198 
199 /** Opens a cursor at either end of an index. */
201  bool from_left, /*!< in: true if open to the low end,
202  false if to the high end */
203  dict_index_t *index, /*!< in: index */
204  ulint latch_mode, /*!< in: latch mode */
205  btr_cur_t *cursor, /*!< in/out: cursor */
206  ulint level, /*!< in: level to search for
207  (0=leaf) */
208  const char *file, /*!< in: file name */
209  ulint line, /*!< in: line where called */
210  mtr_t *mtr); /*!< in/out: mini-transaction */
211 #define btr_cur_open_at_index_side(f, i, l, c, lv, m) \
212  btr_cur_open_at_index_side_func(f, i, l, c, lv, __FILE__, __LINE__, m)
213 
214 /** Opens a cursor at either end of an index.
215 Avoid taking latches on buffer, just pin (by incrementing fix_count)
216 to keep them in buffer pool. This mode is used by intrinsic table
217 as they are not shared and so there is no need of latching.
218 @param[in] from_left true if open to low end, false if open
219  to high end.
220 @param[in] index index
221 @param[in,out] cursor cursor
222 @param[in] file file name
223 @param[in] line line where called
224 @param[in,out] mtr mini transaction
225 */
227  bool from_left, dict_index_t *index, btr_cur_t *cursor, ulint level,
228  const char *file, ulint line, mtr_t *mtr);
229 #define btr_cur_open_at_index_side_with_no_latch(f, i, c, lv, m) \
230  btr_cur_open_at_index_side_with_no_latch_func(f, i, c, lv, __FILE__, \
231  __LINE__, m)
232 
233 /** Positions a cursor at a randomly chosen position within a B-tree.
234  @return true if the index is available and we have put the cursor, false
235  if the index is unavailable */
237  dict_index_t *index, /*!< in: index */
238  ulint latch_mode, /*!< in: BTR_SEARCH_LEAF, ... */
239  btr_cur_t *cursor, /*!< in/out: B-tree cursor */
240  const char *file, /*!< in: file name */
241  ulint line, /*!< in: line where called */
242  mtr_t *mtr); /*!< in: mtr */
243 #define btr_cur_open_at_rnd_pos(i, l, c, m) \
244  btr_cur_open_at_rnd_pos_func(i, l, c, __FILE__, __LINE__, m)
245 /** Tries to perform an insert to a page in an index tree, next to cursor.
246  It is assumed that mtr holds an x-latch on the page. The operation does
247  not succeed if there is too little space on the page. If there is just
248  one record on the page, the insert will always succeed; this is to
249  prevent trying to split a page with just one record.
250  @return DB_SUCCESS, DB_WAIT_LOCK, DB_FAIL, or error number */
252  ulint flags, /*!< in: undo logging and locking flags: if not
253  zero, the parameters index and thr should be
254  specified */
255  btr_cur_t *cursor, /*!< in: cursor on page after which to insert;
256  cursor stays valid */
257  ulint **offsets, /*!< out: offsets on *rec */
258  mem_heap_t **heap, /*!< in/out: pointer to memory heap, or NULL */
259  dtuple_t *entry, /*!< in/out: entry to insert */
260  rec_t **rec, /*!< out: pointer to inserted record if
261  succeed */
262  big_rec_t **big_rec, /*!< out: big rec vector whose fields have to
263  be stored externally by the caller, or
264  NULL */
265  ulint n_ext, /*!< in: number of externally stored columns */
266  que_thr_t *thr, /*!< in: query thread or NULL */
267  mtr_t *mtr) /*!< in/out: mini-transaction;
268  if this function returns DB_SUCCESS on
269  a leaf page of a secondary index in a
270  compressed tablespace, the caller must
271  mtr_commit(mtr) before latching
272  any further pages */
273  MY_ATTRIBUTE((warn_unused_result));
274 /** Performs an insert on a page of an index tree. It is assumed that mtr
275  holds an x-latch on the tree and on the cursor page. If the insert is
276  made on the leaf level, to avoid deadlocks, mtr must also own x-latches
277  to brothers of page, if those brothers exist.
278  @return DB_SUCCESS or error number */
280  ulint flags, /*!< in: undo logging and locking flags: if not
281  zero, the parameter thr should be
282  specified; if no undo logging is specified,
283  then the caller must have reserved enough
284  free extents in the file space so that the
285  insertion will certainly succeed */
286  btr_cur_t *cursor, /*!< in: cursor after which to insert;
287  cursor stays valid */
288  ulint **offsets, /*!< out: offsets on *rec */
289  mem_heap_t **heap, /*!< in/out: pointer to memory heap
290  that can be emptied, or NULL */
291  dtuple_t *entry, /*!< in/out: entry to insert */
292  rec_t **rec, /*!< out: pointer to inserted record if
293  succeed */
294  big_rec_t **big_rec, /*!< out: big rec vector whose fields have to
295  be stored externally by the caller, or
296  NULL */
297  ulint n_ext, /*!< in: number of externally stored columns */
298  que_thr_t *thr, /*!< in: query thread or NULL */
299  mtr_t *mtr) /*!< in/out: mini-transaction */
300  MY_ATTRIBUTE((warn_unused_result));
301 /** See if there is enough place in the page modification log to log
302  an update-in-place.
303 
304  @retval false if out of space; IBUF_BITMAP_FREE will be reset
305  outside mtr if the page was recompressed
306  @retval true if enough place;
307 
308  IMPORTANT: The caller will have to update IBUF_BITMAP_FREE if this is
309  a secondary index leaf page. This has to be done either within the
310  same mini-transaction, or by invoking ibuf_reset_free_bits() before
311  mtr_commit(mtr). */
313  page_zip_des_t *page_zip, /*!< in/out: compressed page */
314  page_cur_t *cursor, /*!< in/out: B-tree page cursor */
315  dict_index_t *index, /*!< in: the index corresponding to cursor */
316 #ifdef UNIV_DEBUG
317  ulint *offsets, /*!< in/out: offsets of the cursor record */
318 #endif /* UNIV_DEBUG */
319  ulint length, /*!< in: size needed */
320  bool create, /*!< in: true=delete-and-insert,
321  false=update-in-place */
322  mtr_t *mtr) /*!< in/out: mini-transaction */
323  MY_ATTRIBUTE((warn_unused_result));
324 #ifdef UNIV_DEBUG
325 #define btr_cur_update_alloc_zip(page_zip, cursor, index, offsets, len, cr, \
326  mtr) \
327  btr_cur_update_alloc_zip_func(page_zip, cursor, index, offsets, len, cr, mtr)
328 #else /* UNIV_DEBUG */
329 #define btr_cur_update_alloc_zip(page_zip, cursor, index, offsets, len, cr, \
330  mtr) \
331  btr_cur_update_alloc_zip_func(page_zip, cursor, index, len, cr, mtr)
332 #endif /* UNIV_DEBUG */
333 /** Updates a record when the update causes no size changes in its fields.
334  @return locking or undo log related error code, or
335  @retval DB_SUCCESS on success
336  @retval DB_ZIP_OVERFLOW if there is not enough space left
337  on the compressed page (IBUF_BITMAP_FREE was reset outside mtr) */
339  ulint flags, /*!< in: undo logging and locking flags */
340  btr_cur_t *cursor, /*!< in: cursor on the record to update;
341  cursor stays valid and positioned on the
342  same record */
343  ulint *offsets, /*!< in/out: offsets on cursor->page_cur.rec */
344  const upd_t *update, /*!< in: update vector */
345  ulint cmpl_info, /*!< in: compiler info on secondary index
346  updates */
347  que_thr_t *thr, /*!< in: query thread, or NULL if
348  flags & (BTR_NO_LOCKING_FLAG
349  | BTR_NO_UNDO_LOG_FLAG
350  | BTR_CREATE_FLAG
351  | BTR_KEEP_SYS_FLAG) */
352  trx_id_t trx_id, /*!< in: transaction id */
353  mtr_t *mtr) /*!< in/out: mini-transaction; if this
354  is a secondary index, the caller must
355  mtr_commit(mtr) before latching any
356  further pages */
357  MY_ATTRIBUTE((warn_unused_result));
358 /** Writes a redo log record of updating a record in-place. */
360  ulint flags, /*!< in: undo logging and locking flags */
361  const rec_t *rec, /*!< in: record */
362  dict_index_t *index, /*!< in: index of the record */
363  const upd_t *update, /*!< in: update vector */
364  trx_id_t trx_id, /*!< in: transaction id */
365  roll_ptr_t roll_ptr, /*!< in: roll ptr */
366  mtr_t *mtr); /*!< in: mtr */
367 /** Tries to update a record on a page in an index tree. It is assumed that mtr
368  holds an x-latch on the page. The operation does not succeed if there is too
369  little space on the page or if the update would result in too empty a page,
370  so that tree compression is recommended.
371  @return error code, including
372  @retval DB_SUCCESS on success
373  @retval DB_OVERFLOW if the updated record does not fit
374  @retval DB_UNDERFLOW if the page would become too empty
375  @retval DB_ZIP_OVERFLOW if there is not enough space left
376  on the compressed page */
378  ulint flags, /*!< in: undo logging and locking flags */
379  btr_cur_t *cursor, /*!< in: cursor on the record to update;
380  cursor stays valid and positioned on the
381  same record */
382  ulint **offsets, /*!< out: offsets on cursor->page_cur.rec */
383  mem_heap_t **heap, /*!< in/out: pointer to NULL or memory heap */
384  const upd_t *update, /*!< in: update vector; this must also
385  contain trx id and roll ptr fields */
386  ulint cmpl_info, /*!< in: compiler info on secondary index
387  updates */
388  que_thr_t *thr, /*!< in: query thread, or NULL if
389  flags & (BTR_NO_UNDO_LOG_FLAG
390  | BTR_NO_LOCKING_FLAG
391  | BTR_CREATE_FLAG
392  | BTR_KEEP_SYS_FLAG) */
393  trx_id_t trx_id, /*!< in: transaction id */
394  mtr_t *mtr) /*!< in/out: mini-transaction; if this
395  is a secondary index, the caller must
396  mtr_commit(mtr) before latching any
397  further pages */
398  MY_ATTRIBUTE((warn_unused_result));
399 
400 /** Performs an update of a record on a page of a tree. It is assumed
401 that mtr holds an x-latch on the tree and on the cursor page. If the
402 update is made on the leaf level, to avoid deadlocks, mtr must also
403 own x-latches to brothers of page, if those brothers exist.
404 @param[in] flags undo logging, locking, and rollback flags
405 @param[in,out] cursor cursor on the record to update;
406  cursor may become invalid if *big_rec == NULL
407  || !(flags & BTR_KEEP_POS_FLAG)
408 @param[out] offsets offsets on cursor->page_cur.rec
409 @param[in,out] offsets_heap pointer to memory heap that can be emptied,
410  or NULL
411 @param[in,out] entry_heap memory heap for allocating big_rec and the
412  index tuple.
413 @param[out] big_rec big rec vector whose fields have to be stored
414  externally by the caller, or NULL
415 @param[in,out] update update vector; this is allowed to also contain
416  trx id and roll ptr fields. Non-updated columns
417  that are moved offpage will be appended to this.
418 @param[in] cmpl_info compiler info on secondary index updates
419 @param[in] thr query thread, or NULL if flags &
420  (BTR_NO_UNDO_LOG_FLAG | BTR_NO_LOCKING_FLAG |
421  BTR_CREATE_FLAG | BTR_KEEP_SYS_FLAG)
422 @param[in] trx_id transaction id
423 @param[in] undo_no undo number of the transaction. This is needed
424  for rollback to savepoint of partially updated LOB.
425 @param[in,out] mtr mini transaction; must be committed before latching
426  any further pages
427 @param[in] pcur the persistent cursor on the record to update.
428 @return DB_SUCCESS or error code */
430  ulint flags, btr_cur_t *cursor, ulint **offsets, mem_heap_t **offsets_heap,
431  mem_heap_t *entry_heap, big_rec_t **big_rec, upd_t *update, ulint cmpl_info,
432  que_thr_t *thr, trx_id_t trx_id, undo_no_t undo_no, mtr_t *mtr,
433  btr_pcur_t *pcur = nullptr) MY_ATTRIBUTE((warn_unused_result));
434 
435 /** Marks a clustered index record deleted. Writes an undo log record to
436  undo log on this delete marking. Writes in the trx id field the id
437  of the deleting transaction, and in the roll ptr field pointer to the
438  undo log record created.
439  @return DB_SUCCESS, DB_LOCK_WAIT, or error number */
441  ulint flags, /*!< in: undo logging and locking flags */
442  buf_block_t *block, /*!< in/out: buffer block of the record */
443  rec_t *rec, /*!< in/out: record */
444  dict_index_t *index, /*!< in: clustered index of the record */
445  const ulint *offsets, /*!< in: rec_get_offsets(rec) */
446  que_thr_t *thr, /*!< in: query thread */
447  const dtuple_t *entry, /*!< in: dtuple for the deleting record */
448  mtr_t *mtr) /*!< in/out: mini-transaction */
449  MY_ATTRIBUTE((warn_unused_result));
450 /** Sets a secondary index record delete mark to TRUE or FALSE.
451  @return DB_SUCCESS, DB_LOCK_WAIT, or error number */
453  ulint flags, /*!< in: locking flag */
454  btr_cur_t *cursor, /*!< in: cursor */
455  ibool val, /*!< in: value to set */
456  que_thr_t *thr, /*!< in: query thread */
457  mtr_t *mtr) /*!< in/out: mini-transaction */
458  MY_ATTRIBUTE((warn_unused_result));
459 /** Tries to compress a page of the tree if it seems useful. It is assumed
460  that mtr holds an x-latch on the tree and on the cursor page. To avoid
461  deadlocks, mtr must also own x-latches to brothers of page, if those
462  brothers exist. NOTE: it is assumed that the caller has reserved enough
463  free extents so that the compression will always succeed if done!
464  @return true if compression occurred */
466  btr_cur_t *cursor, /*!< in/out: cursor on the page to compress;
467  cursor does not stay valid if compression
468  occurs */
469  ibool adjust, /*!< in: TRUE if should adjust the
470  cursor position even if compression occurs */
471  mtr_t *mtr); /*!< in/out: mini-transaction */
472 /** Removes the record on which the tree cursor is positioned. It is assumed
473  that the mtr has an x-latch on the page where the cursor is positioned,
474  but no latch on the whole tree.
475  @return true if success, i.e., the page did not become too empty */
477  btr_cur_t *cursor, /*!< in: cursor on the record to delete;
478  cursor stays valid: if deletion succeeds,
479  on function exit it points to the successor
480  of the deleted record */
481 #ifdef UNIV_DEBUG
482  ulint flags, /*!< in: BTR_CREATE_FLAG or 0 */
483 #endif /* UNIV_DEBUG */
484  mtr_t *mtr) /*!< in: mtr; if this function returns
485  TRUE on a leaf page of a secondary
486  index, the mtr must be committed
487  before latching any further pages */
488  MY_ATTRIBUTE((warn_unused_result));
489 #ifdef UNIV_DEBUG
490 #define btr_cur_optimistic_delete(cursor, flags, mtr) \
491  btr_cur_optimistic_delete_func(cursor, flags, mtr)
492 #else /* UNIV_DEBUG */
493 #define btr_cur_optimistic_delete(cursor, flags, mtr) \
494  btr_cur_optimistic_delete_func(cursor, mtr)
495 #endif /* UNIV_DEBUG */
496 
497 /** Removes the record on which the tree cursor is positioned. Tries
498  to compress the page if its fillfactor drops below a threshold
499  or if it is the only page on the level. It is assumed that mtr holds
500  an x-latch on the tree and on the cursor page. To avoid deadlocks,
501  mtr must also own x-latches to brothers of page, if those brothers
502  exist.
503 @param[out] err DB_SUCCESS or DB_OUT_OF_FILE_SPACE; the latter may occur
504  because we may have to update node pointers on upper
505  levels, and in the case of variable length keys these may
506  actually grow in size
507 @param[in] has_reserved_extents TRUE if the caller has already reserved
508  enough free extents so that he knows
509  that the operation will succeed
510 @param[in] cursor cursor on the record to delete; if compression does not
511  occur, the cursor stays valid: it points to successor of
512  deleted record on function exit
513 @param[in] flags BTR_CREATE_FLAG or 0
514 @param[in] rollback true if performing rollback, false otherwise.
515 @param[in] trx_id the current transaction id.
516 @param[in] undo_no undo number of the transaction. This is needed for rollback
517  to savepoint of partially updated LOB.
518 @param[in] rec_type undo record type.
519 @param[in] mtr the mini transaction
520 @param[in] pcur persistent cursor on the record to delete.
521 @return true if compression occurred */
522 ibool btr_cur_pessimistic_delete(dberr_t *err, ibool has_reserved_extents,
523  btr_cur_t *cursor, ulint flags, bool rollback,
524  trx_id_t trx_id, undo_no_t undo_no,
525  ulint rec_type, mtr_t *mtr,
526  btr_pcur_t *pcur = nullptr);
527 
528 /** Parses a redo log record of updating a record in-place.
529  @return end of log record or NULL */
531  byte *ptr, /*!< in: buffer */
532  byte *end_ptr, /*!< in: buffer end */
533  page_t *page, /*!< in/out: page or NULL */
534  page_zip_des_t *page_zip, /*!< in/out: compressed page, or NULL */
535  dict_index_t *index); /*!< in: index corresponding to page */
536 /** Parses the redo log record for delete marking or unmarking of a clustered
537  index record.
538  @return end of log record or NULL */
540  byte *ptr, /*!< in: buffer */
541  byte *end_ptr, /*!< in: buffer end */
542  page_t *page, /*!< in/out: page or NULL */
543  page_zip_des_t *page_zip, /*!< in/out: compressed page, or NULL */
544  dict_index_t *index); /*!< in: index corresponding to page */
545 /** Parses the redo log record for delete marking or unmarking of a secondary
546  index record.
547  @return end of log record or NULL */
549  byte *ptr, /*!< in: buffer */
550  byte *end_ptr, /*!< in: buffer end */
551  page_t *page, /*!< in/out: page or NULL */
552  page_zip_des_t *page_zip); /*!< in/out: compressed page, or NULL */
553 #ifndef UNIV_HOTBACKUP
554 
555 /** Estimates the number of rows in a given index range.
556 @param[in] index index
557 @param[in] tuple1 range start, may also be empty tuple
558 @param[in] mode1 search mode for range start
559 @param[in] tuple2 range end, may also be empty tuple
560 @param[in] mode2 search mode for range end
561 @return estimated number of rows */
563  const dtuple_t *tuple1,
564  page_cur_mode_t mode1,
565  const dtuple_t *tuple2,
566  page_cur_mode_t mode2);
567 
568 /** Estimates the number of different key values in a given index, for
569  each n-column prefix of the index where 1 <= n <=
570  dict_index_get_n_unique(index). The estimates are stored in the array
571  index->stat_n_diff_key_vals[] (indexed 0..n_uniq-1) and the number of pages
572  that were sampled is saved in index->stat_n_sample_sizes[]. If
573  innodb_stats_method is nulls_ignored, we also record the number of non-null
574  values for each prefix and stored the estimates in array
575  index->stat_n_non_null_key_vals.
576  @return true if the index is available and we get the estimated numbers,
577  false if the index is unavailable. */
579  dict_index_t *index); /*!< in: index */
580 
581 /** Copies an externally stored field of a record to mem heap.
582 @param[in] trx the trx doing the operation.
583 @param[in] index index containing the LOB.
584 @param[in] rec record in a clustered index; must be
585  protected by a lock or a page latch
586 @param[in] offsets array returned by rec_get_offsets()
587 @param[in] page_size BLOB page size
588 @param[in] no field number
589 @param[out] len length of the field
590 @param[out] lob_version version of lob
591 @param[in] is_sdi true for SDI Indexes
592 @param[in,out] heap mem heap
593 @return the field copied to heap, or NULL if the field is incomplete */
595  trx_t *trx, dict_index_t *index, const rec_t *rec, const ulint *offsets,
596  const page_size_t &page_size, ulint no, ulint *len, size_t *lob_version,
597 #ifdef UNIV_DEBUG
598  bool is_sdi,
599 #endif /* UNIV_DEBUG */
600  mem_heap_t *heap);
601 
602 /** Sets a secondary index record's delete mark to the given value. This
603  function is only used by the insert buffer merge mechanism. */
605  rec_t *rec, /*!< in/out: record */
606  page_zip_des_t *page_zip, /*!< in/out: compressed page
607  corresponding to rec, or NULL
608  when the tablespace is uncompressed */
609  ibool val, /*!< in: value to set */
610  mtr_t *mtr); /*!< in/out: mini-transaction */
611 
612 /** The following function is used to set the deleted bit of a record.
613 @param[in,out] rec physical record
614 @param[in,out] page_zip compressed page (or NULL)
615 @param[in] flag nonzero if delete marked */
616 UNIV_INLINE
617 void btr_rec_set_deleted_flag(rec_t *rec, page_zip_des_t *page_zip, ulint flag);
618 
619 /** Latches the leaf page or pages requested.
620 @param[in] block leaf page where the search converged
621 @param[in] page_id page id of the leaf
622 @param[in] latch_mode BTR_SEARCH_LEAF, ...
623 @param[in] cursor cursor
624 @param[in] mtr mini-transaction
625 @return blocks and savepoints which actually latched. */
627  const page_id_t &page_id,
628  const page_size_t &page_size,
629  ulint latch_mode, btr_cur_t *cursor,
630  mtr_t *mtr);
631 #endif /* !UNIV_HOTBACKUP */
632 
633 /*######################################################################*/
634 
635 /** In the pessimistic delete, if the page data size drops below this
636 limit, merging it to a neighbor is tried */
637 #define BTR_CUR_PAGE_COMPRESS_LIMIT(index) \
638  ((UNIV_PAGE_SIZE * (ulint)((index)->merge_threshold)) / 100)
639 
640 /** A slot in the path array. We store here info on a search path down the
641 tree. Each slot contains data on a single level of the tree. */
642 struct btr_path_t {
643  /* Assume a page like:
644  records: (inf, a, b, c, d, sup)
645  index of the record: 0, 1, 2, 3, 4, 5
646  */
647 
648  /** Index of the record where the page cursor stopped on this level
649  (index in alphabetical order). Value ULINT_UNDEFINED denotes array
650  end. In the above example, if the search stopped on record 'c', then
651  nth_rec will be 3. */
652  ulint nth_rec{ULINT_UNDEFINED};
653 
654  /** Number of the records on the page, not counting inf and sup.
655  In the above example n_recs will be 4. */
656  ulint n_recs{ULINT_UNDEFINED};
657 
658  /** Number of the page containing the record. */
660 
661  /** Level of the page. If later we fetch the page under page_no
662  and it is on a different level then we know that the tree has been
663  reorganized. */
664  ulint page_level{ULINT_UNDEFINED};
665 };
666 
667 #define BTR_PATH_ARRAY_N_SLOTS 250 /*!< size of path array (in slots) */
668 
669 /** Values for the flag documenting the used search method */
671  BTR_CUR_UNSET = 0, /*!< Flag for initialization only,
672  not in real use. */
673  BTR_CUR_HASH = 1, /*!< successful shortcut using
674  the hash index */
675  BTR_CUR_HASH_FAIL, /*!< failure using hash, success using
676  binary search: the misleading hash
677  reference is stored in the field
678  hash_node, and might be necessary to
679  update */
680  BTR_CUR_BINARY, /*!< success using the binary search */
681  BTR_CUR_INSERT_TO_IBUF, /*!< performed the intended insert to
682  the insert buffer */
683  BTR_CUR_DEL_MARK_IBUF, /*!< performed the intended delete
684  mark in the insert/delete buffer */
685  BTR_CUR_DELETE_IBUF, /*!< performed the intended delete in
686  the insert/delete buffer */
687  BTR_CUR_DELETE_REF /*!< row_purge_poss_sec() failed */
688 };
689 
690 /** The tree cursor: the definition appears here only for the compiler
691 to know struct size! */
692 struct btr_cur_t {
693  dict_index_t *index{nullptr}; /*!< index where positioned */
694  page_cur_t page_cur; /*!< page cursor */
695  purge_node_t *purge_node{nullptr}; /*!< purge node, for BTR_DELETE */
696  buf_block_t *left_block{nullptr}; /*!< this field is used to store
697  a pointer to the left neighbor
698  page, in the cases
699  BTR_SEARCH_PREV and
700  BTR_MODIFY_PREV */
701  /*------------------------------*/
702  que_thr_t *thr{nullptr}; /*!< this field is only used
703  when btr_cur_search_to_nth_level
704  is called for an index entry
705  insertion: the calling query
706  thread is passed here to be
707  used in the insert buffer */
708  /*------------------------------*/
709  /** The following fields are used in
710  btr_cur_search_to_nth_level to pass information: */
711  /* @{ */
712  btr_cur_method flag{BTR_CUR_UNSET}; /*!< Search method used */
713  ulint tree_height{0}; /*!< Tree height if the search is done
714  for a pessimistic insert or update
715  operation */
716  ulint up_match{0}; /*!< If the search mode was PAGE_CUR_LE,
717  the number of matched fields to the
718  the first user record to the right of
719  the cursor record after
720  btr_cur_search_to_nth_level;
721  for the mode PAGE_CUR_GE, the matched
722  fields to the first user record AT THE
723  CURSOR or to the right of it;
724  NOTE that the up_match and low_match
725  values may exceed the correct values
726  for comparison to the adjacent user
727  record if that record is on a
728  different leaf page! (See the note in
729  row_ins_duplicate_error_in_clust.) */
730  ulint up_bytes{0}; /*!< number of matched bytes to the
731  right at the time cursor positioned;
732  only used internally in searches: not
733  defined after the search */
734  ulint low_match{0}; /*!< if search mode was PAGE_CUR_LE,
735  the number of matched fields to the
736  first user record AT THE CURSOR or
737  to the left of it after
738  btr_cur_search_to_nth_level;
739  NOT defined for PAGE_CUR_GE or any
740  other search modes; see also the NOTE
741  in up_match! */
742  ulint low_bytes{0}; /*!< number of matched bytes to the
743  left at the time cursor positioned;
744  only used internally in searches: not
745  defined after the search */
746  ulint n_fields{0}; /*!< prefix length used in a hash
747  search if hash_node != NULL */
748  ulint n_bytes{0}; /*!< hash prefix bytes if hash_node !=
749  NULL */
750  ulint fold{0}; /*!< fold value used in the search if
751  flag is BTR_CUR_HASH */
752  /* @} */
753  btr_path_t *path_arr{nullptr}; /*!< in estimating the number of
754  rows in range, we store in this array
755  information of the path through
756  the tree */
757  rtr_info_t *rtr_info{nullptr}; /*!< rtree search info */
758 
759  /** Ownership of the above rtr_info member. */
760  bool m_own_rtr_info = true;
761 
762  /** If cursor is used in a scan or simple page fetch. */
764 };
765 
766 /** The following function is used to set the deleted bit of a record.
767 @param[in,out] rec physical record
768 @param[in,out] page_zip compressed page (or NULL)
769 @param[in] flag nonzero if delete marked */
770 UNIV_INLINE
771 void btr_rec_set_deleted_flag(rec_t *rec, page_zip_des_t *page_zip, ulint flag);
772 
773 /** If pessimistic delete fails because of lack of file space, there
774 is still a good change of success a little later. Try this many
775 times. */
776 #define BTR_CUR_RETRY_DELETE_N_TIMES 100
777 /** If pessimistic delete fails because of lack of file space, there
778 is still a good change of success a little later. Sleep this many
779 microseconds between retries. */
780 #define BTR_CUR_RETRY_SLEEP_TIME 50000
781 
782 /** Number of searches down the B-tree in btr_cur_search_to_nth_level(). */
783 extern ulint btr_cur_n_non_sea;
784 /** Number of successful adaptive hash index lookups in
785 btr_cur_search_to_nth_level(). */
786 extern ulint btr_cur_n_sea;
787 /** Old value of btr_cur_n_non_sea. Copied by
788 srv_refresh_innodb_monitor_stats(). Referenced by
789 srv_printf_innodb_monitor(). */
790 extern ulint btr_cur_n_non_sea_old;
791 /** Old value of btr_cur_n_sea. Copied by
792 srv_refresh_innodb_monitor_stats(). Referenced by
793 srv_printf_innodb_monitor(). */
794 extern ulint btr_cur_n_sea_old;
795 
796 #ifdef UNIV_DEBUG
797 /* Flag to limit optimistic insert records */
799 #endif /* UNIV_DEBUG */
800 
801 #include "btr0cur.ic"
802 
803 #endif
page_no_t
uint32 page_no_t
Page number.
Definition: api0api.h:57
rtr_info
Vectors holding the matching internal pages/nodes and leaf records.
Definition: gis0type.h:108
rollback
static bool rollback(THD *thd)
Abort the current statement and transaction.
Definition: sql_cmd_srs.cc:139
btr_path_t
A slot in the path array.
Definition: btr0cur.h:642
roll_ptr_t
ib_id_t roll_ptr_t
Rollback pointer (DB_ROLL_PTR, DATA_ROLL_PTR)
Definition: trx0types.h:150
Page_fetch::NORMAL
@ NORMAL
Get always.
dtuple_t
Structure for an SQL data tuple of fields (logical record)
Definition: data0data.h:716
btr_pcur_t
Definition: btr0pcur.h:177
btr_cur_t::up_match
ulint up_match
If the search mode was PAGE_CUR_LE, the number of matched fields to the the first user record to the ...
Definition: btr0cur.h:716
btr_cur_optimistic_insert
dberr_t btr_cur_optimistic_insert(ulint flags, btr_cur_t *cursor, ulint **offsets, mem_heap_t **heap, dtuple_t *entry, rec_t **rec, big_rec_t **big_rec, ulint n_ext, que_thr_t *thr, mtr_t *mtr)
Tries to perform an insert to a page in an index tree, next to cursor.
Definition: btr0cur.cc:2691
BTR_CUR_BINARY
@ BTR_CUR_BINARY
success using the binary search
Definition: btr0cur.h:680
page_t
byte page_t
Type of the index page.
Definition: page0types.h:133
undo_no_t
ib_id_t undo_no_t
Undo number.
Definition: trx0types.h:152
btr_cur_t::flag
btr_cur_method flag
The following fields are used in btr_cur_search_to_nth_level to pass information:
Definition: btr0cur.h:712
btr_cur_t::up_bytes
ulint up_bytes
number of matched bytes to the right at the time cursor positioned; only used internally in searches:...
Definition: btr0cur.h:730
BTR_CUR_DELETE_REF
@ BTR_CUR_DELETE_REF
row_purge_poss_sec() failed
Definition: btr0cur.h:687
btr_cur_n_non_sea_old
ulint btr_cur_n_non_sea_old
Old value of btr_cur_n_non_sea.
Definition: btr0cur.cc:133
gis0type.h
btr_latch_leaves_t::savepoints
ulint savepoints[3]
Definition: btr0cur.h:70
trx_id_t
ib_id_t trx_id_t
Transaction identifier (DB_TRX_ID, DATA_TRX_ID)
Definition: trx0types.h:148
btr_cur_parse_update_in_place
byte * btr_cur_parse_update_in_place(byte *ptr, byte *end_ptr, page_t *page, page_zip_des_t *page_zip, dict_index_t *index)
Parses a redo log record of updating a record in-place.
Definition: btr0cur.cc:3223
purge_node_t
Definition: row0purge.h:81
page_cur_mode_t
page_cur_mode_t
Definition: page0types.h:158
btr_cur_latch_leaves
btr_latch_leaves_t btr_cur_latch_leaves(buf_block_t *block, const page_id_t &page_id, const page_size_t &page_size, ulint latch_mode, btr_cur_t *cursor, mtr_t *mtr)
Latches the leaf page or pages requested.
Definition: btr0cur.cc:179
btr_cur_t::path_arr
btr_path_t * path_arr
in estimating the number of rows in range, we store in this array information of the path through the...
Definition: btr0cur.h:753
dict_index_t
Data structure for an index.
Definition: dict0mem.h:869
mtr_t
Mini-transaction handle and buffer.
Definition: mtr0mtr.h:169
btr_cur_t::n_bytes
ulint n_bytes
hash prefix bytes if hash_node != NULL
Definition: btr0cur.h:748
btr_cur_t::tree_height
ulint tree_height
Tree height if the search is done for a pessimistic insert or update operation.
Definition: btr0cur.h:713
page_cur_t
Index page cursor.
Definition: page0cur.h:315
btr_path_t::n_recs
ulint n_recs
Number of the records on the page, not counting inf and sup.
Definition: btr0cur.h:656
BTR_CUR_UNSET
@ BTR_CUR_UNSET
Flag for initialization only, not in real use.
Definition: btr0cur.h:671
btr_cur_get_block
UNIV_INLINE buf_block_t * btr_cur_get_block(const btr_cur_t *cursor)
Returns the buffer block on which the tree cursor is positioned.
ha0ha.h
BTR_KEEP_IBUF_BITMAP
@ BTR_KEEP_IBUF_BITMAP
the caller of btr_cur_optimistic_update() or btr_cur_update_in_place() will take care of updating IBU...
Definition: btr0cur.h:63
dberr_t
dberr_t
Definition: db0err.h:38
btr_latch_leaves_t::blocks
buf_block_t * blocks[3]
Definition: btr0cur.h:69
btr_cur_open_at_rnd_pos_func
bool btr_cur_open_at_rnd_pos_func(dict_index_t *index, ulint latch_mode, btr_cur_t *cursor, const char *file, ulint line, mtr_t *mtr)
Positions a cursor at a randomly chosen position within a B-tree.
Definition: btr0cur.cc:2282
buf_block_t
The buffer control block structure.
Definition: buf0buf.h:1318
BTR_KEEP_POS_FLAG
@ BTR_KEEP_POS_FLAG
btr_cur_pessimistic_update() must keep cursor position when moving columns to big_rec
Definition: btr0cur.h:56
btr_latch_leaves_t
Definition: btr0cur.h:67
btr_cur_get_page
UNIV_INLINE page_t * btr_cur_get_page(btr_cur_t *cursor)
Returns the page of a tree cursor.
btr_cur_method
btr_cur_method
Values for the flag documenting the used search method.
Definition: btr0cur.h:670
btr_cur_t::n_fields
ulint n_fields
prefix length used in a hash search if hash_node != NULL
Definition: btr0cur.h:746
json_binary::err
static Value err()
Create a Value object that represents an error condition.
Definition: json_binary.cc:908
btr_cur_pessimistic_insert
dberr_t btr_cur_pessimistic_insert(ulint flags, btr_cur_t *cursor, ulint **offsets, mem_heap_t **heap, dtuple_t *entry, rec_t **rec, big_rec_t **big_rec, ulint n_ext, que_thr_t *thr, mtr_t *mtr)
Performs an insert on a page of an index tree.
Definition: btr0cur.cc:2966
rec_t
byte rec_t
Definition: rem0types.h:39
btr_path_t::nth_rec
ulint nth_rec
Index of the record where the page cursor stopped on this level (index in alphabetical order).
Definition: btr0cur.h:652
big_rec_t
Storage format for overflow data in a big record, that is, a clustered index record which needs exter...
Definition: data0data.h:853
que0types.h
mem_block_info_t
The info structure stored at the beginning of a heap block.
Definition: mem0mem.h:337
page_zip_des_t
Compressed page descriptor.
Definition: page0types.h:182
Page_fetch
Page_fetch
Definition: buf0buf.h:57
btr_cur_open_at_index_side_with_no_latch_func
void btr_cur_open_at_index_side_with_no_latch_func(bool from_left, dict_index_t *index, btr_cur_t *cursor, ulint level, const char *file, ulint line, mtr_t *mtr)
Opens a cursor at either end of an index.
Definition: btr0cur.cc:2198
btr_cur_t::m_own_rtr_info
bool m_own_rtr_info
Ownership of the above rtr_info member.
Definition: btr0cur.h:760
btr_cur_set_deleted_flag_for_ibuf
void btr_cur_set_deleted_flag_for_ibuf(rec_t *rec, page_zip_des_t *page_zip, ibool val, mtr_t *mtr)
Sets a secondary index record's delete mark to the given value.
Definition: btr0cur.cc:4498
btr_cur_t::purge_node
purge_node_t * purge_node
purge node, for BTR_DELETE
Definition: btr0cur.h:695
btr_cur_limit_optimistic_insert_debug
uint btr_cur_limit_optimistic_insert_debug
Definition: btr0cur.cc:141
btr_cur_t::low_bytes
ulint low_bytes
number of matched bytes to the left at the time cursor positioned; only used internally in searches: ...
Definition: btr0cur.h:742
btr_cur_get_rec
UNIV_INLINE rec_t * btr_cur_get_rec(const btr_cur_t *cursor)
Returns the record pointer of a tree cursor.
page_size_t
Page size descriptor.
Definition: page0size.h:50
btr_estimate_n_rows_in_range
int64_t btr_estimate_n_rows_in_range(dict_index_t *index, const dtuple_t *tuple1, page_cur_mode_t mode1, const dtuple_t *tuple2, page_cur_mode_t mode2)
Estimates the number of rows in a given index range.
Definition: btr0cur.cc:5386
BTR_CUR_DELETE_IBUF
@ BTR_CUR_DELETE_IBUF
performed the intended delete in the insert/delete buffer
Definition: btr0cur.h:685
page0cur.h
btr_cur_update_in_place_log
void btr_cur_update_in_place_log(ulint flags, const rec_t *rec, dict_index_t *index, const upd_t *update, trx_id_t trx_id, roll_ptr_t roll_ptr, mtr_t *mtr)
Writes a redo log record of updating a record in-place.
Definition: btr0cur.cc:3166
page
int page
Definition: ctype-mb.cc:1232
btr_cur_t::page_cur
page_cur_t page_cur
page cursor
Definition: btr0cur.h:694
row0types.h
uint
unsigned int uint
Definition: uca-dump.cc:29
btr_cur_get_page_cur
UNIV_INLINE page_cur_t * btr_cur_get_page_cur(const btr_cur_t *cursor)
Returns the page cursor component of a tree cursor.
BTR_KEEP_SYS_FLAG
@ BTR_KEEP_SYS_FLAG
sys fields will be found in the update vector or inserted entry
Definition: btr0cur.h:53
BTR_CUR_HASH_FAIL
@ BTR_CUR_HASH_FAIL
failure using hash, success using binary search: the misleading hash reference is stored in the field...
Definition: btr0cur.h:675
btr_cur_open_at_index_side_func
void btr_cur_open_at_index_side_func(bool from_left, dict_index_t *index, ulint latch_mode, btr_cur_t *cursor, ulint level, const char *file, ulint line, mtr_t *mtr)
Opens a cursor at either end of an index.
Definition: btr0cur.cc:1873
btr_cur_t::thr
que_thr_t * thr
this field is only used when btr_cur_search_to_nth_level is called for an index entry insertion: the ...
Definition: btr0cur.h:702
btr0types.h
btr_cur_update_in_place
dberr_t btr_cur_update_in_place(ulint flags, btr_cur_t *cursor, ulint *offsets, const upd_t *update, ulint cmpl_info, que_thr_t *thr, trx_id_t trx_id, mtr_t *mtr)
Updates a record when the update causes no size changes in its fields.
Definition: btr0cur.cc:3376
btr_cur_search_to_nth_level_with_no_latch
void btr_cur_search_to_nth_level_with_no_latch(dict_index_t *index, ulint level, const dtuple_t *tuple, page_cur_mode_t mode, btr_cur_t *cursor, const char *file, ulint line, mtr_t *mtr, bool mark_dirty=true)
Searches an index tree and positions a tree cursor on a given level.
Definition: btr0cur.cc:1745
btr_cur_t
The tree cursor: the definition appears here only for the compiler to know struct size!
Definition: btr0cur.h:692
btr_cur_t::index
dict_index_t * index
index where positioned
Definition: btr0cur.h:693
btr_rec_set_deleted_flag
UNIV_INLINE void btr_rec_set_deleted_flag(rec_t *rec, page_zip_des_t *page_zip, ulint flag)
The following function is used to set the deleted bit of a record.
update
static uint update
Definition: myisamlog.cc:88
btr_cur_parse_del_mark_set_clust_rec
byte * btr_cur_parse_del_mark_set_clust_rec(byte *ptr, byte *end_ptr, page_t *page, page_zip_des_t *page_zip, dict_index_t *index)
Parses the redo log record for delete marking or unmarking of a clustered index record.
Definition: btr0cur.cc:4234
btr_cur_del_mark_set_sec_rec
dberr_t btr_cur_del_mark_set_sec_rec(ulint flags, btr_cur_t *cursor, ibool val, que_thr_t *thr, mtr_t *mtr)
Sets a secondary index record delete mark to TRUE or FALSE.
Definition: btr0cur.cc:4458
page_id_t
Page identifier.
Definition: buf0types.h:153
btr_cur_get_page_zip
UNIV_INLINE page_zip_des_t * btr_cur_get_page_zip(btr_cur_t *cursor)
Returns the compressed page on which the tree cursor is positioned.
BTR_CREATE_FLAG
@ BTR_CREATE_FLAG
the caller is creating the index or wants to bypass the index->info.online creation log
Definition: btr0cur.h:59
btr_cur_t::low_match
ulint low_match
if search mode was PAGE_CUR_LE, the number of matched fields to the first user record AT THE CURSOR o...
Definition: btr0cur.h:734
_entry
Definition: completion_hash.h:34
btr_cur_update_alloc_zip_func
bool btr_cur_update_alloc_zip_func(page_zip_des_t *page_zip, page_cur_t *cursor, dict_index_t *index, ulint *offsets, ulint length, bool create, mtr_t *mtr)
See if there is enough place in the page modification log to log an update-in-place.
Definition: btr0cur.cc:3303
btr_cur_pessimistic_delete
ibool btr_cur_pessimistic_delete(dberr_t *err, ibool has_reserved_extents, btr_cur_t *cursor, ulint flags, bool rollback, trx_id_t trx_id, undo_no_t undo_no, ulint rec_type, mtr_t *mtr, btr_pcur_t *pcur=nullptr)
Removes the record on which the tree cursor is positioned.
Definition: btr0cur.cc:4663
btr_cur_t::fold
ulint fold
fold value used in the search if flag is BTR_CUR_HASH
Definition: btr0cur.h:750
btr_cur_position
UNIV_INLINE void btr_cur_position(dict_index_t *index, rec_t *rec, buf_block_t *block, btr_cur_t *cursor)
Positions a tree cursor at a given record.
btr_cur_n_non_sea
ulint btr_cur_n_non_sea
Number of searches down the B-tree in btr_cur_search_to_nth_level().
Definition: btr0cur.cc:126
btr_path_t::page_no
page_no_t page_no
Number of the page containing the record.
Definition: btr0cur.h:659
btr_cur_search_to_nth_level
void btr_cur_search_to_nth_level(dict_index_t *index, ulint level, const dtuple_t *tuple, page_cur_mode_t mode, ulint latch_mode, btr_cur_t *cursor, ulint has_search_latch, const char *file, ulint line, mtr_t *mtr)
Searches an index tree and positions a tree cursor on a given level.
Definition: btr0cur.cc:623
BTR_NO_LOCKING_FLAG
@ BTR_NO_LOCKING_FLAG
do no record lock checking
Definition: btr0cur.h:50
btr_cur_n_sea_old
ulint btr_cur_n_sea_old
Old value of btr_cur_n_sea.
Definition: btr0cur.cc:137
FIL_NULL
constexpr page_no_t FIL_NULL
'null' (undefined) page offset in the context of file spaces
Definition: fil0fil.h:884
gis::length
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:75
btr_rec_copy_externally_stored_field_func
byte * btr_rec_copy_externally_stored_field_func(trx_t *trx, dict_index_t *index, const rec_t *rec, const ulint *offsets, const page_size_t &page_size, ulint no, ulint *len, size_t *lob_version, bool is_sdi, mem_heap_t *heap)
Copies an externally stored field of a record to mem heap.
upd_t
Definition: row0upd.h:570
btr_cur_pessimistic_update
dberr_t btr_cur_pessimistic_update(ulint flags, btr_cur_t *cursor, ulint **offsets, mem_heap_t **offsets_heap, mem_heap_t *entry_heap, big_rec_t **big_rec, upd_t *update, ulint cmpl_info, que_thr_t *thr, trx_id_t trx_id, undo_no_t undo_no, mtr_t *mtr, btr_pcur_t *pcur=nullptr)
Performs an update of a record on a page of a tree.
Definition: btr0cur.cc:3812
btr_estimate_number_of_different_key_vals
bool btr_estimate_number_of_different_key_vals(dict_index_t *index)
Estimates the number of different key values in a given index, for each n-column prefix of the index ...
Definition: btr0cur.cc:5438
btr_cur_t::left_block
buf_block_t * left_block
this field is used to store a pointer to the left neighbor page, in the cases BTR_SEARCH_PREV and BTR...
Definition: btr0cur.h:696
btr_cur_t::m_fetch_mode
Page_fetch m_fetch_mode
If cursor is used in a scan or simple page fetch.
Definition: btr0cur.h:763
btr_cur_optimistic_update
dberr_t btr_cur_optimistic_update(ulint flags, btr_cur_t *cursor, ulint **offsets, mem_heap_t **heap, const upd_t *update, ulint cmpl_info, que_thr_t *thr, trx_id_t trx_id, mtr_t *mtr)
Tries to update a record on a page in an index tree.
Definition: btr0cur.cc:3523
btr_cur_optimistic_latch_leaves
bool btr_cur_optimistic_latch_leaves(buf_block_t *block, ib_uint64_t modify_clock, ulint *latch_mode, btr_cur_t *cursor, const char *file, ulint line, mtr_t *mtr)
Optimistically latches the leaf page or pages requested.
Definition: btr0cur.cc:333
btr_cur_del_mark_set_clust_rec
dberr_t btr_cur_del_mark_set_clust_rec(ulint flags, buf_block_t *block, rec_t *rec, dict_index_t *index, const ulint *offsets, que_thr_t *thr, const dtuple_t *entry, mtr_t *mtr)
Marks a clustered index record deleted.
Definition: btr0cur.cc:4309
btr_cur_parse_del_mark_set_sec_rec
byte * btr_cur_parse_del_mark_set_sec_rec(byte *ptr, byte *end_ptr, page_t *page, page_zip_des_t *page_zip)
Parses the redo log record for delete marking or unmarking of a secondary index record.
Definition: btr0cur.cc:4419
btr_cur_compress_if_useful
ibool btr_cur_compress_if_useful(btr_cur_t *cursor, ibool adjust, mtr_t *mtr)
Tries to compress a page of the tree if it seems useful.
Definition: btr0cur.cc:4526
que_thr_t
Definition: que0que.h:246
BTR_CUR_INSERT_TO_IBUF
@ BTR_CUR_INSERT_TO_IBUF
performed the intended insert to the insert buffer
Definition: btr0cur.h:681
BTR_CUR_HASH
@ BTR_CUR_HASH
successful shortcut using the hash index
Definition: btr0cur.h:673
btr_cur_optimistic_delete_func
ibool btr_cur_optimistic_delete_func(btr_cur_t *cursor, ulint flags, mtr_t *mtr)
Removes the record on which the tree cursor is positioned.
Definition: btr0cur.cc:4570
dict0dict.h
btr_path_t::page_level
ulint page_level
Level of the page.
Definition: btr0cur.h:664
btr_cur_n_sea
ulint btr_cur_n_sea
Number of successful adaptive hash index lookups in btr_cur_search_to_nth_level().
Definition: btr0cur.cc:129
index
char * index(const char *, int c)
Definition: mysql.cc:2875
trx_t
Definition: trx0trx.h:780
flag
static int flag
Definition: hp_test1.cc:39
BTR_CUR_DEL_MARK_IBUF
@ BTR_CUR_DEL_MARK_IBUF
performed the intended delete mark in the insert/delete buffer
Definition: btr0cur.h:683
flags
static int flags[50]
Definition: hp_test1.cc:39
BTR_NO_UNDO_LOG_FLAG
@ BTR_NO_UNDO_LOG_FLAG
do no undo logging
Definition: btr0cur.h:48