Drizzled Public API Documentation

ibuf0ibuf.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3 Copyright (C) 1997, 2009, 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 ibuf0ibuf_h
28 #define ibuf0ibuf_h
29 
30 #include "univ.i"
31 
32 #include "mtr0mtr.h"
33 #include "dict0mem.h"
34 #include "fsp0fsp.h"
35 
36 #ifndef UNIV_HOTBACKUP
37 # include "ibuf0types.h"
38 
39 /* Possible operations buffered in the insert/whatever buffer. See
40 ibuf_insert(). DO NOT CHANGE THE VALUES OF THESE, THEY ARE STORED ON DISK. */
41 typedef enum {
42  IBUF_OP_INSERT = 0,
43  IBUF_OP_DELETE_MARK = 1,
44  IBUF_OP_DELETE = 2,
45 
46  /* Number of different operation types. */
47  IBUF_OP_COUNT = 3
48 } ibuf_op_t;
49 
53 typedef enum {
54  IBUF_USE_NONE = 0,
55  IBUF_USE_INSERT, /* insert */
56  IBUF_USE_DELETE_MARK, /* delete */
57  IBUF_USE_INSERT_DELETE_MARK, /* insert+delete */
58  IBUF_USE_DELETE, /* delete+purge */
59  IBUF_USE_ALL, /* insert+delete+purge */
60 
61  IBUF_USE_COUNT /* number of entries in ibuf_use_t */
62 } ibuf_use_t;
63 
65 extern ibuf_use_t ibuf_use;
66 
67 #if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG
68 
69 extern uint ibuf_debug;
70 #endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */
71 
73 extern ibuf_t* ibuf;
74 
75 /* The purpose of the insert buffer is to reduce random disk access.
76 When we wish to insert a record into a non-unique secondary index and
77 the B-tree leaf page where the record belongs to is not in the buffer
78 pool, we insert the record into the insert buffer B-tree, indexed by
79 (space_id, page_no). When the page is eventually read into the buffer
80 pool, we look up the insert buffer B-tree for any modifications to the
81 page, and apply these upon the completion of the read operation. This
82 is called the insert buffer merge. */
83 
84 /* The insert buffer merge must always succeed. To guarantee this,
85 the insert buffer subsystem keeps track of the free space in pages for
86 which it can buffer operations. Two bits per page in the insert
87 buffer bitmap indicate the available space in coarse increments. The
88 free bits in the insert buffer bitmap must never exceed the free space
89 on a page. It is safe to decrement or reset the bits in the bitmap in
90 a mini-transaction that is committed before the mini-transaction that
91 affects the free space. It is unsafe to increment the bits in a
92 separately committed mini-transaction, because in crash recovery, the
93 free bits could momentarily be set too high. */
94 
95 /******************************************************************/
97 UNIV_INTERN
98 void
100 /*=======================*/
101 /*********************************************************************/
104 UNIV_INTERN
105 void
107 /*===============================*/
108 /***************************************************************/
110 UNIV_INLINE
111 void
113 /*===========*/
114  mtr_t* mtr)
115  __attribute__((nonnull));
116 /***************************************************************/
118 UNIV_INLINE
119 void
121 /*============*/
122  mtr_t* mtr)
123  __attribute__((nonnull));
124 /*********************************************************************/
126 UNIV_INTERN
127 void
129 /*==================*/
130  buf_block_t* block,
131  mtr_t* mtr);
132 /************************************************************************/
141 UNIV_INTERN
142 void
144 /*=================*/
145  buf_block_t* block);
148 /************************************************************************/
161 UNIV_INLINE
162 void
164 /*==========================*/
165  buf_block_t* block,
170  ulint max_ins_size,
173  ulint increase);
176 /**********************************************************************/
184 UNIV_INTERN
185 void
187 /*======================*/
188  const buf_block_t* block,
189  ulint max_ins_size,
194  mtr_t* mtr);
195 /**********************************************************************/
203 UNIV_INTERN
204 void
206 /*======================*/
207  buf_block_t* block,
208  mtr_t* mtr);
209 /**********************************************************************/
216 UNIV_INTERN
217 void
219 /*====================================*/
220  ulint zip_size,
222  buf_block_t* block1,
223  buf_block_t* block2,
224  mtr_t* mtr);
225 /**********************************************************************/
228 UNIV_INLINE
229 ibool
231 /*============*/
232  dict_index_t* index,
233  ulint ignore_sec_unique);
237 /******************************************************************/
244 UNIV_INLINE
245 ibool
247 /*========*/
248  const mtr_t* mtr)
249  __attribute__((nonnull, pure));
250 /***********************************************************************/
253 UNIV_INLINE
254 ibool
256 /*=============*/
257  ulint zip_size,
259  ulint page_no);
260 /***********************************************************************/
264 UNIV_INTERN
265 ibool
267 /*==========*/
268  ulint space,
269  ulint zip_size,
270  ulint page_no,
271 #ifdef UNIV_DEBUG
272  ibool x_latch,
274 #endif /* UNIV_DEBUG */
275  const char* file,
276  ulint line,
277  mtr_t* mtr)
282  __attribute__((warn_unused_result));
283 #ifdef UNIV_DEBUG
284 
291 # define ibuf_page(space, zip_size, page_no, mtr) \
292  ibuf_page_low(space, zip_size, page_no, TRUE, __FILE__, __LINE__, mtr)
293 #else /* UVIV_DEBUG */
294 
301 # define ibuf_page(space, zip_size, page_no, mtr) \
302  ibuf_page_low(space, zip_size, page_no, __FILE__, __LINE__, mtr)
303 #endif /* UVIV_DEBUG */
304 /***********************************************************************/
308 UNIV_INTERN
309 void
311 /*========================*/
312 /*********************************************************************/
317 UNIV_INTERN
318 ibool
320 /*========*/
321  ibuf_op_t op,
322  const dtuple_t* entry,
323  dict_index_t* index,
324  ulint space,
325  ulint zip_size,
326  ulint page_no,
327  que_thr_t* thr);
328 /*********************************************************************/
335 UNIV_INTERN
336 void
338 /*==========================*/
339  buf_block_t* block,
342  ulint space,
343  ulint page_no,
344  ulint zip_size,
346  ibool update_ibuf_bitmap);
351 /*********************************************************************/
356 UNIV_INTERN
357 void
359 /*============================*/
360  ulint space);
361 /*********************************************************************/
366 UNIV_INTERN
367 ulint
369 /*==========*/
370  ibool sync);
373 /*********************************************************************/
378 UNIV_INTERN
379 ulint
381 /*======================*/
382  ibool sync,
385  ulint n_pages);
388 #endif /* !UNIV_HOTBACKUP */
389 /*********************************************************************/
392 UNIV_INTERN
393 byte*
395 /*===================*/
396  byte* ptr,
397  byte* end_ptr,
398  buf_block_t* block,
399  mtr_t* mtr);
400 #ifndef UNIV_HOTBACKUP
401 #ifdef UNIV_IBUF_COUNT_DEBUG
402 /******************************************************************/
406 UNIV_INTERN
407 ulint
408 ibuf_count_get(
409 /*===========*/
410  ulint space,
411  ulint page_no);
412 #endif
413 /******************************************************************/
416 UNIV_INTERN
417 ibool
418 ibuf_is_empty(void);
419 /*===============*/
420 /******************************************************************/
422 UNIV_INTERN
423 void
424 ibuf_print(
425 /*=======*/
426  FILE* file);
427 /********************************************************************
428 Read the first two bytes from a record's fourth field (counter field in new
429 records; something else in older records).
430 @return "counter" field, or ULINT_UNDEFINED if for some reason it can't be read */
431 UNIV_INTERN
432 ulint
434 /*=================*/
435  const rec_t* rec);
436 /******************************************************************/
438 UNIV_INTERN
439 void
440 ibuf_close(void);
441 /*============*/
442 
443 #define IBUF_HEADER_PAGE_NO FSP_IBUF_HEADER_PAGE_NO
444 #define IBUF_TREE_ROOT_PAGE_NO FSP_IBUF_TREE_ROOT_PAGE_NO
445 
446 #endif /* !UNIV_HOTBACKUP */
447 
448 /* The ibuf header page currently contains only the file segment header
449 for the file segment from which the pages for the ibuf tree are allocated */
450 #define IBUF_HEADER PAGE_DATA
451 #define IBUF_TREE_SEG_HEADER 0 /* fseg header for ibuf tree */
452 
453 /* The insert buffer tree itself is always located in space 0. */
454 #define IBUF_SPACE_ID 0
455 
456 #ifndef UNIV_NONINL
457 #include "ibuf0ibuf.ic"
458 #endif
459 
460 #endif
UNIV_INTERN ibool ibuf_page_low(ulint space, ulint zip_size, ulint page_no, const char *file, ulint line, mtr_t *mtr) __attribute__((warn_unused_result))
Definition: ibuf0ibuf.cc:1139
UNIV_INTERN void ibuf_update_free_bits_zip(buf_block_t *block, mtr_t *mtr)
Definition: ibuf0ibuf.cc:1046
ibuf_t * ibuf
Definition: ibuf0ibuf.cc:201
UNIV_INLINE void ibuf_update_free_bits_if_full(buf_block_t *block, ulint max_ins_size, ulint increase)
UNIV_INTERN void ibuf_update_free_bits_for_two_pages_low(ulint zip_size, buf_block_t *block1, buf_block_t *block2, mtr_t *mtr)
Definition: ibuf0ibuf.cc:1090
ibuf_use_t ibuf_use
Definition: ibuf0ibuf.cc:193
UNIV_INTERN void ibuf_bitmap_page_init(buf_block_t *block, mtr_t *mtr)
Definition: ibuf0ibuf.cc:605
UNIV_INLINE ibool ibuf_inside(const mtr_t *mtr) __attribute__((nonnull
UNIV_INTERN void ibuf_init_at_db_start(void)
Definition: ibuf0ibuf.cc:506
UNIV_INTERN void ibuf_print(FILE *file)
Definition: ibuf0ibuf.cc:4926
UNIV_INTERN void ibuf_free_excess_pages(void)
Definition: ibuf0ibuf.cc:2400
UNIV_INLINE void ibuf_mtr_start(mtr_t *mtr) __attribute__((nonnull))
ibuf_use_t
Definition: ibuf0ibuf.h:53
UNIV_INTERN void ibuf_merge_or_delete_for_page(buf_block_t *block, ulint space, ulint page_no, ulint zip_size, ibool update_ibuf_bitmap)
Definition: ibuf0ibuf.cc:4419
UNIV_INTERN ibool ibuf_insert(ibuf_op_t op, const dtuple_t *entry, dict_index_t *index, ulint space, ulint zip_size, ulint page_no, que_thr_t *thr)
Definition: ibuf0ibuf.cc:3754
UNIV_INTERN byte * ibuf_parse_bitmap_init(byte *ptr, byte *end_ptr, buf_block_t *block, mtr_t *mtr)
Definition: ibuf0ibuf.cc:642
UNIV_INTERN ulint ibuf_rec_get_counter(const rec_t *rec)
Definition: ibuf0ibuf.cc:1458
UNIV_INLINE void ibuf_mtr_commit(mtr_t *mtr) __attribute__((nonnull))
UNIV_INTERN ibool ibuf_is_empty(void)
Definition: ibuf0ibuf.cc:4902
UNIV_INTERN void ibuf_reset_free_bits(buf_block_t *block)
Definition: ibuf0ibuf.cc:989
UNIV_INTERN void ibuf_update_free_bits_low(const buf_block_t *block, ulint max_ins_size, mtr_t *mtr)
Definition: ibuf0ibuf.cc:1008
UNIV_INTERN ulint ibuf_contract_for_n_pages(ibool sync, ulint n_pages)
Definition: ibuf0ibuf.cc:2730
UNIV_INTERN void ibuf_update_max_tablespace_id(void)
Definition: ibuf0ibuf.cc:3169
UNIV_INLINE ibool ibuf_should_try(dict_index_t *index, ulint ignore_sec_unique)
UNIV_INTERN void ibuf_delete_for_discarded_space(ulint space)
Definition: ibuf0ibuf.cc:4812
UNIV_INTERN void ibuf_close(void)
Definition: ibuf0ibuf.cc:463
UNIV_INTERN ulint ibuf_contract(ibool sync)
Definition: ibuf0ibuf.cc:2712
UNIV_INLINE ibool ibuf_bitmap_page(ulint zip_size, ulint page_no)