00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00026 #pragma once
00027 #ifndef page0page_h
00028 #define page0page_h
00029
00030 #include "univ.i"
00031
00032 #include "page0types.h"
00033 #include "fil0fil.h"
00034 #include "buf0buf.h"
00035 #include "data0data.h"
00036 #include "dict0dict.h"
00037 #include "rem0rec.h"
00038 #include "fsp0fsp.h"
00039 #include "mtr0mtr.h"
00040
00041 #ifdef UNIV_MATERIALIZE
00042 #undef UNIV_INLINE
00043 #define UNIV_INLINE
00044 #endif
00045
00046
00047
00048
00049
00050
00051 typedef byte page_header_t;
00052
00053 #define PAGE_HEADER FSEG_PAGE_DATA
00054
00055
00056 #define PAGE_N_DIR_SLOTS 0
00057 #define PAGE_HEAP_TOP 2
00058 #define PAGE_N_HEAP 4
00059
00060 #define PAGE_FREE 6
00061 #define PAGE_GARBAGE 8
00062 #define PAGE_LAST_INSERT 10
00063
00064
00065 #define PAGE_DIRECTION 12
00066 #define PAGE_N_DIRECTION 14
00067
00068 #define PAGE_N_RECS 16
00069 #define PAGE_MAX_TRX_ID 18
00070
00071
00072
00073
00074
00075
00076 #define PAGE_HEADER_PRIV_END 26
00077
00078
00079 #define PAGE_LEVEL 26
00080
00081
00082 #define PAGE_INDEX_ID 28
00083
00084
00085 #define PAGE_BTR_SEG_LEAF 36
00086
00087
00088 #define PAGE_BTR_IBUF_FREE_LIST PAGE_BTR_SEG_LEAF
00089 #define PAGE_BTR_IBUF_FREE_LIST_NODE PAGE_BTR_SEG_LEAF
00090
00091
00092
00093
00094
00095 #define PAGE_BTR_SEG_TOP (36 + FSEG_HEADER_SIZE)
00096
00097
00098
00099
00100
00101 #define PAGE_DATA (PAGE_HEADER + 36 + 2 * FSEG_HEADER_SIZE)
00102
00103
00104 #define PAGE_OLD_INFIMUM (PAGE_DATA + 1 + REC_N_OLD_EXTRA_BYTES)
00105
00106
00107 #define PAGE_OLD_SUPREMUM (PAGE_DATA + 2 + 2 * REC_N_OLD_EXTRA_BYTES + 8)
00108
00109
00110 #define PAGE_OLD_SUPREMUM_END (PAGE_OLD_SUPREMUM + 9)
00111
00112
00113 #define PAGE_NEW_INFIMUM (PAGE_DATA + REC_N_NEW_EXTRA_BYTES)
00114
00115
00116 #define PAGE_NEW_SUPREMUM (PAGE_DATA + 2 * REC_N_NEW_EXTRA_BYTES + 8)
00117
00118
00119 #define PAGE_NEW_SUPREMUM_END (PAGE_NEW_SUPREMUM + 8)
00120
00121
00122
00123
00124
00125 #define PAGE_HEAP_NO_INFIMUM 0
00126 #define PAGE_HEAP_NO_SUPREMUM 1
00127 #define PAGE_HEAP_NO_USER_LOW 2
00128
00129
00130
00131
00132
00133 #define PAGE_LEFT 1
00134 #define PAGE_RIGHT 2
00135 #define PAGE_SAME_REC 3
00136 #define PAGE_SAME_PAGE 4
00137 #define PAGE_NO_DIRECTION 5
00138
00139
00140
00141
00142
00143 typedef byte page_dir_slot_t;
00144 typedef page_dir_slot_t page_dir_t;
00145
00146
00147
00148
00149 #define PAGE_DIR FIL_PAGE_DATA_END
00150
00151
00152 #define PAGE_DIR_SLOT_SIZE 2
00153
00154
00155
00156 #define PAGE_EMPTY_DIR_START (PAGE_DIR + 2 * PAGE_DIR_SLOT_SIZE)
00157
00158
00159
00160
00161 #define PAGE_DIR_SLOT_MAX_N_OWNED 8
00162 #define PAGE_DIR_SLOT_MIN_N_OWNED 4
00163
00164
00167 UNIV_INLINE
00168 page_t*
00169 page_align(
00170
00171 const void* ptr)
00172 __attribute__((const));
00173
00176 UNIV_INLINE
00177 ulint
00178 page_offset(
00179
00180 const void* ptr)
00181 __attribute__((const));
00182
00184 UNIV_INLINE
00185 trx_id_t
00186 page_get_max_trx_id(
00187
00188 const page_t* page);
00189
00191 UNIV_INTERN
00192 void
00193 page_set_max_trx_id(
00194
00195 buf_block_t* block,
00196 page_zip_des_t* page_zip,
00197 trx_id_t trx_id,
00198 mtr_t* mtr);
00199
00202 UNIV_INLINE
00203 void
00204 page_update_max_trx_id(
00205
00206 buf_block_t* block,
00207 page_zip_des_t* page_zip,
00209 trx_id_t trx_id,
00210 mtr_t* mtr);
00211
00213 UNIV_INLINE
00214 ulint
00215 page_header_get_field(
00216
00217 const page_t* page,
00218 ulint field);
00219
00221 UNIV_INLINE
00222 void
00223 page_header_set_field(
00224
00225 page_t* page,
00226 page_zip_des_t* page_zip,
00228 ulint field,
00229 ulint val);
00230
00233 UNIV_INLINE
00234 ulint
00235 page_header_get_offs(
00236
00237 const page_t* page,
00238 ulint field)
00239 __attribute__((nonnull, pure));
00240
00241
00243 #define page_header_get_ptr(page, field) \
00244 (page_header_get_offs(page, field) \
00245 ? page + page_header_get_offs(page, field) : NULL)
00246
00248 UNIV_INLINE
00249 void
00250 page_header_set_ptr(
00251
00252 page_t* page,
00253 page_zip_des_t* page_zip,
00255 ulint field,
00256 const byte* ptr);
00257 #ifndef UNIV_HOTBACKUP
00258
00261 UNIV_INLINE
00262 void
00263 page_header_reset_last_insert(
00264
00265 page_t* page,
00266 page_zip_des_t* page_zip,
00268 mtr_t* mtr);
00269 #endif
00270
00273 UNIV_INLINE
00274 ulint
00275 page_get_infimum_offset(
00276
00277 const page_t* page);
00278
00281 UNIV_INLINE
00282 ulint
00283 page_get_supremum_offset(
00284
00285 const page_t* page);
00286 #define page_get_infimum_rec(page) ((page) + page_get_infimum_offset(page))
00287 #define page_get_supremum_rec(page) ((page) + page_get_supremum_offset(page))
00288
00292 UNIV_INTERN
00293 rec_t*
00294 page_get_middle_rec(
00295
00296 page_t* page);
00297 #ifndef UNIV_HOTBACKUP
00298
00306 UNIV_INLINE
00307 int
00308 page_cmp_dtuple_rec_with_match(
00309
00310 const dtuple_t* dtuple,
00311 const rec_t* rec,
00315 const ulint* offsets,
00316 ulint* matched_fields,
00319 ulint* matched_bytes);
00323 #endif
00324
00327 UNIV_INLINE
00328 ulint
00329 page_get_page_no(
00330
00331 const page_t* page);
00332
00335 UNIV_INLINE
00336 ulint
00337 page_get_space_id(
00338
00339 const page_t* page);
00340
00344 UNIV_INLINE
00345 ulint
00346 page_get_n_recs(
00347
00348 const page_t* page);
00349
00353 UNIV_INTERN
00354 ulint
00355 page_rec_get_n_recs_before(
00356
00357 const rec_t* rec);
00358
00361 UNIV_INLINE
00362 ulint
00363 page_dir_get_n_heap(
00364
00365 const page_t* page);
00366
00368 UNIV_INLINE
00369 void
00370 page_dir_set_n_heap(
00371
00372 page_t* page,
00373 page_zip_des_t* page_zip,
00378 ulint n_heap);
00379
00382 UNIV_INLINE
00383 ulint
00384 page_dir_get_n_slots(
00385
00386 const page_t* page);
00387
00389 UNIV_INLINE
00390 void
00391 page_dir_set_n_slots(
00392
00393 page_t* page,
00394 page_zip_des_t* page_zip,
00396 ulint n_slots);
00397 #ifdef UNIV_DEBUG
00398
00401 UNIV_INLINE
00402 page_dir_slot_t*
00403 page_dir_get_nth_slot(
00404
00405 const page_t* page,
00406 ulint n);
00407 #else
00408 # define page_dir_get_nth_slot(page, n) \
00409 ((page) + UNIV_PAGE_SIZE - PAGE_DIR \
00410 - (n + 1) * PAGE_DIR_SLOT_SIZE)
00411 #endif
00412
00415 UNIV_INLINE
00416 ibool
00417 page_rec_check(
00418
00419 const rec_t* rec);
00420
00423 UNIV_INLINE
00424 const rec_t*
00425 page_dir_slot_get_rec(
00426
00427 const page_dir_slot_t* slot);
00428
00430 UNIV_INLINE
00431 void
00432 page_dir_slot_set_rec(
00433
00434 page_dir_slot_t* slot,
00435 rec_t* rec);
00436
00439 UNIV_INLINE
00440 ulint
00441 page_dir_slot_get_n_owned(
00442
00443 const page_dir_slot_t* slot);
00444
00446 UNIV_INLINE
00447 void
00448 page_dir_slot_set_n_owned(
00449
00450 page_dir_slot_t*slot,
00451 page_zip_des_t* page_zip,
00452 ulint n);
00453
00458 UNIV_INLINE
00459 ulint
00460 page_dir_calc_reserved_space(
00461
00462 ulint n_recs);
00463
00466 UNIV_INTERN
00467 ulint
00468 page_dir_find_owner_slot(
00469
00470 const rec_t* rec);
00471
00475 UNIV_INLINE
00476 ulint
00477 page_is_comp(
00478
00479 const page_t* page);
00480
00483 UNIV_INLINE
00484 ulint
00485 page_rec_is_comp(
00486
00487 const rec_t* rec);
00488
00491 UNIV_INLINE
00492 ulint
00493 page_rec_get_heap_no(
00494
00495 const rec_t* rec);
00496
00499 UNIV_INLINE
00500 ibool
00501 page_is_leaf(
00502
00503 const page_t* page)
00504 __attribute__((nonnull, pure));
00505
00508 UNIV_INLINE
00509 const rec_t*
00510 page_rec_get_next_low(
00511
00512 const rec_t* rec,
00513 ulint comp);
00514
00517 UNIV_INLINE
00518 rec_t*
00519 page_rec_get_next(
00520
00521 rec_t* rec);
00522
00525 UNIV_INLINE
00526 const rec_t*
00527 page_rec_get_next_const(
00528
00529 const rec_t* rec);
00530
00532 UNIV_INLINE
00533 void
00534 page_rec_set_next(
00535
00536 rec_t* rec,
00538 rec_t* next);
00540
00543 UNIV_INLINE
00544 const rec_t*
00545 page_rec_get_prev_const(
00546
00547 const rec_t* rec);
00549
00552 UNIV_INLINE
00553 rec_t*
00554 page_rec_get_prev(
00555
00556 rec_t* rec);
00558
00561 UNIV_INLINE
00562 ibool
00563 page_rec_is_user_rec_low(
00564
00565 ulint offset)
00566 __attribute__((const));
00567
00570 UNIV_INLINE
00571 ibool
00572 page_rec_is_supremum_low(
00573
00574 ulint offset)
00575 __attribute__((const));
00576
00579 UNIV_INLINE
00580 ibool
00581 page_rec_is_infimum_low(
00582
00583 ulint offset)
00584 __attribute__((const));
00585
00586
00589 UNIV_INLINE
00590 ibool
00591 page_rec_is_user_rec(
00592
00593 const rec_t* rec)
00594 __attribute__((const));
00595
00598 UNIV_INLINE
00599 ibool
00600 page_rec_is_supremum(
00601
00602 const rec_t* rec)
00603 __attribute__((const));
00604
00605
00608 UNIV_INLINE
00609 ibool
00610 page_rec_is_infimum(
00611
00612 const rec_t* rec)
00613 __attribute__((const));
00614
00617 UNIV_INLINE
00618 rec_t*
00619 page_rec_find_owner_rec(
00620
00621 rec_t* rec);
00622
00626 UNIV_INTERN
00627 void
00628 page_rec_write_index_page_no(
00629
00630 rec_t* rec,
00631 ulint i,
00632 ulint page_no,
00633 mtr_t* mtr);
00634
00638 UNIV_INLINE
00639 ulint
00640 page_get_max_insert_size(
00641
00642 const page_t* page,
00643 ulint n_recs);
00644
00648 UNIV_INLINE
00649 ulint
00650 page_get_max_insert_size_after_reorganize(
00651
00652 const page_t* page,
00653 ulint n_recs);
00654
00657 UNIV_INLINE
00658 ulint
00659 page_get_free_space_of_empty(
00660
00661 ulint comp)
00662 __attribute__((const));
00663
00667 UNIV_INLINE
00668 ulint
00669 page_rec_get_base_extra_size(
00670
00671 const rec_t* rec);
00672
00676 UNIV_INLINE
00677 ulint
00678 page_get_data_size(
00679
00680 const page_t* page);
00681
00684 UNIV_INLINE
00685 void
00686 page_mem_alloc_free(
00687
00688 page_t* page,
00689 page_zip_des_t* page_zip,
00692 rec_t* next_rec,
00694 ulint need);
00695
00698 UNIV_INTERN
00699 byte*
00700 page_mem_alloc_heap(
00701
00702 page_t* page,
00703 page_zip_des_t* page_zip,
00706 ulint need,
00707 ulint* heap_no);
00710
00712 UNIV_INLINE
00713 void
00714 page_mem_free(
00715
00716 page_t* page,
00717 page_zip_des_t* page_zip,
00718 rec_t* rec,
00719 dict_index_t* index,
00720 const ulint* offsets);
00721
00724 UNIV_INTERN
00725 page_t*
00726 page_create(
00727
00728 buf_block_t* block,
00730 mtr_t* mtr,
00731 ulint comp);
00732
00735 UNIV_INTERN
00736 page_t*
00737 page_create_zip(
00738
00739 buf_block_t* block,
00741 dict_index_t* index,
00742 ulint level,
00743 mtr_t* mtr);
00745
00748 UNIV_INTERN
00749 void
00750 page_copy_rec_list_end_no_locks(
00751
00752 buf_block_t* new_block,
00753 buf_block_t* block,
00754 rec_t* rec,
00755 dict_index_t* index,
00756 mtr_t* mtr);
00757
00763 UNIV_INTERN
00764 rec_t*
00765 page_copy_rec_list_end(
00766
00767 buf_block_t* new_block,
00768 buf_block_t* block,
00769 rec_t* rec,
00770 dict_index_t* index,
00771 mtr_t* mtr)
00772 __attribute__((nonnull));
00773
00779 UNIV_INTERN
00780 rec_t*
00781 page_copy_rec_list_start(
00782
00783 buf_block_t* new_block,
00784 buf_block_t* block,
00785 rec_t* rec,
00786 dict_index_t* index,
00787 mtr_t* mtr)
00788 __attribute__((nonnull));
00789
00792 UNIV_INTERN
00793 void
00794 page_delete_rec_list_end(
00795
00796 rec_t* rec,
00797 buf_block_t* block,
00798 dict_index_t* index,
00799 ulint n_recs,
00801 ulint size,
00804 mtr_t* mtr)
00805 __attribute__((nonnull));
00806
00809 UNIV_INTERN
00810 void
00811 page_delete_rec_list_start(
00812
00813 rec_t* rec,
00814 buf_block_t* block,
00815 dict_index_t* index,
00816 mtr_t* mtr)
00817 __attribute__((nonnull));
00818
00823 UNIV_INTERN
00824 ibool
00825 page_move_rec_list_end(
00826
00827 buf_block_t* new_block,
00828 buf_block_t* block,
00829 rec_t* split_rec,
00830 dict_index_t* index,
00831 mtr_t* mtr)
00832 __attribute__((nonnull(1, 2, 4, 5)));
00833
00837 UNIV_INTERN
00838 ibool
00839 page_move_rec_list_start(
00840
00841 buf_block_t* new_block,
00842 buf_block_t* block,
00843 rec_t* split_rec,
00844 dict_index_t* index,
00845 mtr_t* mtr)
00846 __attribute__((nonnull(1, 2, 4, 5)));
00847
00849 UNIV_INTERN
00850 void
00851 page_dir_split_slot(
00852
00853 page_t* page,
00854 page_zip_des_t* page_zip,
00856 ulint slot_no)
00857 __attribute__((nonnull(1)));
00858
00863 UNIV_INTERN
00864 void
00865 page_dir_balance_slot(
00866
00867 page_t* page,
00868 page_zip_des_t* page_zip,
00869 ulint slot_no)
00870 __attribute__((nonnull(1)));
00871
00874 UNIV_INTERN
00875 byte*
00876 page_parse_delete_rec_list(
00877
00878 byte type,
00882 byte* ptr,
00883 byte* end_ptr,
00884 buf_block_t* block,
00885 dict_index_t* index,
00886 mtr_t* mtr);
00887
00890 UNIV_INTERN
00891 byte*
00892 page_parse_create(
00893
00894 byte* ptr,
00895 byte* end_ptr,
00896 ulint comp,
00897 buf_block_t* block,
00898 mtr_t* mtr);
00899
00902 UNIV_INTERN
00903 void
00904 page_rec_print(
00905
00906 const rec_t* rec,
00907 const ulint* offsets);
00908
00911 UNIV_INTERN
00912 void
00913 page_dir_print(
00914
00915 page_t* page,
00916 ulint pr_n);
00917
00920 UNIV_INTERN
00921 void
00922 page_print_list(
00923
00924 buf_block_t* block,
00925 dict_index_t* index,
00926 ulint pr_n);
00927
00929 UNIV_INTERN
00930 void
00931 page_header_print(
00932
00933 const page_t* page);
00934
00937 UNIV_INTERN
00938 void
00939 page_print(
00940
00941 buf_block_t* block,
00942 dict_index_t* index,
00943 ulint dn,
00945 ulint rn);
00947
00952 UNIV_INTERN
00953 ibool
00954 page_rec_validate(
00955
00956 rec_t* rec,
00957 const ulint* offsets);
00958
00962 UNIV_INTERN
00963 void
00964 page_check_dir(
00965
00966 const page_t* page);
00967
00972 UNIV_INTERN
00973 ibool
00974 page_simple_validate_old(
00975
00976 page_t* page);
00977
00982 UNIV_INTERN
00983 ibool
00984 page_simple_validate_new(
00985
00986 page_t* block);
00987
00990 UNIV_INTERN
00991 ibool
00992 page_validate(
00993
00994 page_t* page,
00995 dict_index_t* index);
00997
01001 const rec_t*
01002 page_find_rec_with_heap_no(
01003
01004 const page_t* page,
01005 ulint heap_no);
01007 #ifdef UNIV_MATERIALIZE
01008 #undef UNIV_INLINE
01009 #define UNIV_INLINE UNIV_INLINE_ORIGINAL
01010 #endif
01011
01012 #ifndef UNIV_NONINL
01013 #include "page0page.ic"
01014 #endif
01015
01016 #endif