Commit 0d298ea5 authored by marko's avatar marko

page_offset(): New function to replace many ut_align_offset(., UNIV_PAGE_SIZE)

calls.

dict_index_build_node_ptr(): Correct a typo in a comment.
parent fd1bd26b
......@@ -1851,8 +1851,7 @@ btr_set_min_rec_mark_log(
(rec, comp ? MLOG_COMP_REC_MIN_MARK : MLOG_REC_MIN_MARK, mtr);
/* Write rec offset as a 2-byte ulint */
mlog_catenate_ulint(mtr, ut_align_offset(rec, UNIV_PAGE_SIZE),
MLOG_2BYTES);
mlog_catenate_ulint(mtr, page_offset(rec), MLOG_2BYTES);
}
/********************************************************************
......
......@@ -1345,7 +1345,7 @@ btr_cur_update_in_place_log(
log_ptr = row_upd_write_sys_vals_to_log(index, trx, roll_ptr, log_ptr,
mtr);
mach_write_to_2(log_ptr, ut_align_offset(rec, UNIV_PAGE_SIZE));
mach_write_to_2(log_ptr, page_offset(rec));
log_ptr += 2;
row_upd_index_write_log(update, log_ptr, mtr);
......@@ -2049,7 +2049,7 @@ btr_cur_del_mark_set_clust_rec_log(
log_ptr = row_upd_write_sys_vals_to_log(index, trx, roll_ptr, log_ptr,
mtr);
mach_write_to_2(log_ptr, ut_align_offset(rec, UNIV_PAGE_SIZE));
mach_write_to_2(log_ptr, page_offset(rec));
log_ptr += 2;
mlog_close(mtr, log_ptr);
......@@ -2251,7 +2251,7 @@ btr_cur_del_mark_set_sec_rec_log(
mach_write_to_1(log_ptr, val);
log_ptr++;
mach_write_to_2(log_ptr, ut_align_offset(rec, UNIV_PAGE_SIZE));
mach_write_to_2(log_ptr, page_offset(rec));
log_ptr += 2;
mlog_close(mtr, log_ptr);
......
......@@ -89,7 +89,7 @@ btr_pcur_store_position(
rec = page_cur_get_rec(page_cursor);
page = page_align(rec);
offs = ut_align_offset(rec, UNIV_PAGE_SIZE);
offs = page_offset(rec);
ut_ad(mtr_memo_contains(mtr, buf_block_align(page),
MTR_MEMO_PAGE_S_FIX)
......
......@@ -3630,7 +3630,7 @@ dict_index_build_node_ptr(
if (UNIV_UNLIKELY(index->type & DICT_UNIVERSAL)) {
/* In a universal index tree, we take the whole record as
the node pointer if the reord is on the leaf level,
the node pointer if the record is on the leaf level,
on non-leaf levels we remove the last field, which
contains the page number of the child page */
......
......@@ -204,7 +204,7 @@ btr_node_ptr_get_child_page_no(
fprintf(stderr,
"InnoDB: a nonsensical page number 0"
" in a node ptr record at offset %lu\n",
(ulong) ut_align_offset(rec, UNIV_PAGE_SIZE));
(ulong) page_offset(rec));
buf_page_print(buf_frame_align(rec));
}
......
......@@ -141,6 +141,15 @@ page_align(
/* out: start of the page */
void* ptr) /* in: pointer to page frame */
__attribute__((const));
/****************************************************************
Gets the offset within a page. */
UNIV_INLINE
ulint
page_offset(
/*========*/
/* out: offset from the start of the page */
const void* ptr) /* in: pointer to page frame */
__attribute__((const));
/*****************************************************************
Returns the max trx id field value. */
UNIV_INLINE
......
......@@ -26,6 +26,17 @@ page_align(
{
return((page_t*) ut_align_down(ptr, UNIV_PAGE_SIZE));
}
/****************************************************************
Gets the offset within a page. */
UNIV_INLINE
ulint
page_offset(
/*========*/
/* out: offset from the start of the page */
const void* ptr) /* in: pointer to page frame */
{
return(ut_align_offset(ptr, UNIV_PAGE_SIZE));
}
/*****************************************************************
Returns the max trx id field value. */
UNIV_INLINE
......@@ -302,7 +313,7 @@ page_rec_is_user_rec(
/* out: TRUE if a user record */
const rec_t* rec) /* in: record */
{
return(page_rec_is_user_rec_low(ut_align_offset(rec, UNIV_PAGE_SIZE)));
return(page_rec_is_user_rec_low(page_offset(rec)));
}
/****************************************************************
......@@ -314,7 +325,7 @@ page_rec_is_supremum(
/* out: TRUE if the supremum record */
const rec_t* rec) /* in: record */
{
return(page_rec_is_supremum_low(ut_align_offset(rec, UNIV_PAGE_SIZE)));
return(page_rec_is_supremum_low(page_offset(rec)));
}
/****************************************************************
......@@ -326,7 +337,7 @@ page_rec_is_infimum(
/* out: TRUE if the infimum record */
const rec_t* rec) /* in: record */
{
return(page_rec_is_infimum_low(ut_align_offset(rec, UNIV_PAGE_SIZE)));
return(page_rec_is_infimum_low(page_offset(rec)));
}
/*****************************************************************
......@@ -362,7 +373,7 @@ page_cmp_dtuple_rec_with_match(
ut_ad(rec_offs_validate(rec, NULL, offsets));
ut_ad(!rec_offs_comp(offsets) == !page_rec_is_comp(rec));
rec_offset = ut_align_offset(rec, UNIV_PAGE_SIZE);
rec_offset = page_offset(rec);
if (UNIV_UNLIKELY(rec_offset == PAGE_NEW_INFIMUM)
|| UNIV_UNLIKELY(rec_offset == PAGE_OLD_INFIMUM)) {
......@@ -503,7 +514,7 @@ page_dir_slot_set_rec(
{
ut_ad(page_rec_check(rec));
mach_write_to_2(slot, ut_align_offset(rec, UNIV_PAGE_SIZE));
mach_write_to_2(slot, page_offset(rec));
}
/*******************************************************************
......
......@@ -1278,7 +1278,7 @@ page_cur_delete_rec_write_log(
}
/* Write the cursor rec offset as a 2-byte ulint */
mach_write_to_2(log_ptr, ut_align_offset(rec, UNIV_PAGE_SIZE));
mach_write_to_2(log_ptr, page_offset(rec));
mlog_close(mtr, log_ptr + 2);
}
......
......@@ -650,7 +650,7 @@ page_delete_rec_list_write_log(
log_ptr = mlog_open_and_write_index(mtr, rec, index, type, 2);
if (log_ptr) {
/* Write the parameter as a 2-byte ulint */
mach_write_to_2(log_ptr, ut_align_offset(rec, UNIV_PAGE_SIZE));
mach_write_to_2(log_ptr, page_offset(rec));
mlog_close(mtr, log_ptr + 2);
}
}
......
......@@ -3752,7 +3752,7 @@ row_search_for_mysql(
"InnoDB: Index corruption: rec offs %lu"
" next offs %lu, page no %lu,\n"
"InnoDB: ",
(ulong) ut_align_offset(rec, UNIV_PAGE_SIZE),
(ulong) page_offset(rec),
(ulong) next_offs,
(ulong) buf_frame_get_page_no(rec));
dict_index_name_print(stderr, trx, index);
......@@ -3772,7 +3772,7 @@ row_search_for_mysql(
"InnoDB: Index corruption: rec offs %lu"
" next offs %lu, page no %lu,\n"
"InnoDB: ",
(ulong) ut_align_offset(rec, UNIV_PAGE_SIZE),
(ulong) page_offset(rec),
(ulong) next_offs,
(ulong) buf_frame_get_page_no(rec));
dict_index_name_print(stderr, trx, index);
......@@ -3797,7 +3797,7 @@ row_search_for_mysql(
"InnoDB: Index corruption: rec offs %lu"
" next offs %lu, page no %lu,\n"
"InnoDB: ",
(ulong) ut_align_offset(rec, UNIV_PAGE_SIZE),
(ulong) page_offset(rec),
(ulong) next_offs,
(ulong) buf_frame_get_page_no(rec));
dict_index_name_print(stderr, trx, index);
......
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