55
54
mini-transaction, hence this operation does not restrict further work to only
56
55
ibuf bitmap operations, which would result if the latch to the bitmap page
60
ibuf_set_free_bits_func(
61
/*====================*/
62
buf_block_t* block, /* in: index page of a non-clustered index;
63
free bit is reset if page level is 0 */
64
#ifdef UNIV_IBUF_DEBUG
65
ulint max_val,/* in: ULINT_UNDEFINED or a maximum
66
value which the bits must have before
67
setting; this is for debugging */
68
#endif /* UNIV_IBUF_DEBUG */
69
ulint val); /* in: value to set: < 4 */
70
#ifdef UNIV_IBUF_DEBUG
71
# define ibuf_set_free_bits(b,v,max) ibuf_set_free_bits_func(b,max,v)
72
#else /* UNIV_IBUF_DEBUG */
73
# define ibuf_set_free_bits(b,v,max) ibuf_set_free_bits_func(b,v)
74
#endif /* UNIV_IBUF_DEBUG */
61
ulint type, /* in: index type */
62
page_t* page, /* in: index page; free bit is reset if the index is
63
a non-clustered non-unique, and page level is 0 */
64
ulint val, /* in: value to set: < 4 */
65
ulint max_val);/* in: ULINT_UNDEFINED or a maximum value which
66
the bits must have before setting; this is for
76
69
/**************************************************************************
77
70
A basic partial test if an insert to the insert buffer could be possible and
86
79
a secondary index when we
89
if (!dict_index_is_clust(index)
90
&& (ignore_sec_unique || !dict_index_is_unique(index))) {
82
if (!(index->type & DICT_CLUSTERED)
83
&& (ignore_sec_unique || !(index->type & DICT_UNIQUE))) {
92
85
ibuf_flush_count++;
109
102
ibuf_bitmap_page(
110
103
/*=============*/
111
104
/* out: TRUE if a bitmap page */
112
ulint zip_size,/* in: compressed page size in bytes;
113
0 for uncompressed pages */
114
105
ulint page_no)/* in: page number */
116
ut_ad(ut_is_2pow(zip_size));
107
if (page_no % XDES_DESCRIBED_PER_PAGE == FSP_IBUF_BITMAP_OFFSET) {
119
return(UNIV_UNLIKELY((page_no & (UNIV_PAGE_SIZE - 1))
120
== FSP_IBUF_BITMAP_OFFSET));
123
return(UNIV_UNLIKELY((page_no & (zip_size - 1))
124
== FSP_IBUF_BITMAP_OFFSET));
127
115
/*************************************************************************
131
119
ibuf_index_page_calc_free_bits(
132
120
/*===========================*/
133
121
/* out: value for ibuf bitmap bits */
134
ulint zip_size, /* in: compressed page size in bytes;
135
0 for uncompressed pages */
136
122
ulint max_ins_size) /* in: maximum insert size after reorganize
140
ut_ad(ut_is_2pow(zip_size));
141
ut_ad(!zip_size || zip_size > IBUF_PAGE_SIZE_PER_FREE_SPACE);
142
ut_ad(zip_size <= UNIV_PAGE_SIZE);
146
/ (zip_size / IBUF_PAGE_SIZE_PER_FREE_SPACE);
149
/ (UNIV_PAGE_SIZE / IBUF_PAGE_SIZE_PER_FREE_SPACE);
127
n = max_ins_size / (UNIV_PAGE_SIZE / IBUF_PAGE_SIZE_PER_FREE_SPACE);
168
145
/*================================*/
169
146
/* out: maximum insert size after reorganize for the
171
ulint zip_size,/* in: compressed page size in bytes;
172
0 for uncompressed pages */
173
148
ulint bits) /* in: value for ibuf bitmap bits */
176
ut_ad(ut_is_2pow(zip_size));
177
ut_ad(!zip_size || zip_size > IBUF_PAGE_SIZE_PER_FREE_SPACE);
178
ut_ad(zip_size <= UNIV_PAGE_SIZE);
182
return(4 * zip_size / IBUF_PAGE_SIZE_PER_FREE_SPACE);
185
return(bits * zip_size / IBUF_PAGE_SIZE_PER_FREE_SPACE);
189
153
return(4 * UNIV_PAGE_SIZE / IBUF_PAGE_SIZE_PER_FREE_SPACE);
192
return(bits * (UNIV_PAGE_SIZE / IBUF_PAGE_SIZE_PER_FREE_SPACE));
195
/*************************************************************************
196
Translates the free space on a compressed page to a value in the ibuf bitmap.*/
199
ibuf_index_page_calc_free_zip(
200
/*==========================*/
201
/* out: value for ibuf bitmap bits */
203
/* in: compressed page size in bytes */
204
const buf_block_t* block) /* in: buffer block */
207
const page_zip_des_t* page_zip;
210
ut_ad(zip_size == buf_block_get_zip_size(block));
213
max_ins_size = page_get_max_insert_size_after_reorganize(
214
buf_block_get_frame(block), 1);
216
page_zip = buf_block_get_page_zip(block);
217
zip_max_ins = page_zip_max_ins_size(page_zip,
218
FALSE/* not clustered */);
220
if (UNIV_UNLIKELY(zip_max_ins < 0)) {
222
} else if (UNIV_LIKELY(max_ins_size > (ulint) zip_max_ins)) {
223
max_ins_size = (ulint) zip_max_ins;
226
return(ibuf_index_page_calc_free_bits(zip_size, max_ins_size));
156
return(bits * UNIV_PAGE_SIZE / IBUF_PAGE_SIZE_PER_FREE_SPACE);
229
159
/*************************************************************************
233
163
ibuf_index_page_calc_free(
234
164
/*======================*/
235
/* out: value for ibuf bitmap bits */
236
ulint zip_size,/* in: compressed page size in bytes;
237
0 for uncompressed pages */
238
const buf_block_t* block) /* in: buffer block */
165
/* out: value for ibuf bitmap bits */
166
page_t* page) /* in: non-unique secondary index page */
240
ut_ad(zip_size == buf_block_get_zip_size(block));
245
max_ins_size = page_get_max_insert_size_after_reorganize(
246
buf_block_get_frame(block), 1);
248
return(ibuf_index_page_calc_free_bits(0, max_ins_size));
250
return(ibuf_index_page_calc_free_zip(zip_size, block));
168
return(ibuf_index_page_calc_free_bits(
169
page_get_max_insert_size_after_reorganize(page, 1)));
254
172
/****************************************************************************
255
Updates the free bits of an uncompressed page in the ibuf bitmap if
256
there is not enough free on the page any more. This is done in a
257
separate mini-transaction, hence this operation does not restrict
258
further work to only ibuf bitmap operations, which would result if the
259
latch to the bitmap page were kept. */
173
Updates the free bits of the page in the ibuf bitmap if there is not enough
174
free on the page any more. This is done in a separate mini-transaction, hence
175
this operation does not restrict further work to only ibuf bitmap operations,
176
which would result if the latch to the bitmap page were kept. */
262
179
ibuf_update_free_bits_if_full(
263
180
/*==========================*/
264
buf_block_t* block, /* in: index page to which we have added new
181
dict_index_t* index, /* in: index */
182
page_t* page, /* in: index page to which we have added new
265
183
records; the free bits are updated if the
266
184
index is non-clustered and non-unique and
267
185
the page level is 0, and the page becomes
279
ut_ad(!buf_block_get_page_zip(block));
281
before = ibuf_index_page_calc_free_bits(0, max_ins_size);
197
before = ibuf_index_page_calc_free_bits(max_ins_size);
283
199
if (max_ins_size >= increase) {
284
200
#if ULINT32_UNDEFINED <= UNIV_PAGE_SIZE
285
201
# error "ULINT32_UNDEFINED <= UNIV_PAGE_SIZE"
287
after = ibuf_index_page_calc_free_bits(0, max_ins_size
203
after = ibuf_index_page_calc_free_bits(max_ins_size
289
205
#ifdef UNIV_IBUF_DEBUG
290
ut_a(after <= ibuf_index_page_calc_free(0, block));
206
ut_a(after <= ibuf_index_page_calc_free(page));
293
after = ibuf_index_page_calc_free(0, block);
209
after = ibuf_index_page_calc_free(page);
296
212
if (after == 0) {
299
215
cannot make inserts using the insert buffer from slipping
300
216
out of the buffer pool */
302
buf_page_make_young(&block->page);
218
buf_page_make_young(page);
305
221
if (before > after) {
306
ibuf_set_free_bits(block, after, before);
222
ibuf_set_free_bits(index->type, page, after, before);