67
67
/******************************************************************
68
68
Gets a buffer page and declares its latching order level. */
73
ulint space, /* in: space id */
74
ulint zip_size, /* in: compressed page size in bytes
75
or 0 for uncompressed pages */
76
ulint page_no, /* in: page number */
77
ulint mode, /* in: latch mode */
78
mtr_t* mtr); /* in: mtr */
79
/******************************************************************
80
Gets a buffer page and declares its latching order level. */
85
73
ulint space, /* in: space id */
86
ulint zip_size, /* in: compressed page size in bytes
87
or 0 for uncompressed pages */
88
74
ulint page_no, /* in: page number */
89
75
ulint mode, /* in: latch mode */
90
76
mtr_t* mtr); /* in: mtr */
95
81
btr_page_get_index_id(
96
82
/*==================*/
97
83
/* out: index id */
98
const page_t* page); /* in: index page */
84
page_t* page); /* in: index page */
99
85
/************************************************************
100
86
Gets the node level field in an index page. */
103
89
btr_page_get_level_low(
104
90
/*===================*/
105
/* out: level, leaf level == 0 */
106
const page_t* page); /* in: index page */
91
/* out: level, leaf level == 0 */
92
page_t* page); /* in: index page */
107
93
/************************************************************
108
94
Gets the node level field in an index page. */
111
97
btr_page_get_level(
112
98
/*===============*/
113
/* out: level, leaf level == 0 */
114
const page_t* page, /* in: index page */
115
mtr_t* mtr); /* in: mini-transaction handle */
99
/* out: level, leaf level == 0 */
100
page_t* page, /* in: index page */
101
mtr_t* mtr); /* in: mini-transaction handle */
116
102
/************************************************************
117
103
Gets the next index page number. */
120
106
btr_page_get_next(
121
107
/*==============*/
122
/* out: next page number */
123
const page_t* page, /* in: index page */
124
mtr_t* mtr); /* in: mini-transaction handle */
108
/* out: next page number */
109
page_t* page, /* in: index page */
110
mtr_t* mtr); /* in: mini-transaction handle */
125
111
/************************************************************
126
112
Gets the previous index page number. */
129
115
btr_page_get_prev(
130
116
/*==============*/
131
/* out: prev page number */
132
const page_t* page, /* in: index page */
133
mtr_t* mtr); /* in: mini-transaction handle */
117
/* out: prev page number */
118
page_t* page, /* in: index page */
119
mtr_t* mtr); /* in: mini-transaction handle */
134
120
/*****************************************************************
135
121
Gets pointer to the previous user record in the tree. It is assumed
136
122
that the caller has appropriate latches on the page and its neighbor. */
139
125
btr_get_prev_user_rec(
140
126
/*==================*/
160
146
btr_leaf_page_release(
161
147
/*==================*/
162
buf_block_t* block, /* in: buffer block */
163
ulint latch_mode, /* in: BTR_SEARCH_LEAF or
165
mtr_t* mtr); /* in: mtr */
148
page_t* page, /* in: page */
149
ulint latch_mode, /* in: BTR_SEARCH_LEAF or BTR_MODIFY_LEAF */
150
mtr_t* mtr); /* in: mtr */
166
151
/******************************************************************
167
152
Gets the child node file address in a node pointer. */
170
155
btr_node_ptr_get_child_page_no(
171
156
/*===========================*/
172
157
/* out: child node address */
173
const rec_t* rec, /* in: node pointer record */
158
rec_t* rec, /* in: node pointer record */
174
159
const ulint* offsets);/* in: array returned by rec_get_offsets() */
175
160
/****************************************************************
176
161
Creates the root node for a new index tree. */
181
/* out: page number of the created root,
182
FIL_NULL if did not succeed */
183
ulint type, /* in: type of the index */
184
ulint space, /* in: space where created */
185
ulint zip_size,/* in: compressed page size in bytes
186
or 0 for uncompressed pages */
187
dulint index_id,/* in: index id */
188
dict_index_t* index, /* in: index */
189
mtr_t* mtr); /* in: mini-transaction handle */
166
/* out: page number of the created root, FIL_NULL if
168
ulint type, /* in: type of the index */
169
ulint space, /* in: space where created */
170
dulint index_id,/* in: index id */
171
ulint comp, /* in: nonzero=compact page format */
172
mtr_t* mtr); /* in: mini-transaction handle */
190
173
/****************************************************************
191
174
Frees a B-tree except the root page, which MUST be freed after this
192
175
by calling btr_free_root. */
195
178
btr_free_but_not_root(
196
179
/*==================*/
197
180
ulint space, /* in: space where created */
198
ulint zip_size, /* in: compressed page size in bytes
199
or 0 for uncompressed pages */
200
181
ulint root_page_no); /* in: root page number */
201
182
/****************************************************************
202
183
Frees the B-tree root page. Other tree MUST already have been freed. */
207
188
ulint space, /* in: space where created */
208
ulint zip_size, /* in: compressed page size in bytes
209
or 0 for uncompressed pages */
210
189
ulint root_page_no, /* in: root page number */
211
190
mtr_t* mtr); /* in: a mini-transaction which has already
225
204
on the root page; when the function returns,
226
205
the cursor is positioned on the predecessor
227
206
of the inserted record */
228
const dtuple_t* tuple, /* in: tuple to insert */
229
ulint n_ext, /* in: number of externally stored columns */
207
dtuple_t* tuple, /* in: tuple to insert */
230
208
mtr_t* mtr); /* in: mtr */
231
209
/*****************************************************************
232
Reorganizes an index page.
233
IMPORTANT: if btr_page_reorganize() is invoked on a compressed leaf
234
page of a non-clustered index, the caller must update the insert
235
buffer free bits in the same mini-transaction in such a way that the
236
modification will be redo-logged. */
210
Reorganizes an index page. */
239
213
btr_page_reorganize(
240
214
/*================*/
241
/* out: TRUE on success, FALSE on failure */
242
buf_block_t* block, /* in: page to be reorganized */
215
page_t* page, /* in: page to be reorganized */
243
216
dict_index_t* index, /* in: record descriptor */
244
217
mtr_t* mtr); /* in: mtr */
245
218
/*****************************************************************
246
219
Decides if the page should be split at the convergence point of
247
220
inserts converging to left. */
250
223
btr_page_get_split_rec_to_left(
251
224
/*===========================*/
283
256
btr_cur_t* cursor, /* in: cursor at which to insert; when the
284
257
function returns, the cursor is positioned
285
258
on the predecessor of the inserted record */
286
const dtuple_t* tuple, /* in: tuple to insert */
287
ulint n_ext, /* in: number of externally stored columns */
259
dtuple_t* tuple, /* in: tuple to insert */
288
260
mtr_t* mtr); /* in: mtr */
289
261
/***********************************************************
290
262
Inserts a data tuple to a tree on a non-leaf level. It is assumed
291
263
that mtr holds an x-latch on the tree. */
294
266
btr_insert_on_non_leaf_level(
295
267
/*=========================*/
299
271
mtr_t* mtr); /* in: mtr */
300
272
/********************************************************************
301
273
Sets a record as the predefined minimum record. */
304
276
btr_set_min_rec_mark(
305
277
/*=================*/
306
rec_t* rec, /* in/out: record */
278
rec_t* rec, /* in: record */
279
ulint comp, /* in: nonzero=compact page format */
307
280
mtr_t* mtr); /* in: mtr */
308
281
/*****************************************************************
309
282
Deletes on the upper level the node pointer to a page. */
312
285
btr_node_ptr_delete(
313
286
/*================*/
314
287
dict_index_t* index, /* in: index tree */
315
buf_block_t* block, /* in: page whose node pointer is deleted */
288
page_t* page, /* in: page whose node pointer is deleted */
316
289
mtr_t* mtr); /* in: mtr */
317
290
#ifdef UNIV_DEBUG
318
291
/****************************************************************
319
292
Checks that the node pointer to a page is appropriate. */
322
295
btr_check_node_ptr(
323
296
/*===============*/
325
298
dict_index_t* index, /* in: index tree */
326
buf_block_t* block, /* in: index page */
299
page_t* page, /* in: index page */
327
300
mtr_t* mtr); /* in: mtr */
328
301
#endif /* UNIV_DEBUG */
329
302
/*****************************************************************
334
307
level lifts the records of the page to the father page, thus reducing the
335
308
tree height. It is assumed that mtr holds an x-latch on the tree and on the
336
309
page. If cursor is on the leaf level, mtr must also hold x-latches to
337
the brothers, if they exist. */
310
the brothers, if they exist. NOTE: it is assumed that the caller has reserved
311
enough free extents so that the compression will always succeed if done! */
342
/* out: TRUE on success */
343
315
btr_cur_t* cursor, /* in: cursor on the page to merge or lift;
344
316
the page must not be empty: in record delete
345
317
use btr_discard_page if the page would become
379
351
byte* ptr, /* in: buffer */
380
352
byte* end_ptr,/* in: buffer end */
381
353
dict_index_t* index, /* in: record descriptor */
382
buf_block_t* block, /* in: page to be reorganized, or NULL */
354
page_t* page, /* in: page or NULL */
383
355
mtr_t* mtr); /* in: mtr or NULL */
384
356
/******************************************************************
385
357
Gets the number of pages in a B-tree. */
393
365
/******************************************************************
394
366
Allocates a new file page to be used in an index tree. NOTE: we assume
395
367
that the caller has made the reservation for free extents! */
400
/* out: new allocated block, x-latched;
372
/* out: new allocated page, x-latched;
401
373
NULL if out of space */
402
374
dict_index_t* index, /* in: index tree */
403
375
ulint hint_page_no, /* in: hint of a good page */
409
381
/******************************************************************
410
382
Frees a file page used in an index tree. NOTE: cannot free field external
411
383
storage pages because the page must contain info on its level. */
416
388
dict_index_t* index, /* in: index tree */
417
buf_block_t* block, /* in: block to be freed, x-latched */
389
page_t* page, /* in: page to be freed, x-latched */
418
390
mtr_t* mtr); /* in: mtr */
419
391
/******************************************************************
420
392
Frees a file page used in an index tree. Can be used also to BLOB
421
393
external storage pages, because the page level 0 can be given as an
425
397
btr_page_free_low(
426
398
/*==============*/
427
399
dict_index_t* index, /* in: index tree */
428
buf_block_t* block, /* in: block to be freed, x-latched */
400
page_t* page, /* in: page to be freed, x-latched */
429
401
ulint level, /* in: page level */
430
402
mtr_t* mtr); /* in: mtr */
431
403
#ifdef UNIV_BTR_PRINT
432
404
/*****************************************************************
433
405
Prints size info of a B-tree. */
438
410
dict_index_t* index); /* in: index tree */
439
411
/******************************************************************
440
412
Prints directories and other info of all nodes in the index. */
449
421
/****************************************************************
450
422
Checks the size and number of fields in a record based on the definition of
454
426
btr_index_rec_validate(
455
427
/*===================*/
456
/* out: TRUE if ok */
457
const rec_t* rec, /* in: index record */
458
const dict_index_t* index, /* in: index */
459
ibool dump_on_error); /* in: TRUE if the function
460
should print hex dump of record
428
/* out: TRUE if ok */
429
rec_t* rec, /* in: index record */
430
dict_index_t* index, /* in: index */
431
ibool dump_on_error); /* in: TRUE if the function
432
should print hex dump of record
462
434
/******************************************************************
463
435
Checks the consistency of an index tree. */
466
438
btr_validate_index(
467
439
/*===============*/