~mysql/mysql-server/mysql-6.0

« back to all changes in this revision

Viewing changes to innobase/include/ibuf0ibuf.h

  • Committer: monty at mysql
  • Date: 2001-02-17 12:19:19 UTC
  • mto: (554.1.1)
  • mto: This revision was merged to the branch mainline in revision 556.
  • Revision ID: sp1r-monty@donna.mysql.com-20010217121919-07904
Added Innobase to source distribution

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************
 
2
Insert buffer
 
3
 
 
4
(c) 1997 Innobase Oy
 
5
 
 
6
Created 7/19/1997 Heikki Tuuri
 
7
*******************************************************/
 
8
 
 
9
#ifndef ibuf0ibuf_h
 
10
#define ibuf0ibuf_h
 
11
 
 
12
#include "univ.i"
 
13
 
 
14
#include "dict0mem.h"
 
15
#include "dict0dict.h"
 
16
#include "mtr0mtr.h"
 
17
#include "que0types.h"
 
18
#include "ibuf0types.h"
 
19
#include "fsp0fsp.h"
 
20
 
 
21
extern ibuf_t*  ibuf;
 
22
 
 
23
/**********************************************************************
 
24
Creates the insert buffer data struct for a single tablespace. Reads the
 
25
root page of the insert buffer tree in the tablespace. This function can
 
26
be called only after the dictionary system has been initialized, as this
 
27
creates also the insert buffer table and index for this tablespace. */
 
28
 
 
29
ibuf_data_t*
 
30
ibuf_data_init_for_space(
 
31
/*=====================*/
 
32
                        /* out, own: ibuf data struct, linked to the list
 
33
                        in ibuf control structure. */
 
34
        ulint   space); /* in: space id */
 
35
/**********************************************************************
 
36
Creates the insert buffer data structure at a database startup and
 
37
initializes the data structures for the insert buffer of each tablespace. */
 
38
 
 
39
void
 
40
ibuf_init_at_db_start(void);
 
41
/*=======================*/
 
42
/*************************************************************************
 
43
Initializes an ibuf bitmap page. */
 
44
 
 
45
void
 
46
ibuf_bitmap_page_init(
 
47
/*==================*/
 
48
        page_t* page,   /* in: bitmap page */
 
49
        mtr_t*  mtr);   /* in: mtr */
 
50
/****************************************************************************
 
51
Resets the free bits of the page in the ibuf bitmap. This is done in a
 
52
separate mini-transaction, hence this operation does not restrict further
 
53
work to only ibuf bitmap operations, which would result if the latch to the
 
54
bitmap page were kept. */
 
55
 
 
56
void
 
57
ibuf_reset_free_bits_with_type(
 
58
/*===========================*/
 
59
        ulint   type,   /* in: index type */
 
60
        page_t* page);  /* in: index page; free bits are set to 0 if the index
 
61
                        is non-clustered and non-unique and the page level is
 
62
                        0 */
 
63
/****************************************************************************
 
64
Resets the free bits of the page in the ibuf bitmap. This is done in a
 
65
separate mini-transaction, hence this operation does not restrict further
 
66
work to solely ibuf bitmap operations, which would result if the latch to
 
67
the bitmap page were kept. */
 
68
 
 
69
void
 
70
ibuf_reset_free_bits(
 
71
/*=================*/
 
72
        dict_index_t*   index,  /* in: index */
 
73
        page_t*         page);  /* in: index page; free bits are set to 0 if
 
74
                                the index is non-clustered and non-unique and
 
75
                                the page level is 0 */
 
76
/****************************************************************************
 
77
Updates the free bits of the page in the ibuf bitmap if there is not enough
 
78
free on the page any more. This is done in a separate mini-transaction, hence
 
79
this operation does not restrict further work to only ibuf bitmap operations,
 
80
which would result if the latch to the bitmap page were kept. */
 
81
UNIV_INLINE
 
82
void
 
83
ibuf_update_free_bits_if_full(
 
84
/*==========================*/
 
85
        dict_index_t*   index,  /* in: index */
 
86
        page_t*         page,   /* in: index page to which we have added new
 
87
                                records; the free bits are updated if the
 
88
                                index is non-clustered and non-unique and
 
89
                                the page level is 0, and the page becomes
 
90
                                fuller */
 
91
        ulint           max_ins_size,/* in: value of maximum insert size with
 
92
                                reorganize before the latest operation
 
93
                                performed to the page */
 
94
        ulint           increase);/* in: upper limit for the additional space
 
95
                                used in the latest operation, if known, or
 
96
                                ULINT_UNDEFINED */
 
97
/**************************************************************************
 
98
Updates the free bits for the page to reflect the present state. Does this
 
99
in the mtr given, which means that the latching order rules virtually
 
100
prevent any further operations for this OS thread until mtr is committed. */
 
101
 
 
102
void
 
103
ibuf_update_free_bits_low(
 
104
/*======================*/
 
105
        dict_index_t*   index,          /* in: index */
 
106
        page_t*         page,           /* in: index page */
 
107
        ulint           max_ins_size,   /* in: value of maximum insert size
 
108
                                        with reorganize before the latest
 
109
                                        operation performed to the page */
 
110
        mtr_t*          mtr);           /* in: mtr */
 
111
/**************************************************************************
 
112
Updates the free bits for the two pages to reflect the present state. Does
 
113
this in the mtr given, which means that the latching order rules virtually
 
114
prevent any further operations until mtr is committed. */
 
115
 
 
116
void
 
117
ibuf_update_free_bits_for_two_pages_low(
 
118
/*====================================*/
 
119
        dict_index_t*   index,  /* in: index */
 
120
        page_t*         page1,  /* in: index page */
 
121
        page_t*         page2,  /* in: index page */
 
122
        mtr_t*          mtr);   /* in: mtr */
 
123
/**************************************************************************
 
124
A basic partial test if an insert to the insert buffer could be possible and
 
125
recommended. */
 
126
UNIV_INLINE
 
127
ibool
 
128
ibuf_should_try(
 
129
/*============*/
 
130
        dict_index_t*   index); /* in: index where to insert */
 
131
/**********************************************************************
 
132
Returns TRUE if the current OS thread is performing an insert buffer
 
133
routine. */
 
134
 
 
135
ibool
 
136
ibuf_inside(void);
 
137
/*=============*/
 
138
                /* out: TRUE if inside an insert buffer routine: for instance,
 
139
                a read-ahead of non-ibuf pages is then forbidden */
 
140
/***************************************************************************
 
141
Checks if a page address is an ibuf bitmap page (level 3 page) address. */
 
142
UNIV_INLINE
 
143
ibool
 
144
ibuf_bitmap_page(
 
145
/*=============*/
 
146
                        /* out: TRUE if a bitmap page */
 
147
        ulint   page_no);/* in: page number */
 
148
/***************************************************************************
 
149
Checks if a page is a level 2 or 3 page in the ibuf hierarchy of pages. */
 
150
 
 
151
ibool
 
152
ibuf_page(
 
153
/*======*/
 
154
                        /* out: TRUE if level 2 or level 3 page */
 
155
        ulint   space,  /* in: space id */
 
156
        ulint   page_no);/* in: page number */
 
157
/***************************************************************************
 
158
Checks if a page is a level 2 or 3 page in the ibuf hierarchy of pages. */
 
159
 
 
160
ibool
 
161
ibuf_page_low(
 
162
/*==========*/
 
163
                        /* out: TRUE if level 2 or level 3 page */
 
164
        ulint   space,  /* in: space id */
 
165
        ulint   page_no,/* in: page number */
 
166
        mtr_t*  mtr);   /* in: mtr which will contain an x-latch to the
 
167
                        bitmap page if the page is not one of the fixed
 
168
                        address ibuf pages */
 
169
/*************************************************************************
 
170
Checks if an index page has so much free space that the free bit should
 
171
be set TRUE in the ibuf bitmap. */
 
172
 
 
173
ibool
 
174
ibuf_index_page_has_free(
 
175
/*=====================*/
 
176
                        /* out: TRUE if there is enough free space */
 
177
        page_t* page);  /* in: non-unique secondary index page */
 
178
/***************************************************************************
 
179
Frees excess pages from the ibuf free list. This function is called when an OS
 
180
thread calls fsp services to allocate a new file segment, or a new page to a
 
181
file segment, and the thread did not own the fsp latch before this call. */ 
 
182
 
 
183
void
 
184
ibuf_free_excess_pages(
 
185
/*===================*/
 
186
        ulint   space); /* in: space id */
 
187
/*************************************************************************
 
188
Makes an index insert to the insert buffer, instead of directly to the disk
 
189
page, if this is possible. Does not do insert if the index is clustered
 
190
or unique. */
 
191
 
 
192
ibool
 
193
ibuf_insert(
 
194
/*========*/
 
195
                                /* out: TRUE if success */
 
196
        dtuple_t*       entry,  /* in: index entry to insert */
 
197
        dict_index_t*   index,  /* in: index where to insert */
 
198
        ulint           space,  /* in: space id where to insert */
 
199
        ulint           page_no,/* in: page number where to insert */
 
200
        que_thr_t*      thr);   /* in: query thread */
 
201
/*************************************************************************
 
202
When an index page is read from a disk to the buffer pool, this function
 
203
inserts to the page the possible index entries buffered in the insert buffer.
 
204
The entries are deleted from the insert buffer. If the page is not read, but
 
205
created in the buffer pool, this function deletes its buffered entries from
 
206
the insert buffer; note that there can exist entries if the page belonged to
 
207
an index which was dropped. */
 
208
 
 
209
void
 
210
ibuf_merge_or_delete_for_page(
 
211
/*==========================*/
 
212
        page_t* page,   /* in: if page has been read from disk, pointer to
 
213
                        the page x-latched, else NULL */
 
214
        ulint   space,  /* in: space id of the index page */
 
215
        ulint   page_no);/* in: page number of the index page */
 
216
/*************************************************************************
 
217
Contracts insert buffer trees by reading pages to the buffer pool. */
 
218
 
 
219
ulint
 
220
ibuf_contract(
 
221
/*==========*/
 
222
                        /* out: a lower limit for the combined size in bytes
 
223
                        of entries which will be merged from ibuf trees to the
 
224
                        pages read, 0 if ibuf is empty */
 
225
        ibool   sync);  /* in: TRUE if the caller wants to wait for the
 
226
                        issued read with the highest tablespace address
 
227
                        to complete */
 
228
/*************************************************************************
 
229
Parses a redo log record of an ibuf bitmap page init. */
 
230
 
 
231
byte*
 
232
ibuf_parse_bitmap_init(
 
233
/*===================*/
 
234
                        /* out: end of log record or NULL */
 
235
        byte*   ptr,    /* in: buffer */
 
236
        byte*   end_ptr,/* in: buffer end */
 
237
        page_t* page,   /* in: page or NULL */
 
238
        mtr_t*  mtr);   /* in: mtr or NULL */
 
239
/**********************************************************************
 
240
Gets the ibuf count for a given page. */
 
241
 
 
242
ulint
 
243
ibuf_count_get(
 
244
/*===========*/
 
245
                        /* out: number of entries in the insert buffer
 
246
                        currently buffered for this page */
 
247
        ulint   space,  /* in: space id */
 
248
        ulint   page_no);/* in: page number */
 
249
/**********************************************************************
 
250
Prints info of ibuf. */
 
251
 
 
252
void
 
253
ibuf_print(void);
 
254
/*============*/
 
255
 
 
256
#define IBUF_HEADER_PAGE_NO     FSP_IBUF_HEADER_PAGE_NO
 
257
#define IBUF_TREE_ROOT_PAGE_NO  FSP_IBUF_TREE_ROOT_PAGE_NO
 
258
 
 
259
/* The ibuf header page currently contains only the file segment header
 
260
for the file segment from which the pages for the ibuf tree are allocated */
 
261
#define IBUF_HEADER             PAGE_DATA
 
262
#define IBUF_TREE_SEG_HEADER    0       /* fseg header for ibuf tree */
 
263
 
 
264
#ifndef UNIV_NONINL
 
265
#include "ibuf0ibuf.ic"
 
266
#endif
 
267
 
 
268
#endif