Skip to content

Commit

Permalink
Add the parameter bool leaf to rec_get_offsets()
Browse files Browse the repository at this point in the history
This should affect debug builds only. Debug builds will check that
the status bits of ROW_FORMAT!=REDUNDANT records match the is_leaf
parameter.

The only observable change to non-debug should be the addition of
the is_leaf parameter to the function rec_copy_prefix_to_dtuple(),
and the removal of some calls to update the adaptive hash index
(it is only built for the leaf pages).

This change should have been made in MySQL 5.0.3, instead of
introducing the status flags in the ROW_FORMAT=COMPACT record header.
  • Loading branch information
dr-m committed Sep 20, 2017
1 parent 2d9f5f6 commit 48192f9
Show file tree
Hide file tree
Showing 37 changed files with 456 additions and 364 deletions.
55 changes: 32 additions & 23 deletions storage/innobase/btr/btr0btr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -720,8 +720,9 @@ btr_page_free_low(
ulint* offsets = NULL;
rec_t* rec = page_rec_get_next(page_get_infimum_rec(page));
while (!page_rec_is_supremum(rec)) {
offsets = rec_get_offsets(rec, index,
offsets, ULINT_UNDEFINED,
offsets = rec_get_offsets(rec, index, offsets,
page_is_leaf(page),
ULINT_UNDEFINED,
&heap);
ulint size = rec_offs_data_size(offsets);
memset(rec, 0, size);
Expand Down Expand Up @@ -937,7 +938,7 @@ btr_page_get_father_node_ptr_func(

node_ptr = btr_cur_get_rec(cursor);

offsets = rec_get_offsets(node_ptr, index, offsets,
offsets = rec_get_offsets(node_ptr, index, offsets, false,
ULINT_UNDEFINED, &heap);

if (btr_node_ptr_get_child_page_no(node_ptr, offsets) != page_no) {
Expand All @@ -953,10 +954,11 @@ btr_page_get_father_node_ptr_func(

print_rec = page_rec_get_next(
page_get_infimum_rec(page_align(user_rec)));
offsets = rec_get_offsets(print_rec, index,
offsets, ULINT_UNDEFINED, &heap);
offsets = rec_get_offsets(print_rec, index, offsets,
page_rec_is_leaf(user_rec),
ULINT_UNDEFINED, &heap);
page_rec_print(print_rec, offsets);
offsets = rec_get_offsets(node_ptr, index, offsets,
offsets = rec_get_offsets(node_ptr, index, offsets, false,
ULINT_UNDEFINED, &heap);
page_rec_print(node_ptr, offsets);

Expand Down Expand Up @@ -2275,9 +2277,9 @@ btr_page_get_split_rec(
/* Include tuple */
incl_data += insert_size;
} else {
offsets = rec_get_offsets(rec, cursor->index,
offsets, ULINT_UNDEFINED,
&heap);
offsets = rec_get_offsets(rec, cursor->index, offsets,
page_is_leaf(page),
ULINT_UNDEFINED, &heap);
incl_data += rec_offs_size(offsets);
}

Expand Down Expand Up @@ -2385,6 +2387,7 @@ btr_page_insert_fits(
space after rec is removed from page. */

*offsets = rec_get_offsets(rec, cursor->index, *offsets,
page_is_leaf(page),
ULINT_UNDEFINED, heap);

total_data -= rec_offs_size(*offsets);
Expand Down Expand Up @@ -2673,7 +2676,7 @@ btr_page_tuple_smaller(
first_rec = page_cur_get_rec(&pcur);

*offsets = rec_get_offsets(
first_rec, cursor->index, *offsets,
first_rec, cursor->index, *offsets, page_is_leaf(block->frame),
n_uniq, heap);

return(cmp_dtuple_rec(tuple, first_rec, *offsets) < 0);
Expand Down Expand Up @@ -2980,7 +2983,7 @@ btr_page_split_and_insert(
first_rec = move_limit = split_rec;

*offsets = rec_get_offsets(split_rec, cursor->index, *offsets,
n_uniq, heap);
page_is_leaf(page), n_uniq, heap);

if (tuple != NULL) {
insert_left = cmp_dtuple_rec(
Expand Down Expand Up @@ -3808,8 +3811,9 @@ btr_compress(
cursor2.tree_height = cursor->tree_height;

offsets2 = rec_get_offsets(
btr_cur_get_rec(&cursor2), index,
NULL, ULINT_UNDEFINED, &heap);
btr_cur_get_rec(&cursor2), index, NULL,
page_is_leaf(cursor2.page_cur.block->frame),
ULINT_UNDEFINED, &heap);

/* Check if parent entry needs to be updated */
mbr_changed = rtr_merge_mbr_changed(
Expand Down Expand Up @@ -3989,8 +3993,9 @@ btr_compress(
ulint rec_info;

offsets2 = rec_get_offsets(
btr_cur_get_rec(&cursor2),
index, NULL, ULINT_UNDEFINED, &heap);
btr_cur_get_rec(&cursor2), index, NULL,
page_is_leaf(cursor2.page_cur.block->frame),
ULINT_UNDEFINED, &heap);

ut_ad(btr_node_ptr_get_child_page_no(
btr_cur_get_rec(&cursor2), offsets2)
Expand Down Expand Up @@ -4468,8 +4473,9 @@ btr_print_recursive(

node_ptr = page_cur_get_rec(&cursor);

*offsets = rec_get_offsets(node_ptr, index, *offsets,
ULINT_UNDEFINED, heap);
*offsets = rec_get_offsets(
node_ptr, index, *offsets, false,
ULINT_UNDEFINED, heap);
btr_print_recursive(index,
btr_node_ptr_get_child(node_ptr,
index,
Expand Down Expand Up @@ -4662,7 +4668,8 @@ btr_index_rec_validate(
return(FALSE);
}

offsets = rec_get_offsets(rec, index, offsets, ULINT_UNDEFINED, &heap);
offsets = rec_get_offsets(rec, index, offsets, page_is_leaf(page),
ULINT_UNDEFINED, &heap);

for (i = 0; i < n; i++) {
dict_field_t* field = dict_index_get_nth_field(index, i);
Expand Down Expand Up @@ -4916,7 +4923,7 @@ btr_validate_level(
page_cur_move_to_next(&cursor);

node_ptr = page_cur_get_rec(&cursor);
offsets = rec_get_offsets(node_ptr, index, offsets,
offsets = rec_get_offsets(node_ptr, index, offsets, false,
ULINT_UNDEFINED, &heap);

savepoint2 = mtr_set_savepoint(&mtr);
Expand Down Expand Up @@ -5042,10 +5049,12 @@ btr_validate_level(
rec = page_rec_get_prev(page_get_supremum_rec(page));
right_rec = page_rec_get_next(page_get_infimum_rec(
right_page));
offsets = rec_get_offsets(rec, index,
offsets, ULINT_UNDEFINED, &heap);
offsets2 = rec_get_offsets(right_rec, index,
offsets2, ULINT_UNDEFINED, &heap);
offsets = rec_get_offsets(rec, index, offsets,
page_is_leaf(page),
ULINT_UNDEFINED, &heap);
offsets2 = rec_get_offsets(right_rec, index, offsets2,
page_is_leaf(right_page),
ULINT_UNDEFINED, &heap);

/* For spatial index, we cannot guarantee the key ordering
across pages, so skip the record compare verification for
Expand Down
28 changes: 15 additions & 13 deletions storage/innobase/btr/btr0bulk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ PageBulk::insert(
if (!page_rec_is_infimum(m_cur_rec)) {
rec_t* old_rec = m_cur_rec;
ulint* old_offsets = rec_get_offsets(
old_rec, m_index, NULL, ULINT_UNDEFINED, &m_heap);
old_rec, m_index, NULL, page_rec_is_leaf(old_rec),
ULINT_UNDEFINED, &m_heap);

ut_ad(cmp_rec_rec(rec, old_rec, offsets, old_offsets, m_index)
> 0);
Expand Down Expand Up @@ -377,9 +378,9 @@ PageBulk::getSplitRec()
rec = page_rec_get_next(rec);
ut_ad(page_rec_is_user_rec(rec));

offsets = rec_get_offsets(rec, m_index,
offsets, ULINT_UNDEFINED,
&(m_heap));
offsets = rec_get_offsets(rec, m_index, offsets,
page_is_leaf(m_page),
ULINT_UNDEFINED, &m_heap);
total_recs_size += rec_offs_size(offsets);
n_recs++;
} while (total_recs_size + page_dir_calc_reserved_space(n_recs)
Expand Down Expand Up @@ -409,7 +410,8 @@ PageBulk::copyIn(

do {
offsets = rec_get_offsets(rec, m_index, offsets,
ULINT_UNDEFINED, &(m_heap));
page_rec_is_leaf(split_rec),
ULINT_UNDEFINED, &m_heap);

insert(rec, offsets);

Expand Down Expand Up @@ -449,18 +451,18 @@ PageBulk::copyOut(
/* Set last record's next in page */
ulint* offsets = NULL;
rec = page_rec_get_prev(split_rec);
offsets = rec_get_offsets(rec, m_index,
offsets, ULINT_UNDEFINED,
&(m_heap));
offsets = rec_get_offsets(rec, m_index, offsets,
page_rec_is_leaf(split_rec),
ULINT_UNDEFINED, &m_heap);
page_rec_set_next(rec, page_get_supremum_rec(m_page));

/* Set related members */
m_cur_rec = rec;
m_heap_top = rec_get_end(rec, offsets);

offsets = rec_get_offsets(last_rec, m_index,
offsets, ULINT_UNDEFINED,
&(m_heap));
offsets = rec_get_offsets(last_rec, m_index, offsets,
page_rec_is_leaf(split_rec),
ULINT_UNDEFINED, &m_heap);

m_free_space += rec_get_end(last_rec, offsets)
- m_heap_top
Expand Down Expand Up @@ -876,8 +878,8 @@ BtrBulk::insert(
/* Convert tuple to rec. */
rec = rec_convert_dtuple_to_rec(static_cast<byte*>(mem_heap_alloc(
page_bulk->m_heap, rec_size)), m_index, tuple, n_ext);
offsets = rec_get_offsets(rec, m_index, offsets, ULINT_UNDEFINED,
&(page_bulk->m_heap));
offsets = rec_get_offsets(rec, m_index, offsets, !level,
ULINT_UNDEFINED, &page_bulk->m_heap);

page_bulk->insert(rec, offsets);

Expand Down
Loading

0 comments on commit 48192f9

Please sign in to comment.