Commit 736a8ffb authored by marko's avatar marko

branches/zip: Replace buf_frame_get_page_no() and buf_frame_get_space_id()

with page_get_page_no() and page_get_space_id().  We want to avoid
buf_block_align() calls, and the page_no and space_id are now stamped
on the pages early on.
parent 1003d199
This diff is collapsed.
......@@ -204,7 +204,7 @@ btr_cur_latch_leaves(
RW_X_LATCH, mtr);
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_next(get_page, mtr)
== buf_frame_get_page_no(page));
== page_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */
ut_a(page_is_comp(get_page) == page_is_comp(page));
buf_block_align(get_page)->check_index_page_at_flush
......@@ -222,7 +222,7 @@ btr_cur_latch_leaves(
RW_X_LATCH, mtr);
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_prev(get_page, mtr)
== buf_frame_get_page_no(page));
== page_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */
buf_block_align(get_page)->check_index_page_at_flush
= TRUE;
......@@ -238,7 +238,7 @@ btr_cur_latch_leaves(
RW_S_LATCH, mtr);
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_next(cursor->left_page, mtr)
== buf_frame_get_page_no(page));
== page_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */
ut_a(page_is_comp(cursor->left_page)
== page_is_comp(page));
......@@ -260,7 +260,7 @@ btr_cur_latch_leaves(
RW_X_LATCH, mtr);
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_next(cursor->left_page, mtr)
== buf_frame_get_page_no(page));
== page_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */
ut_a(page_is_comp(cursor->left_page)
== page_is_comp(page));
......@@ -1200,7 +1200,7 @@ btr_cur_optimistic_insert(
#if 0
fprintf(stderr, "Insert into page %lu, max ins size %lu,"
" rec %lu ind type %lu\n",
buf_frame_get_page_no(page), max_size,
page_get_page_no(page), max_size,
rec_size + PAGE_DIR_SLOT_SIZE, type);
#endif
if (!(type & DICT_CLUSTERED)) {
......@@ -1373,7 +1373,7 @@ btr_cur_pessimistic_insert(
}
}
if (dict_index_get_page(index) == buf_frame_get_page_no(page)) {
if (dict_index_get_page(index) == page_get_page_no(page)) {
/* The page is the root page */
*rec = btr_root_raise_and_insert(cursor, entry,
......@@ -1943,14 +1943,14 @@ btr_cur_pess_upd_restore_supremum(
return;
}
space = buf_frame_get_space_id(page);
space = page_get_space_id(page);
prev_page_no = btr_page_get_prev(page, mtr);
ut_ad(prev_page_no != FIL_NULL);
prev_page = buf_page_get_with_no_latch(space, prev_page_no, mtr);
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_next(prev_page, mtr)
== buf_frame_get_page_no(page));
== page_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */
/* We must already have an x-latch to prev_page! */
......@@ -2776,7 +2776,7 @@ btr_cur_pessimistic_delete(
if (UNIV_UNLIKELY(page_get_n_recs(page) < 2)
&& UNIV_UNLIKELY(dict_index_get_page(btr_cur_get_index(cursor))
!= buf_frame_get_page_no(page))) {
!= page_get_page_no(page))) {
/* If there is only one record, drop the whole page in
btr_discard_page, if this is not the root page */
......@@ -2819,7 +2819,7 @@ btr_cur_pessimistic_delete(
btr_node_ptr_delete(index, page, mtr);
node_ptr = dict_index_build_node_ptr(
index, next_rec, buf_frame_get_page_no(page),
index, next_rec, page_get_page_no(page),
heap, level);
btr_insert_on_non_leaf_level(index,
......@@ -3605,7 +3605,7 @@ btr_store_big_rec_extern_fields(
ut_ad(mtr_memo_contains_page(local_mtr, rec, MTR_MEMO_PAGE_X_FIX));
ut_a(dict_index_is_clust(index));
space_id = buf_frame_get_space_id(rec);
space_id = page_get_space_id(page_align(rec));
page_zip = buf_frame_get_page_zip(rec);
ut_a(dict_table_zip_size(index->table)
......@@ -3655,7 +3655,8 @@ btr_store_big_rec_extern_fields(
mtr_start(&mtr);
if (prev_page_no == FIL_NULL) {
hint_page_no = buf_frame_get_page_no(rec) + 1;
hint_page_no = 1
+ page_get_page_no(page_align(rec));
} else {
hint_page_no = prev_page_no + 1;
}
......@@ -3673,7 +3674,7 @@ btr_store_big_rec_extern_fields(
return(DB_OUT_OF_FILE_SPACE);
}
page_no = buf_frame_get_page_no(page);
page_no = page_get_page_no(page);
if (prev_page_no != FIL_NULL) {
page_t* prev_page;
......@@ -3748,10 +3749,10 @@ btr_store_big_rec_extern_fields(
goto next_zip_page;
}
rec_page = buf_page_get(space_id,
buf_frame_get_page_no(
field_ref),
RW_X_LATCH, &mtr);
rec_page = buf_page_get(
space_id, page_get_page_no(
page_align(field_ref)),
RW_X_LATCH, &mtr);
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(rec_page,
SYNC_NO_ORDER_CHECK);
......@@ -3825,10 +3826,10 @@ btr_store_big_rec_extern_fields(
extern_len -= store_len;
rec_page = buf_page_get(space_id,
buf_frame_get_page_no(
field_ref),
RW_X_LATCH, &mtr);
rec_page = buf_page_get(
space_id, page_get_page_no(
page_align(field_ref)),
RW_X_LATCH, &mtr);
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(rec_page,
SYNC_NO_ORDER_CHECK);
......@@ -3937,8 +3938,10 @@ btr_free_externally_stored_field(
for (;;) {
mtr_start(&mtr);
rec_page = buf_page_get(buf_frame_get_space_id(field_ref),
buf_frame_get_page_no(field_ref),
rec_page = buf_page_get(page_get_space_id(
page_align(field_ref)),
page_get_page_no(
page_align(field_ref)),
RW_X_LATCH, &mtr);
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(rec_page, SYNC_NO_ORDER_CHECK);
......@@ -4008,8 +4011,8 @@ btr_free_externally_stored_field(
because we did not store it on the page (we save the
space overhead from an index page header. */
ut_a(space_id == buf_frame_get_space_id(page));
ut_a(page_no == buf_frame_get_page_no(page));
ut_a(space_id == page_get_space_id(page));
ut_a(page_no == page_get_page_no(page));
btr_page_free_low(index, page,
space_id, page_no, 0, &mtr);
......
......@@ -391,13 +391,13 @@ btr_pcur_move_to_next_page(
page = btr_pcur_get_page(cursor);
next_page_no = btr_page_get_next(page, mtr);
space = buf_frame_get_space_id(page);
space = page_get_space_id(page);
ut_ad(next_page_no != FIL_NULL);
next_page = btr_page_get(space, next_page_no, cursor->latch_mode, mtr);
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_prev(next_page, mtr) == buf_frame_get_page_no(page));
ut_a(btr_page_get_prev(next_page, mtr) == page_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */
ut_a(page_is_comp(next_page) == page_is_comp(page));
buf_block_align(next_page)->check_index_page_at_flush = TRUE;
......@@ -463,7 +463,7 @@ btr_pcur_move_backward_from_page(
page = btr_pcur_get_page(cursor);
prev_page_no = btr_page_get_prev(page, mtr);
space = buf_frame_get_space_id(page);
space = page_get_space_id(page);
if (btr_pcur_is_before_first_on_page(cursor, mtr)
&& (prev_page_no != FIL_NULL)) {
......
......@@ -1654,7 +1654,7 @@ btr_search_validate(void)
"InnoDB: ptr mem address %p"
" index id %lu %lu,"
" node fold %lu, rec fold %lu\n",
(ulong) buf_frame_get_page_no(page),
(ulong) page_get_page_no(page),
node->data,
(ulong) ut_dulint_get_high(
btr_page_get_index_id(page)),
......
......@@ -1477,8 +1477,8 @@ buf_page_optimistic_get_func(
/* In the case of a first access, try to apply linear
read-ahead */
buf_read_ahead_linear(buf_frame_get_space_id(guess),
buf_frame_get_page_no(guess));
buf_read_ahead_linear(page_get_space_id(guess),
page_get_page_no(guess));
}
#ifdef UNIV_IBUF_DEBUG
......
......@@ -123,7 +123,7 @@ dict_hdr_create(
page = fseg_create(DICT_HDR_SPACE, 0,
DICT_HDR + DICT_HDR_FSEG_HEADER, mtr);
hdr_page_no = buf_frame_get_page_no(page);
hdr_page_no = page_get_page_no(page);
ut_a(DICT_HDR_PAGE_NO == hdr_page_no);
......
......@@ -783,7 +783,7 @@ xdes_lst_get_next(
ut_ad(mtr && descr);
space = buf_frame_get_space_id(descr);
space = page_get_space_id(page_align(descr));
return(xdes_lst_get_descriptor(
space,
......@@ -801,7 +801,7 @@ xdes_get_offset(
{
ut_ad(descr);
return(buf_frame_get_page_no(descr)
return(page_get_page_no(page_align(descr))
+ ((page_offset(descr) - XDES_ARR_OFFSET) / XDES_SIZE)
* FSP_EXTENT_SIZE);
}
......@@ -1827,7 +1827,7 @@ fsp_alloc_seg_inode_page(
ulint zip_size;
ulint i;
space = buf_frame_get_space_id(space_header);
space = page_get_space_id(page_align(space_header));
page_no = fsp_alloc_free_page(space, 0, mtr);
......@@ -1894,8 +1894,8 @@ fsp_alloc_seg_inode(
page_no = flst_get_first(space_header + FSP_SEG_INODES_FREE, mtr).page;
zip_size = mach_read_from_4(space_header + FSP_PAGE_ZIP_SIZE);
page = buf_page_get(buf_frame_get_space_id(space_header), page_no,
RW_X_LATCH, mtr);
page = buf_page_get(page_get_space_id(page_align(space_header)),
page_no, RW_X_LATCH, mtr);
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(page, SYNC_FSP_PAGE);
#endif /* UNIV_SYNC_DEBUG */
......@@ -1965,7 +1965,7 @@ fsp_free_seg_inode(
flst_remove(space_header + FSP_SEG_INODES_FREE,
page + FSEG_INODE_PAGE_NODE, mtr);
fsp_free_page(space, buf_frame_get_page_no(page), mtr);
fsp_free_page(space, page_get_page_no(page), mtr);
}
}
......@@ -2228,7 +2228,8 @@ fseg_create_general(
page_offset(inode), MLOG_2BYTES, mtr);
mlog_write_ulint(header + FSEG_HDR_PAGE_NO,
buf_frame_get_page_no(inode), MLOG_4BYTES, mtr);
page_get_page_no(page_align(inode)),
MLOG_4BYTES, mtr);
mlog_write_ulint(header + FSEG_HDR_SPACE, space, MLOG_4BYTES, mtr);
......@@ -2309,7 +2310,7 @@ fseg_n_reserved_pages(
fseg_inode_t* inode;
ulint space;
space = buf_frame_get_space_id(header);
space = page_get_space_id(page_align(header));
#ifdef UNIV_SYNC_DEBUG
ut_ad(!mutex_own(&kernel_mutex)
......@@ -2710,7 +2711,7 @@ fseg_alloc_free_page_general(
ulint page_no;
ulint n_reserved;
space = buf_frame_get_space_id(seg_header);
space = page_get_space_id(page_align(seg_header));
#ifdef UNIV_SYNC_DEBUG
ut_ad(!mutex_own(&kernel_mutex)
......@@ -2740,7 +2741,8 @@ fseg_alloc_free_page_general(
}
}
page_no = fseg_alloc_free_page_low(buf_frame_get_space_id(inode),
page_no = fseg_alloc_free_page_low(page_get_space_id(
page_align(inode)),
inode, hint, direction, mtr);
if (!has_done_reservation) {
fil_space_release_free_extents(space, n_reserved);
......@@ -3353,8 +3355,10 @@ fseg_free_step(
xdes_t* descr;
fseg_inode_t* inode;
ulint space;
ulint header_page;
space = buf_frame_get_space_id(header);
space = page_get_space_id(page_align(header));
header_page = page_get_page_no(page_align(header));
#ifdef UNIV_SYNC_DEBUG
ut_ad(!mutex_own(&kernel_mutex)
......@@ -3363,14 +3367,14 @@ fseg_free_step(
#endif /* UNIV_SYNC_DEBUG */
mtr_x_lock(fil_space_get_latch(space), mtr);
descr = xdes_get_descriptor(space, buf_frame_get_page_no(header), mtr);
descr = xdes_get_descriptor(space, header_page, mtr);
/* Check that the header resides on a page which has not been
freed yet */
ut_a(descr);
ut_a(xdes_get_bit(descr, XDES_FREE_BIT, buf_frame_get_page_no(header)
% FSP_EXTENT_SIZE, mtr) == FALSE);
ut_a(xdes_get_bit(descr, XDES_FREE_BIT,
header_page % FSP_EXTENT_SIZE, mtr) == FALSE);
inode = fseg_inode_get(header, mtr);
descr = fseg_get_first_extent(inode, mtr);
......@@ -3429,7 +3433,7 @@ fseg_free_step_not_header(
ulint space;
ulint page_no;
space = buf_frame_get_space_id(header);
space = page_get_space_id(page_align(header));
#ifdef UNIV_SYNC_DEBUG
ut_ad(!mutex_own(&kernel_mutex)
......@@ -3461,7 +3465,7 @@ fseg_free_step_not_header(
page_no = fseg_get_nth_frag_page_no(inode, n, mtr);
if (page_no == buf_frame_get_page_no(header)) {
if (page_no == page_get_page_no(page_align(header))) {
return(TRUE);
}
......@@ -3527,7 +3531,7 @@ fseg_get_first_extent(
ut_ad(inode && mtr);
space = buf_frame_get_space_id(inode);
space = page_get_space_id(page_align(inode));
first = fil_addr_null;
......@@ -3574,7 +3578,7 @@ fseg_validate_low(
ut_ad(mtr_memo_contains_page(mtr2, inode, MTR_MEMO_PAGE_X_FIX));
ut_ad(mach_read_from_4(inode + FSEG_MAGIC_N) == FSEG_MAGIC_N_VALUE);
space = buf_frame_get_space_id(inode);
space = page_get_space_id(page_align(inode));
seg_id = mtr_read_dulint(inode + FSEG_ID, mtr2);
n_used = mtr_read_ulint(inode + FSEG_NOT_FULL_N_USED,
......@@ -3661,7 +3665,7 @@ fseg_validate(
ibool ret;
ulint space;
space = buf_frame_get_space_id(header);
space = page_get_space_id(page_align(header));
mtr_x_lock(fil_space_get_latch(space), mtr2);
......@@ -3695,8 +3699,8 @@ fseg_print_low(
dulint d_var;
ut_ad(mtr_memo_contains_page(mtr, inode, MTR_MEMO_PAGE_X_FIX));
space = buf_frame_get_space_id(inode);
page_no = buf_frame_get_page_no(inode);
space = page_get_space_id(page_align(inode));
page_no = page_get_page_no(page_align(inode));
reserved = fseg_n_reserved_pages_low(inode, &used, mtr);
......@@ -3736,7 +3740,7 @@ fseg_print(
fseg_inode_t* inode;
ulint space;
space = buf_frame_get_space_id(header);
space = page_get_space_id(page_align(header));
mtr_x_lock(fil_space_get_latch(space), mtr);
......
......@@ -491,7 +491,7 @@ flst_print(
fprintf(stderr,
"FILE-BASED LIST:\n"
"Base node in space %lu page %lu byte offset %lu; len %lu\n",
(ulong) buf_frame_get_space_id(frame),
(ulong) buf_frame_get_page_no(frame),
(ulong) page_get_space_id(frame),
(ulong) page_get_page_no(frame),
(ulong) (base - frame), (ulong) len);
}
......@@ -688,7 +688,7 @@ ibuf_bitmap_page_set_bits(
ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX));
#ifdef UNIV_IBUF_DEBUG
ut_a((bit != IBUF_BITMAP_BUFFERED) || (val != FALSE)
|| (0 == ibuf_count_get(buf_frame_get_space_id(page),
|| (0 == ibuf_count_get(page_get_space_id(page),
page_no)));
#endif
if (!zip_size) {
......@@ -802,15 +802,15 @@ ibuf_set_free_bits_low(
return;
}
space = buf_frame_get_space_id(page);
page_no = buf_frame_get_page_no(page);
space = page_get_space_id(page);
page_no = page_get_page_no(page);
zip_size = fil_space_get_zip_size(space);
bitmap_page = ibuf_bitmap_get_map_page(space, page_no, zip_size, mtr);
#ifdef UNIV_IBUF_DEBUG
# if 0
fprintf(stderr,
"Setting page no %lu free bits to %lu should be %lu\n",
buf_frame_get_page_no(page), val,
page_get_page_no(page), val,
ibuf_index_page_calc_free(page));
# endif
......@@ -855,8 +855,8 @@ ibuf_set_free_bits(
mtr_start(&mtr);
space = buf_frame_get_space_id(page);
page_no = buf_frame_get_page_no(page);
space = page_get_space_id(page);
page_no = page_get_page_no(page);
zip_size = fil_space_get_zip_size(space);
bitmap_page = ibuf_bitmap_get_map_page(space, page_no, zip_size, &mtr);
......@@ -871,7 +871,7 @@ ibuf_set_free_bits(
if (old_val != max_val) {
fprintf(stderr,
"Ibuf: page %lu old val %lu max val %lu\n",
buf_frame_get_page_no(page),
page_get_page_no(page),
old_val, max_val);
}
# endif
......@@ -882,7 +882,7 @@ ibuf_set_free_bits(
#ifdef UNIV_IBUF_DEBUG
# if 0
fprintf(stderr, "Setting page no %lu free bits to %lu should be %lu\n",
buf_frame_get_page_no(page), val,
page_get_page_no(page), val,
ibuf_index_page_calc_free(page));
# endif
......@@ -2399,7 +2399,7 @@ ibuf_get_volume_buffered(
prev_page = buf_page_get(0, prev_page_no, RW_X_LATCH, mtr);
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_next(prev_page, mtr)
== buf_frame_get_page_no(page));
== page_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */
#ifdef UNIV_SYNC_DEBUG
......@@ -2466,7 +2466,7 @@ ibuf_get_volume_buffered(
next_page = buf_page_get(0, next_page_no, RW_X_LATCH, mtr);
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_prev(next_page, mtr)
== buf_frame_get_page_no(page));
== page_get_page_no(page));
#endif /* UNIV_BTR_DEBUG */
#ifdef UNIV_SYNC_DEBUG
......@@ -2967,9 +2967,9 @@ ibuf_insert_to_index_page(
" Please run CHECK TABLE on\n"
"InnoDB: that table.\n", stderr);
space = buf_frame_get_space_id(page);
space = page_get_space_id(page);
zip_size = fil_space_get_zip_size(space);
page_no = buf_frame_get_page_no(page);
page_no = page_get_page_no(page);
bitmap_page = ibuf_bitmap_get_map_page(
space, page_no, zip_size, mtr);
......
......@@ -110,7 +110,7 @@ btr_cur_compress_recommendation(
root page. */
return(dict_index_get_page(cursor->index)
!= buf_frame_get_page_no(page));
!= page_get_page_no(page));
}
return(FALSE);
......@@ -147,7 +147,7 @@ btr_cur_can_delete_without_compress(
compression if this is not the root page. */
return(dict_index_get_page(cursor->index)
== buf_frame_get_page_no(page));
== page_get_page_no(page));
}
return(TRUE);
......
......@@ -446,24 +446,6 @@ buf_page_is_corrupted(
ulint zip_size); /* in: size of compressed page;
0 for uncompressed pages */
/**************************************************************************
Gets the page number of a pointer pointing within a buffer frame containing
a file page. */
UNIV_INLINE
ulint
buf_frame_get_page_no(
/*==================*/
/* out: page number */
byte* ptr); /* in: pointer to within a buffer frame */
/**************************************************************************
Gets the space id of a pointer pointing within a buffer frame containing a
file page. */
UNIV_INLINE
ulint
buf_frame_get_space_id(
/*===================*/
/* out: space id */
byte* ptr); /* in: pointer to within a buffer frame */
/**************************************************************************
Gets the space id, page offset, and byte offset within page of a
pointer pointing to a buffer frame containing a file page. */
UNIV_INLINE
......
......@@ -251,32 +251,6 @@ buf_block_align(
return(block);
}
/**************************************************************************
Gets the page number of a pointer pointing within a buffer frame containing
a file page. */
UNIV_INLINE
ulint
buf_frame_get_page_no(
/*==================*/
/* out: page number */
byte* ptr) /* in: pointer to within a buffer frame */
{
return(buf_block_get_page_no(buf_block_align(ptr)));
}
/**************************************************************************
Gets the space id of a pointer pointing within a buffer frame containing a
file page. */
UNIV_INLINE
ulint
buf_frame_get_space_id(
/*===================*/
/* out: space id */
byte* ptr) /* in: pointer to within a buffer frame */
{
return(buf_block_get_space(buf_block_align(ptr)));
}
/**************************************************************************
Gets the space id, page offset, and byte offset within page of a
pointer pointing to a buffer frame containing a file page. */
......
......@@ -156,7 +156,7 @@ UNIV_INLINE
dulint
page_get_max_trx_id(
/*================*/
page_t* page); /* in: page */
const page_t* page); /* in: page */
/*****************************************************************
Sets the max trx id field value. */
......@@ -184,8 +184,8 @@ UNIV_INLINE
ulint
page_header_get_field(
/*==================*/
page_t* page, /* in: page */
ulint field); /* in: PAGE_N_DIR_SLOTS, ... */
const page_t* page, /* in: page */
ulint field); /* in: PAGE_N_DIR_SLOTS, ... */
/*****************************************************************
Sets the given header field. */
UNIV_INLINE
......@@ -280,14 +280,30 @@ page_cmp_dtuple_rec_with_match(
matched; when function returns contains the
value for current comparison */
/*****************************************************************
Gets the page number. */
UNIV_INLINE
ulint
page_get_page_no(
/*=============*/
/* out: page number */
const page_t* page); /* in: page */
/*****************************************************************
Gets the tablespace identifier. */
UNIV_INLINE
ulint
page_get_space_id(
/*==============*/
/* out: space id */
const page_t* page); /* in: page */
/*****************************************************************
Gets the number of user records on page (the infimum and supremum records
are not user records). */
UNIV_INLINE
ulint
page_get_n_recs(
/*============*/
/* out: number of user records */
page_t* page); /* in: index page */
/* out: number of user records */
const page_t* page); /* in: index page */
/*******************************************************************
Returns the number of records before the given record in chain.
The number includes infimum and supremum records. */
......@@ -303,8 +319,8 @@ UNIV_INLINE
ulint
page_dir_get_n_heap(
/*================*/
/* out: number of user records */
page_t* page); /* in: index page */
/* out: number of user records */
const page_t* page); /* in: index page */
/*****************************************************************
Sets the number of records in the heap. */
UNIV_INLINE
......@@ -324,8 +340,8 @@ UNIV_INLINE
ulint
page_dir_get_n_slots(
/*=================*/
/* out: number of slots */
page_t* page); /* in: index page */
/* out: number of slots */
const page_t* page); /* in: index page */
/*****************************************************************
Sets the number of dir slots in directory. */
UNIV_INLINE
......@@ -410,9 +426,9 @@ UNIV_INLINE
ulint
page_is_comp(
/*=========*/
/* out: nonzero if the page is in compact
format, zero if it is in old-style format */
page_t* page); /* in: index page */
/* out: nonzero if the page is in compact
format, zero if it is in old-style format */
const page_t* page); /* in: index page */
/****************************************************************
TRUE if the record is on a page in compact format. */
UNIV_INLINE
......@@ -549,9 +565,10 @@ UNIV_INLINE
ulint
page_get_max_insert_size(
/*=====================*/
/* out: maximum combined size for inserted records */
page_t* page, /* in: index page */
ulint n_recs); /* in: number of records */
/* out: maximum combined size for
inserted records */
const page_t* page, /* in: index page */
ulint n_recs);/* in: number of records */
/****************************************************************
Returns the maximum combined size of records which can be inserted on top
of record heap if page is first reorganized. */
......@@ -559,9 +576,10 @@ UNIV_INLINE
ulint
page_get_max_insert_size_after_reorganize(
/*======================================*/
/* out: maximum combined size for inserted records */
page_t* page, /* in: index page */
ulint n_recs);/* in: number of records */
/* out: maximum combined size for
inserted records */
const page_t* page, /* in: index page */
ulint n_recs);/* in: number of records */
/*****************************************************************
Calculates free space if a page is emptied. */
UNIV_INLINE
......@@ -588,8 +606,8 @@ UNIV_INLINE
ulint
page_get_data_size(
/*===============*/
/* out: data in bytes */
page_t* page); /* in: index page */
/* out: data in bytes */
const page_t* page); /* in: index page */
/****************************************************************
Allocates a block of memory from the head of the free list
of an index page. */
......
......@@ -44,7 +44,7 @@ UNIV_INLINE
dulint
page_get_max_trx_id(
/*================*/
page_t* page) /* in: page */
const page_t* page) /* in: page */
{
ut_ad(page);
......@@ -77,8 +77,8 @@ UNIV_INLINE
ulint
page_header_get_field(
/*==================*/
page_t* page, /* in: page */
ulint field) /* in: PAGE_LEVEL, ... */
const page_t* page, /* in: page */
ulint field) /* in: PAGE_LEVEL, ... */
{
ut_ad(page);
ut_ad(field <= PAGE_INDEX_ID);
......@@ -200,9 +200,9 @@ UNIV_INLINE
ulint
page_is_comp(
/*=========*/
/* out: nonzero if the page is in compact
format, zero if it is in old-style format */
page_t* page) /* in: index page */
/* out: nonzero if the page is in compact
format, zero if it is in old-style format */
const page_t* page) /* in: index page */
{
return(UNIV_EXPECT(page_header_get_field(page, PAGE_N_HEAP) & 0x8000,
0x8000));
......@@ -421,6 +421,32 @@ page_cmp_dtuple_rec_with_match(
matched_bytes));
}
/*****************************************************************
Gets the page number. */
UNIV_INLINE
ulint
page_get_page_no(
/*=============*/
/* out: page number */
const page_t* page) /* in: page */
{
ut_ad(page == page_align((page_t*) page));
return(mach_read_from_4(page + FIL_PAGE_OFFSET));
}
/*****************************************************************
Gets the tablespace identifier. */
UNIV_INLINE
ulint
page_get_space_id(
/*==============*/
/* out: space id */
const page_t* page) /* in: page */
{
ut_ad(page == page_align((page_t*) page));
return(mach_read_from_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID));
}
/*****************************************************************
Gets the number of user records on page (infimum and supremum records
are not user records). */
......@@ -428,8 +454,8 @@ UNIV_INLINE
ulint
page_get_n_recs(
/*============*/
/* out: number of user records */
page_t* page) /* in: index page */
/* out: number of user records */
const page_t* page) /* in: index page */
{
return(page_header_get_field(page, PAGE_N_RECS));
}
......@@ -440,8 +466,8 @@ UNIV_INLINE
ulint
page_dir_get_n_slots(
/*=================*/
/* out: number of slots */
page_t* page) /* in: index page */
/* out: number of slots */
const page_t* page) /* in: index page */
{
return(page_header_get_field(page, PAGE_N_DIR_SLOTS));
}
......@@ -465,8 +491,8 @@ UNIV_INLINE
ulint
page_dir_get_n_heap(
/*================*/
/* out: number of user records */
page_t* page) /* in: index page */
/* out: number of user records */
const page_t* page) /* in: index page */
{
return(page_header_get_field(page, PAGE_N_HEAP) & 0x7fff);
}
......@@ -788,8 +814,8 @@ UNIV_INLINE
ulint
page_get_data_size(
/*===============*/
/* out: data in bytes */
page_t* page) /* in: index page */
/* out: data in bytes */
const page_t* page) /* in: index page */
{
ulint ret;
......@@ -868,9 +894,10 @@ UNIV_INLINE
ulint
page_get_max_insert_size(
/*=====================*/
/* out: maximum combined size for inserted records */
page_t* page, /* in: index page */
ulint n_recs) /* in: number of records */
/* out: maximum combined size for
inserted records */
const page_t* page, /* in: index page */
ulint n_recs) /* in: number of records */
{
ulint occupied;
ulint free_space;
......@@ -910,9 +937,10 @@ UNIV_INLINE
ulint
page_get_max_insert_size_after_reorganize(
/*======================================*/
/* out: maximum combined size for inserted records */
page_t* page, /* in: index page */
ulint n_recs) /* in: number of records */
/* out: maximum combined size for
inserted records */
const page_t* page, /* in: index page */
ulint n_recs) /* in: number of records */
{
ulint occupied;
ulint free_space;
......
......@@ -7,6 +7,7 @@ Created 3/26/1996 Heikki Tuuri
*******************************************************/
#include "data0type.h"
#include "page0page.h"
/***************************************************************************
Builds a roll pointer dulint. */
......@@ -177,7 +178,7 @@ trx_undo_page_get_start(
{
ulint start;
if (page_no == buf_frame_get_page_no(undo_page)) {
if (page_no == page_get_page_no(undo_page)) {
start = mach_read_from_2(offset + undo_page
+ TRX_UNDO_LOG_START);
......@@ -203,7 +204,7 @@ trx_undo_page_get_end(
trx_ulogf_t* log_hdr;
ulint end;
if (page_no == buf_frame_get_page_no(undo_page)) {
if (page_no == page_get_page_no(undo_page)) {
log_hdr = undo_page + offset;
......
......@@ -1258,8 +1258,8 @@ lock_rec_get_first_on_page(
{
ulint hash;
lock_t* lock;
ulint space;
ulint page_no;
ulint space = page_get_space_id(page_align(ptr));
ulint page_no = page_get_page_no(page_align(ptr));
#ifdef UNIV_SYNC_DEBUG
ut_ad(mutex_own(&kernel_mutex));
......@@ -1270,9 +1270,6 @@ lock_rec_get_first_on_page(
lock = HASH_GET_FIRST(lock_sys->rec_hash, hash);
while (lock) {
space = buf_frame_get_space_id(ptr);
page_no = buf_frame_get_page_no(ptr);
if ((lock->un_member.rec_lock.space == space)
&& (lock->un_member.rec_lock.page_no == page_no)) {
......@@ -1768,8 +1765,8 @@ lock_rec_create(
#endif /* UNIV_SYNC_DEBUG */
page = page_align(rec);
space = buf_frame_get_space_id(page);
page_no = buf_frame_get_page_no(page);
space = page_get_space_id(page);
page_no = page_get_page_no(page);
ut_ad(!!page_is_comp(page) == dict_table_is_comp(index->table));
......@@ -2433,8 +2430,8 @@ lock_rec_free_all_from_discard_page(
ut_ad(mutex_own(&kernel_mutex));
#endif /* UNIV_SYNC_DEBUG */
space = buf_frame_get_space_id(page);
page_no = buf_frame_get_page_no(page);
space = page_get_space_id(page);
page_no = page_get_page_no(page);
lock = lock_rec_get_first_on_page_addr(space, page_no);
......@@ -2764,8 +2761,8 @@ lock_move_reorganize_page(
mem_heap_free(heap);
#if 0
ut_ad(lock_rec_validate_page(buf_frame_get_space_id(page),
buf_frame_get_page_no(page)));
ut_ad(lock_rec_validate_page(page_get_space_id(page),
page_get_page_no(page)));
#endif
}
......@@ -2860,10 +2857,10 @@ lock_move_rec_list_end(
lock_mutex_exit_kernel();
#if 0
ut_ad(lock_rec_validate_page(buf_frame_get_space_id(page),
buf_frame_get_page_no(page)));
ut_ad(lock_rec_validate_page(buf_frame_get_space_id(new_page),
buf_frame_get_page_no(new_page)));
ut_ad(lock_rec_validate_page(page_get_space_id(page),
page_get_page_no(page)));
ut_ad(lock_rec_validate_page(page_get_space_id(new_page),
page_get_page_no(new_page)));
#endif
}
......@@ -2952,10 +2949,10 @@ lock_move_rec_list_start(
lock_mutex_exit_kernel();
#if 0
ut_ad(lock_rec_validate_page(buf_frame_get_space_id(page),
buf_frame_get_page_no(page)));
ut_ad(lock_rec_validate_page(buf_frame_get_space_id(new_page),
buf_frame_get_page_no(new_page)));
ut_ad(lock_rec_validate_page(page_get_space_id(page),
page_get_page_no(page)));
ut_ad(lock_rec_validate_page(page_get_space_id(new_page),
page_get_page_no(new_page)));
#endif
}
......
......@@ -108,7 +108,7 @@ page_dir_find_owner_slot(
"InnoDB: Probable data corruption on"
" page %lu\n"
"InnoDB: Original record ",
(ulong) buf_frame_get_page_no(page));
(ulong) page_get_page_no(page));
if (page_is_comp(page)) {
fputs("(compact record)", stderr);
......@@ -2298,7 +2298,7 @@ page_validate(
fprintf(stderr,
"InnoDB: Records in wrong order"
" on page %lu ",
(ulong) buf_frame_get_page_no(page));
(ulong) page_get_page_no(page));
dict_index_name_print(stderr, NULL, index);
fputs("\nInnoDB: previous record ", stderr);
rec_print_new(stderr, old_rec, old_offsets);
......@@ -2452,7 +2452,7 @@ page_validate(
if (UNIV_UNLIKELY(ret == FALSE)) {
func_exit2:
fprintf(stderr, "InnoDB: Apparent corruption in page %lu in ",
(ulong) buf_frame_get_page_no(page));
(ulong) page_get_page_no(page));
dict_index_name_print(stderr, NULL, index);
putc('\n', stderr);
buf_page_print(page, 0);
......
......@@ -3709,7 +3709,7 @@ row_search_for_mysql(
fputs("Using ", stderr);
dict_index_name_print(stderr, index);
fprintf(stderr, " cnt %lu ; Page no %lu\n", cnt,
buf_frame_get_page_no(page_align(rec)));
page_get_page_no(page_align(rec)));
rec_print(rec);
*/
#endif /* UNIV_SEARCH_DEBUG */
......@@ -3792,7 +3792,7 @@ row_search_for_mysql(
"InnoDB: ",
(ulong) page_offset(rec),
(ulong) next_offs,
(ulong) buf_frame_get_page_no(rec));
(ulong) page_get_page_no(page_align(rec)));
dict_index_name_print(stderr, trx, index);
fputs(". Run CHECK TABLE. You may need to\n"
"InnoDB: restore from a backup, or"
......@@ -3812,7 +3812,7 @@ row_search_for_mysql(
"InnoDB: ",
(ulong) page_offset(rec),
(ulong) next_offs,
(ulong) buf_frame_get_page_no(rec));
(ulong) page_get_page_no(page_align(rec)));
dict_index_name_print(stderr, trx, index);
fputs(". We try to skip the rest of the page.\n",
stderr);
......@@ -3837,7 +3837,7 @@ row_search_for_mysql(
"InnoDB: ",
(ulong) page_offset(rec),
(ulong) next_offs,
(ulong) buf_frame_get_page_no(rec));
(ulong) page_get_page_no(page_align(rec)));
dict_index_name_print(stderr, trx, index);
fputs(". We try to skip the record.\n",
stderr);
......
......@@ -788,7 +788,7 @@ trx_purge_choose_next_log(void)
} else {
purge_sys->purge_undo_no = trx_undo_rec_get_undo_no(rec);
purge_sys->page_no = buf_frame_get_page_no(rec);
purge_sys->page_no = page_get_page_no(page_align(rec));
purge_sys->offset = page_offset(rec);
}
......@@ -900,7 +900,7 @@ trx_purge_get_next_rec(
page = page_align(rec2);
purge_sys->purge_undo_no = trx_undo_rec_get_undo_no(rec2);
purge_sys->page_no = buf_frame_get_page_no(page);
purge_sys->page_no = page_get_page_no(page);
purge_sys->offset = rec2 - page;
if (undo_page != page) {
......
......@@ -839,7 +839,7 @@ trx_roll_pop_top_rec(
trx->pages_undone++;
}
undo->top_page_no = buf_frame_get_page_no(prev_rec_page);
undo->top_page_no = page_get_page_no(prev_rec_page);
undo->top_offset = prev_rec - prev_rec_page;
undo->top_undo_no = trx_undo_rec_get_undo_no(prev_rec);
}
......
......@@ -87,7 +87,7 @@ trx_rseg_header_create(
buf_page_dbg_add_level(page, SYNC_RSEG_HEADER_NEW);
#endif /* UNIV_SYNC_DEBUG */
page_no = buf_frame_get_page_no(page);
page_no = page_get_page_no(page);
/* Get the rollback segment file page */
rsegf = trx_rsegf_get_new(space, page_no, mtr);
......
......@@ -851,7 +851,7 @@ trx_sysf_create(
/* Create the trx sys file block in a new allocated file segment */
page = fseg_create(TRX_SYS_SPACE, 0, TRX_SYS + TRX_SYS_FSEG_HEADER,
mtr);
ut_a(buf_frame_get_page_no(page) == TRX_SYS_PAGE_NO);
ut_a(page_get_page_no(page) == TRX_SYS_PAGE_NO);
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(page, SYNC_TRX_SYS_HEADER);
......
......@@ -154,7 +154,7 @@ trx_undo_get_prev_rec_from_prev_page(
}
prev_page = trx_undo_page_get_s_latched(
buf_frame_get_space_id(undo_page), prev_page_no, mtr);
page_get_space_id(undo_page), prev_page_no, mtr);
return(trx_undo_page_get_last_rec(prev_page, page_no, offset));
}
......@@ -208,7 +208,7 @@ trx_undo_get_next_rec_from_next_page(
ulint space;
ulint next;
if (page_no == buf_frame_get_page_no(undo_page)) {
if (page_no == page_get_page_no(undo_page)) {
log_hdr = undo_page + offset;
next = mach_read_from_2(log_hdr + TRX_UNDO_NEXT_LOG);
......@@ -219,7 +219,7 @@ trx_undo_get_next_rec_from_next_page(
}
}
space = buf_frame_get_space_id(undo_page);
space = page_get_space_id(undo_page);
next_page_no = flst_get_next_addr(undo_page + TRX_UNDO_PAGE_HDR
+ TRX_UNDO_PAGE_NODE, mtr)
......@@ -415,7 +415,7 @@ trx_undo_seg_create(
return(NULL);
}
space = buf_frame_get_space_id(rseg_hdr);
space = page_get_space_id(page_align(rseg_hdr));
success = fsp_reserve_free_extents(&n_reserved, space, 2, FSP_UNDO,
mtr);
......@@ -458,7 +458,7 @@ trx_undo_seg_create(
page_hdr + TRX_UNDO_PAGE_NODE, mtr);
trx_rsegf_set_nth_undo(rseg_hdr, slot_no,
buf_frame_get_page_no(undo_page), mtr);
page_get_page_no(undo_page), mtr);
*id = slot_no;
return(undo_page);
......@@ -1128,7 +1128,7 @@ trx_undo_truncate_start(
return;
}
page_no = buf_frame_get_page_no(undo_page);
page_no = page_get_page_no(undo_page);
if (page_no == hdr_page_no) {
trx_undo_empty_header_page(space, hdr_page_no, hdr_offset,
......@@ -1524,7 +1524,7 @@ trx_undo_create(
return(NULL);
}
page_no = buf_frame_get_page_no(undo_page);
page_no = page_get_page_no(undo_page);
offset = trx_undo_header_create(undo_page, trx_id, mtr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment