~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/include/ibuf0ibuf.ic

  • Committer: Monty Taylor
  • Date: 2009-08-12 06:25:19 UTC
  • mto: (1114.1.1 innodb-plugin-merge)
  • mto: This revision was merged to the branch mainline in revision 1183.
  • Revision ID: mordred@inaugust.com-20090812062519-cij02mrrunvnxblt
Tags: innodb-plugin-1.0.4
InnoDB Plugin 1.0.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
*****************************************************************************/
18
18
 
19
 
/******************************************************
 
19
/**************************************************//**
 
20
@file include/ibuf0ibuf.ic
20
21
Insert buffer
21
22
 
22
23
Created 7/19/1997 Heikki Tuuri
23
24
*******************************************************/
24
25
 
25
 
#include "buf0lru.h"
26
26
#include "page0page.h"
27
27
#include "page0zip.h"
 
28
#ifndef UNIV_HOTBACKUP
 
29
#include "buf0lru.h"
28
30
 
 
31
/** Counter for ibuf_should_try() */
29
32
extern ulint    ibuf_flush_count;
30
33
 
31
 
/* If this number is n, an index page must contain at least the page size
32
 
per n bytes of free space for ibuf to try to buffer inserts to this page.
33
 
If there is this much of free space, the corresponding bits are set in the
34
 
ibuf bitmap. */
 
34
/** An index page must contain at least UNIV_PAGE_SIZE /
 
35
IBUF_PAGE_SIZE_PER_FREE_SPACE bytes of free space for ibuf to try to
 
36
buffer inserts to this page.  If there is this much of free space, the
 
37
corresponding bits are set in the ibuf bitmap. */
35
38
#define IBUF_PAGE_SIZE_PER_FREE_SPACE   32
36
39
 
37
 
/* Insert buffer struct */
38
 
 
 
40
/** Insert buffer struct */
39
41
struct ibuf_struct{
40
 
        ulint           size;           /* current size of the ibuf index
 
42
        ulint           size;           /*!< current size of the ibuf index
41
43
                                        tree, in pages */
42
 
        ulint           max_size;       /* recommended maximum size of the
 
44
        ulint           max_size;       /*!< recommended maximum size of the
43
45
                                        ibuf index tree, in pages */
44
 
        ulint           seg_size;       /* allocated pages of the file
 
46
        ulint           seg_size;       /*!< allocated pages of the file
45
47
                                        segment containing ibuf header and
46
48
                                        tree */
47
 
        ibool           empty;          /* after an insert to the ibuf tree
 
49
        ibool           empty;          /*!< after an insert to the ibuf tree
48
50
                                        is performed, this is set to FALSE,
49
51
                                        and if a contract operation finds
50
52
                                        the tree empty, this is set to
51
53
                                        TRUE */
52
 
        ulint           free_list_len;  /* length of the free list */
53
 
        ulint           height;         /* tree height */
54
 
        dict_index_t*   index;          /* insert buffer index */
 
54
        ulint           free_list_len;  /*!< length of the free list */
 
55
        ulint           height;         /*!< tree height */
 
56
        dict_index_t*   index;          /*!< insert buffer index */
55
57
 
56
 
        ulint           n_inserts;      /* number of inserts made to
 
58
        ulint           n_inserts;      /*!< number of inserts made to
57
59
                                        the insert buffer */
58
 
        ulint           n_merges;       /* number of pages merged */
59
 
        ulint           n_merged_recs;  /* number of records merged */
 
60
        ulint           n_merges;       /*!< number of pages merged */
 
61
        ulint           n_merged_recs;  /*!< number of records merged */
60
62
};
61
63
 
62
 
/****************************************************************************
 
64
/************************************************************************//**
63
65
Sets the free bit of the page in the ibuf bitmap. This is done in a separate
64
66
mini-transaction, hence this operation does not restrict further work to only
65
67
ibuf bitmap operations, which would result if the latch to the bitmap page
68
70
void
69
71
ibuf_set_free_bits_func(
70
72
/*====================*/
71
 
        buf_block_t*    block,  /* in: index page of a non-clustered index;
 
73
        buf_block_t*    block,  /*!< in: index page of a non-clustered index;
72
74
                                free bit is reset if page level is 0 */
73
75
#ifdef UNIV_IBUF_DEBUG
74
 
        ulint           max_val,/* in: ULINT_UNDEFINED or a maximum
 
76
        ulint           max_val,/*!< in: ULINT_UNDEFINED or a maximum
75
77
                                value which the bits must have before
76
78
                                setting; this is for debugging */
77
79
#endif /* UNIV_IBUF_DEBUG */
78
 
        ulint           val);   /* in: value to set: < 4 */
 
80
        ulint           val);   /*!< in: value to set: < 4 */
79
81
#ifdef UNIV_IBUF_DEBUG
80
82
# define ibuf_set_free_bits(b,v,max) ibuf_set_free_bits_func(b,max,v)
81
83
#else /* UNIV_IBUF_DEBUG */
82
84
# define ibuf_set_free_bits(b,v,max) ibuf_set_free_bits_func(b,v)
83
85
#endif /* UNIV_IBUF_DEBUG */
84
86
 
85
 
/**************************************************************************
 
87
/**********************************************************************//**
86
88
A basic partial test if an insert to the insert buffer could be possible and
87
89
recommended. */
88
90
UNIV_INLINE
89
91
ibool
90
92
ibuf_should_try(
91
93
/*============*/
92
 
        dict_index_t*   index,                  /* in: index where to insert */
93
 
        ulint           ignore_sec_unique)      /* in: if != 0, we should
 
94
        dict_index_t*   index,                  /*!< in: index where to insert */
 
95
        ulint           ignore_sec_unique)      /*!< in: if != 0, we should
94
96
                                                ignore UNIQUE constraint on
95
97
                                                a secondary index when we
96
98
                                                decide */
112
114
        return(FALSE);
113
115
}
114
116
 
115
 
/***************************************************************************
116
 
Checks if a page address is an ibuf bitmap page address. */
 
117
/***********************************************************************//**
 
118
Checks if a page address is an ibuf bitmap page address.
 
119
@return TRUE if a bitmap page */
117
120
UNIV_INLINE
118
121
ibool
119
122
ibuf_bitmap_page(
120
123
/*=============*/
121
 
                        /* out: TRUE if a bitmap page */
122
 
        ulint   zip_size,/* in: compressed page size in bytes;
 
124
        ulint   zip_size,/*!< in: compressed page size in bytes;
123
125
                        0 for uncompressed pages */
124
 
        ulint   page_no)/* in: page number */
 
126
        ulint   page_no)/*!< in: page number */
125
127
{
126
128
        ut_ad(ut_is_2pow(zip_size));
127
129
 
134
136
                             == FSP_IBUF_BITMAP_OFFSET));
135
137
}
136
138
 
137
 
/*************************************************************************
138
 
Translates the free space on a page to a value in the ibuf bitmap.*/
 
139
/*********************************************************************//**
 
140
Translates the free space on a page to a value in the ibuf bitmap.
 
141
@return value for ibuf bitmap bits */
139
142
UNIV_INLINE
140
143
ulint
141
144
ibuf_index_page_calc_free_bits(
142
145
/*===========================*/
143
 
                                /* out: value for ibuf bitmap bits */
144
 
        ulint   zip_size,       /* in: compressed page size in bytes;
 
146
        ulint   zip_size,       /*!< in: compressed page size in bytes;
145
147
                                0 for uncompressed pages */
146
 
        ulint   max_ins_size)   /* in: maximum insert size after reorganize
 
148
        ulint   max_ins_size)   /*!< in: maximum insert size after reorganize
147
149
                                for the page */
148
150
{
149
151
        ulint   n;
170
172
        return(n);
171
173
}
172
174
 
173
 
/*************************************************************************
174
 
Translates the ibuf free bits to the free space on a page in bytes. */
 
175
/*********************************************************************//**
 
176
Translates the ibuf free bits to the free space on a page in bytes.
 
177
@return maximum insert size after reorganize for the page */
175
178
UNIV_INLINE
176
179
ulint
177
180
ibuf_index_page_calc_free_from_bits(
178
181
/*================================*/
179
 
                        /* out: maximum insert size after reorganize for the
180
 
                        page */
181
 
        ulint   zip_size,/* in: compressed page size in bytes;
 
182
        ulint   zip_size,/*!< in: compressed page size in bytes;
182
183
                        0 for uncompressed pages */
183
 
        ulint   bits)   /* in: value for ibuf bitmap bits */
 
184
        ulint   bits)   /*!< in: value for ibuf bitmap bits */
184
185
{
185
186
        ut_ad(bits < 4);
186
187
        ut_ad(ut_is_2pow(zip_size));
202
203
        return(bits * (UNIV_PAGE_SIZE / IBUF_PAGE_SIZE_PER_FREE_SPACE));
203
204
}
204
205
 
205
 
/*************************************************************************
206
 
Translates the free space on a compressed page to a value in the ibuf bitmap.*/
 
206
/*********************************************************************//**
 
207
Translates the free space on a compressed page to a value in the ibuf bitmap.
 
208
@return value for ibuf bitmap bits */
207
209
UNIV_INLINE
208
210
ulint
209
211
ibuf_index_page_calc_free_zip(
210
212
/*==========================*/
211
 
                                        /* out: value for ibuf bitmap bits */
212
213
        ulint                   zip_size,
213
 
                                        /* in: compressed page size in bytes */
214
 
        const buf_block_t*      block)  /* in: buffer block */
 
214
                                        /*!< in: compressed page size in bytes */
 
215
        const buf_block_t*      block)  /*!< in: buffer block */
215
216
{
216
217
        ulint                   max_ins_size;
217
218
        const page_zip_des_t*   page_zip;
236
237
        return(ibuf_index_page_calc_free_bits(zip_size, max_ins_size));
237
238
}
238
239
 
239
 
/*************************************************************************
240
 
Translates the free space on a page to a value in the ibuf bitmap.*/
 
240
/*********************************************************************//**
 
241
Translates the free space on a page to a value in the ibuf bitmap.
 
242
@return value for ibuf bitmap bits */
241
243
UNIV_INLINE
242
244
ulint
243
245
ibuf_index_page_calc_free(
244
246
/*======================*/
245
 
                                        /* out: value for ibuf bitmap bits */
246
 
        ulint                   zip_size,/* in: compressed page size in bytes;
 
247
        ulint                   zip_size,/*!< in: compressed page size in bytes;
247
248
                                        0 for uncompressed pages */
248
 
        const buf_block_t*      block)  /* in: buffer block */
 
249
        const buf_block_t*      block)  /*!< in: buffer block */
249
250
{
250
251
        ut_ad(zip_size == buf_block_get_zip_size(block));
251
252
 
261
262
        }
262
263
}
263
264
 
264
 
/****************************************************************************
 
265
/************************************************************************//**
265
266
Updates the free bits of an uncompressed page in the ibuf bitmap if
266
267
there is not enough free on the page any more.  This is done in a
267
268
separate mini-transaction, hence this operation does not restrict
278
279
void
279
280
ibuf_update_free_bits_if_full(
280
281
/*==========================*/
281
 
        buf_block_t*    block,  /* in: index page to which we have added new
 
282
        buf_block_t*    block,  /*!< in: index page to which we have added new
282
283
                                records; the free bits are updated if the
283
284
                                index is non-clustered and non-unique and
284
285
                                the page level is 0, and the page becomes
285
286
                                fuller */
286
 
        ulint           max_ins_size,/* in: value of maximum insert size with
 
287
        ulint           max_ins_size,/*!< in: value of maximum insert size with
287
288
                                reorganize before the latest operation
288
289
                                performed to the page */
289
 
        ulint           increase)/* in: upper limit for the additional space
 
290
        ulint           increase)/*!< in: upper limit for the additional space
290
291
                                used in the latest operation, if known, or
291
292
                                ULINT_UNDEFINED */
292
293
{
323
324
                ibuf_set_free_bits(block, after, before);
324
325
        }
325
326
}
 
327
#endif /* !UNIV_HOTBACKUP */