Commit d583b180 authored by marko's avatar marko

branches/zip: Eliminate many buf_block_align() calls.

Replace page_t* or page_zip_des_t* parameters in some functions with
buf_block_t*.

buf_frame_get_page_zip(): Disable unless #ifdef UNIV_DEBUG || UNIV_ZIP_DEBUG.

btr_cur_t: Add buf_block_t* page_block.

btr_pcur_get_block(), btr_cur_get_block(), btr_cur_get_page_zip():
New functions.

btr_cur_position(): Add the parameter block.
parent 8f077940
This diff is collapsed.
This diff is collapsed.
...@@ -75,6 +75,7 @@ btr_pcur_store_position( ...@@ -75,6 +75,7 @@ btr_pcur_store_position(
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
{ {
page_cur_t* page_cursor; page_cur_t* page_cursor;
buf_block_t* block;
rec_t* rec; rec_t* rec;
dict_index_t* index; dict_index_t* index;
page_t* page; page_t* page;
...@@ -83,6 +84,7 @@ btr_pcur_store_position( ...@@ -83,6 +84,7 @@ btr_pcur_store_position(
ut_a(cursor->pos_state == BTR_PCUR_IS_POSITIONED); ut_a(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
ut_ad(cursor->latch_mode != BTR_NO_LATCHES); ut_ad(cursor->latch_mode != BTR_NO_LATCHES);
block = btr_pcur_get_block(cursor);
index = btr_cur_get_index(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); page_cursor = btr_pcur_get_page_cur(cursor);
...@@ -91,8 +93,8 @@ btr_pcur_store_position( ...@@ -91,8 +93,8 @@ btr_pcur_store_position(
page = page_align(rec); page = page_align(rec);
offs = page_offset(rec); offs = page_offset(rec);
ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_S_FIX) ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_S_FIX)
|| mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX)); || mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
ut_a(cursor->latch_mode != BTR_NO_LATCHES); ut_a(cursor->latch_mode != BTR_NO_LATCHES);
if (UNIV_UNLIKELY(page_get_n_recs(page) == 0)) { if (UNIV_UNLIKELY(page_get_n_recs(page) == 0)) {
...@@ -135,9 +137,8 @@ btr_pcur_store_position( ...@@ -135,9 +137,8 @@ btr_pcur_store_position(
index, rec, &cursor->old_n_fields, index, rec, &cursor->old_n_fields,
&cursor->old_rec_buf, &cursor->buf_size); &cursor->old_rec_buf, &cursor->buf_size);
cursor->block_when_stored = buf_block_align(page); cursor->block_when_stored = block;
cursor->modify_clock = buf_block_get_modify_clock( cursor->modify_clock = buf_block_get_modify_clock(block);
cursor->block_when_stored);
} }
/****************************************************************** /******************************************************************
...@@ -215,9 +216,9 @@ btr_pcur_restore_position( ...@@ -215,9 +216,9 @@ btr_pcur_restore_position(
ut_error; ut_error;
} }
if (UNIV_UNLIKELY( if (UNIV_UNLIKELY
cursor->rel_pos == BTR_PCUR_AFTER_LAST_IN_TREE (cursor->rel_pos == BTR_PCUR_AFTER_LAST_IN_TREE
|| cursor->rel_pos == BTR_PCUR_BEFORE_FIRST_IN_TREE)) { || cursor->rel_pos == BTR_PCUR_BEFORE_FIRST_IN_TREE)) {
/* In these cases we do not try an optimistic restoration, /* In these cases we do not try an optimistic restoration,
but always do a search */ but always do a search */
...@@ -226,8 +227,7 @@ btr_pcur_restore_position( ...@@ -226,8 +227,7 @@ btr_pcur_restore_position(
cursor->rel_pos == BTR_PCUR_BEFORE_FIRST_IN_TREE, cursor->rel_pos == BTR_PCUR_BEFORE_FIRST_IN_TREE,
index, latch_mode, btr_pcur_get_btr_cur(cursor), mtr); index, latch_mode, btr_pcur_get_btr_cur(cursor), mtr);
cursor->block_when_stored cursor->block_when_stored = btr_pcur_get_block(cursor);
= buf_block_align(btr_pcur_get_page(cursor));
return(FALSE); return(FALSE);
} }
...@@ -235,7 +235,7 @@ btr_pcur_restore_position( ...@@ -235,7 +235,7 @@ btr_pcur_restore_position(
ut_a(cursor->old_rec); ut_a(cursor->old_rec);
ut_a(cursor->old_n_fields); ut_a(cursor->old_n_fields);
page = btr_cur_get_page(btr_pcur_get_btr_cur(cursor)); page = btr_pcur_get_page(cursor);
if (UNIV_LIKELY(latch_mode == BTR_SEARCH_LEAF) if (UNIV_LIKELY(latch_mode == BTR_SEARCH_LEAF)
|| UNIV_LIKELY(latch_mode == BTR_MODIFY_LEAF)) { || UNIV_LIKELY(latch_mode == BTR_MODIFY_LEAF)) {
...@@ -247,7 +247,7 @@ btr_pcur_restore_position( ...@@ -247,7 +247,7 @@ btr_pcur_restore_position(
cursor->modify_clock, mtr))) { cursor->modify_clock, mtr))) {
cursor->pos_state = BTR_PCUR_IS_POSITIONED; cursor->pos_state = BTR_PCUR_IS_POSITIONED;
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
buf_block_dbg_add_level(buf_block_align(page), buf_block_dbg_add_level(btr_pcur_get_block(cursor),
SYNC_TREE_NODE); SYNC_TREE_NODE);
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
if (cursor->rel_pos == BTR_PCUR_ON) { if (cursor->rel_pos == BTR_PCUR_ON) {
...@@ -316,8 +316,7 @@ btr_pcur_restore_position( ...@@ -316,8 +316,7 @@ btr_pcur_restore_position(
the cursor can now be on a different page! But we can retain the cursor can now be on a different page! But we can retain
the value of old_rec */ the value of old_rec */
cursor->block_when_stored = buf_block_align( cursor->block_when_stored = btr_pcur_get_block(cursor);
btr_pcur_get_page(cursor));
cursor->modify_clock = buf_block_get_modify_clock( cursor->modify_clock = buf_block_get_modify_clock(
cursor->block_when_stored); cursor->block_when_stored);
cursor->old_stored = BTR_PCUR_OLD_STORED; cursor->old_stored = BTR_PCUR_OLD_STORED;
...@@ -356,7 +355,7 @@ btr_pcur_release_leaf( ...@@ -356,7 +355,7 @@ btr_pcur_release_leaf(
ut_a(cursor->pos_state == BTR_PCUR_IS_POSITIONED); ut_a(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
ut_ad(cursor->latch_mode != BTR_NO_LATCHES); ut_ad(cursor->latch_mode != BTR_NO_LATCHES);
block = buf_block_align(btr_cur_get_rec(btr_pcur_get_btr_cur(cursor))); block = btr_pcur_get_block(cursor);
btr_leaf_page_release(block, cursor->latch_mode, mtr); btr_leaf_page_release(block, cursor->latch_mode, mtr);
...@@ -391,9 +390,8 @@ btr_pcur_move_to_next_page( ...@@ -391,9 +390,8 @@ btr_pcur_move_to_next_page(
cursor->old_stored = BTR_PCUR_OLD_NOT_STORED; cursor->old_stored = BTR_PCUR_OLD_NOT_STORED;
page = btr_pcur_get_page(cursor); page = btr_pcur_get_page(cursor);
next_page_no = btr_page_get_next(page, mtr); next_page_no = btr_page_get_next(page, mtr);
space = page_get_space_id(page); space = buf_block_get_space(btr_pcur_get_block(cursor));
ut_ad(next_page_no != FIL_NULL); ut_ad(next_page_no != FIL_NULL);
...@@ -402,12 +400,15 @@ btr_pcur_move_to_next_page( ...@@ -402,12 +400,15 @@ btr_pcur_move_to_next_page(
next_page = buf_block_get_frame(next_block); next_page = buf_block_get_frame(next_block);
#ifdef UNIV_BTR_DEBUG #ifdef UNIV_BTR_DEBUG
ut_a(page_is_comp(next_page) == page_is_comp(page)); ut_a(page_is_comp(next_page) == page_is_comp(page));
ut_a(btr_page_get_prev(next_page, mtr) == page_get_page_no(page)); ut_a(btr_page_get_prev(next_page, mtr)
== buf_block_get_page_no(btr_pcur_get_block(cursor)));
#endif /* UNIV_BTR_DEBUG */ #endif /* UNIV_BTR_DEBUG */
next_block->check_index_page_at_flush = TRUE; next_block->check_index_page_at_flush = TRUE;
btr_leaf_page_release(buf_block_align(page), cursor->latch_mode, mtr); btr_leaf_page_release(btr_pcur_get_block(cursor),
cursor->latch_mode, mtr);
btr_pcur_get_btr_cur(cursor)->page_block = next_block;
page_cur_set_before_first(next_page, btr_pcur_get_page_cur(cursor)); page_cur_set_before_first(next_page, btr_pcur_get_page_cur(cursor));
page_check_dir(next_page); page_check_dir(next_page);
...@@ -467,18 +468,21 @@ btr_pcur_move_backward_from_page( ...@@ -467,18 +468,21 @@ btr_pcur_move_backward_from_page(
page = btr_pcur_get_page(cursor); page = btr_pcur_get_page(cursor);
prev_page_no = btr_page_get_prev(page, mtr); prev_page_no = btr_page_get_prev(page, mtr);
space = page_get_space_id(page); space = buf_block_get_space(btr_pcur_get_block(cursor));
if (btr_pcur_is_before_first_on_page(cursor, mtr) if (prev_page_no == FIL_NULL) {
&& (prev_page_no != FIL_NULL)) { } else if (btr_pcur_is_before_first_on_page(cursor, mtr)) {
prev_page = btr_pcur_get_btr_cur(cursor)->left_page; prev_page = btr_pcur_get_btr_cur(cursor)->left_page;
btr_leaf_page_release(buf_block_align(page), latch_mode, mtr); btr_leaf_page_release(btr_pcur_get_block(cursor),
latch_mode, mtr);
btr_pcur_get_btr_cur(cursor)->page_block
= buf_block_align(prev_page);
page_cur_set_after_last(prev_page, page_cur_set_after_last(prev_page,
btr_pcur_get_page_cur(cursor)); btr_pcur_get_page_cur(cursor));
} else if (prev_page_no != FIL_NULL) { } else {
/* The repositioned cursor did not end on an infimum record on /* The repositioned cursor did not end on an infimum record on
a page. Cursor repositioning acquired a latch also on the a page. Cursor repositioning acquired a latch also on the
......
...@@ -464,7 +464,7 @@ btr_search_info_update_slow( ...@@ -464,7 +464,7 @@ btr_search_info_update_slow(
ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX)); ut_ad(!rw_lock_own(&btr_search_latch, RW_LOCK_EX));
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
block = buf_block_align(btr_cur_get_rec(cursor)); block = btr_cur_get_block(cursor);
/* NOTE that the following two function calls do NOT protect /* NOTE that the following two function calls do NOT protect
info or block->n_fields etc. with any semaphore, to save CPU time! info or block->n_fields etc. with any semaphore, to save CPU time!
...@@ -789,7 +789,7 @@ btr_search_guess_on_hash( ...@@ -789,7 +789,7 @@ btr_search_guess_on_hash(
ut_ad(block->state == BUF_BLOCK_FILE_PAGE); ut_ad(block->state == BUF_BLOCK_FILE_PAGE);
ut_ad(page_rec_is_user_rec(rec)); ut_ad(page_rec_is_user_rec(rec));
btr_cur_position(index, rec, cursor); btr_cur_position(index, rec, block, cursor);
/* Check the validity of the guess within the page */ /* Check the validity of the guess within the page */
......
...@@ -2875,14 +2875,14 @@ void ...@@ -2875,14 +2875,14 @@ void
ibuf_insert_to_index_page( ibuf_insert_to_index_page(
/*======================*/ /*======================*/
dtuple_t* entry, /* in: buffered entry to insert */ dtuple_t* entry, /* in: buffered entry to insert */
page_t* page, /* in/out: index page where the buffered entry buf_block_t* block, /* in/out: index page where the buffered entry
should be placed */ should be placed */
page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
{ {
page_cur_t page_cur; page_cur_t page_cur;
ulint low_match; ulint low_match;
page_t* page = buf_block_get_frame(block);
rec_t* rec; rec_t* rec;
page_t* bitmap_page; page_t* bitmap_page;
ulint old_bits; ulint old_bits;
...@@ -2931,21 +2931,23 @@ dump: ...@@ -2931,21 +2931,23 @@ dump:
btr_cur_del_unmark_for_ibuf(rec, mtr); btr_cur_del_unmark_for_ibuf(rec, mtr);
} else { } else {
rec = page_cur_tuple_insert(&page_cur, page_zip, rec = page_cur_tuple_insert(&page_cur,
buf_block_get_page_zip(block),
entry, index, NULL, 0, mtr); entry, index, NULL, 0, mtr);
if (UNIV_UNLIKELY(rec == NULL)) { if (UNIV_UNLIKELY(rec == NULL)) {
/* If the record did not fit, reorganize */ /* If the record did not fit, reorganize */
btr_page_reorganize(page, index, mtr); btr_page_reorganize(block, index, mtr);
page_cur_search(page, index, entry, page_cur_search(page, index, entry,
PAGE_CUR_LE, &page_cur); PAGE_CUR_LE, &page_cur);
/* This time the record must fit */ /* This time the record must fit */
if (UNIV_UNLIKELY if (UNIV_UNLIKELY
(!page_cur_tuple_insert(&page_cur, page_zip, entry, (!page_cur_tuple_insert(
index, NULL, 0, mtr))) { &page_cur, buf_block_get_page_zip(block),
entry, index, NULL, 0, mtr))) {
ulint space; ulint space;
ulint page_no; ulint page_no;
...@@ -3345,7 +3347,7 @@ loop: ...@@ -3345,7 +3347,7 @@ loop:
ut_a(volume <= 4 * UNIV_PAGE_SIZE ut_a(volume <= 4 * UNIV_PAGE_SIZE
/ IBUF_PAGE_SIZE_PER_FREE_SPACE); / IBUF_PAGE_SIZE_PER_FREE_SPACE);
#endif #endif
ibuf_insert_to_index_page(entry, page, page_zip, ibuf_insert_to_index_page(entry, block,
dummy_index, &mtr); dummy_index, &mtr);
ibuf_dummy_index_free(dummy_index); ibuf_dummy_index_free(dummy_index);
} }
......
...@@ -156,7 +156,7 @@ ulint ...@@ -156,7 +156,7 @@ ulint
btr_node_ptr_get_child_page_no( btr_node_ptr_get_child_page_no(
/*===========================*/ /*===========================*/
/* out: child node address */ /* out: child node address */
rec_t* rec, /* in: node pointer record */ const rec_t* rec, /* in: node pointer record */
const ulint* offsets);/* in: array returned by rec_get_offsets() */ const ulint* offsets);/* in: array returned by rec_get_offsets() */
/**************************************************************** /****************************************************************
Creates the root node for a new index tree. */ Creates the root node for a new index tree. */
...@@ -216,7 +216,7 @@ ibool ...@@ -216,7 +216,7 @@ ibool
btr_page_reorganize( btr_page_reorganize(
/*================*/ /*================*/
/* out: TRUE on success, FALSE on failure */ /* out: TRUE on success, FALSE on failure */
page_t* page, /* in: page to be reorganized */ buf_block_t* block, /* in: page to be reorganized */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
mtr_t* mtr); /* in: mtr */ mtr_t* mtr); /* in: mtr */
/***************************************************************** /*****************************************************************
...@@ -290,7 +290,7 @@ void ...@@ -290,7 +290,7 @@ void
btr_node_ptr_delete( btr_node_ptr_delete(
/*================*/ /*================*/
dict_index_t* index, /* in: index tree */ dict_index_t* index, /* in: index tree */
page_t* page, /* in: page whose node pointer is deleted */ buf_block_t* block, /* in: page whose node pointer is deleted */
mtr_t* mtr); /* in: mtr */ mtr_t* mtr); /* in: mtr */
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
/**************************************************************** /****************************************************************
...@@ -357,8 +357,7 @@ btr_parse_page_reorganize( ...@@ -357,8 +357,7 @@ btr_parse_page_reorganize(
byte* ptr, /* in: buffer */ byte* ptr, /* in: buffer */
byte* end_ptr,/* in: buffer end */ byte* end_ptr,/* in: buffer end */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
page_t* page, /* in/out: page to be reorganized, or NULL */ buf_block_t* block, /* in: page to be reorganized, or NULL */
page_zip_des_t* page_zip,/* in/out: compressed page, or NULL */
mtr_t* mtr); /* in: mtr or NULL */ mtr_t* mtr); /* in: mtr or NULL */
/****************************************************************** /******************************************************************
Gets the number of pages in a B-tree. */ Gets the number of pages in a B-tree. */
......
...@@ -229,17 +229,17 @@ ulint ...@@ -229,17 +229,17 @@ ulint
btr_node_ptr_get_child_page_no( btr_node_ptr_get_child_page_no(
/*===========================*/ /*===========================*/
/* out: child node address */ /* out: child node address */
rec_t* rec, /* in: node pointer record */ const rec_t* rec, /* in: node pointer record */
const ulint* offsets)/* in: array returned by rec_get_offsets() */ const ulint* offsets)/* in: array returned by rec_get_offsets() */
{ {
byte* field; const byte* field;
ulint len; ulint len;
ulint page_no; ulint page_no;
ut_ad(!rec_offs_comp(offsets) || rec_get_node_ptr_flag(rec)); ut_ad(!rec_offs_comp(offsets) || rec_get_node_ptr_flag(rec));
/* The child address is in the last field */ /* The child address is in the last field */
field = rec_get_nth_field(rec, offsets, field = rec_get_nth_field((rec_t*) rec, offsets,
rec_offs_n_fields(offsets) - 1, &len); rec_offs_n_fields(offsets) - 1, &len);
ut_ad(len == 4); ut_ad(len == 4);
...@@ -251,7 +251,7 @@ btr_node_ptr_get_child_page_no( ...@@ -251,7 +251,7 @@ btr_node_ptr_get_child_page_no(
"InnoDB: a nonsensical page number 0" "InnoDB: a nonsensical page number 0"
" in a node ptr record at offset %lu\n", " in a node ptr record at offset %lu\n",
(ulong) page_offset(rec)); (ulong) page_offset(rec));
buf_page_print(page_align(rec), 0); buf_page_print(page_align((rec_t*) rec), 0);
} }
return(page_no); return(page_no);
......
...@@ -36,6 +36,14 @@ btr_cur_get_page_cur( ...@@ -36,6 +36,14 @@ btr_cur_get_page_cur(
/* out: pointer to page cursor component */ /* out: pointer to page cursor component */
btr_cur_t* cursor);/* in: tree cursor */ btr_cur_t* cursor);/* in: tree cursor */
/************************************************************* /*************************************************************
Returns the buffer block on which the tree cursor is positioned. */
UNIV_INLINE
buf_block_t*
btr_cur_get_block(
/*==============*/
/* out: pointer to buffer block */
btr_cur_t* cursor);/* in: tree cursor */
/*************************************************************
Returns the record pointer of a tree cursor. */ Returns the record pointer of a tree cursor. */
UNIV_INLINE UNIV_INLINE
rec_t* rec_t*
...@@ -44,6 +52,15 @@ btr_cur_get_rec( ...@@ -44,6 +52,15 @@ btr_cur_get_rec(
/* out: pointer to record */ /* out: pointer to record */
btr_cur_t* cursor);/* in: tree cursor */ btr_cur_t* cursor);/* in: tree cursor */
/************************************************************* /*************************************************************
Returns the compressed page on which the tree cursor is positioned. */
UNIV_INLINE
page_zip_des_t*
btr_cur_get_page_zip(
/*=================*/
/* out: pointer to compressed page,
or NULL if the page is not compressed */
btr_cur_t* cursor);/* in: tree cursor */
/*************************************************************
Invalidates a tree cursor by setting record pointer to NULL. */ Invalidates a tree cursor by setting record pointer to NULL. */
UNIV_INLINE UNIV_INLINE
void void
...@@ -74,6 +91,7 @@ btr_cur_position( ...@@ -74,6 +91,7 @@ btr_cur_position(
/*=============*/ /*=============*/
dict_index_t* index, /* in: index */ dict_index_t* index, /* in: index */
rec_t* rec, /* in: record in tree */ rec_t* rec, /* in: record in tree */
buf_block_t* block, /* in: buffer block of rec */
btr_cur_t* cursor);/* in: cursor */ btr_cur_t* cursor);/* in: cursor */
/************************************************************************ /************************************************************************
Searches an index tree and positions a tree cursor on a given level. Searches an index tree and positions a tree cursor on a given level.
...@@ -577,6 +595,9 @@ to know struct size! */ ...@@ -577,6 +595,9 @@ to know struct size! */
struct btr_cur_struct { struct btr_cur_struct {
dict_index_t* index; /* index where positioned */ dict_index_t* index; /* index where positioned */
page_cur_t page_cur; /* page cursor */ page_cur_t page_cur; /* page cursor */
buf_block_t* page_block; /* buffer pool block were
cursor is positioned; needed
to avoid buf_block_align() */
page_t* left_page; /* this field is used to store page_t* left_page; /* this field is used to store
a pointer to the left neighbor a pointer to the left neighbor
page, in the cases page, in the cases
......
...@@ -19,6 +19,18 @@ btr_cur_get_page_cur( ...@@ -19,6 +19,18 @@ btr_cur_get_page_cur(
{ {
return(&(cursor->page_cur)); return(&(cursor->page_cur));
} }
/*************************************************************
Returns the buffer block on which the tree cursor is positioned. */
UNIV_INLINE
buf_block_t*
btr_cur_get_block(
/*==============*/
/* out: pointer to buffer block */
btr_cur_t* cursor) /* in: tree cursor */
{
ut_ad(page_align(cursor->page_cur.rec) == cursor->page_block->frame);
return(cursor->page_block);
}
/************************************************************* /*************************************************************
Returns the record pointer of a tree cursor. */ Returns the record pointer of a tree cursor. */
...@@ -29,9 +41,23 @@ btr_cur_get_rec( ...@@ -29,9 +41,23 @@ btr_cur_get_rec(
/* out: pointer to record */ /* out: pointer to record */
btr_cur_t* cursor) /* in: tree cursor */ btr_cur_t* cursor) /* in: tree cursor */
{ {
ut_ad(page_align(cursor->page_cur.rec) == cursor->page_block->frame);
return(page_cur_get_rec(&(cursor->page_cur))); return(page_cur_get_rec(&(cursor->page_cur)));
} }
/*************************************************************
Returns the compressed page on which the tree cursor is positioned. */
UNIV_INLINE
page_zip_des_t*
btr_cur_get_page_zip(
/*=================*/
/* out: pointer to compressed page,
or NULL if the page is not compressed */
btr_cur_t* cursor) /* in: tree cursor */
{
return(buf_block_get_page_zip(btr_cur_get_block(cursor)));
}
/************************************************************* /*************************************************************
Invalidates a tree cursor by setting record pointer to NULL. */ Invalidates a tree cursor by setting record pointer to NULL. */
UNIV_INLINE UNIV_INLINE
...@@ -41,6 +67,7 @@ btr_cur_invalidate( ...@@ -41,6 +67,7 @@ btr_cur_invalidate(
btr_cur_t* cursor) /* in: tree cursor */ btr_cur_t* cursor) /* in: tree cursor */
{ {
page_cur_invalidate(&(cursor->page_cur)); page_cur_invalidate(&(cursor->page_cur));
cursor->page_block = NULL;
} }
/************************************************************* /*************************************************************
...@@ -75,9 +102,13 @@ btr_cur_position( ...@@ -75,9 +102,13 @@ btr_cur_position(
/*=============*/ /*=============*/
dict_index_t* index, /* in: index */ dict_index_t* index, /* in: index */
rec_t* rec, /* in: record in tree */ rec_t* rec, /* in: record in tree */
btr_cur_t* cursor) /* in: cursor */ buf_block_t* block, /* in: buffer block of rec */
btr_cur_t* cursor) /* out: cursor */
{ {
ut_ad(page_align(rec) == buf_block_get_frame(block));
page_cur_position(rec, btr_cur_get_page_cur(cursor)); page_cur_position(rec, btr_cur_get_page_cur(cursor));
cursor->page_block = block;
cursor->index = index; cursor->index = index;
} }
......
...@@ -371,6 +371,14 @@ btr_pcur_get_page( ...@@ -371,6 +371,14 @@ btr_pcur_get_page(
/* out: pointer to the page */ /* out: pointer to the page */
btr_pcur_t* cursor);/* in: persistent cursor */ btr_pcur_t* cursor);/* in: persistent cursor */
/************************************************************* /*************************************************************
Returns the buffer block of a persistent cursor. */
UNIV_INLINE
buf_block_t*
btr_pcur_get_block(
/*===============*/
/* out: pointer to the block */
btr_pcur_t* cursor);/* in: persistent cursor */
/*************************************************************
Returns the record of a persistent cursor. */ Returns the record of a persistent cursor. */
UNIV_INLINE UNIV_INLINE
rec_t* rec_t*
......
...@@ -88,7 +88,21 @@ btr_pcur_get_page( ...@@ -88,7 +88,21 @@ btr_pcur_get_page(
{ {
ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED); ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
return(page_cur_get_page(btr_pcur_get_page_cur(cursor))); return(btr_cur_get_page(btr_pcur_get_btr_cur(cursor)));
}
/*************************************************************
Returns the buffer block of a persistent cursor. */
UNIV_INLINE
buf_block_t*
btr_pcur_get_block(
/*===============*/
/* out: pointer to the block */
btr_pcur_t* cursor) /* in: persistent cursor */
{
ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
return(btr_cur_get_block(btr_pcur_get_btr_cur(cursor)));
} }
/************************************************************* /*************************************************************
...@@ -103,7 +117,7 @@ btr_pcur_get_rec( ...@@ -103,7 +117,7 @@ btr_pcur_get_rec(
ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED); ut_ad(cursor->pos_state == BTR_PCUR_IS_POSITIONED);
ut_ad(cursor->latch_mode != BTR_NO_LATCHES); ut_ad(cursor->latch_mode != BTR_NO_LATCHES);
return(page_cur_get_rec(btr_pcur_get_page_cur(cursor))); return(btr_cur_get_rec(btr_pcur_get_btr_cur(cursor)));
} }
/****************************************************************** /******************************************************************
...@@ -296,7 +310,7 @@ btr_pcur_move_to_last_on_page( ...@@ -296,7 +310,7 @@ btr_pcur_move_to_last_on_page(
UT_NOT_USED(mtr); UT_NOT_USED(mtr);
ut_ad(cursor->latch_mode != BTR_NO_LATCHES); ut_ad(cursor->latch_mode != BTR_NO_LATCHES);
page_cur_set_after_last(page_align(btr_pcur_get_rec(cursor)), page_cur_set_after_last(btr_pcur_get_page(cursor),
btr_pcur_get_page_cur(cursor)); btr_pcur_get_page_cur(cursor));
cursor->old_stored = BTR_PCUR_OLD_NOT_STORED; cursor->old_stored = BTR_PCUR_OLD_NOT_STORED;
...@@ -619,6 +633,7 @@ btr_pcur_close( ...@@ -619,6 +633,7 @@ btr_pcur_close(
cursor->old_rec_buf = NULL; cursor->old_rec_buf = NULL;
} }
cursor->btr_cur.page_block = NULL;
cursor->btr_cur.page_cur.rec = NULL; cursor->btr_cur.page_cur.rec = NULL;
cursor->old_rec = NULL; cursor->old_rec = NULL;
cursor->old_stored = BTR_PCUR_OLD_NOT_STORED; cursor->old_stored = BTR_PCUR_OLD_NOT_STORED;
......
...@@ -132,9 +132,9 @@ UNIV_INLINE ...@@ -132,9 +132,9 @@ UNIV_INLINE
byte* byte*
buf_frame_copy( buf_frame_copy(
/*===========*/ /*===========*/
/* out: buf */ /* out: buf */
byte* buf, /* in: buffer to copy to */ byte* buf, /* in: buffer to copy to */
buf_frame_t* frame); /* in: buffer frame */ const buf_frame_t* frame); /* in: buffer frame */
/****************************************************************** /******************************************************************
NOTE! The following macros should be used instead of buf_page_get_gen, NOTE! The following macros should be used instead of buf_page_get_gen,
to improve debugging. Only values RW_S_LATCH and RW_X_LATCH are allowed to improve debugging. Only values RW_S_LATCH and RW_X_LATCH are allowed
...@@ -618,6 +618,7 @@ buf_block_align( ...@@ -618,6 +618,7 @@ buf_block_align(
/*============*/ /*============*/
/* out: pointer to block */ /* out: pointer to block */
byte* ptr); /* in: pointer to a frame */ byte* ptr); /* in: pointer to a frame */
#if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG
/************************************************************************* /*************************************************************************
Gets the compressed page descriptor corresponding to an uncompressed page Gets the compressed page descriptor corresponding to an uncompressed page
if applicable. */ if applicable. */
...@@ -628,6 +629,7 @@ buf_frame_get_page_zip( ...@@ -628,6 +629,7 @@ buf_frame_get_page_zip(
/* out: compressed page descriptor, or NULL */ /* out: compressed page descriptor, or NULL */
byte* ptr) /* in: pointer to the page */ byte* ptr) /* in: pointer to the page */
__attribute((const)); __attribute((const));
#endif /* UNIV_DEBUG || UNIV_ZIP_DEBUG */
/************************************************************************ /************************************************************************
This function is used to get info if there is an io operation This function is used to get info if there is an io operation
going on on a buffer page. */ going on on a buffer page. */
......
...@@ -261,6 +261,7 @@ buf_block_align( ...@@ -261,6 +261,7 @@ buf_block_align(
return(block); return(block);
} }
#if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG
/************************************************************************* /*************************************************************************
Gets the compressed page descriptor corresponding to an uncompressed page Gets the compressed page descriptor corresponding to an uncompressed page
if applicable. */ if applicable. */
...@@ -273,6 +274,7 @@ buf_frame_get_page_zip( ...@@ -273,6 +274,7 @@ buf_frame_get_page_zip(
{ {
return(buf_block_get_page_zip(buf_block_align(ptr))); return(buf_block_get_page_zip(buf_block_align(ptr)));
} }
#endif /* UNIV_DEBUG || UNIV_ZIP_DEBUG */
/************************************************************************** /**************************************************************************
Gets the space id, page offset, and byte offset within page of a Gets the space id, page offset, and byte offset within page of a
...@@ -286,7 +288,7 @@ buf_ptr_get_fsp_addr( ...@@ -286,7 +288,7 @@ buf_ptr_get_fsp_addr(
fil_addr_t* addr) /* out: page offset and byte offset */ fil_addr_t* addr) /* out: page offset and byte offset */
{ {
const page_t* page = ut_align_down((void*) ptr, UNIV_PAGE_SIZE); const page_t* page = ut_align_down((void*) ptr, UNIV_PAGE_SIZE);
ut_ad(buf_block_align(ptr)); ut_ad(buf_block_align((byte*) ptr));
*space = mach_read_from_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); *space = mach_read_from_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
addr->page = mach_read_from_4(page + FIL_PAGE_OFFSET); addr->page = mach_read_from_4(page + FIL_PAGE_OFFSET);
...@@ -361,9 +363,9 @@ UNIV_INLINE ...@@ -361,9 +363,9 @@ UNIV_INLINE
byte* byte*
buf_frame_copy( buf_frame_copy(
/*===========*/ /*===========*/
/* out: buf */ /* out: buf */
byte* buf, /* in: buffer to copy to */ byte* buf, /* in: buffer to copy to */
buf_frame_t* frame) /* in: buffer frame */ const buf_frame_t* frame) /* in: buffer frame */
{ {
ut_ad(buf && frame); ut_ad(buf && frame);
......
...@@ -10,6 +10,7 @@ Created 5/7/1996 Heikki Tuuri ...@@ -10,6 +10,7 @@ Created 5/7/1996 Heikki Tuuri
#define lock0lock_h #define lock0lock_h
#include "univ.i" #include "univ.i"
#include "buf0types.h"
#include "trx0types.h" #include "trx0types.h"
#include "rem0types.h" #include "rem0types.h"
#include "dict0types.h" #include "dict0types.h"
...@@ -250,6 +251,7 @@ lock_rec_insert_check_and_lock( ...@@ -250,6 +251,7 @@ lock_rec_insert_check_and_lock(
ulint flags, /* in: if BTR_NO_LOCKING_FLAG bit is set, ulint flags, /* in: if BTR_NO_LOCKING_FLAG bit is set,
does nothing */ does nothing */
rec_t* rec, /* in: record after which to insert */ rec_t* rec, /* in: record after which to insert */
buf_block_t* block, /* in: buffer block of rec */
dict_index_t* index, /* in: index */ dict_index_t* index, /* in: index */
que_thr_t* thr, /* in: query thread */ que_thr_t* thr, /* in: query thread */
ibool* inherit);/* out: set to TRUE if the new inserted ibool* inherit);/* out: set to TRUE if the new inserted
...@@ -289,6 +291,7 @@ lock_sec_rec_modify_check_and_lock( ...@@ -289,6 +291,7 @@ lock_sec_rec_modify_check_and_lock(
NOTE: as this is a secondary index, we NOTE: as this is a secondary index, we
always have to modify the clustered index always have to modify the clustered index
record first: see the comment below */ record first: see the comment below */
buf_block_t* block, /* in: buffer block of rec */
dict_index_t* index, /* in: secondary index */ dict_index_t* index, /* in: secondary index */
que_thr_t* thr); /* in: query thread */ que_thr_t* thr); /* in: query thread */
/************************************************************************* /*************************************************************************
......
...@@ -698,12 +698,11 @@ page_copy_rec_list_end( ...@@ -698,12 +698,11 @@ page_copy_rec_list_end(
on new_page, or NULL on zip overflow on new_page, or NULL on zip overflow
(new_page will be decompressed (new_page will be decompressed
from new_page_zip) */ from new_page_zip) */
page_t* new_page, /* in/out: index page to copy to */ buf_block_t* new_block, /* in/out: index page to copy to */
page_zip_des_t* new_page_zip, /* in/out: compressed page, or NULL */
rec_t* rec, /* in: record on page */ rec_t* rec, /* in: record on page */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
__attribute__((warn_unused_result, nonnull(1, 3, 4, 5))); __attribute__((warn_unused_result, nonnull));
/***************************************************************** /*****************************************************************
Copies records from page to new_page, up to the given record, NOT Copies records from page to new_page, up to the given record, NOT
including that record. Infimum and supremum records are not copied. including that record. Infimum and supremum records are not copied.
...@@ -717,12 +716,11 @@ page_copy_rec_list_start( ...@@ -717,12 +716,11 @@ page_copy_rec_list_start(
on new_page, or NULL on zip overflow on new_page, or NULL on zip overflow
(new_page will be decompressed (new_page will be decompressed
from new_page_zip) */ from new_page_zip) */
page_t* new_page, /* in/out: index page to copy to */ buf_block_t* new_block, /* in/out: index page to copy to */
page_zip_des_t* new_page_zip, /* in/out: compressed page, or NULL */
rec_t* rec, /* in: record on page */ rec_t* rec, /* in: record on page */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
__attribute__((warn_unused_result, nonnull(1, 3, 4, 5))); __attribute__((warn_unused_result, nonnull));
/***************************************************************** /*****************************************************************
Deletes records from a page from a given record onward, including that record. Deletes records from a page from a given record onward, including that record.
The infimum and supremum records are not deleted. */ The infimum and supremum records are not deleted. */
...@@ -762,15 +760,13 @@ page_move_rec_list_end( ...@@ -762,15 +760,13 @@ page_move_rec_list_end(
/* out: TRUE on success; FALSE on /* out: TRUE on success; FALSE on
compression failure (new_page will compression failure (new_page will
be decompressed from new_page_zip) */ be decompressed from new_page_zip) */
page_t* new_page, /* in: index page where to move */ buf_block_t* new_block, /* in/out: index page where to move */
page_zip_des_t* new_page_zip, /* in/out: compressed page of
new_page, or NULL */
rec_t* split_rec, /* in: first record to move */ rec_t* split_rec, /* in: first record to move */
page_zip_des_t* page_zip, /* in/out: compressed page of page_zip_des_t* page_zip, /* in/out: compressed page of
split_rec, or NULL */ split_rec, or NULL */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
__attribute__((nonnull(1, 3, 5, 6))); __attribute__((nonnull(1, 2, 4, 5)));
/***************************************************************** /*****************************************************************
Moves record list start to another page. Moved records do not include Moves record list start to another page. Moved records do not include
split_rec. */ split_rec. */
...@@ -780,15 +776,13 @@ page_move_rec_list_start( ...@@ -780,15 +776,13 @@ page_move_rec_list_start(
/*=====================*/ /*=====================*/
/* out: TRUE on success; FALSE on /* out: TRUE on success; FALSE on
compression failure */ compression failure */
page_t* new_page, /* in: index page where to move */ buf_block_t* new_block, /* in/out: index page where to move */
page_zip_des_t* new_page_zip, /* in/out: compressed page of
new_page, or NULL */
rec_t* split_rec, /* in: first record not to move */ rec_t* split_rec, /* in: first record not to move */
page_zip_des_t* page_zip, /* in/out: compressed page of page_zip_des_t* page_zip, /* in/out: compressed page of
split_rec, or NULL */ split_rec, or NULL */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
__attribute__((nonnull(1, 3, 5, 6))); __attribute__((nonnull(1, 2, 4, 5)));
/******************************************************************** /********************************************************************
Splits a directory slot which owns too many records. */ Splits a directory slot which owns too many records. */
......
...@@ -16,6 +16,7 @@ Created June 2005 by Marko Makela ...@@ -16,6 +16,7 @@ Created June 2005 by Marko Makela
#include "mtr0types.h" #include "mtr0types.h"
#include "page0types.h" #include "page0types.h"
#include "buf0types.h"
#include "dict0types.h" #include "dict0types.h"
#include "ut0byte.h" #include "ut0byte.h"
...@@ -335,9 +336,9 @@ page_zip_reorganize( ...@@ -335,9 +336,9 @@ page_zip_reorganize(
/* out: TRUE on success, FALSE on failure; /* out: TRUE on success, FALSE on failure;
page and page_zip will be left intact page and page_zip will be left intact
on failure. */ on failure. */
page_zip_des_t* page_zip,/* in: size; out: data, n_blobs, buf_block_t* block, /* in/out: page with compressed page;
m_start, m_end */ on the compressed page, in: size;
page_t* page, /* in/out: uncompressed page */ out: data, n_blobs, m_start, m_end */
dict_index_t* index, /* in: index of the B-tree node */ dict_index_t* index, /* in: index of the B-tree node */
mtr_t* mtr) /* in: mini-transaction */ mtr_t* mtr) /* in: mini-transaction */
__attribute__((warn_unused_result, nonnull)); __attribute__((warn_unused_result, nonnull));
......
...@@ -4926,6 +4926,7 @@ lock_rec_insert_check_and_lock( ...@@ -4926,6 +4926,7 @@ lock_rec_insert_check_and_lock(
ulint flags, /* in: if BTR_NO_LOCKING_FLAG bit is set, ulint flags, /* in: if BTR_NO_LOCKING_FLAG bit is set,
does nothing */ does nothing */
rec_t* rec, /* in: record after which to insert */ rec_t* rec, /* in: record after which to insert */
buf_block_t* block, /* in: buffer block of rec */
dict_index_t* index, /* in: index */ dict_index_t* index, /* in: index */
que_thr_t* thr, /* in: query thread */ que_thr_t* thr, /* in: query thread */
ibool* inherit)/* out: set to TRUE if the new inserted ibool* inherit)/* out: set to TRUE if the new inserted
...@@ -4968,7 +4969,7 @@ lock_rec_insert_check_and_lock( ...@@ -4968,7 +4969,7 @@ lock_rec_insert_check_and_lock(
if (!dict_index_is_clust(index)) { if (!dict_index_is_clust(index)) {
/* Update the page max trx id field */ /* Update the page max trx id field */
page_update_max_trx_id(page_align(rec), page_update_max_trx_id(page_align(rec),
buf_frame_get_page_zip(rec), buf_block_get_page_zip(block),
thr_get_trx(thr)->id); thr_get_trx(thr)->id);
} }
...@@ -5006,7 +5007,7 @@ lock_rec_insert_check_and_lock( ...@@ -5006,7 +5007,7 @@ lock_rec_insert_check_and_lock(
if ((err == DB_SUCCESS) && !dict_index_is_clust(index)) { if ((err == DB_SUCCESS) && !dict_index_is_clust(index)) {
/* Update the page max trx id field */ /* Update the page max trx id field */
page_update_max_trx_id(page_align(rec), page_update_max_trx_id(page_align(rec),
buf_frame_get_page_zip(rec), buf_block_get_page_zip(block),
thr_get_trx(thr)->id); thr_get_trx(thr)->id);
} }
...@@ -5142,6 +5143,7 @@ lock_sec_rec_modify_check_and_lock( ...@@ -5142,6 +5143,7 @@ lock_sec_rec_modify_check_and_lock(
NOTE: as this is a secondary index, we NOTE: as this is a secondary index, we
always have to modify the clustered index always have to modify the clustered index
record first: see the comment below */ record first: see the comment below */
buf_block_t* block, /* in: buffer block of rec */
dict_index_t* index, /* in: secondary index */ dict_index_t* index, /* in: secondary index */
que_thr_t* thr) /* in: query thread */ que_thr_t* thr) /* in: query thread */
{ {
...@@ -5186,7 +5188,7 @@ lock_sec_rec_modify_check_and_lock( ...@@ -5186,7 +5188,7 @@ lock_sec_rec_modify_check_and_lock(
if (err == DB_SUCCESS) { if (err == DB_SUCCESS) {
/* Update the page max trx id field */ /* Update the page max trx id field */
page_update_max_trx_id(page_align(rec), page_update_max_trx_id(page_align(rec),
buf_frame_get_page_zip(rec), buf_block_get_page_zip(block),
thr_get_trx(thr)->id); thr_get_trx(thr)->id);
} }
......
...@@ -881,7 +881,7 @@ recv_parse_or_apply_log_rec_body( ...@@ -881,7 +881,7 @@ recv_parse_or_apply_log_rec_body(
|| (ibool)!!page_is_comp(page) || (ibool)!!page_is_comp(page)
== dict_table_is_comp(index->table)); == dict_table_is_comp(index->table));
ptr = btr_parse_page_reorganize(ptr, end_ptr, index, ptr = btr_parse_page_reorganize(ptr, end_ptr, index,
page, page_zip, mtr); block, mtr);
} }
break; break;
case MLOG_PAGE_CREATE: case MLOG_COMP_PAGE_CREATE: case MLOG_PAGE_CREATE: case MLOG_COMP_PAGE_CREATE:
......
...@@ -1130,11 +1130,14 @@ use_heap: ...@@ -1130,11 +1130,14 @@ use_heap:
(!page_zip_compress(page_zip_orig, page, index, mtr))) { (!page_zip_compress(page_zip_orig, page, index, mtr))) {
/* Before trying to reorganize the page, /* Before trying to reorganize the page,
store the number of preceding records on the page. */ store the number of preceding records on the page. */
ulint insert_pos ulint insert_pos
= page_rec_get_n_recs_before(insert_rec); = page_rec_get_n_recs_before(insert_rec);
buf_block_t* block
= buf_block_align(page);
if (page_zip_reorganize(page_zip_orig, page, ut_ad(buf_block_get_page_zip(block) == page_zip_orig);
index, mtr)) {
if (page_zip_reorganize(block, index, mtr)) {
/* The page was reorganized: /* The page was reorganized:
Seek to insert_pos to find insert_rec. */ Seek to insert_pos to find insert_rec. */
insert_rec = page + PAGE_NEW_INFIMUM; insert_rec = page + PAGE_NEW_INFIMUM;
......
...@@ -579,15 +579,17 @@ page_copy_rec_list_end( ...@@ -579,15 +579,17 @@ page_copy_rec_list_end(
on new_page, or NULL on zip overflow on new_page, or NULL on zip overflow
(new_page will be decompressed (new_page will be decompressed
from new_page_zip) */ from new_page_zip) */
page_t* new_page, /* in/out: index page to copy to */ buf_block_t* new_block, /* in/out: index page to copy to */
page_zip_des_t* new_page_zip, /* in/out: compressed page, or NULL */
rec_t* rec, /* in: record on page */ rec_t* rec, /* in: record on page */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
{ {
page_t* page = page_align(rec); page_t* new_page = buf_block_get_frame(new_block);
rec_t* ret = page_rec_get_next(page_get_infimum_rec(new_page)); page_zip_des_t* new_page_zip = buf_block_get_page_zip(new_block);
ulint log_mode= 0; /* remove warning */ page_t* page = page_align(rec);
rec_t* ret = page_rec_get_next(
page_get_infimum_rec(new_page));
ulint log_mode = 0; /* remove warning */
/* page_zip_validate() will fail here if btr_compress() /* page_zip_validate() will fail here if btr_compress()
sets FIL_PAGE_PREV to FIL_NULL */ sets FIL_PAGE_PREV to FIL_NULL */
...@@ -616,8 +618,7 @@ page_copy_rec_list_end( ...@@ -616,8 +618,7 @@ page_copy_rec_list_end(
= page_rec_get_n_recs_before(ret); = page_rec_get_n_recs_before(ret);
if (UNIV_UNLIKELY if (UNIV_UNLIKELY
(!page_zip_reorganize(new_page_zip, new_page, (!page_zip_reorganize(new_block, index, mtr))) {
index, mtr))) {
if (UNIV_UNLIKELY if (UNIV_UNLIKELY
(!page_zip_decompress(new_page_zip, (!page_zip_decompress(new_page_zip,
...@@ -663,12 +664,13 @@ page_copy_rec_list_start( ...@@ -663,12 +664,13 @@ page_copy_rec_list_start(
on new_page, or NULL on zip overflow on new_page, or NULL on zip overflow
(new_page will be decompressed (new_page will be decompressed
from new_page_zip) */ from new_page_zip) */
page_t* new_page, /* in/out: index page to copy to */ buf_block_t* new_block, /* in/out: index page to copy to */
page_zip_des_t* new_page_zip, /* in/out: compressed page, or NULL */
rec_t* rec, /* in: record on page */ rec_t* rec, /* in: record on page */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
{ {
page_t* new_page = buf_block_get_frame(new_block);
page_zip_des_t* new_page_zip = buf_block_get_page_zip(new_block);
page_cur_t cur1; page_cur_t cur1;
page_cur_t cur2; page_cur_t cur2;
page_t* page; page_t* page;
...@@ -726,8 +728,7 @@ page_copy_rec_list_start( ...@@ -726,8 +728,7 @@ page_copy_rec_list_start(
= page_rec_get_n_recs_before(ret); = page_rec_get_n_recs_before(ret);
if (UNIV_UNLIKELY if (UNIV_UNLIKELY
(!page_zip_reorganize(new_page_zip, new_page, (!page_zip_reorganize(new_block, index, mtr))) {
index, mtr))) {
if (UNIV_UNLIKELY if (UNIV_UNLIKELY
(!page_zip_decompress(new_page_zip, (!page_zip_decompress(new_page_zip,
...@@ -1090,19 +1091,21 @@ page_move_rec_list_end( ...@@ -1090,19 +1091,21 @@ page_move_rec_list_end(
/* out: TRUE on success; FALSE on /* out: TRUE on success; FALSE on
compression failure (new_page will compression failure (new_page will
be decompressed from new_page_zip) */ be decompressed from new_page_zip) */
page_t* new_page, /* in: index page where to move */ buf_block_t* new_block, /* in/out: index page where to move */
page_zip_des_t* new_page_zip, /* in/out: compressed page of
new_page, or NULL */
rec_t* split_rec, /* in: first record to move */ rec_t* split_rec, /* in: first record to move */
page_zip_des_t* page_zip, /* in/out: compressed page of page_zip_des_t* page_zip, /* in/out: compressed page of
split_rec, or NULL */ split_rec, or NULL */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
{ {
ulint old_data_size; page_t* new_page = buf_block_get_frame(new_block);
ulint new_data_size; #ifdef UNIV_ZIP_DEBUG
ulint old_n_recs; page_zip_des_t* new_page_zip = buf_block_get_page_zip(new_block);
ulint new_n_recs; #endif /* UNIV_ZIP_DEBUG */
ulint old_data_size;
ulint new_data_size;
ulint old_n_recs;
ulint new_n_recs;
old_data_size = page_get_data_size(new_page); old_data_size = page_get_data_size(new_page);
old_n_recs = page_get_n_recs(new_page); old_n_recs = page_get_n_recs(new_page);
...@@ -1111,8 +1114,8 @@ page_move_rec_list_end( ...@@ -1111,8 +1114,8 @@ page_move_rec_list_end(
ut_a(!page_zip || page_zip_validate(page_zip, page_align(split_rec))); ut_a(!page_zip || page_zip_validate(page_zip, page_align(split_rec)));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
if (UNIV_UNLIKELY(!page_copy_rec_list_end(new_page, new_page_zip, if (UNIV_UNLIKELY(!page_copy_rec_list_end(new_block, split_rec,
split_rec, index, mtr))) { index, mtr))) {
return(FALSE); return(FALSE);
} }
...@@ -1138,17 +1141,15 @@ page_move_rec_list_start( ...@@ -1138,17 +1141,15 @@ page_move_rec_list_start(
/*=====================*/ /*=====================*/
/* out: TRUE on success; FALSE on /* out: TRUE on success; FALSE on
compression failure */ compression failure */
page_t* new_page, /* in: index page where to move */ buf_block_t* new_block, /* in/out: index page where to move */
page_zip_des_t* new_page_zip, /* in/out: compressed page of
new_page, or NULL */
rec_t* split_rec, /* in: first record not to move */ rec_t* split_rec, /* in: first record not to move */
page_zip_des_t* page_zip, /* in/out: compressed page of page_zip_des_t* page_zip, /* in/out: compressed page of
split_rec, or NULL */ split_rec, or NULL */
dict_index_t* index, /* in: record descriptor */ dict_index_t* index, /* in: record descriptor */
mtr_t* mtr) /* in: mtr */ mtr_t* mtr) /* in: mtr */
{ {
if (UNIV_UNLIKELY(!page_copy_rec_list_start(new_page, new_page_zip, if (UNIV_UNLIKELY(!page_copy_rec_list_start(new_block, split_rec,
split_rec, index, mtr))) { index, mtr))) {
return(FALSE); return(FALSE);
} }
......
...@@ -3504,13 +3504,14 @@ page_zip_reorganize( ...@@ -3504,13 +3504,14 @@ page_zip_reorganize(
/* out: TRUE on success, FALSE on failure; /* out: TRUE on success, FALSE on failure;
page and page_zip will be left intact page and page_zip will be left intact
on failure. */ on failure. */
page_zip_des_t* page_zip,/* in: size; out: data, n_blobs, buf_block_t* block, /* in/out: page with compressed page;
m_start, m_end */ on the compressed page, in: size;
page_t* page, /* in/out: uncompressed page */ out: data, n_blobs, m_start, m_end */
dict_index_t* index, /* in: index of the B-tree node */ dict_index_t* index, /* in: index of the B-tree node */
mtr_t* mtr) /* in: mini-transaction */ mtr_t* mtr) /* in: mini-transaction */
{ {
buf_block_t* block; page_zip_des_t* page_zip = buf_block_get_page_zip(block);
page_t* page = buf_block_get_frame(block);
buf_block_t* temp_block; buf_block_t* temp_block;
page_t* temp_page; page_t* temp_page;
ulint log_mode; ulint log_mode;
...@@ -3531,7 +3532,6 @@ page_zip_reorganize( ...@@ -3531,7 +3532,6 @@ page_zip_reorganize(
/* Recreate the page: note that global data on page (possible /* Recreate the page: note that global data on page (possible
segment headers, next page-field, etc.) is preserved intact */ segment headers, next page-field, etc.) is preserved intact */
block = buf_block_align(page);
page_create(block, mtr, dict_table_is_comp(index->table)); page_create(block, mtr, dict_table_is_comp(index->table));
block->check_index_page_at_flush = TRUE; block->check_index_page_at_flush = TRUE;
......
...@@ -2084,7 +2084,8 @@ row_ins_index_entry_low( ...@@ -2084,7 +2084,8 @@ row_ins_index_entry_low(
if (modify == ROW_INS_NEXT) { if (modify == ROW_INS_NEXT) {
rec = page_rec_get_next(btr_cur_get_rec(&cursor)); rec = page_rec_get_next(btr_cur_get_rec(&cursor));
btr_cur_position(index, rec, &cursor); btr_cur_position(index, rec,
btr_cur_get_block(&cursor),&cursor);
} }
if (dict_index_is_clust(index)) { if (dict_index_is_clust(index)) {
......
...@@ -3793,7 +3793,9 @@ wrong_offs: ...@@ -3793,7 +3793,9 @@ wrong_offs:
" buf block fix count %lu\n", " buf block fix count %lu\n",
(void*) rec, (void*) buf_pool->frame_zero, (void*) rec, (void*) buf_pool->frame_zero,
(void*) buf_pool->high_end, (void*) buf_pool->high_end,
(ulong)buf_block_align(rec)->buf_fix_count); (ulong)
btr_cur_get_block(btr_pcur_get_btr_cur(pcur))
->buf_fix_count);
fprintf(stderr, fprintf(stderr,
"InnoDB: Index corruption: rec offs %lu" "InnoDB: Index corruption: rec offs %lu"
" next offs %lu, page no %lu,\n" " next offs %lu, page no %lu,\n"
......
...@@ -1470,7 +1470,7 @@ row_upd_clust_rec_by_insert( ...@@ -1470,7 +1470,7 @@ row_upd_clust_rec_by_insert(
index = dict_table_get_first_index(table); index = dict_table_get_first_index(table);
btr_cur_mark_extern_inherited_fields( btr_cur_mark_extern_inherited_fields(
buf_frame_get_page_zip(rec), btr_cur_get_page_zip(btr_cur),
rec, index, rec, index,
rec_get_offsets(rec, index, offsets_, rec_get_offsets(rec, index, offsets_,
ULINT_UNDEFINED, &heap), ULINT_UNDEFINED, &heap),
......
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