Drizzled Public API Documentation

btr0pcur.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (C) 1996, 2010, Innobase Oy. 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., 51 Franklin
15 St, Fifth Floor, Boston, MA 02110-1301 USA
16 
17 *****************************************************************************/
18 
19 /**************************************************/
26 #pragma once
27 #ifndef btr0pcur_h
28 #define btr0pcur_h
29 
30 #include "univ.i"
31 #include "dict0dict.h"
32 #include "data0data.h"
33 #include "mtr0mtr.h"
34 #include "page0cur.h"
35 #include "btr0cur.h"
36 #include "btr0btr.h"
37 #include "btr0types.h"
38 
39 /* Relative positions for a stored cursor position */
40 #define BTR_PCUR_ON 1
41 #define BTR_PCUR_BEFORE 2
42 #define BTR_PCUR_AFTER 3
43 /* Note that if the tree is not empty, btr_pcur_store_position does not
44 use the following, but only uses the above three alternatives, where the
45 position is stored relative to a specific record: this makes implementation
46 of a scroll cursor easier */
47 #define BTR_PCUR_BEFORE_FIRST_IN_TREE 4 /* in an empty tree */
48 #define BTR_PCUR_AFTER_LAST_IN_TREE 5 /* in an empty tree */
49 
50 /**************************************************************/
53 UNIV_INTERN
55 btr_pcur_create_for_mysql(void);
56 /*============================*/
57 /**************************************************************/
59 UNIV_INTERN
60 void
61 btr_pcur_free_for_mysql(
62 /*====================*/
63  btr_pcur_t* cursor);
64 /**************************************************************/
66 UNIV_INTERN
67 void
68 btr_pcur_copy_stored_position(
69 /*==========================*/
70  btr_pcur_t* pcur_receive,
72  btr_pcur_t* pcur_donate);
74 /**************************************************************/
76 UNIV_INLINE
77 void
79 /*==========*/
80  btr_pcur_t* pcur);
81 /**************************************************************/
84 UNIV_INLINE
85 void
87 /*===============*/
88  dict_index_t* index,
89  const dtuple_t* tuple,
90  ulint mode,
96  ulint latch_mode,
97  btr_pcur_t* cursor,
98  const char* file,
99  ulint line,
100  mtr_t* mtr);
101 #define btr_pcur_open(i,t,md,l,c,m) \
102  btr_pcur_open_func(i,t,md,l,c,__FILE__,__LINE__,m)
103 /**************************************************************/
106 UNIV_INLINE
107 void
109 /*============================*/
110  dict_index_t* index,
111  const dtuple_t* tuple,
112  ulint mode,
118  ulint latch_mode,
123  btr_pcur_t* cursor,
124  ulint has_search_latch,
127  const char* file,
128  ulint line,
129  mtr_t* mtr);
130 #define btr_pcur_open_with_no_init(ix,t,md,l,cur,has,m) \
131  btr_pcur_open_with_no_init_func(ix,t,md,l,cur,has,__FILE__,__LINE__,m)
132 
133 /*****************************************************************/
135 UNIV_INLINE
136 void
138 /*========================*/
139  ibool from_left,
141  dict_index_t* index,
142  ulint latch_mode,
143  btr_pcur_t* pcur,
144  ibool do_init,
145  mtr_t* mtr);
146 /**************************************************************/
150 UNIV_INLINE
151 ulint
153 /*==================*/
154  btr_pcur_t* cursor);
155 /**************************************************************/
159 UNIV_INLINE
160 ulint
162 /*===================*/
163  btr_pcur_t* cursor);
164 /**************************************************************/
171 UNIV_INTERN
172 void
173 btr_pcur_open_on_user_rec_func(
174 /*===========================*/
175  dict_index_t* index,
176  const dtuple_t* tuple,
177  ulint mode,
178  ulint latch_mode,
180  btr_pcur_t* cursor,
182  const char* file,
183  ulint line,
184  mtr_t* mtr);
185 #define btr_pcur_open_on_user_rec(i,t,md,l,c,m) \
186  btr_pcur_open_on_user_rec_func(i,t,md,l,c,__FILE__,__LINE__,m)
187 /**********************************************************************/
189 UNIV_INLINE
190 void
192 /*==========================*/
193  dict_index_t* index,
194  ulint latch_mode,
195  btr_pcur_t* cursor,
196  const char* file,
197  ulint line,
198  mtr_t* mtr);
199 #define btr_pcur_open_at_rnd_pos(i,l,c,m) \
200  btr_pcur_open_at_rnd_pos_func(i,l,c,__FILE__,__LINE__,m)
201 /**************************************************************/
204 UNIV_INLINE
205 void
207 /*===========*/
208  btr_pcur_t* cursor);
209 /**************************************************************/
216 UNIV_INTERN
217 void
218 btr_pcur_store_position(
219 /*====================*/
220  btr_pcur_t* cursor,
221  mtr_t* mtr);
222 /**************************************************************/
237 UNIV_INTERN
238 ibool
239 btr_pcur_restore_position_func(
240 /*===========================*/
241  ulint latch_mode,
242  btr_pcur_t* cursor,
243  const char* file,
244  ulint line,
245  mtr_t* mtr);
246 #define btr_pcur_restore_position(l,cur,mtr) \
247  btr_pcur_restore_position_func(l,cur,__FILE__,__LINE__,mtr)
248 /**************************************************************/
254 UNIV_INTERN
255 void
256 btr_pcur_release_leaf(
257 /*==================*/
258  btr_pcur_t* cursor,
259  mtr_t* mtr);
260 /*********************************************************/
263 UNIV_INLINE
264 ulint
266 /*=================*/
267  const btr_pcur_t* cursor);
268 /*********************************************************/
270 UNIV_INLINE
271 void
273 /*=============*/
274  btr_pcur_t* cursor,
275  mtr_t* mtr);
276 /*********************************************************/
279 UNIV_INLINE
280 mtr_t*
282 /*=============*/
283  btr_pcur_t* cursor);
284 /**************************************************************/
290 UNIV_INLINE
291 void
293 /*========================*/
294  btr_pcur_t* pcur,
295  mtr_t* mtr);
296 /*********************************************************/
300 UNIV_INLINE
301 ibool
303 /*==================*/
304  btr_pcur_t* cursor,
306  mtr_t* mtr);
307 /*********************************************************/
311 UNIV_INTERN
312 ibool
313 btr_pcur_move_to_prev(
314 /*==================*/
315  btr_pcur_t* cursor,
317  mtr_t* mtr);
318 /*********************************************************/
320 UNIV_INLINE
321 void
323 /*==========================*/
324  btr_pcur_t* cursor,
325  mtr_t* mtr);
326 /*********************************************************/
330 UNIV_INLINE
331 ibool
333 /*===========================*/
334  btr_pcur_t* cursor,
336  mtr_t* mtr);
337 /*********************************************************/
342 UNIV_INTERN
343 void
344 btr_pcur_move_to_next_page(
345 /*=======================*/
346  btr_pcur_t* cursor,
348  mtr_t* mtr);
349 /*********************************************************/
359 UNIV_INTERN
360 void
361 btr_pcur_move_backward_from_page(
362 /*=============================*/
363  btr_pcur_t* cursor,
365  mtr_t* mtr);
366 #ifdef UNIV_DEBUG
367 /*********************************************************/
370 UNIV_INLINE
371 btr_cur_t*
372 btr_pcur_get_btr_cur(
373 /*=================*/
374  const btr_pcur_t* cursor);
375 /*********************************************************/
378 UNIV_INLINE
379 page_cur_t*
380 btr_pcur_get_page_cur(
381 /*==================*/
382  const btr_pcur_t* cursor);
383 #else /* UNIV_DEBUG */
384 # define btr_pcur_get_btr_cur(cursor) (&(cursor)->btr_cur)
385 # define btr_pcur_get_page_cur(cursor) (&(cursor)->btr_cur.page_cur)
386 #endif /* UNIV_DEBUG */
387 /*********************************************************/
390 UNIV_INLINE
391 page_t*
393 /*==============*/
394  btr_pcur_t* cursor);
395 /*********************************************************/
398 UNIV_INLINE
401 /*===============*/
402  btr_pcur_t* cursor);
403 /*********************************************************/
406 UNIV_INLINE
407 rec_t*
409 /*=============*/
410  btr_pcur_t* cursor);
411 /*********************************************************/
413 UNIV_INLINE
414 ibool
416 /*====================*/
417  const btr_pcur_t* cursor);
418 /*********************************************************/
421 UNIV_INLINE
422 ibool
424 /*===========================*/
425  const btr_pcur_t* cursor);
426 /*********************************************************/
429 UNIV_INLINE
430 ibool
432 /*=============================*/
433  const btr_pcur_t* cursor);
434 /*********************************************************/
437 UNIV_INLINE
438 ibool
440 /*=============================*/
441  btr_pcur_t* cursor,
442  mtr_t* mtr);
443 /*********************************************************/
446 UNIV_INLINE
447 ibool
449 /*===========================*/
450  btr_pcur_t* cursor,
451  mtr_t* mtr);
452 /*********************************************************/
454 UNIV_INLINE
455 void
457 /*==========================*/
458  btr_pcur_t* cursor);
459 /*********************************************************/
461 UNIV_INLINE
462 void
464 /*==========================*/
465  btr_pcur_t* cursor);
468 /* The persistent B-tree cursor structure. This is used mainly for SQL
469 selects, updates, and deletes. */
470 
473  ulint latch_mode;
484  ulint old_stored;
486  rec_t* old_rec;
490  ulint old_n_fields;
491  ulint rel_pos;
495  buf_block_t* block_when_stored;/* buffer block when the position was
496  stored */
497  ib_uint64_t modify_clock;
500  ulint pos_state;
504  ulint search_mode;
509  /*-----------------------------*/
510  /* NOTE that the following fields may possess dynamically allocated
511  memory which should be freed if not needed anymore! */
512 
516  byte* old_rec_buf;
518  ulint buf_size;
520 };
521 
522 #define BTR_PCUR_IS_POSITIONED 1997660512 /* TODO: currently, the state
523  can be BTR_PCUR_IS_POSITIONED,
524  though it really should be
525  BTR_PCUR_WAS_POSITIONED,
526  because we have no obligation
527  to commit the cursor with
528  mtr; similarly latch_mode may
529  be out of date. This can
530  lead to problems if btr_pcur
531  is not used the right way;
532  all current code should be
533  ok. */
534 #define BTR_PCUR_WAS_POSITIONED 1187549791
535 #define BTR_PCUR_NOT_POSITIONED 1328997689
536 
537 #define BTR_PCUR_OLD_STORED 908467085
538 #define BTR_PCUR_OLD_NOT_STORED 122766467
539 
540 #ifndef UNIV_NONINL
541 #include "btr0pcur.ic"
542 #endif
543 
544 #endif