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  const btr_pcur_t* cursor);
155 /**************************************************************/
159 UNIV_INLINE
160 ulint
162 /*===================*/
163  const 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 /**************************************************************/
274 UNIV_INLINE
275 void
277 /*========================*/
278  btr_pcur_t* pcur,
279  mtr_t* mtr);
280 /*********************************************************/
284 UNIV_INLINE
285 ibool
287 /*==================*/
288  btr_pcur_t* cursor,
290  mtr_t* mtr);
291 /*********************************************************/
295 UNIV_INTERN
296 ibool
297 btr_pcur_move_to_prev(
298 /*==================*/
299  btr_pcur_t* cursor,
301  mtr_t* mtr);
302 /*********************************************************/
304 UNIV_INLINE
305 void
307 /*==========================*/
308  btr_pcur_t* cursor,
309  mtr_t* mtr);
310 /*********************************************************/
314 UNIV_INLINE
315 ibool
317 /*===========================*/
318  btr_pcur_t* cursor,
320  mtr_t* mtr);
321 /*********************************************************/
326 UNIV_INTERN
327 void
328 btr_pcur_move_to_next_page(
329 /*=======================*/
330  btr_pcur_t* cursor,
332  mtr_t* mtr);
333 /*********************************************************/
343 UNIV_INTERN
344 void
345 btr_pcur_move_backward_from_page(
346 /*=============================*/
347  btr_pcur_t* cursor,
349  mtr_t* mtr);
350 #ifdef UNIV_DEBUG
351 /*********************************************************/
354 UNIV_INLINE
355 btr_cur_t*
356 btr_pcur_get_btr_cur(
357 /*=================*/
358  const btr_pcur_t* cursor);
359 /*********************************************************/
362 UNIV_INLINE
363 page_cur_t*
364 btr_pcur_get_page_cur(
365 /*==================*/
366  const btr_pcur_t* cursor);
367 /*********************************************************/
370 UNIV_INLINE
371 page_t*
372 btr_pcur_get_page(
373 /*==============*/
374  const btr_pcur_t* cursor);
375 /*********************************************************/
378 UNIV_INLINE
380 btr_pcur_get_block(
381 /*===============*/
382  const btr_pcur_t* cursor);
383 /*********************************************************/
386 UNIV_INLINE
387 rec_t*
388 btr_pcur_get_rec(
389 /*=============*/
390  const btr_pcur_t* cursor);
391 #else /* UNIV_DEBUG */
392 # define btr_pcur_get_btr_cur(cursor) (&(cursor)->btr_cur)
393 # define btr_pcur_get_page_cur(cursor) (&(cursor)->btr_cur.page_cur)
394 # define btr_pcur_get_page(cursor) ((cursor)->btr_cur.page_cur.block->frame)
395 # define btr_pcur_get_block(cursor) ((cursor)->btr_cur.page_cur.block)
396 # define btr_pcur_get_rec(cursor) ((cursor)->btr_cur.page_cur.rec)
397 #endif /* UNIV_DEBUG */
398 /*********************************************************/
400 UNIV_INLINE
401 ibool
403 /*====================*/
404  const btr_pcur_t* cursor);
405 /*********************************************************/
408 UNIV_INLINE
409 ibool
411 /*===========================*/
412  const btr_pcur_t* cursor);
413 /*********************************************************/
416 UNIV_INLINE
417 ibool
419 /*=============================*/
420  const btr_pcur_t* cursor);
421 /*********************************************************/
424 UNIV_INLINE
425 ibool
427 /*=============================*/
428  btr_pcur_t* cursor,
429  mtr_t* mtr);
430 /*********************************************************/
433 UNIV_INLINE
434 ibool
436 /*===========================*/
437  btr_pcur_t* cursor,
438  mtr_t* mtr);
439 /*********************************************************/
441 UNIV_INLINE
442 void
444 /*==========================*/
445  btr_pcur_t* cursor);
446 /*********************************************************/
448 UNIV_INLINE
449 void
451 /*==========================*/
452  btr_pcur_t* cursor);
455 /* The persistent B-tree cursor structure. This is used mainly for SQL
456 selects, updates, and deletes. */
457 
460  ulint latch_mode;
471  ulint old_stored;
473  rec_t* old_rec;
477  ulint old_n_fields;
478  ulint rel_pos;
482  buf_block_t* block_when_stored;/* buffer block when the position was
483  stored */
484  ib_uint64_t modify_clock;
487  ulint pos_state;
491  ulint search_mode;
496  /*-----------------------------*/
497  /* NOTE that the following fields may possess dynamically allocated
498  memory which should be freed if not needed anymore! */
499 
500  byte* old_rec_buf;
502  ulint buf_size;
504 };
505 
506 #define BTR_PCUR_IS_POSITIONED 1997660512 /* TODO: currently, the state
507  can be BTR_PCUR_IS_POSITIONED,
508  though it really should be
509  BTR_PCUR_WAS_POSITIONED,
510  because we have no obligation
511  to commit the cursor with
512  mtr; similarly latch_mode may
513  be out of date. This can
514  lead to problems if btr_pcur
515  is not used the right way;
516  all current code should be
517  ok. */
518 #define BTR_PCUR_WAS_POSITIONED 1187549791
519 #define BTR_PCUR_NOT_POSITIONED 1328997689
520 
521 #define BTR_PCUR_OLD_STORED 908467085
522 #define BTR_PCUR_OLD_NOT_STORED 122766467
523 
524 #ifndef UNIV_NONINL
525 #include "btr0pcur.ic"
526 #endif
527 
528 #endif