InnoDB Plugin  1.0
btr0pcur.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (c) 1996, 2013, 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 as published by the Free Software
7 Foundation; version 2 of the License.
8 
9 This program is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12 
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.,
15 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
16 
17 *****************************************************************************/
18 
19 /**************************************************/
26 #ifndef btr0pcur_h
27 #define btr0pcur_h
28 
29 #include "univ.i"
30 #include "dict0dict.h"
31 #include "data0data.h"
32 #include "mtr0mtr.h"
33 #include "page0cur.h"
34 #include "btr0cur.h"
35 #include "btr0btr.h"
36 #include "btr0types.h"
37 
38 /* Relative positions for a stored cursor position */
39 #define BTR_PCUR_ON 1
40 #define BTR_PCUR_BEFORE 2
41 #define BTR_PCUR_AFTER 3
42 /* Note that if the tree is not empty, btr_pcur_store_position does not
43 use the following, but only uses the above three alternatives, where the
44 position is stored relative to a specific record: this makes implementation
45 of a scroll cursor easier */
46 #define BTR_PCUR_BEFORE_FIRST_IN_TREE 4 /* in an empty tree */
47 #define BTR_PCUR_AFTER_LAST_IN_TREE 5 /* in an empty tree */
48 
49 /**************************************************************/
52 UNIV_INTERN
55 /*============================*/
56 
57 /**************************************************************/
60 UNIV_INTERN
61 void
63 /*===========*/
64  btr_pcur_t* cursor);
66 /**************************************************************/
68 UNIV_INTERN
69 void
71 /*====================*/
72  btr_pcur_t* cursor);
73 /**************************************************************/
75 UNIV_INTERN
76 void
78 /*==========================*/
79  btr_pcur_t* pcur_receive,
81  btr_pcur_t* pcur_donate);
83 /**************************************************************/
85 UNIV_INLINE
86 void
88 /*==========*/
89  btr_pcur_t* pcur);
90 /**************************************************************/
93 UNIV_INLINE
94 void
96 /*==============*/
97  dict_index_t* index,
98  ulint level,
99  const dtuple_t* tuple,
100  ulint mode,
106  ulint latch_mode,
107  btr_pcur_t* cursor,
108  const char* file,
109  ulint line,
110  mtr_t* mtr);
111 #define btr_pcur_open(i,t,md,l,c,m) \
112  btr_pcur_open_low(i,0,t,md,l,c,__FILE__,__LINE__,m)
113 /**************************************************************/
116 UNIV_INLINE
117 void
119 /*============================*/
120  dict_index_t* index,
121  const dtuple_t* tuple,
122  ulint mode,
128  ulint latch_mode,
133  btr_pcur_t* cursor,
134  ulint has_search_latch,
137  const char* file,
138  ulint line,
139  mtr_t* mtr);
140 #define btr_pcur_open_with_no_init(ix,t,md,l,cur,has,m) \
141  btr_pcur_open_with_no_init_func(ix,t,md,l,cur,has,__FILE__,__LINE__,m)
142 
143 /*****************************************************************/
145 UNIV_INLINE
146 void
148 /*========================*/
149  bool from_left,
151  dict_index_t* index,
152  ulint latch_mode,
153  btr_pcur_t* pcur,
154  bool init_pcur,
155  ulint level,
157  mtr_t* mtr)
158  __attribute__((nonnull));
159 /**************************************************************/
163 UNIV_INLINE
164 ulint
166 /*==================*/
167  const btr_pcur_t* cursor);
168 /**************************************************************/
172 UNIV_INLINE
173 ulint
175 /*===================*/
176  const btr_pcur_t* cursor);
177 /**************************************************************/
184 UNIV_INTERN
185 void
187 /*===========================*/
188  dict_index_t* index,
189  const dtuple_t* tuple,
190  ulint mode,
191  ulint latch_mode,
193  btr_pcur_t* cursor,
195  const char* file,
196  ulint line,
197  mtr_t* mtr);
198 #define btr_pcur_open_on_user_rec(i,t,md,l,c,m) \
199  btr_pcur_open_on_user_rec_func(i,t,md,l,c,__FILE__,__LINE__,m)
200 /**********************************************************************/
202 UNIV_INLINE
203 void
205 /*==========================*/
206  dict_index_t* index,
207  ulint latch_mode,
208  btr_pcur_t* cursor,
209  const char* file,
210  ulint line,
211  mtr_t* mtr);
212 #define btr_pcur_open_at_rnd_pos(i,l,c,m) \
213  btr_pcur_open_at_rnd_pos_func(i,l,c,__FILE__,__LINE__,m)
214 /**************************************************************/
226 UNIV_INLINE
227 void
229 /*===========*/
230  btr_pcur_t* cursor);
231 /**************************************************************/
238 UNIV_INTERN
239 void
241 /*====================*/
242  btr_pcur_t* cursor,
243  mtr_t* mtr);
244 /**************************************************************/
259 UNIV_INTERN
260 ibool
262 /*===========================*/
263  ulint latch_mode,
264  btr_pcur_t* cursor,
265  const char* file,
266  ulint line,
267  mtr_t* mtr);
268 #define btr_pcur_restore_position(l,cur,mtr) \
269  btr_pcur_restore_position_func(l,cur,__FILE__,__LINE__,mtr)
270 /*********************************************************/
273 UNIV_INLINE
274 ulint
276 /*=================*/
277  const btr_pcur_t* cursor);
278 /**************************************************************/
283 UNIV_INLINE
284 void
286 /*========================*/
287  btr_pcur_t* pcur,
288  mtr_t* mtr);
289 /*********************************************************/
293 UNIV_INLINE
294 ibool
296 /*==================*/
297  btr_pcur_t* cursor,
299  mtr_t* mtr);
300 /*********************************************************/
304 UNIV_INTERN
305 ibool
307 /*==================*/
308  btr_pcur_t* cursor,
310  mtr_t* mtr);
311 /*********************************************************/
313 UNIV_INLINE
314 void
316 /*==========================*/
317  btr_pcur_t* cursor,
318  mtr_t* mtr);
319 /*********************************************************/
323 UNIV_INLINE
324 ibool
326 /*===========================*/
327  btr_pcur_t* cursor,
329  mtr_t* mtr);
330 /*********************************************************/
335 UNIV_INTERN
336 void
338 /*=======================*/
339  btr_pcur_t* cursor,
341  mtr_t* mtr);
342 /*********************************************************/
352 UNIV_INTERN
353 void
355 /*=============================*/
356  btr_pcur_t* cursor,
358  mtr_t* mtr);
359 #ifdef UNIV_DEBUG
360 /*********************************************************/
363 UNIV_INLINE
364 btr_cur_t*
366 /*=================*/
367  const btr_pcur_t* cursor);
368 /*********************************************************/
371 UNIV_INLINE
372 page_cur_t*
374 /*==================*/
375  const btr_pcur_t* cursor);
376 /*********************************************************/
379 UNIV_INLINE
380 page_t*
382 /*==============*/
383  const btr_pcur_t* cursor);
384 /*********************************************************/
387 UNIV_INLINE
390 /*===============*/
391  const btr_pcur_t* cursor);
392 /*********************************************************/
395 UNIV_INLINE
396 rec_t*
398 /*=============*/
399  const btr_pcur_t* cursor);
400 #else /* UNIV_DEBUG */
401 # define btr_pcur_get_btr_cur(cursor) (&(cursor)->btr_cur)
402 # define btr_pcur_get_page_cur(cursor) (&(cursor)->btr_cur.page_cur)
403 # define btr_pcur_get_page(cursor) ((cursor)->btr_cur.page_cur.block->frame)
404 # define btr_pcur_get_block(cursor) ((cursor)->btr_cur.page_cur.block)
405 # define btr_pcur_get_rec(cursor) ((cursor)->btr_cur.page_cur.rec)
406 #endif /* UNIV_DEBUG */
407 /*********************************************************/
409 UNIV_INLINE
410 ibool
412 /*====================*/
413  const btr_pcur_t* cursor);
414 /*********************************************************/
417 UNIV_INLINE
418 ibool
420 /*===========================*/
421  const btr_pcur_t* cursor);
422 /*********************************************************/
425 UNIV_INLINE
426 ibool
428 /*=============================*/
429  const btr_pcur_t* cursor);
430 /*********************************************************/
433 UNIV_INLINE
434 ibool
436 /*=============================*/
437  btr_pcur_t* cursor,
438  mtr_t* mtr);
439 /*********************************************************/
442 UNIV_INLINE
443 ibool
445 /*===========================*/
446  btr_pcur_t* cursor,
447  mtr_t* mtr);
448 /*********************************************************/
450 UNIV_INLINE
451 void
453 /*==========================*/
454  btr_pcur_t* cursor);
455 /*********************************************************/
457 UNIV_INLINE
458 void
460 /*==========================*/
461  btr_pcur_t* cursor);
462 /*********************************************************/
464 UNIV_INLINE
465 void
467 /*===============================*/
468  btr_pcur_t* cursor);
490 };
491 
492 /* The persistent B-tree cursor structure. This is used mainly for SQL
493 selects, updates, and deletes. */
494 
495 struct btr_pcur_t{
497  ulint latch_mode;
508  ulint old_stored;
510  rec_t* old_rec;
514  ulint old_n_fields;
515  ulint rel_pos;
519  buf_block_t* block_when_stored;/* buffer block when the position was
520  stored */
521  ib_uint64_t modify_clock;
526  ulint search_mode;
531  /*-----------------------------*/
532  /* NOTE that the following fields may possess dynamically allocated
533  memory which should be freed if not needed anymore! */
534 
535  byte* old_rec_buf;
537  ulint buf_size;
539 };
540 
541 #define BTR_PCUR_OLD_STORED 908467085
542 #define BTR_PCUR_OLD_NOT_STORED 122766467
543 
544 #ifndef UNIV_NONINL
545 #include "btr0pcur.ic"
546 #endif
547 
548 #endif