~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Brian Aker
  • Date: 2008-11-04 15:39:09 UTC
  • mfrom: (575.1.2 devel)
  • Revision ID: brian@tangent.org-20081104153909-c72hn65udxs1ccal
Merge of Monty's work

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
root page of the insert buffer tree in the tablespace. This function can
26
26
be called only after the dictionary system has been initialized, as this
27
27
creates also the insert buffer table and index for this tablespace. */
28
 
 
 
28
UNIV_INTERN
29
29
ibuf_data_t*
30
30
ibuf_data_init_for_space(
31
31
/*=====================*/
35
35
/**********************************************************************
36
36
Creates the insert buffer data structure at a database startup and
37
37
initializes the data structures for the insert buffer of each tablespace. */
38
 
 
 
38
UNIV_INTERN
39
39
void
40
40
ibuf_init_at_db_start(void);
41
41
/*=======================*/
42
42
/*************************************************************************
43
43
Reads the biggest tablespace id from the high end of the insert buffer
44
44
tree and updates the counter in fil_system. */
45
 
 
 
45
UNIV_INTERN
46
46
void
47
47
ibuf_update_max_tablespace_id(void);
48
48
/*===============================*/
49
49
/*************************************************************************
50
50
Initializes an ibuf bitmap page. */
51
 
 
 
51
UNIV_INTERN
52
52
void
53
53
ibuf_bitmap_page_init(
54
54
/*==================*/
55
 
        page_t* page,   /* in: bitmap page */
56
 
        mtr_t*  mtr);   /* in: mtr */
 
55
        buf_block_t*    block,  /* in: bitmap page */
 
56
        mtr_t*          mtr);   /* in: mtr */
57
57
/****************************************************************************
58
58
Resets the free bits of the page in the ibuf bitmap. This is done in a
59
59
separate mini-transaction, hence this operation does not restrict further
60
60
work to only ibuf bitmap operations, which would result if the latch to the
61
61
bitmap page were kept. */
62
 
 
63
 
void
64
 
ibuf_reset_free_bits_with_type(
65
 
/*===========================*/
66
 
        ulint   type,   /* in: index type */
67
 
        page_t* page);  /* in: index page; free bits are set to 0 if the index
68
 
                        is non-clustered and non-unique and the page level is
69
 
                        0 */
70
 
/****************************************************************************
71
 
Resets the free bits of the page in the ibuf bitmap. This is done in a
72
 
separate mini-transaction, hence this operation does not restrict further
73
 
work to solely ibuf bitmap operations, which would result if the latch to
74
 
the bitmap page were kept. */
75
 
 
 
62
UNIV_INTERN
76
63
void
77
64
ibuf_reset_free_bits(
78
65
/*=================*/
79
 
        dict_index_t*   index,  /* in: index */
80
 
        page_t*         page);  /* in: index page; free bits are set to 0 if
81
 
                                the index is non-clustered and non-unique and
82
 
                                the page level is 0 */
 
66
        buf_block_t*    block); /* in: index page; free bits are set to 0
 
67
                                if the index is a non-clustered
 
68
                                non-unique, and page level is 0 */
83
69
/****************************************************************************
84
 
Updates the free bits of the page in the ibuf bitmap if there is not enough
85
 
free on the page any more. This is done in a separate mini-transaction, hence
86
 
this operation does not restrict further work to only ibuf bitmap operations,
87
 
which would result if the latch to the bitmap page were kept. */
 
70
Updates the free bits of an uncompressed page in the ibuf bitmap if
 
71
there is not enough free on the page any more. This is done in a
 
72
separate mini-transaction, hence this operation does not restrict
 
73
further work to only ibuf bitmap operations, which would result if the
 
74
latch to the bitmap page were kept. */
88
75
UNIV_INLINE
89
76
void
90
77
ibuf_update_free_bits_if_full(
91
78
/*==========================*/
92
 
        dict_index_t*   index,  /* in: index */
93
 
        page_t*         page,   /* in: index page to which we have added new
 
79
        buf_block_t*    block,  /* in: index page to which we have added new
94
80
                                records; the free bits are updated if the
95
81
                                index is non-clustered and non-unique and
96
82
                                the page level is 0, and the page becomes
102
88
                                used in the latest operation, if known, or
103
89
                                ULINT_UNDEFINED */
104
90
/**************************************************************************
105
 
Updates the free bits for the page to reflect the present state. Does this
106
 
in the mtr given, which means that the latching order rules virtually
 
91
Updates the free bits for an uncompressed page to reflect the present state.
 
92
Does this in the mtr given, which means that the latching order rules virtually
107
93
prevent any further operations for this OS thread until mtr is committed. */
108
 
 
 
94
UNIV_INTERN
109
95
void
110
96
ibuf_update_free_bits_low(
111
97
/*======================*/
112
 
        dict_index_t*   index,          /* in: index */
113
 
        page_t*         page,           /* in: index page */
114
 
        ulint           max_ins_size,   /* in: value of maximum insert size
115
 
                                        with reorganize before the latest
116
 
                                        operation performed to the page */
117
 
        mtr_t*          mtr);           /* in: mtr */
 
98
        const buf_block_t*      block,          /* in: index page */
 
99
        ulint                   max_ins_size,   /* in: value of
 
100
                                                maximum insert size
 
101
                                                with reorganize before
 
102
                                                the latest operation
 
103
                                                performed to the page */
 
104
        mtr_t*                  mtr);           /* in/out: mtr */
 
105
/**************************************************************************
 
106
Updates the free bits for a compressed page to reflect the present state.
 
107
Does this in the mtr given, which means that the latching order rules virtually
 
108
prevent any further operations for this OS thread until mtr is committed. */
 
109
UNIV_INTERN
 
110
void
 
111
ibuf_update_free_bits_zip(
 
112
/*======================*/
 
113
        buf_block_t*    block,  /* in/out: index page */
 
114
        mtr_t*          mtr);   /* in/out: mtr */
118
115
/**************************************************************************
119
116
Updates the free bits for the two pages to reflect the present state. Does
120
117
this in the mtr given, which means that the latching order rules virtually
121
118
prevent any further operations until mtr is committed. */
122
 
 
 
119
UNIV_INTERN
123
120
void
124
121
ibuf_update_free_bits_for_two_pages_low(
125
122
/*====================================*/
126
 
        dict_index_t*   index,  /* in: index */
127
 
        page_t*         page1,  /* in: index page */
128
 
        page_t*         page2,  /* in: index page */
 
123
        ulint           zip_size,/* in: compressed page size in bytes;
 
124
                                0 for uncompressed pages */
 
125
        buf_block_t*    block1, /* in: index page */
 
126
        buf_block_t*    block2, /* in: index page */
129
127
        mtr_t*          mtr);   /* in: mtr */
130
128
/**************************************************************************
131
129
A basic partial test if an insert to the insert buffer could be possible and
142
140
/**********************************************************************
143
141
Returns TRUE if the current OS thread is performing an insert buffer
144
142
routine. */
145
 
 
 
143
UNIV_INTERN
146
144
ibool
147
145
ibuf_inside(void);
148
146
/*=============*/
155
153
ibuf_bitmap_page(
156
154
/*=============*/
157
155
                        /* out: TRUE if a bitmap page */
 
156
        ulint   zip_size,/* in: compressed page size in bytes;
 
157
                        0 for uncompressed pages */
158
158
        ulint   page_no);/* in: page number */
159
159
/***************************************************************************
160
160
Checks if a page is a level 2 or 3 page in the ibuf hierarchy of pages. */
161
 
 
 
161
UNIV_INTERN
162
162
ibool
163
163
ibuf_page(
164
164
/*======*/
165
165
                        /* out: TRUE if level 2 or level 3 page */
166
166
        ulint   space,  /* in: space id */
 
167
        ulint   zip_size,/* in: compressed page size in bytes, or 0 */
167
168
        ulint   page_no);/* in: page number */
168
169
/***************************************************************************
169
170
Checks if a page is a level 2 or 3 page in the ibuf hierarchy of pages. */
170
 
 
 
171
UNIV_INTERN
171
172
ibool
172
173
ibuf_page_low(
173
174
/*==========*/
174
175
                        /* out: TRUE if level 2 or level 3 page */
175
176
        ulint   space,  /* in: space id */
 
177
        ulint   zip_size,/* in: compressed page size in bytes, or 0 */
176
178
        ulint   page_no,/* in: page number */
177
179
        mtr_t*  mtr);   /* in: mtr which will contain an x-latch to the
178
180
                        bitmap page if the page is not one of the fixed
181
183
Frees excess pages from the ibuf free list. This function is called when an OS
182
184
thread calls fsp services to allocate a new file segment, or a new page to a
183
185
file segment, and the thread did not own the fsp latch before this call. */
184
 
 
 
186
UNIV_INTERN
185
187
void
186
188
ibuf_free_excess_pages(
187
189
/*===================*/
188
 
        ulint   space); /* in: space id */
 
190
        ulint   space);         /* in: space id */
189
191
/*************************************************************************
190
192
Makes an index insert to the insert buffer, instead of directly to the disk
191
193
page, if this is possible. Does not do insert if the index is clustered
192
194
or unique. */
193
 
 
 
195
UNIV_INTERN
194
196
ibool
195
197
ibuf_insert(
196
198
/*========*/
197
199
                                /* out: TRUE if success */
198
 
        dtuple_t*       entry,  /* in: index entry to insert */
 
200
        const dtuple_t* entry,  /* in: index entry to insert */
199
201
        dict_index_t*   index,  /* in: index where to insert */
200
202
        ulint           space,  /* in: space id where to insert */
 
203
        ulint           zip_size,/* in: compressed page size in bytes, or 0 */
201
204
        ulint           page_no,/* in: page number where to insert */
202
205
        que_thr_t*      thr);   /* in: query thread */
203
206
/*************************************************************************
207
210
created in the buffer pool, this function deletes its buffered entries from
208
211
the insert buffer; there can exist entries for such a page if the page
209
212
belonged to an index which subsequently was dropped. */
210
 
 
 
213
UNIV_INTERN
211
214
void
212
215
ibuf_merge_or_delete_for_page(
213
216
/*==========================*/
214
 
        page_t* page,   /* in: if page has been read from disk, pointer to
215
 
                        the page x-latched, else NULL */
216
 
        ulint   space,  /* in: space id of the index page */
217
 
        ulint   page_no,/* in: page number of the index page */
218
 
        ibool   update_ibuf_bitmap);/* in: normally this is set to TRUE, but if
219
 
                        we have deleted or are deleting the tablespace, then we
220
 
                        naturally do not want to update a non-existent bitmap
221
 
                        page */
 
217
        buf_block_t*    block,  /* in: if page has been read from
 
218
                                disk, pointer to the page x-latched,
 
219
                                else NULL */
 
220
        ulint           space,  /* in: space id of the index page */
 
221
        ulint           page_no,/* in: page number of the index page */
 
222
        ulint           zip_size,/* in: compressed page size in bytes,
 
223
                                or 0 */
 
224
        ibool           update_ibuf_bitmap);/* in: normally this is set
 
225
                                to TRUE, but if we have deleted or are
 
226
                                deleting the tablespace, then we
 
227
                                naturally do not want to update a
 
228
                                non-existent bitmap page */
222
229
/*************************************************************************
223
230
Deletes all entries in the insert buffer for a given space id. This is used
224
231
in DISCARD TABLESPACE and IMPORT TABLESPACE.
225
232
NOTE: this does not update the page free bitmaps in the space. The space will
226
233
become CORRUPT when you call this function! */
227
 
 
 
234
UNIV_INTERN
228
235
void
229
236
ibuf_delete_for_discarded_space(
230
237
/*============================*/
231
238
        ulint   space); /* in: space id */
232
239
/*************************************************************************
233
240
Contracts insert buffer trees by reading pages to the buffer pool. */
234
 
 
 
241
UNIV_INTERN
235
242
ulint
236
243
ibuf_contract(
237
244
/*==========*/
243
250
                        to complete */
244
251
/*************************************************************************
245
252
Contracts insert buffer trees by reading pages to the buffer pool. */
246
 
 
 
253
UNIV_INTERN
247
254
ulint
248
255
ibuf_contract_for_n_pages(
249
256
/*======================*/
258
265
                        them */
259
266
/*************************************************************************
260
267
Parses a redo log record of an ibuf bitmap page init. */
261
 
 
 
268
UNIV_INTERN
262
269
byte*
263
270
ibuf_parse_bitmap_init(
264
271
/*===================*/
265
 
                        /* out: end of log record or NULL */
266
 
        byte*   ptr,    /* in: buffer */
267
 
        byte*   end_ptr,/* in: buffer end */
268
 
        page_t* page,   /* in: page or NULL */
269
 
        mtr_t*  mtr);   /* in: mtr or NULL */
270
 
#ifdef UNIV_IBUF_DEBUG
 
272
                                /* out: end of log record or NULL */
 
273
        byte*           ptr,    /* in: buffer */
 
274
        byte*           end_ptr,/* in: buffer end */
 
275
        buf_block_t*    block,  /* in: block or NULL */
 
276
        mtr_t*          mtr);   /* in: mtr or NULL */
 
277
#ifdef UNIV_IBUF_COUNT_DEBUG
271
278
/**********************************************************************
272
279
Gets the ibuf count for a given page. */
273
 
 
 
280
UNIV_INTERN
274
281
ulint
275
282
ibuf_count_get(
276
283
/*===========*/
281
288
#endif
282
289
/**********************************************************************
283
290
Looks if the insert buffer is empty. */
284
 
 
 
291
UNIV_INTERN
285
292
ibool
286
293
ibuf_is_empty(void);
287
294
/*===============*/
288
295
                        /* out: TRUE if empty */
289
296
/**********************************************************************
290
297
Prints info of ibuf. */
291
 
 
 
298
UNIV_INTERN
292
299
void
293
300
ibuf_print(
294
301
/*=======*/