1
1
/*****************************************************************************
3
Copyright (c) 1994, 2010, Innobase Oy. All Rights Reserved.
3
Copyright (c) 1994, 2009, 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., 51 Franklin
15
St, Fifth Floor, Boston, MA 02110-1301 USA
14
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15
Place, Suite 330, Boston, MA 02111-1307 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
at most one of BTR_INSERT, BTR_DELETE_MARK,
142
BTR_DELETE, or BTR_ESTIMATE;
141
BTR_INSERT and BTR_ESTIMATE;
143
142
cursor->left_block is used to store a pointer
144
143
to the left neighbor page, in the cases
145
144
BTR_SEARCH_PREV and BTR_MODIFY_PREV;
153
152
ulint has_search_latch,/*!< in: latch mode the caller
154
153
currently has on btr_search_latch:
155
154
RW_S_LATCH, or 0 */
156
const char* file, /*!< in: file name */
157
ulint line, /*!< in: line where called */
158
155
mtr_t* mtr); /*!< in: mtr */
159
156
/*****************************************************************//**
160
157
Opens a cursor at either end of an index. */
163
btr_cur_open_at_index_side_func(
164
/*============================*/
160
btr_cur_open_at_index_side(
161
/*=======================*/
165
162
ibool from_left, /*!< in: TRUE if open to the low end,
166
163
FALSE if to the high end */
167
164
dict_index_t* index, /*!< in: index */
168
165
ulint latch_mode, /*!< in: latch mode */
169
166
btr_cur_t* cursor, /*!< in: cursor */
170
const char* file, /*!< in: file name */
171
ulint line, /*!< in: line where called */
172
167
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)
175
168
/**********************************************************************//**
176
169
Positions a cursor at a randomly chosen position within a B-tree. */
179
btr_cur_open_at_rnd_pos_func(
180
/*=========================*/
172
btr_cur_open_at_rnd_pos(
173
/*====================*/
181
174
dict_index_t* index, /*!< in: index */
182
175
ulint latch_mode, /*!< in: BTR_SEARCH_LEAF, ... */
183
176
btr_cur_t* cursor, /*!< in/out: B-tree cursor */
184
const char* file, /*!< in: file name */
185
ulint line, /*!< in: line where called */
186
177
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)
189
178
/*************************************************************//**
190
179
Tries to perform an insert to a page in an index tree, next to cursor.
191
180
It is assumed that mtr holds an x-latch on the page. The operation does
333
322
ibool val, /*!< in: value to set */
334
323
que_thr_t* thr, /*!< in: query thread */
335
324
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 */
336
338
/*************************************************************//**
337
339
Tries to compress a page of the tree if it seems useful. It is assumed
338
340
that mtr holds an x-latch on the tree and on the cursor page. To avoid
456
458
Marks not updated extern fields as not-owned by this record. The ownership
457
459
is transferred to the updated record which is inserted elsewhere in the
458
460
index tree. In purge only the owner of externally stored field is allowed
460
@return TRUE if BLOB ownership was transferred */
461
to free the field. */
463
464
btr_cur_mark_extern_inherited_fields(
464
465
/*=================================*/
465
466
page_zip_des_t* page_zip,/*!< in/out: compressed page whose uncompressed
559
560
ulint local_len);/*!< in: length of data, in bytes */
560
561
/*******************************************************************//**
561
562
Copies an externally stored field of a record to mem heap.
562
@return the field copied to heap, or NULL if the field is incomplete */
563
@return the field copied to heap */
565
566
btr_rec_copy_externally_stored_field(
585
586
const upd_t* update, /*!< in: update vector */
586
587
mem_heap_t* heap) /*!< in: memory heap */
587
588
__attribute__((nonnull));
588
/***********************************************************//**
589
Sets a secondary index record's delete mark to the given value. This
590
function is only used by the insert buffer merge mechanism. */
593
btr_cur_set_deleted_flag_for_ibuf(
594
/*==============================*/
595
rec_t* rec, /*!< in/out: record */
596
page_zip_des_t* page_zip, /*!< in/out: compressed page
597
corresponding to rec, or NULL
598
when the tablespace is
600
ibool val, /*!< in: value to set */
601
mtr_t* mtr); /*!< in: mtr */
602
590
/*######################################################################*/
604
592
/** In the pessimistic delete, if the page data size drops below this
616
604
order); value ULINT_UNDEFINED
617
605
denotes array end */
618
606
ulint n_recs; /*!< number of records on the page */
619
ulint page_no; /*!< no of the page containing the record */
620
ulint page_level; /*!< level of the page, if later we fetch
621
the page under page_no and it is no different
622
level then we know that the tree has been
626
609
#define BTR_PATH_ARRAY_N_SLOTS 250 /*!< size of path array (in slots) */
635
618
hash_node, and might be necessary to
637
620
BTR_CUR_BINARY, /*!< success using the binary search */
638
BTR_CUR_INSERT_TO_IBUF, /*!< performed the intended insert to
640
BTR_CUR_DEL_MARK_IBUF, /*!< performed the intended delete
641
mark in the insert/delete buffer */
642
BTR_CUR_DELETE_IBUF, /*!< performed the intended delete in
643
the insert/delete buffer */
644
BTR_CUR_DELETE_REF /*!< row_purge_poss_sec() failed */
621
BTR_CUR_INSERT_TO_IBUF /*!< performed the intended insert to
647
625
/** The tree cursor: the definition appears here only for the compiler
707
684
ulint fold; /*!< fold value used in the search if
708
685
flag is BTR_CUR_HASH */
709
/*----- Delete buffering -------*/
710
ulint ibuf_cnt; /* in searches done on insert buffer
711
trees, this contains the "counter"
712
value (the first two bytes of the
713
fourth field) extracted from the
714
page above the leaf page, from the
715
father node pointer that pointed to
716
the leaf page. in other words, it
717
contains the minimum counter value
718
for records to be inserted on the
719
chosen leaf page. If for some reason
720
this can't be read, or if the search
721
ended on the leftmost leaf page in
722
the tree (in which case the father
723
node pointer had the 'minimum
724
record' flag set), this is
726
686
/*------------------------------*/
728
688
btr_path_t* path_arr; /*!< in estimating the number of