1
1
/*****************************************************************************
3
Copyright (c) 1994, 2009, Innobase Oy. All Rights Reserved.
3
Copyright (C) 1994, 2010, Innobase Oy. All Rights Reserved.
5
5
This program is free software; you can redistribute it and/or modify it under
6
6
the terms of the GNU General Public License as published by the Free Software
11
11
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
13
You should have received a copy of the GNU General Public License along with
14
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15
Place, Suite 330, Boston, MA 02111-1307 USA
14
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15
St, Fifth Floor, Boston, MA 02110-1301 USA
17
17
*****************************************************************************/
138
138
should always be made using PAGE_CUR_LE to
139
139
search the position! */
140
140
ulint latch_mode, /*!< in: BTR_SEARCH_LEAF, ..., ORed with
141
BTR_INSERT and BTR_ESTIMATE;
141
at most one of BTR_INSERT, BTR_DELETE_MARK,
142
BTR_DELETE, or BTR_ESTIMATE;
142
143
cursor->left_block is used to store a pointer
143
144
to the left neighbor page, in the cases
144
145
BTR_SEARCH_PREV and BTR_MODIFY_PREV;
152
153
ulint has_search_latch,/*!< in: latch mode the caller
153
154
currently has on btr_search_latch:
154
155
RW_S_LATCH, or 0 */
156
const char* file, /*!< in: file name */
157
ulint line, /*!< in: line where called */
155
158
mtr_t* mtr); /*!< in: mtr */
156
159
/*****************************************************************//**
157
160
Opens a cursor at either end of an index. */
160
btr_cur_open_at_index_side(
161
/*=======================*/
163
btr_cur_open_at_index_side_func(
164
/*============================*/
162
165
ibool from_left, /*!< in: TRUE if open to the low end,
163
166
FALSE if to the high end */
164
167
dict_index_t* index, /*!< in: index */
165
168
ulint latch_mode, /*!< in: latch mode */
166
169
btr_cur_t* cursor, /*!< in: cursor */
170
const char* file, /*!< in: file name */
171
ulint line, /*!< in: line where called */
167
172
mtr_t* mtr); /*!< in: mtr */
173
#define btr_cur_open_at_index_side(f,i,l,c,m) \
174
btr_cur_open_at_index_side_func(f,i,l,c,__FILE__,__LINE__,m)
168
175
/**********************************************************************//**
169
176
Positions a cursor at a randomly chosen position within a B-tree. */
172
btr_cur_open_at_rnd_pos(
173
/*====================*/
179
btr_cur_open_at_rnd_pos_func(
180
/*=========================*/
174
181
dict_index_t* index, /*!< in: index */
175
182
ulint latch_mode, /*!< in: BTR_SEARCH_LEAF, ... */
176
183
btr_cur_t* cursor, /*!< in/out: B-tree cursor */
184
const char* file, /*!< in: file name */
185
ulint line, /*!< in: line where called */
177
186
mtr_t* mtr); /*!< in: mtr */
187
#define btr_cur_open_at_rnd_pos(i,l,c,m) \
188
btr_cur_open_at_rnd_pos_func(i,l,c,__FILE__,__LINE__,m)
178
189
/*************************************************************//**
179
190
Tries to perform an insert to a page in an index tree, next to cursor.
180
191
It is assumed that mtr holds an x-latch on the page. The operation does
232
243
que_thr_t* thr, /*!< in: query thread or NULL */
233
244
mtr_t* mtr); /*!< in: mtr */
234
245
/*************************************************************//**
246
See if there is enough place in the page modification log to log
248
@return TRUE if enough place */
251
btr_cur_update_alloc_zip(
252
/*=====================*/
253
page_zip_des_t* page_zip,/*!< in/out: compressed page */
254
buf_block_t* block, /*!< in/out: buffer page */
255
dict_index_t* index, /*!< in: the index corresponding to the block */
256
ulint length, /*!< in: size needed */
257
ibool create, /*!< in: TRUE=delete-and-insert,
258
FALSE=update-in-place */
259
mtr_t* mtr) /*!< in: mini-transaction */
260
UNIV_WARN_UNUSED_RESULT_NONNULL;
261
/*************************************************************//**
235
262
Updates a record when the update causes no size changes in its fields.
236
263
@return DB_SUCCESS or error number */
322
349
ibool val, /*!< in: value to set */
323
350
que_thr_t* thr, /*!< in: query thread */
324
351
mtr_t* mtr); /*!< in: mtr */
325
/***********************************************************//**
326
Clear a secondary index record's delete mark. This function is only
327
used by the insert buffer insert merge mechanism. */
330
btr_cur_del_unmark_for_ibuf(
331
/*========================*/
332
rec_t* rec, /*!< in/out: record to delete unmark */
333
page_zip_des_t* page_zip, /*!< in/out: compressed page
334
corresponding to rec, or NULL
335
when the tablespace is
337
mtr_t* mtr); /*!< in: mtr */
338
352
/*************************************************************//**
339
353
Tries to compress a page of the tree if it seems useful. It is assumed
340
354
that mtr holds an x-latch on the tree and on the cursor page. To avoid
458
472
Marks not updated extern fields as not-owned by this record. The ownership
459
473
is transferred to the updated record which is inserted elsewhere in the
460
474
index tree. In purge only the owner of externally stored field is allowed
461
to free the field. */
476
@return TRUE if BLOB ownership was transferred */
464
479
btr_cur_mark_extern_inherited_fields(
465
480
/*=================================*/
466
481
page_zip_des_t* page_zip,/*!< in/out: compressed page whose uncompressed
560
575
ulint local_len);/*!< in: length of data, in bytes */
561
576
/*******************************************************************//**
562
577
Copies an externally stored field of a record to mem heap.
563
@return the field copied to heap */
578
@return the field copied to heap, or NULL if the field is incomplete */
566
581
btr_rec_copy_externally_stored_field(
586
601
const upd_t* update, /*!< in: update vector */
587
602
mem_heap_t* heap) /*!< in: memory heap */
588
603
__attribute__((nonnull));
604
/***********************************************************//**
605
Sets a secondary index record's delete mark to the given value. This
606
function is only used by the insert buffer merge mechanism. */
609
btr_cur_set_deleted_flag_for_ibuf(
610
/*==============================*/
611
rec_t* rec, /*!< in/out: record */
612
page_zip_des_t* page_zip, /*!< in/out: compressed page
613
corresponding to rec, or NULL
614
when the tablespace is
616
ibool val, /*!< in: value to set */
617
mtr_t* mtr); /*!< in: mtr */
590
618
/*######################################################################*/
592
620
/** In the pessimistic delete, if the page data size drops below this
604
632
order); value ULINT_UNDEFINED
605
633
denotes array end */
606
634
ulint n_recs; /*!< number of records on the page */
635
ulint page_no; /*!< no of the page containing the record */
636
ulint page_level; /*!< level of the page, if later we fetch
637
the page under page_no and it is no different
638
level then we know that the tree has been
609
642
#define BTR_PATH_ARRAY_N_SLOTS 250 /*!< size of path array (in slots) */
618
651
hash_node, and might be necessary to
620
653
BTR_CUR_BINARY, /*!< success using the binary search */
621
BTR_CUR_INSERT_TO_IBUF /*!< performed the intended insert to
654
BTR_CUR_INSERT_TO_IBUF, /*!< performed the intended insert to
656
BTR_CUR_DEL_MARK_IBUF, /*!< performed the intended delete
657
mark in the insert/delete buffer */
658
BTR_CUR_DELETE_IBUF, /*!< performed the intended delete in
659
the insert/delete buffer */
660
BTR_CUR_DELETE_REF /*!< row_purge_poss_sec() failed */
625
663
/** The tree cursor: the definition appears here only for the compiler
684
723
ulint fold; /*!< fold value used in the search if
685
724
flag is BTR_CUR_HASH */
725
/*----- Delete buffering -------*/
726
ulint ibuf_cnt; /* in searches done on insert buffer
727
trees, this contains the "counter"
728
value (the first two bytes of the
729
fourth field) extracted from the
730
page above the leaf page, from the
731
father node pointer that pointed to
732
the leaf page. in other words, it
733
contains the minimum counter value
734
for records to be inserted on the
735
chosen leaf page. If for some reason
736
this can't be read, or if the search
737
ended on the leftmost leaf page in
738
the tree (in which case the father
739
node pointer had the 'minimum
740
record' flag set), this is
686
742
/*------------------------------*/
688
744
btr_path_t* path_arr; /*!< in estimating the number of