drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
ibuf0ibuf.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (C) 1997, 2009, Innobase Oy. All Rights Reserved.
4
5This program is free software; you can redistribute it and/or modify it under
6the terms of the GNU General Public License as published by the Free Software
7Foundation; version 2 of the License.
8
9This program is distributed in the hope that it will be useful, but WITHOUT
10ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
13You should have received a copy of the GNU General Public License along with
14this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15St, Fifth Floor, Boston, MA 02110-1301 USA
16
17*****************************************************************************/
18
19/**************************************************/
25
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
40ibuf_insert(). DO NOT CHANGE THE VALUES OF THESE, THEY ARE STORED ON DISK. */
41typedef 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
53typedef 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 */
63
65extern ibuf_use_t ibuf_use;
66
67#if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG
69extern uint ibuf_debug;
70#endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */
71
73extern ibuf_t* ibuf;
74
75/* The purpose of the insert buffer is to reduce random disk access.
76When we wish to insert a record into a non-unique secondary index and
77the B-tree leaf page where the record belongs to is not in the buffer
78pool, 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
80pool, we look up the insert buffer B-tree for any modifications to the
81page, and apply these upon the completion of the read operation. This
82is called the insert buffer merge. */
83
84/* The insert buffer merge must always succeed. To guarantee this,
85the insert buffer subsystem keeps track of the free space in pages for
86which it can buffer operations. Two bits per page in the insert
87buffer bitmap indicate the available space in coarse increments. The
88free bits in the insert buffer bitmap must never exceed the free space
89on a page. It is safe to decrement or reset the bits in the bitmap in
90a mini-transaction that is committed before the mini-transaction that
91affects the free space. It is unsafe to increment the bits in a
92separately committed mini-transaction, because in crash recovery, the
93free bits could momentarily be set too high. */
94
95/******************************************************************/
97UNIV_INTERN
98void
100/*=======================*/
101/*********************************************************************/
104UNIV_INTERN
105void
107/*===============================*/
108/***************************************************************/
110UNIV_INLINE
111void
113/*===========*/
114 mtr_t* mtr)
115 __attribute__((nonnull));
116/***************************************************************/
118UNIV_INLINE
119void
121/*============*/
122 mtr_t* mtr)
123 __attribute__((nonnull));
124/*********************************************************************/
126UNIV_INTERN
127void
129/*==================*/
130 buf_block_t* block,
131 mtr_t* mtr);
132/************************************************************************/
141UNIV_INTERN
142void
144/*=================*/
145 buf_block_t* block);
148/************************************************************************/
161UNIV_INLINE
162void
164/*==========================*/
165 buf_block_t* block,
170 ulint max_ins_size,
173 ulint increase);
176/**********************************************************************/
184UNIV_INTERN
185void
187/*======================*/
188 const buf_block_t* block,
189 ulint max_ins_size,
194 mtr_t* mtr);
195/**********************************************************************/
203UNIV_INTERN
204void
206/*======================*/
207 buf_block_t* block,
208 mtr_t* mtr);
209/**********************************************************************/
216UNIV_INTERN
217void
219/*====================================*/
220 ulint zip_size,
222 buf_block_t* block1,
223 buf_block_t* block2,
224 mtr_t* mtr);
225/**********************************************************************/
228UNIV_INLINE
229ibool
231/*============*/
232 dict_index_t* index,
233 ulint ignore_sec_unique);
237/******************************************************************/
244UNIV_INLINE
245ibool
247/*========*/
248 const mtr_t* mtr)
249 __attribute__((nonnull, pure));
250/***********************************************************************/
253UNIV_INLINE
254ibool
256/*=============*/
257 ulint zip_size,
259 ulint page_no);
260/***********************************************************************/
264UNIV_INTERN
265ibool
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
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 */
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/***********************************************************************/
308UNIV_INTERN
309void
311/*========================*/
312/*********************************************************************/
317UNIV_INTERN
318ibool
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/*********************************************************************/
335UNIV_INTERN
336void
338/*==========================*/
339 buf_block_t* block,
342 ulint space,
343 ulint page_no,
344 ulint zip_size,
346 ibool update_ibuf_bitmap);
351/*********************************************************************/
356UNIV_INTERN
357void
359/*============================*/
360 ulint space);
361/*********************************************************************/
366UNIV_INTERN
367ulint
369/*==========*/
370 ibool sync);
373/*********************************************************************/
378UNIV_INTERN
379ulint
381/*======================*/
382 ibool sync,
385 ulint n_pages);
388#endif /* !UNIV_HOTBACKUP */
389/*********************************************************************/
392UNIV_INTERN
393byte*
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/******************************************************************/
406UNIV_INTERN
407ulint
408ibuf_count_get(
409/*===========*/
410 ulint space,
411 ulint page_no);
412#endif
413/******************************************************************/
416UNIV_INTERN
417ibool
418ibuf_is_empty(void);
419/*===============*/
420/******************************************************************/
422UNIV_INTERN
423void
425/*=======*/
426 FILE* file);
427/********************************************************************
428Read the first two bytes from a record's fourth field (counter field in new
429records; something else in older records).
430@return "counter" field, or ULINT_UNDEFINED if for some reason it can't be read */
431UNIV_INTERN
432ulint
434/*=================*/
435 const rec_t* rec);
436/******************************************************************/
438UNIV_INTERN
439void
440ibuf_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
449for 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
struct buf_block_struct buf_block_t
Definition buf0types.h:33
UNIV_INTERN ibool ibuf_is_empty(void)
UNIV_INLINE ibool ibuf_should_try(dict_index_t *index, ulint ignore_sec_unique)
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)
UNIV_INLINE void ibuf_mtr_start(mtr_t *mtr) __attribute__((nonnull))
UNIV_INTERN void ibuf_init_at_db_start(void)
Definition ibuf0ibuf.cc:497
UNIV_INTERN void ibuf_update_free_bits_zip(buf_block_t *block, mtr_t *mtr)
UNIV_INTERN void ibuf_delete_for_discarded_space(ulint space)
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)
UNIV_INLINE ibool ibuf_bitmap_page(ulint zip_size, ulint page_no)
UNIV_INTERN ulint ibuf_contract(ibool sync)
UNIV_INLINE ibool ibuf_inside(const mtr_t *mtr) __attribute__((nonnull
UNIV_INTERN ulint ibuf_contract_for_n_pages(ibool sync, ulint n_pages)
UNIV_INTERN void ibuf_update_free_bits_low(const buf_block_t *block, ulint max_ins_size, mtr_t *mtr)
Definition ibuf0ibuf.cc:999
UNIV_INLINE void ibuf_mtr_commit(mtr_t *mtr) __attribute__((nonnull))
UNIV_INTERN ulint ibuf_rec_get_counter(const rec_t *rec)
UNIV_INTERN void ibuf_print(FILE *file)
UNIV_INLINE void ibuf_update_free_bits_if_full(buf_block_t *block, ulint max_ins_size, ulint increase)
ibuf_use_t
Definition ibuf0ibuf.h:53
UNIV_INTERN void ibuf_reset_free_bits(buf_block_t *block)
Definition ibuf0ibuf.cc:980
UNIV_INTERN void ibuf_close(void)
Definition ibuf0ibuf.cc:454
UNIV_INTERN void ibuf_bitmap_page_init(buf_block_t *block, mtr_t *mtr)
Definition ibuf0ibuf.cc:596
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)
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))
UNIV_INTERN void ibuf_update_max_tablespace_id(void)
UNIV_INTERN byte * ibuf_parse_bitmap_init(byte *ptr, byte *end_ptr, buf_block_t *block, mtr_t *mtr)
Definition ibuf0ibuf.cc:633
UNIV_INTERN void ibuf_free_excess_pages(void)