summaryrefslogtreecommitdiff
path: root/storage/innobase/btr/btr0pcur.c
diff options
context:
space:
mode:
Diffstat (limited to 'storage/innobase/btr/btr0pcur.c')
-rw-r--r--storage/innobase/btr/btr0pcur.c81
1 files changed, 39 insertions, 42 deletions
diff --git a/storage/innobase/btr/btr0pcur.c b/storage/innobase/btr/btr0pcur.c
index a8d8b2f072a..65b3c90c809 100644
--- a/storage/innobase/btr/btr0pcur.c
+++ b/storage/innobase/btr/btr0pcur.c
@@ -76,20 +76,20 @@ btr_pcur_store_position(
{
page_cur_t* page_cursor;
rec_t* rec;
- dict_tree_t* tree;
+ dict_index_t* index;
page_t* page;
ulint offs;
ut_a(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
ut_ad(cursor->latch_mode != BTR_NO_LATCHES);
- tree = btr_cur_get_tree(btr_pcur_get_btr_cur(cursor));
+ index = btr_cur_get_index(btr_pcur_get_btr_cur(cursor));
page_cursor = btr_pcur_get_page_cur(cursor);
rec = page_cur_get_rec(page_cursor);
- page = ut_align_down(rec, UNIV_PAGE_SIZE);
- offs = ut_align_offset(rec, UNIV_PAGE_SIZE);
+ page = page_align(rec);
+ offs = page_offset(rec);
ut_ad(mtr_memo_contains(mtr, buf_block_align(page),
MTR_MEMO_PAGE_S_FIX)
@@ -133,13 +133,13 @@ btr_pcur_store_position(
}
cursor->old_stored = BTR_PCUR_OLD_STORED;
- cursor->old_rec = dict_tree_copy_rec_order_prefix
- (tree, rec, &cursor->old_n_fields,
- &cursor->old_rec_buf, &cursor->buf_size);
+ cursor->old_rec = dict_index_copy_rec_order_prefix(
+ index, rec, &cursor->old_n_fields,
+ &cursor->old_rec_buf, &cursor->buf_size);
cursor->block_when_stored = buf_block_align(page);
- cursor->modify_clock = buf_block_get_modify_clock
- (cursor->block_when_stored);
+ cursor->modify_clock = buf_block_get_modify_clock(
+ cursor->block_when_stored);
}
/******************************************************************
@@ -197,13 +197,15 @@ btr_pcur_restore_position(
btr_pcur_t* cursor, /* in: detached persistent cursor */
mtr_t* mtr) /* in: mtr */
{
- dict_tree_t* tree;
+ dict_index_t* index;
page_t* page;
dtuple_t* tuple;
ulint mode;
ulint old_mode;
mem_heap_t* heap;
+ index = btr_cur_get_index(btr_pcur_get_btr_cur(cursor));
+
if (UNIV_UNLIKELY(cursor->old_stored != BTR_PCUR_OLD_STORED)
|| UNIV_UNLIKELY(cursor->pos_state != BTR_PCUR_WAS_POSITIONED
&& cursor->pos_state != BTR_PCUR_IS_POSITIONED)) {
@@ -215,17 +217,16 @@ btr_pcur_restore_position(
ut_error;
}
- if (UNIV_UNLIKELY
- (cursor->rel_pos == BTR_PCUR_AFTER_LAST_IN_TREE
- || cursor->rel_pos == BTR_PCUR_BEFORE_FIRST_IN_TREE)) {
+ if (UNIV_UNLIKELY(
+ cursor->rel_pos == BTR_PCUR_AFTER_LAST_IN_TREE
+ || cursor->rel_pos == BTR_PCUR_BEFORE_FIRST_IN_TREE)) {
/* In these cases we do not try an optimistic restoration,
but always do a search */
- btr_cur_open_at_index_side
- (cursor->rel_pos == BTR_PCUR_BEFORE_FIRST_IN_TREE,
- btr_pcur_get_btr_cur(cursor)->index, latch_mode,
- btr_pcur_get_btr_cur(cursor), mtr);
+ btr_cur_open_at_index_side(
+ cursor->rel_pos == BTR_PCUR_BEFORE_FIRST_IN_TREE,
+ index, latch_mode, btr_pcur_get_btr_cur(cursor), mtr);
cursor->block_when_stored
= buf_block_align(btr_pcur_get_page(cursor));
@@ -242,10 +243,10 @@ btr_pcur_restore_position(
|| UNIV_LIKELY(latch_mode == BTR_MODIFY_LEAF)) {
/* Try optimistic restoration */
- if (UNIV_LIKELY
- (buf_page_optimistic_get(latch_mode,
- cursor->block_when_stored, page,
- cursor->modify_clock, mtr))) {
+ if (UNIV_LIKELY(buf_page_optimistic_get(
+ latch_mode,
+ cursor->block_when_stored, page,
+ cursor->modify_clock, mtr))) {
cursor->pos_state = BTR_PCUR_IS_POSITIONED;
#ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(page, SYNC_TREE_NODE);
@@ -255,20 +256,18 @@ btr_pcur_restore_position(
rec_t* rec;
ulint* offsets1;
ulint* offsets2;
- dict_index_t* index;
#endif /* UNIV_DEBUG */
cursor->latch_mode = latch_mode;
#ifdef UNIV_DEBUG
rec = btr_pcur_get_rec(cursor);
- index = btr_pcur_get_btr_cur(cursor)->index;
heap = mem_heap_create(256);
- offsets1 = rec_get_offsets
- (cursor->old_rec, index, NULL,
- cursor->old_n_fields, &heap);
- offsets2 = rec_get_offsets
- (rec, index, NULL,
- cursor->old_n_fields, &heap);
+ offsets1 = rec_get_offsets(
+ cursor->old_rec, index, NULL,
+ cursor->old_n_fields, &heap);
+ offsets2 = rec_get_offsets(
+ rec, index, NULL,
+ cursor->old_n_fields, &heap);
ut_ad(!cmp_rec_rec(cursor->old_rec,
rec, offsets1, offsets2,
@@ -286,9 +285,8 @@ btr_pcur_restore_position(
heap = mem_heap_create(256);
- tree = btr_cur_get_tree(btr_pcur_get_btr_cur(cursor));
- tuple = dict_tree_build_data_tuple(tree, cursor->old_rec,
- cursor->old_n_fields, heap);
+ tuple = dict_index_build_data_tuple(index, cursor->old_rec,
+ cursor->old_n_fields, heap);
/* Save the old search mode of the cursor */
old_mode = cursor->search_mode;
@@ -302,8 +300,8 @@ btr_pcur_restore_position(
mode = PAGE_CUR_L;
}
- btr_pcur_open_with_no_init(btr_pcur_get_btr_cur(cursor)->index, tuple,
- mode, latch_mode, cursor, 0, mtr);
+ btr_pcur_open_with_no_init(index, tuple, mode, latch_mode,
+ cursor, 0, mtr);
/* Restore the old search mode */
cursor->search_mode = old_mode;
@@ -311,19 +309,18 @@ btr_pcur_restore_position(
if (cursor->rel_pos == BTR_PCUR_ON
&& btr_pcur_is_on_user_rec(cursor, mtr)
&& 0 == cmp_dtuple_rec(tuple, btr_pcur_get_rec(cursor),
- rec_get_offsets
- (btr_pcur_get_rec(cursor),
- btr_pcur_get_btr_cur(cursor)->index,
- NULL, ULINT_UNDEFINED, &heap))) {
+ rec_get_offsets(
+ btr_pcur_get_rec(cursor), index,
+ NULL, ULINT_UNDEFINED, &heap))) {
/* We have to store the NEW value for the modify clock, since
the cursor can now be on a different page! But we can retain
the value of old_rec */
- cursor->block_when_stored = buf_block_align
- (btr_pcur_get_page(cursor));
- cursor->modify_clock = buf_block_get_modify_clock
- (cursor->block_when_stored);
+ cursor->block_when_stored = buf_block_align(
+ btr_pcur_get_page(cursor));
+ cursor->modify_clock = buf_block_get_modify_clock(
+ cursor->block_when_stored);
cursor->old_stored = BTR_PCUR_OLD_STORED;
mem_heap_free(heap);