00001 /****************************************************** 00002 Index page routines 00003 00004 (c) 1994-1996 Innobase Oy 00005 00006 Created 2/2/1994 Heikki Tuuri 00007 *******************************************************/ 00008 00009 #ifndef page0page_h 00010 #define page0page_h 00011 00012 #include "univ.i" 00013 00014 #include "page0types.h" 00015 #include "fil0fil.h" 00016 #include "buf0buf.h" 00017 #include "data0data.h" 00018 #include "dict0dict.h" 00019 #include "rem0rec.h" 00020 #include "fsp0fsp.h" 00021 #include "mtr0mtr.h" 00022 00023 #ifdef UNIV_MATERIALIZE 00024 #undef UNIV_INLINE 00025 #define UNIV_INLINE 00026 #endif 00027 00028 /* PAGE HEADER 00029 =========== 00030 00031 Index page header starts at the first offset left free by the FIL-module */ 00032 00033 typedef byte page_header_t; 00034 00035 #define PAGE_HEADER FSEG_PAGE_DATA /* index page header starts at this 00036 offset */ 00037 /*-----------------------------*/ 00038 #define PAGE_N_DIR_SLOTS 0 /* number of slots in page directory */ 00039 #define PAGE_HEAP_TOP 2 /* pointer to record heap top */ 00040 #define PAGE_N_HEAP 4 /* number of records in the heap, 00041 bit 15=flag: new-style compact page format */ 00042 #define PAGE_FREE 6 /* pointer to start of page free record list */ 00043 #define PAGE_GARBAGE 8 /* number of bytes in deleted records */ 00044 #define PAGE_LAST_INSERT 10 /* pointer to the last inserted record, or 00045 NULL if this info has been reset by a delete, 00046 for example */ 00047 #define PAGE_DIRECTION 12 /* last insert direction: PAGE_LEFT, ... */ 00048 #define PAGE_N_DIRECTION 14 /* number of consecutive inserts to the same 00049 direction */ 00050 #define PAGE_N_RECS 16 /* number of user records on the page */ 00051 #define PAGE_MAX_TRX_ID 18 /* highest id of a trx which may have modified 00052 a record on the page; a dulint; defined only 00053 in secondary indexes; specifically, not in an 00054 ibuf tree; NOTE: this may be modified only 00055 when the thread has an x-latch to the page, 00056 and ALSO an x-latch to btr_search_latch 00057 if there is a hash index to the page! */ 00058 #define PAGE_HEADER_PRIV_END 26 /* end of private data structure of the page 00059 header which are set in a page create */ 00060 /*----*/ 00061 #define PAGE_LEVEL 26 /* level of the node in an index tree; the 00062 leaf level is the level 0 */ 00063 #define PAGE_INDEX_ID 28 /* index id where the page belongs */ 00064 #define PAGE_BTR_SEG_LEAF 36 /* file segment header for the leaf pages in 00065 a B-tree: defined only on the root page of a 00066 B-tree, but not in the root of an ibuf tree */ 00067 #define PAGE_BTR_IBUF_FREE_LIST PAGE_BTR_SEG_LEAF 00068 #define PAGE_BTR_IBUF_FREE_LIST_NODE PAGE_BTR_SEG_LEAF 00069 /* in the place of PAGE_BTR_SEG_LEAF and _TOP 00070 there is a free list base node if the page is 00071 the root page of an ibuf tree, and at the same 00072 place is the free list node if the page is in 00073 a free list */ 00074 #define PAGE_BTR_SEG_TOP (36 + FSEG_HEADER_SIZE) 00075 /* file segment header for the non-leaf pages 00076 in a B-tree: defined only on the root page of 00077 a B-tree, but not in the root of an ibuf 00078 tree */ 00079 /*----*/ 00080 #define PAGE_DATA (PAGE_HEADER + 36 + 2 * FSEG_HEADER_SIZE) 00081 /* start of data on the page */ 00082 00083 #define PAGE_OLD_INFIMUM (PAGE_DATA + 1 + REC_N_OLD_EXTRA_BYTES) 00084 /* offset of the page infimum record on an 00085 old-style page */ 00086 #define PAGE_OLD_SUPREMUM (PAGE_DATA + 2 + 2 * REC_N_OLD_EXTRA_BYTES + 8) 00087 /* offset of the page supremum record on an 00088 old-style page */ 00089 #define PAGE_OLD_SUPREMUM_END (PAGE_OLD_SUPREMUM + 9) 00090 /* offset of the page supremum record end on 00091 an old-style page */ 00092 #define PAGE_NEW_INFIMUM (PAGE_DATA + REC_N_NEW_EXTRA_BYTES) 00093 /* offset of the page infimum record on a 00094 new-style compact page */ 00095 #define PAGE_NEW_SUPREMUM (PAGE_DATA + 2 * REC_N_NEW_EXTRA_BYTES + 8) 00096 /* offset of the page supremum record on a 00097 new-style compact page */ 00098 #define PAGE_NEW_SUPREMUM_END (PAGE_NEW_SUPREMUM + 8) 00099 /* offset of the page supremum record end on 00100 a new-style compact page */ 00101 /*-----------------------------*/ 00102 00103 /* Directions of cursor movement */ 00104 #define PAGE_LEFT 1 00105 #define PAGE_RIGHT 2 00106 #define PAGE_SAME_REC 3 00107 #define PAGE_SAME_PAGE 4 00108 #define PAGE_NO_DIRECTION 5 00109 00110 /* PAGE DIRECTORY 00111 ============== 00112 */ 00113 00114 typedef byte page_dir_slot_t; 00115 typedef page_dir_slot_t page_dir_t; 00116 00117 /* Offset of the directory start down from the page end. We call the 00118 slot with the highest file address directory start, as it points to 00119 the first record in the list of records. */ 00120 #define PAGE_DIR FIL_PAGE_DATA_END 00121 00122 /* We define a slot in the page directory as two bytes */ 00123 #define PAGE_DIR_SLOT_SIZE 2 00124 00125 /* The offset of the physically lower end of the directory, counted from 00126 page end, when the page is empty */ 00127 #define PAGE_EMPTY_DIR_START (PAGE_DIR + 2 * PAGE_DIR_SLOT_SIZE) 00128 00129 /* The maximum and minimum number of records owned by a directory slot. The 00130 number may drop below the minimum in the first and the last slot in the 00131 directory. */ 00132 #define PAGE_DIR_SLOT_MAX_N_OWNED 8 00133 #define PAGE_DIR_SLOT_MIN_N_OWNED 4 00134 00135 /***************************************************************** 00136 Returns the max trx id field value. */ 00137 UNIV_INLINE 00138 dulint 00139 page_get_max_trx_id( 00140 /*================*/ 00141 page_t* page); /* in: page */ 00142 /***************************************************************** 00143 Sets the max trx id field value. */ 00144 00145 void 00146 page_set_max_trx_id( 00147 /*================*/ 00148 page_t* page, /* in: page */ 00149 dulint trx_id);/* in: transaction id */ 00150 /***************************************************************** 00151 Sets the max trx id field value if trx_id is bigger than the previous 00152 value. */ 00153 UNIV_INLINE 00154 void 00155 page_update_max_trx_id( 00156 /*===================*/ 00157 page_t* page, /* in: page */ 00158 dulint trx_id); /* in: transaction id */ 00159 /***************************************************************** 00160 Reads the given header field. */ 00161 UNIV_INLINE 00162 ulint 00163 page_header_get_field( 00164 /*==================*/ 00165 page_t* page, /* in: page */ 00166 ulint field); /* in: PAGE_N_DIR_SLOTS, ... */ 00167 /***************************************************************** 00168 Sets the given header field. */ 00169 UNIV_INLINE 00170 void 00171 page_header_set_field( 00172 /*==================*/ 00173 page_t* page, /* in: page */ 00174 ulint field, /* in: PAGE_N_DIR_SLOTS, ... */ 00175 ulint val); /* in: value */ 00176 /***************************************************************** 00177 Returns the pointer stored in the given header field. */ 00178 UNIV_INLINE 00179 byte* 00180 page_header_get_ptr( 00181 /*================*/ 00182 /* out: pointer or NULL */ 00183 page_t* page, /* in: page */ 00184 ulint field); /* in: PAGE_FREE, ... */ 00185 /***************************************************************** 00186 Sets the pointer stored in the given header field. */ 00187 UNIV_INLINE 00188 void 00189 page_header_set_ptr( 00190 /*================*/ 00191 page_t* page, /* in: page */ 00192 ulint field, /* in: PAGE_FREE, ... */ 00193 byte* ptr); /* in: pointer or NULL*/ 00194 /***************************************************************** 00195 Resets the last insert info field in the page header. Writes to mlog 00196 about this operation. */ 00197 UNIV_INLINE 00198 void 00199 page_header_reset_last_insert( 00200 /*==========================*/ 00201 page_t* page, /* in: page */ 00202 mtr_t* mtr); /* in: mtr */ 00203 /**************************************************************** 00204 Gets the first record on the page. */ 00205 UNIV_INLINE 00206 rec_t* 00207 page_get_infimum_rec( 00208 /*=================*/ 00209 /* out: the first record in record list */ 00210 page_t* page); /* in: page which must have record(s) */ 00211 /**************************************************************** 00212 Gets the last record on the page. */ 00213 UNIV_INLINE 00214 rec_t* 00215 page_get_supremum_rec( 00216 /*==================*/ 00217 /* out: the last record in record list */ 00218 page_t* page); /* in: page which must have record(s) */ 00219 /**************************************************************** 00220 Returns the middle record of record list. If there are an even number 00221 of records in the list, returns the first record of upper half-list. */ 00222 00223 rec_t* 00224 page_get_middle_rec( 00225 /*================*/ 00226 /* out: middle record */ 00227 page_t* page); /* in: page */ 00228 /***************************************************************** 00229 Compares a data tuple to a physical record. Differs from the function 00230 cmp_dtuple_rec_with_match in the way that the record must reside on an 00231 index page, and also page infimum and supremum records can be given in 00232 the parameter rec. These are considered as the negative infinity and 00233 the positive infinity in the alphabetical order. */ 00234 UNIV_INLINE 00235 int 00236 page_cmp_dtuple_rec_with_match( 00237 /*===========================*/ 00238 /* out: 1, 0, -1, if dtuple is greater, equal, 00239 less than rec, respectively, when only the 00240 common first fields are compared */ 00241 dtuple_t* dtuple, /* in: data tuple */ 00242 rec_t* rec, /* in: physical record on a page; may also 00243 be page infimum or supremum, in which case 00244 matched-parameter values below are not 00245 affected */ 00246 const ulint* offsets,/* in: array returned by rec_get_offsets() */ 00247 ulint* matched_fields, /* in/out: number of already completely 00248 matched fields; when function returns 00249 contains the value for current comparison */ 00250 ulint* matched_bytes); /* in/out: number of already matched 00251 bytes within the first field not completely 00252 matched; when function returns contains the 00253 value for current comparison */ 00254 /***************************************************************** 00255 Gets the number of user records on page (the infimum and supremum records 00256 are not user records). */ 00257 UNIV_INLINE 00258 ulint 00259 page_get_n_recs( 00260 /*============*/ 00261 /* out: number of user records */ 00262 page_t* page); /* in: index page */ 00263 /******************************************************************* 00264 Returns the number of records before the given record in chain. 00265 The number includes infimum and supremum records. */ 00266 00267 ulint 00268 page_rec_get_n_recs_before( 00269 /*=======================*/ 00270 /* out: number of records */ 00271 rec_t* rec); /* in: the physical record */ 00272 /***************************************************************** 00273 Gets the number of records in the heap. */ 00274 UNIV_INLINE 00275 ulint 00276 page_dir_get_n_heap( 00277 /*================*/ 00278 /* out: number of user records */ 00279 page_t* page); /* in: index page */ 00280 /***************************************************************** 00281 Sets the number of records in the heap. */ 00282 UNIV_INLINE 00283 void 00284 page_dir_set_n_heap( 00285 /*================*/ 00286 page_t* page, /* in: index page */ 00287 ulint n_heap);/* in: number of records */ 00288 /***************************************************************** 00289 Gets the number of dir slots in directory. */ 00290 UNIV_INLINE 00291 ulint 00292 page_dir_get_n_slots( 00293 /*=================*/ 00294 /* out: number of slots */ 00295 page_t* page); /* in: index page */ 00296 /***************************************************************** 00297 Sets the number of dir slots in directory. */ 00298 UNIV_INLINE 00299 void 00300 page_dir_set_n_slots( 00301 /*=================*/ 00302 /* out: number of slots */ 00303 page_t* page, /* in: index page */ 00304 ulint n_slots);/* in: number of slots */ 00305 /***************************************************************** 00306 Gets pointer to nth directory slot. */ 00307 UNIV_INLINE 00308 page_dir_slot_t* 00309 page_dir_get_nth_slot( 00310 /*==================*/ 00311 /* out: pointer to dir slot */ 00312 page_t* page, /* in: index page */ 00313 ulint n); /* in: position */ 00314 /****************************************************************** 00315 Used to check the consistency of a record on a page. */ 00316 UNIV_INLINE 00317 ibool 00318 page_rec_check( 00319 /*===========*/ 00320 /* out: TRUE if succeed */ 00321 rec_t* rec); /* in: record */ 00322 /******************************************************************* 00323 Gets the record pointed to by a directory slot. */ 00324 UNIV_INLINE 00325 rec_t* 00326 page_dir_slot_get_rec( 00327 /*==================*/ 00328 /* out: pointer to record */ 00329 page_dir_slot_t* slot); /* in: directory slot */ 00330 /******************************************************************* 00331 This is used to set the record offset in a directory slot. */ 00332 UNIV_INLINE 00333 void 00334 page_dir_slot_set_rec( 00335 /*==================*/ 00336 page_dir_slot_t* slot, /* in: directory slot */ 00337 rec_t* rec); /* in: record on the page */ 00338 /******************************************************************* 00339 Gets the number of records owned by a directory slot. */ 00340 UNIV_INLINE 00341 ulint 00342 page_dir_slot_get_n_owned( 00343 /*======================*/ 00344 /* out: number of records */ 00345 page_dir_slot_t* slot); /* in: page directory slot */ 00346 /******************************************************************* 00347 This is used to set the owned records field of a directory slot. */ 00348 UNIV_INLINE 00349 void 00350 page_dir_slot_set_n_owned( 00351 /*======================*/ 00352 page_dir_slot_t* slot, /* in: directory slot */ 00353 ulint n); /* in: number of records owned 00354 by the slot */ 00355 /**************************************************************** 00356 Calculates the space reserved for directory slots of a given 00357 number of records. The exact value is a fraction number 00358 n * PAGE_DIR_SLOT_SIZE / PAGE_DIR_SLOT_MIN_N_OWNED, and it is 00359 rounded upwards to an integer. */ 00360 UNIV_INLINE 00361 ulint 00362 page_dir_calc_reserved_space( 00363 /*=========================*/ 00364 ulint n_recs); /* in: number of records */ 00365 /******************************************************************* 00366 Looks for the directory slot which owns the given record. */ 00367 00368 ulint 00369 page_dir_find_owner_slot( 00370 /*=====================*/ 00371 /* out: the directory slot number */ 00372 rec_t* rec); /* in: the physical record */ 00373 /**************************************************************** 00374 Determine whether the page is in new-style compact format. */ 00375 UNIV_INLINE 00376 ulint 00377 page_is_comp( 00378 /*=========*/ 00379 /* out: nonzero if the page is in compact 00380 format, zero if it is in old-style format */ 00381 page_t* page); /* in: index page */ 00382 /**************************************************************** 00383 TRUE if the record is on a page in compact format. */ 00384 UNIV_INLINE 00385 ulint 00386 page_rec_is_comp( 00387 /*=============*/ 00388 /* out: nonzero if in compact format */ 00389 const rec_t* rec); /* in: record */ 00390 /**************************************************************** 00391 Gets the pointer to the next record on the page. */ 00392 UNIV_INLINE 00393 rec_t* 00394 page_rec_get_next( 00395 /*==============*/ 00396 /* out: pointer to next record */ 00397 rec_t* rec); /* in: pointer to record, must not be page 00398 supremum */ 00399 /**************************************************************** 00400 Sets the pointer to the next record on the page. */ 00401 UNIV_INLINE 00402 void 00403 page_rec_set_next( 00404 /*==============*/ 00405 rec_t* rec, /* in: pointer to record, must not be 00406 page supremum */ 00407 rec_t* next); /* in: pointer to next record, must not 00408 be page infimum */ 00409 /**************************************************************** 00410 Gets the pointer to the previous record. */ 00411 UNIV_INLINE 00412 rec_t* 00413 page_rec_get_prev( 00414 /*==============*/ 00415 /* out: pointer to previous record */ 00416 rec_t* rec); /* in: pointer to record, 00417 must not be page infimum */ 00418 /**************************************************************** 00419 TRUE if the record is a user record on the page. */ 00420 UNIV_INLINE 00421 ibool 00422 page_rec_is_user_rec_low( 00423 /*=====================*/ 00424 /* out: TRUE if a user record */ 00425 ulint offset);/* in: record offset on page */ 00426 /**************************************************************** 00427 TRUE if the record is the supremum record on a page. */ 00428 UNIV_INLINE 00429 ibool 00430 page_rec_is_supremum_low( 00431 /*=====================*/ 00432 /* out: TRUE if the supremum record */ 00433 ulint offset);/* in: record offset on page */ 00434 /**************************************************************** 00435 TRUE if the record is the infimum record on a page. */ 00436 UNIV_INLINE 00437 ibool 00438 page_rec_is_infimum_low( 00439 /*====================*/ 00440 /* out: TRUE if the infimum record */ 00441 ulint offset);/* in: record offset on page */ 00442 00443 /**************************************************************** 00444 TRUE if the record is a user record on the page. */ 00445 UNIV_INLINE 00446 ibool 00447 page_rec_is_user_rec( 00448 /*=================*/ 00449 /* out: TRUE if a user record */ 00450 const rec_t* rec); /* in: record */ 00451 /**************************************************************** 00452 TRUE if the record is the supremum record on a page. */ 00453 UNIV_INLINE 00454 ibool 00455 page_rec_is_supremum( 00456 /*=================*/ 00457 /* out: TRUE if the supremum record */ 00458 const rec_t* rec); /* in: record */ 00459 /**************************************************************** 00460 TRUE if the record is the infimum record on a page. */ 00461 UNIV_INLINE 00462 ibool 00463 page_rec_is_infimum( 00464 /*================*/ 00465 /* out: TRUE if the infimum record */ 00466 const rec_t* rec); /* in: record */ 00467 /******************************************************************* 00468 Looks for the record which owns the given record. */ 00469 UNIV_INLINE 00470 rec_t* 00471 page_rec_find_owner_rec( 00472 /*====================*/ 00473 /* out: the owner record */ 00474 rec_t* rec); /* in: the physical record */ 00475 /*************************************************************************** 00476 This is a low-level operation which is used in a database index creation 00477 to update the page number of a created B-tree to a data dictionary 00478 record. */ 00479 00480 void 00481 page_rec_write_index_page_no( 00482 /*=========================*/ 00483 rec_t* rec, /* in: record to update */ 00484 ulint i, /* in: index of the field to update */ 00485 ulint page_no,/* in: value to write */ 00486 mtr_t* mtr); /* in: mtr */ 00487 /**************************************************************** 00488 Returns the maximum combined size of records which can be inserted on top 00489 of record heap. */ 00490 UNIV_INLINE 00491 ulint 00492 page_get_max_insert_size( 00493 /*=====================*/ 00494 /* out: maximum combined size for inserted records */ 00495 page_t* page, /* in: index page */ 00496 ulint n_recs); /* in: number of records */ 00497 /**************************************************************** 00498 Returns the maximum combined size of records which can be inserted on top 00499 of record heap if page is first reorganized. */ 00500 UNIV_INLINE 00501 ulint 00502 page_get_max_insert_size_after_reorganize( 00503 /*======================================*/ 00504 /* out: maximum combined size for inserted records */ 00505 page_t* page, /* in: index page */ 00506 ulint n_recs);/* in: number of records */ 00507 /***************************************************************** 00508 Calculates free space if a page is emptied. */ 00509 UNIV_INLINE 00510 ulint 00511 page_get_free_space_of_empty( 00512 /*=========================*/ 00513 /* out: free space */ 00514 ulint comp) /* in: nonzero=compact page format */ 00515 __attribute__((const)); 00516 /**************************************************************** 00517 Returns the sum of the sizes of the records in the record list 00518 excluding the infimum and supremum records. */ 00519 UNIV_INLINE 00520 ulint 00521 page_get_data_size( 00522 /*===============*/ 00523 /* out: data in bytes */ 00524 page_t* page); /* in: index page */ 00525 /**************************************************************** 00526 Allocates a block of memory from an index page. */ 00527 00528 byte* 00529 page_mem_alloc( 00530 /*===========*/ 00531 /* out: pointer to start of allocated 00532 buffer, or NULL if allocation fails */ 00533 page_t* page, /* in: index page */ 00534 ulint need, /* in: number of bytes needed */ 00535 dict_index_t* index, /* in: record descriptor */ 00536 ulint* heap_no);/* out: this contains the heap number 00537 of the allocated record 00538 if allocation succeeds */ 00539 /**************************************************************** 00540 Puts a record to free list. */ 00541 UNIV_INLINE 00542 void 00543 page_mem_free( 00544 /*==========*/ 00545 page_t* page, /* in: index page */ 00546 rec_t* rec, /* in: pointer to the (origin of) record */ 00547 const ulint* offsets);/* in: array returned by rec_get_offsets() */ 00548 /************************************************************** 00549 The index page creation function. */ 00550 00551 page_t* 00552 page_create( 00553 /*========*/ 00554 /* out: pointer to the page */ 00555 buf_frame_t* frame, /* in: a buffer frame where the page is 00556 created */ 00557 mtr_t* mtr, /* in: mini-transaction handle */ 00558 ulint comp); /* in: nonzero=compact page format */ 00559 /***************************************************************** 00560 Differs from page_copy_rec_list_end, because this function does not 00561 touch the lock table and max trx id on page. */ 00562 00563 void 00564 page_copy_rec_list_end_no_locks( 00565 /*============================*/ 00566 page_t* new_page, /* in: index page to copy to */ 00567 page_t* page, /* in: index page */ 00568 rec_t* rec, /* in: record on page */ 00569 dict_index_t* index, /* in: record descriptor */ 00570 mtr_t* mtr); /* in: mtr */ 00571 /***************************************************************** 00572 Copies records from page to new_page, from the given record onward, 00573 including that record. Infimum and supremum records are not copied. 00574 The records are copied to the start of the record list on new_page. */ 00575 00576 void 00577 page_copy_rec_list_end( 00578 /*===================*/ 00579 page_t* new_page, /* in: index page to copy to */ 00580 page_t* page, /* in: index page */ 00581 rec_t* rec, /* in: record on page */ 00582 dict_index_t* index, /* in: record descriptor */ 00583 mtr_t* mtr); /* in: mtr */ 00584 /***************************************************************** 00585 Copies records from page to new_page, up to the given record, NOT 00586 including that record. Infimum and supremum records are not copied. 00587 The records are copied to the end of the record list on new_page. */ 00588 00589 void 00590 page_copy_rec_list_start( 00591 /*=====================*/ 00592 page_t* new_page, /* in: index page to copy to */ 00593 page_t* page, /* in: index page */ 00594 rec_t* rec, /* in: record on page */ 00595 dict_index_t* index, /* in: record descriptor */ 00596 mtr_t* mtr); /* in: mtr */ 00597 /***************************************************************** 00598 Deletes records from a page from a given record onward, including that record. 00599 The infimum and supremum records are not deleted. */ 00600 00601 void 00602 page_delete_rec_list_end( 00603 /*=====================*/ 00604 page_t* page, /* in: index page */ 00605 rec_t* rec, /* in: record on page */ 00606 dict_index_t* index, /* in: record descriptor */ 00607 ulint n_recs, /* in: number of records to delete, 00608 or ULINT_UNDEFINED if not known */ 00609 ulint size, /* in: the sum of the sizes of the 00610 records in the end of the chain to 00611 delete, or ULINT_UNDEFINED if not known */ 00612 mtr_t* mtr); /* in: mtr */ 00613 /***************************************************************** 00614 Deletes records from page, up to the given record, NOT including 00615 that record. Infimum and supremum records are not deleted. */ 00616 00617 void 00618 page_delete_rec_list_start( 00619 /*=======================*/ 00620 page_t* page, /* in: index page */ 00621 rec_t* rec, /* in: record on page */ 00622 dict_index_t* index, /* in: record descriptor */ 00623 mtr_t* mtr); /* in: mtr */ 00624 /***************************************************************** 00625 Moves record list end to another page. Moved records include 00626 split_rec. */ 00627 00628 void 00629 page_move_rec_list_end( 00630 /*===================*/ 00631 page_t* new_page, /* in: index page where to move */ 00632 page_t* page, /* in: index page */ 00633 rec_t* split_rec, /* in: first record to move */ 00634 dict_index_t* index, /* in: record descriptor */ 00635 mtr_t* mtr); /* in: mtr */ 00636 /***************************************************************** 00637 Moves record list start to another page. Moved records do not include 00638 split_rec. */ 00639 00640 void 00641 page_move_rec_list_start( 00642 /*=====================*/ 00643 page_t* new_page, /* in: index page where to move */ 00644 page_t* page, /* in: index page */ 00645 rec_t* split_rec, /* in: first record not to move */ 00646 dict_index_t* index, /* in: record descriptor */ 00647 mtr_t* mtr); /* in: mtr */ 00648 /******************************************************************** 00649 Splits a directory slot which owns too many records. */ 00650 00651 void 00652 page_dir_split_slot( 00653 /*================*/ 00654 page_t* page, /* in: the index page in question */ 00655 ulint slot_no); /* in: the directory slot */ 00656 /***************************************************************** 00657 Tries to balance the given directory slot with too few records 00658 with the upper neighbor, so that there are at least the minimum number 00659 of records owned by the slot; this may result in the merging of 00660 two slots. */ 00661 00662 void 00663 page_dir_balance_slot( 00664 /*==================*/ 00665 page_t* page, /* in: index page */ 00666 ulint slot_no); /* in: the directory slot */ 00667 /************************************************************** 00668 Parses a log record of a record list end or start deletion. */ 00669 00670 byte* 00671 page_parse_delete_rec_list( 00672 /*=======================*/ 00673 /* out: end of log record or NULL */ 00674 byte type, /* in: MLOG_LIST_END_DELETE, 00675 MLOG_LIST_START_DELETE, 00676 MLOG_COMP_LIST_END_DELETE or 00677 MLOG_COMP_LIST_START_DELETE */ 00678 byte* ptr, /* in: buffer */ 00679 byte* end_ptr,/* in: buffer end */ 00680 dict_index_t* index, /* in: record descriptor */ 00681 page_t* page, /* in: page or NULL */ 00682 mtr_t* mtr); /* in: mtr or NULL */ 00683 /*************************************************************** 00684 Parses a redo log record of creating a page. */ 00685 00686 byte* 00687 page_parse_create( 00688 /*==============*/ 00689 /* out: end of log record or NULL */ 00690 byte* ptr, /* in: buffer */ 00691 byte* end_ptr,/* in: buffer end */ 00692 ulint comp, /* in: nonzero=compact page format */ 00693 page_t* page, /* in: page or NULL */ 00694 mtr_t* mtr); /* in: mtr or NULL */ 00695 /**************************************************************** 00696 Prints record contents including the data relevant only in 00697 the index page context. */ 00698 00699 void 00700 page_rec_print( 00701 /*===========*/ 00702 rec_t* rec, /* in: physical record */ 00703 const ulint* offsets);/* in: record descriptor */ 00704 /******************************************************************* 00705 This is used to print the contents of the directory for 00706 debugging purposes. */ 00707 00708 void 00709 page_dir_print( 00710 /*===========*/ 00711 page_t* page, /* in: index page */ 00712 ulint pr_n); /* in: print n first and n last entries */ 00713 /******************************************************************* 00714 This is used to print the contents of the page record list for 00715 debugging purposes. */ 00716 00717 void 00718 page_print_list( 00719 /*============*/ 00720 page_t* page, /* in: index page */ 00721 dict_index_t* index, /* in: dictionary index of the page */ 00722 ulint pr_n); /* in: print n first and n last entries */ 00723 /******************************************************************* 00724 Prints the info in a page header. */ 00725 00726 void 00727 page_header_print( 00728 /*==============*/ 00729 page_t* page); 00730 /******************************************************************* 00731 This is used to print the contents of the page for 00732 debugging purposes. */ 00733 00734 void 00735 page_print( 00736 /*=======*/ 00737 page_t* page, /* in: index page */ 00738 dict_index_t* index, /* in: dictionary index of the page */ 00739 ulint dn, /* in: print dn first and last entries 00740 in directory */ 00741 ulint rn); /* in: print rn first and last records 00742 in directory */ 00743 /******************************************************************* 00744 The following is used to validate a record on a page. This function 00745 differs from rec_validate as it can also check the n_owned field and 00746 the heap_no field. */ 00747 00748 ibool 00749 page_rec_validate( 00750 /*==============*/ 00751 /* out: TRUE if ok */ 00752 rec_t* rec, /* in: physical record */ 00753 const ulint* offsets);/* in: array returned by rec_get_offsets() */ 00754 /******************************************************************* 00755 Checks that the first directory slot points to the infimum record and 00756 the last to the supremum. This function is intended to track if the 00757 bug fixed in 4.0.14 has caused corruption to users' databases. */ 00758 00759 void 00760 page_check_dir( 00761 /*===========*/ 00762 page_t* page); /* in: index page */ 00763 /******************************************************************* 00764 This function checks the consistency of an index page when we do not 00765 know the index. This is also resilient so that this should never crash 00766 even if the page is total garbage. */ 00767 00768 ibool 00769 page_simple_validate( 00770 /*=================*/ 00771 /* out: TRUE if ok */ 00772 page_t* page); /* in: index page */ 00773 /******************************************************************* 00774 This function checks the consistency of an index page. */ 00775 00776 ibool 00777 page_validate( 00778 /*==========*/ 00779 /* out: TRUE if ok */ 00780 page_t* page, /* in: index page */ 00781 dict_index_t* index); /* in: data dictionary index containing 00782 the page record type definition */ 00783 /******************************************************************* 00784 Looks in the page record list for a record with the given heap number. */ 00785 00786 rec_t* 00787 page_find_rec_with_heap_no( 00788 /*=======================*/ 00789 /* out: record, NULL if not found */ 00790 page_t* page, /* in: index page */ 00791 ulint heap_no);/* in: heap number */ 00792 00793 #ifdef UNIV_MATERIALIZE 00794 #undef UNIV_INLINE 00795 #define UNIV_INLINE UNIV_INLINE_ORIGINAL 00796 #endif 00797 00798 #ifndef UNIV_NONINL 00799 #include "page0page.ic" 00800 #endif 00801 00802 #endif
1.4.7

