Commit dc80dcac authored by Marko Mäkelä's avatar Marko Mäkelä

Bug#12701488 ASSERT PAGE_ZIP_VALIDATE, UNIV_ZIP_DEBUG

page_zip_validate(), page_zip_validate_low(): Add a parameter for the
B-tree index.

page_zip_validate_low(): If the page contents does not match, check
that the record link chains match. Furthermore, if dict_index_t is
passed, check that the records match. (This reduces coverage a bit: if
index=NULL, we will ignore differences in record contents, that is,
the page payload.)

rb:1264 approved by Inaam Rana
parent 4bfeb52d
2012-09-17 The InnoDB Team
* btr/btr0btr.c, btr/btr0cur.c, buf/buf0lru.c,
include/page0zip.h, log/log0recv.c, page/page0cur.c,
page/page0page.c, page/page0zip.c:
Fix Bug#12701488 ASSERT PAGE_ZIP_VALIDATE, UNIV_ZIP_DEBUG
2012-08-29 The InnoDB Team 2012-08-29 The InnoDB Team
* btr/btr0btr.c, page/page0cur.c, page/page0page.c: * btr/btr0btr.c, page/page0cur.c, page/page0page.c:
......
...@@ -1573,7 +1573,7 @@ btr_page_reorganize_low( ...@@ -1573,7 +1573,7 @@ btr_page_reorganize_low(
ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
ut_ad(!!page_is_comp(page) == dict_table_is_comp(index->table)); ut_ad(!!page_is_comp(page) == dict_table_is_comp(index->table));
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(!page_zip || page_zip_validate(page_zip, page)); ut_a(!page_zip || page_zip_validate(page_zip, page, index));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
data_size1 = page_get_data_size(page); data_size1 = page_get_data_size(page);
max_ins_size1 = page_get_max_insert_size_after_reorganize(page, 1); max_ins_size1 = page_get_max_insert_size_after_reorganize(page, 1);
...@@ -1691,7 +1691,7 @@ btr_page_reorganize_low( ...@@ -1691,7 +1691,7 @@ btr_page_reorganize_low(
func_exit: func_exit:
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(!page_zip || page_zip_validate(page_zip, page)); ut_a(!page_zip || page_zip_validate(page_zip, page, index));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
#ifndef UNIV_HOTBACKUP #ifndef UNIV_HOTBACKUP
buf_block_free(temp_block); buf_block_free(temp_block);
...@@ -1766,7 +1766,7 @@ btr_page_empty( ...@@ -1766,7 +1766,7 @@ btr_page_empty(
ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
ut_ad(page_zip == buf_block_get_page_zip(block)); ut_ad(page_zip == buf_block_get_page_zip(block));
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(!page_zip || page_zip_validate(page_zip, page)); ut_a(!page_zip || page_zip_validate(page_zip, page, index));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
btr_search_drop_page_hash_index(block); btr_search_drop_page_hash_index(block);
...@@ -1823,10 +1823,10 @@ btr_root_raise_and_insert( ...@@ -1823,10 +1823,10 @@ btr_root_raise_and_insert(
root_block = btr_cur_get_block(cursor); root_block = btr_cur_get_block(cursor);
root_page_zip = buf_block_get_page_zip(root_block); root_page_zip = buf_block_get_page_zip(root_block);
ut_ad(page_get_n_recs(root) > 0); ut_ad(page_get_n_recs(root) > 0);
index = btr_cur_get_index(cursor);
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(!root_page_zip || page_zip_validate(root_page_zip, root)); ut_a(!root_page_zip || page_zip_validate(root_page_zip, root, index));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
index = btr_cur_get_index(cursor);
#ifdef UNIV_BTR_DEBUG #ifdef UNIV_BTR_DEBUG
if (!dict_index_is_ibuf(index)) { if (!dict_index_is_ibuf(index)) {
ulint space = dict_index_get_space(index); ulint space = dict_index_get_space(index);
...@@ -2756,8 +2756,8 @@ insert_empty: ...@@ -2756,8 +2756,8 @@ insert_empty:
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
if (UNIV_LIKELY_NULL(page_zip)) { if (UNIV_LIKELY_NULL(page_zip)) {
ut_a(page_zip_validate(page_zip, page)); ut_a(page_zip_validate(page_zip, page, cursor->index));
ut_a(page_zip_validate(new_page_zip, new_page)); ut_a(page_zip_validate(new_page_zip, new_page, cursor->index));
} }
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
...@@ -2791,7 +2791,8 @@ insert_empty: ...@@ -2791,7 +2791,8 @@ insert_empty:
= buf_block_get_page_zip(insert_block); = buf_block_get_page_zip(insert_block);
ut_a(!insert_page_zip ut_a(!insert_page_zip
|| page_zip_validate(insert_page_zip, insert_page)); || page_zip_validate(insert_page_zip, insert_page,
cursor->index));
} }
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
...@@ -3156,7 +3157,7 @@ btr_lift_page_up( ...@@ -3156,7 +3157,7 @@ btr_lift_page_up(
btr_page_set_level(page, page_zip, page_level, mtr); btr_page_set_level(page, page_zip, page_level, mtr);
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(!page_zip || page_zip_validate(page_zip, page)); ut_a(!page_zip || page_zip_validate(page_zip, page, index));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
} }
...@@ -3332,8 +3333,8 @@ err_exit: ...@@ -3332,8 +3333,8 @@ err_exit:
const page_zip_des_t* page_zip const page_zip_des_t* page_zip
= buf_block_get_page_zip(block); = buf_block_get_page_zip(block);
ut_a(page_zip); ut_a(page_zip);
ut_a(page_zip_validate(merge_page_zip, merge_page)); ut_a(page_zip_validate(merge_page_zip, merge_page, index));
ut_a(page_zip_validate(page_zip, page)); ut_a(page_zip_validate(page_zip, page, index));
} }
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
...@@ -3466,7 +3467,8 @@ err_exit: ...@@ -3466,7 +3467,8 @@ err_exit:
ut_ad(page_validate(merge_page, index)); ut_ad(page_validate(merge_page, index));
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(!merge_page_zip || page_zip_validate(merge_page_zip, merge_page)); ut_a(!merge_page_zip || page_zip_validate(merge_page_zip, merge_page,
index));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
/* Free the file page */ /* Free the file page */
...@@ -3649,7 +3651,7 @@ btr_discard_page( ...@@ -3649,7 +3651,7 @@ btr_discard_page(
page_zip_des_t* merge_page_zip page_zip_des_t* merge_page_zip
= buf_block_get_page_zip(merge_block); = buf_block_get_page_zip(merge_block);
ut_a(!merge_page_zip ut_a(!merge_page_zip
|| page_zip_validate(merge_page_zip, merge_page)); || page_zip_validate(merge_page_zip, merge_page, index));
} }
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
...@@ -4126,7 +4128,7 @@ btr_validate_level( ...@@ -4126,7 +4128,7 @@ btr_validate_level(
ut_a(space == page_get_space_id(page)); ut_a(space == page_get_space_id(page));
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
page_zip = buf_block_get_page_zip(block); page_zip = buf_block_get_page_zip(block);
ut_a(!page_zip || page_zip_validate(page_zip, page)); ut_a(!page_zip || page_zip_validate(page_zip, page, index));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
ut_a(!page_is_leaf(page)); ut_a(!page_is_leaf(page));
...@@ -4154,7 +4156,7 @@ loop: ...@@ -4154,7 +4156,7 @@ loop:
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
page_zip = buf_block_get_page_zip(block); page_zip = buf_block_get_page_zip(block);
ut_a(!page_zip || page_zip_validate(page_zip, page)); ut_a(!page_zip || page_zip_validate(page_zip, page, index));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
/* Check ordering etc. of records */ /* Check ordering etc. of records */
......
...@@ -578,7 +578,8 @@ retry_page_get: ...@@ -578,7 +578,8 @@ retry_page_get:
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
const page_zip_des_t* page_zip const page_zip_des_t* page_zip
= buf_block_get_page_zip(block); = buf_block_get_page_zip(block);
ut_a(!page_zip || page_zip_validate(page_zip, page)); ut_a(!page_zip
|| page_zip_validate(page_zip, page, index));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
buf_block_dbg_add_level( buf_block_dbg_add_level(
...@@ -1939,7 +1940,7 @@ any_extern: ...@@ -1939,7 +1940,7 @@ any_extern:
page_zip = buf_block_get_page_zip(block); page_zip = buf_block_get_page_zip(block);
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(!page_zip || page_zip_validate(page_zip, page)); ut_a(!page_zip || page_zip_validate(page_zip, page, index));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
if (page_zip if (page_zip
...@@ -2148,7 +2149,7 @@ btr_cur_pessimistic_update( ...@@ -2148,7 +2149,7 @@ btr_cur_pessimistic_update(
MTR_MEMO_X_LOCK)); MTR_MEMO_X_LOCK));
ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(!page_zip || page_zip_validate(page_zip, page)); ut_a(!page_zip || page_zip_validate(page_zip, page, index));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
/* The insert buffer tree should never be updated in place. */ /* The insert buffer tree should never be updated in place. */
ut_ad(!dict_index_is_ibuf(index)); ut_ad(!dict_index_is_ibuf(index));
...@@ -2286,7 +2287,7 @@ make_external: ...@@ -2286,7 +2287,7 @@ make_external:
btr_search_update_hash_on_delete(cursor); btr_search_update_hash_on_delete(cursor);
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(!page_zip || page_zip_validate(page_zip, page)); ut_a(!page_zip || page_zip_validate(page_zip, page, index));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
page_cursor = btr_cur_get_page_cur(cursor); page_cursor = btr_cur_get_page_cur(cursor);
...@@ -2393,7 +2394,7 @@ make_external: ...@@ -2393,7 +2394,7 @@ make_external:
buf_block_t* rec_block = btr_cur_get_block(cursor); buf_block_t* rec_block = btr_cur_get_block(cursor);
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(!page_zip || page_zip_validate(page_zip, page)); ut_a(!page_zip || page_zip_validate(page_zip, page, index));
page = buf_block_get_frame(rec_block); page = buf_block_get_frame(rec_block);
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
page_zip = buf_block_get_page_zip(rec_block); page_zip = buf_block_get_page_zip(rec_block);
...@@ -2419,7 +2420,7 @@ make_external: ...@@ -2419,7 +2420,7 @@ make_external:
return_after_reservations: return_after_reservations:
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(!page_zip || page_zip_validate(page_zip, page)); ut_a(!page_zip || page_zip_validate(page_zip, page, index));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
if (n_extents > 0) { if (n_extents > 0) {
...@@ -2880,12 +2881,14 @@ btr_cur_optimistic_delete( ...@@ -2880,12 +2881,14 @@ btr_cur_optimistic_delete(
page, 1); page, 1);
} }
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(!page_zip || page_zip_validate(page_zip, page)); ut_a(!page_zip
|| page_zip_validate(page_zip, page, cursor->index));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
page_cur_delete_rec(btr_cur_get_page_cur(cursor), page_cur_delete_rec(btr_cur_get_page_cur(cursor),
cursor->index, offsets, mtr); cursor->index, offsets, mtr);
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(!page_zip || page_zip_validate(page_zip, page)); ut_a(!page_zip
|| page_zip_validate(page_zip, page, cursor->index));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
if (dict_index_is_clust(cursor->index) if (dict_index_is_clust(cursor->index)
...@@ -2980,7 +2983,7 @@ btr_cur_pessimistic_delete( ...@@ -2980,7 +2983,7 @@ btr_cur_pessimistic_delete(
rec = btr_cur_get_rec(cursor); rec = btr_cur_get_rec(cursor);
page_zip = buf_block_get_page_zip(block); page_zip = buf_block_get_page_zip(block);
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(!page_zip || page_zip_validate(page_zip, page)); ut_a(!page_zip || page_zip_validate(page_zip, page, index));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
offsets = rec_get_offsets(rec, index, NULL, ULINT_UNDEFINED, &heap); offsets = rec_get_offsets(rec, index, NULL, ULINT_UNDEFINED, &heap);
...@@ -2990,7 +2993,7 @@ btr_cur_pessimistic_delete( ...@@ -2990,7 +2993,7 @@ btr_cur_pessimistic_delete(
rec, offsets, page_zip, rec, offsets, page_zip,
rb_ctx, mtr); rb_ctx, mtr);
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(!page_zip || page_zip_validate(page_zip, page)); ut_a(!page_zip || page_zip_validate(page_zip, page, index));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
} }
...@@ -3051,7 +3054,7 @@ btr_cur_pessimistic_delete( ...@@ -3051,7 +3054,7 @@ btr_cur_pessimistic_delete(
page_cur_delete_rec(btr_cur_get_page_cur(cursor), index, offsets, mtr); page_cur_delete_rec(btr_cur_get_page_cur(cursor), index, offsets, mtr);
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(!page_zip || page_zip_validate(page_zip, page)); ut_a(!page_zip || page_zip_validate(page_zip, page, index));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
ut_ad(btr_check_node_ptr(index, block, mtr)); ut_ad(btr_check_node_ptr(index, block, mtr));
......
...@@ -1642,7 +1642,9 @@ buf_LRU_block_remove_hashed_page( ...@@ -1642,7 +1642,9 @@ buf_LRU_block_remove_hashed_page(
break; break;
case FIL_PAGE_INDEX: case FIL_PAGE_INDEX:
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(page_zip_validate(&bpage->zip, page)); ut_a(page_zip_validate(
&bpage->zip, page,
((buf_block_t*) bpage)->index));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
break; break;
default: default:
......
...@@ -156,9 +156,10 @@ page_zip_validate_low( ...@@ -156,9 +156,10 @@ page_zip_validate_low(
/*==================*/ /*==================*/
const page_zip_des_t* page_zip,/*!< in: compressed page */ const page_zip_des_t* page_zip,/*!< in: compressed page */
const page_t* page, /*!< in: uncompressed page */ const page_t* page, /*!< in: uncompressed page */
const dict_index_t* index, /*!< in: index of the page, if known */
ibool sloppy) /*!< in: FALSE=strict, ibool sloppy) /*!< in: FALSE=strict,
TRUE=ignore the MIN_REC_FLAG */ TRUE=ignore the MIN_REC_FLAG */
__attribute__((nonnull)); __attribute__((nonnull(1,2)));
/**********************************************************************//** /**********************************************************************//**
Check that the compressed and decompressed pages match. */ Check that the compressed and decompressed pages match. */
UNIV_INTERN UNIV_INTERN
...@@ -166,8 +167,9 @@ ibool ...@@ -166,8 +167,9 @@ ibool
page_zip_validate( page_zip_validate(
/*==============*/ /*==============*/
const page_zip_des_t* page_zip,/*!< in: compressed page */ const page_zip_des_t* page_zip,/*!< in: compressed page */
const page_t* page) /*!< in: uncompressed page */ const page_t* page, /*!< in: uncompressed page */
__attribute__((nonnull)); const dict_index_t* index) /*!< in: index of the page, if known */
__attribute__((nonnull(1,2)));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
/**********************************************************************//** /**********************************************************************//**
......
...@@ -1626,9 +1626,8 @@ recv_recover_page_func( ...@@ -1626,9 +1626,8 @@ recv_recover_page_func(
if (fil_page_get_type(page) == FIL_PAGE_INDEX) { if (fil_page_get_type(page) == FIL_PAGE_INDEX) {
page_zip_des_t* page_zip = buf_block_get_page_zip(block); page_zip_des_t* page_zip = buf_block_get_page_zip(block);
if (page_zip) { ut_a(!page_zip
ut_a(page_zip_validate_low(page_zip, page, FALSE)); || page_zip_validate_low(page_zip, page, NULL, FALSE));
}
} }
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
......
...@@ -310,7 +310,7 @@ page_cur_search_with_match( ...@@ -310,7 +310,7 @@ page_cur_search_with_match(
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
page = buf_block_get_frame(block); page = buf_block_get_frame(block);
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(!page_zip || page_zip_validate(page_zip, page)); ut_a(!page_zip || page_zip_validate(page_zip, page, index));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
page_check_dir(page); page_check_dir(page);
...@@ -1248,7 +1248,7 @@ page_cur_insert_rec_zip( ...@@ -1248,7 +1248,7 @@ page_cur_insert_rec_zip(
ut_ad(!page_rec_is_supremum(*current_rec)); ut_ad(!page_rec_is_supremum(*current_rec));
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(page_zip_validate(page_zip, page)); ut_a(page_zip_validate(page_zip, page, index));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
/* 1. Get the size of the physical record in the page */ /* 1. Get the size of the physical record in the page */
...@@ -1973,7 +1973,7 @@ page_cur_delete_rec( ...@@ -1973,7 +1973,7 @@ page_cur_delete_rec(
} }
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(!page_zip || page_zip_validate(page_zip, page)); ut_a(!page_zip || page_zip_validate(page_zip, page, index));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
} }
......
...@@ -625,7 +625,7 @@ page_copy_rec_list_end( ...@@ -625,7 +625,7 @@ page_copy_rec_list_end(
Furthermore, btr_compress() may set FIL_PAGE_PREV to Furthermore, btr_compress() may set FIL_PAGE_PREV to
FIL_NULL on new_page while leaving it intact on FIL_NULL on new_page while leaving it intact on
new_page_zip. So, we cannot validate new_page_zip. */ new_page_zip. So, we cannot validate new_page_zip. */
ut_a(page_zip_validate_low(page_zip, page, TRUE)); ut_a(page_zip_validate_low(page_zip, page, index, TRUE));
} }
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
ut_ad(buf_block_get_frame(block) == page); ut_ad(buf_block_get_frame(block) == page);
...@@ -945,7 +945,7 @@ page_delete_rec_list_end( ...@@ -945,7 +945,7 @@ page_delete_rec_list_end(
ut_ad(size == ULINT_UNDEFINED || size < UNIV_PAGE_SIZE); ut_ad(size == ULINT_UNDEFINED || size < UNIV_PAGE_SIZE);
ut_ad(!page_zip || page_rec_is_comp(rec)); ut_ad(!page_zip || page_rec_is_comp(rec));
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(!page_zip || page_zip_validate(page_zip, page)); ut_a(!page_zip || page_zip_validate(page_zip, page, index));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
if (page_rec_is_infimum(rec)) { if (page_rec_is_infimum(rec)) {
...@@ -987,7 +987,7 @@ page_delete_rec_list_end( ...@@ -987,7 +987,7 @@ page_delete_rec_list_end(
ULINT_UNDEFINED, &heap); ULINT_UNDEFINED, &heap);
rec = rec_get_next_ptr(rec, TRUE); rec = rec_get_next_ptr(rec, TRUE);
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(page_zip_validate(page_zip, page)); ut_a(page_zip_validate(page_zip, page, index));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
page_cur_delete_rec(&cur, index, offsets, mtr); page_cur_delete_rec(&cur, index, offsets, mtr);
} while (page_offset(rec) != PAGE_NEW_SUPREMUM); } while (page_offset(rec) != PAGE_NEW_SUPREMUM);
...@@ -1127,7 +1127,8 @@ page_delete_rec_list_start( ...@@ -1127,7 +1127,8 @@ page_delete_rec_list_start(
between btr_attach_half_pages() and insert_page = ... between btr_attach_half_pages() and insert_page = ...
when btr_page_get_split_rec_to_left() holds when btr_page_get_split_rec_to_left() holds
(direction == FSP_DOWN). */ (direction == FSP_DOWN). */
ut_a(!page_zip || page_zip_validate_low(page_zip, page, TRUE)); ut_a(!page_zip
|| page_zip_validate_low(page_zip, page, index, TRUE));
} }
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
...@@ -1198,9 +1199,10 @@ page_move_rec_list_end( ...@@ -1198,9 +1199,10 @@ page_move_rec_list_end(
= buf_block_get_page_zip(block); = buf_block_get_page_zip(block);
ut_a(!new_page_zip == !page_zip); ut_a(!new_page_zip == !page_zip);
ut_a(!new_page_zip ut_a(!new_page_zip
|| page_zip_validate(new_page_zip, new_page)); || page_zip_validate(new_page_zip, new_page, index));
ut_a(!page_zip ut_a(!page_zip
|| page_zip_validate(page_zip, page_align(split_rec))); || page_zip_validate(page_zip, page_align(split_rec),
index));
} }
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
......
...@@ -1433,7 +1433,7 @@ err_exit: ...@@ -1433,7 +1433,7 @@ err_exit:
page_zip_get_size(page_zip) - PAGE_DATA); page_zip_get_size(page_zip) - PAGE_DATA);
mem_heap_free(heap); mem_heap_free(heap);
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(page_zip_validate(page_zip, page)); ut_a(page_zip_validate(page_zip, page, index));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
if (mtr) { if (mtr) {
...@@ -3119,6 +3119,7 @@ page_zip_validate_low( ...@@ -3119,6 +3119,7 @@ page_zip_validate_low(
/*==================*/ /*==================*/
const page_zip_des_t* page_zip,/*!< in: compressed page */ const page_zip_des_t* page_zip,/*!< in: compressed page */
const page_t* page, /*!< in: uncompressed page */ const page_t* page, /*!< in: uncompressed page */
const dict_index_t* index, /*!< in: index of the page, if known */
ibool sloppy) /*!< in: FALSE=strict, ibool sloppy) /*!< in: FALSE=strict,
TRUE=ignore the MIN_REC_FLAG */ TRUE=ignore the MIN_REC_FLAG */
{ {
...@@ -3206,39 +3207,102 @@ page_zip_validate_low( ...@@ -3206,39 +3207,102 @@ page_zip_validate_low(
committed. Let us tolerate that difference when we committed. Let us tolerate that difference when we
are performing a sloppy validation. */ are performing a sloppy validation. */
if (sloppy) { ulint* offsets;
byte info_bits_diff; mem_heap_t* heap;
ulint offset const rec_t* rec;
= rec_get_next_offs(page + PAGE_NEW_INFIMUM, const rec_t* trec;
TRUE); byte info_bits_diff;
ut_a(offset >= PAGE_NEW_SUPREMUM); ulint offset
offset -= 5 /* REC_NEW_INFO_BITS */; = rec_get_next_offs(page + PAGE_NEW_INFIMUM, TRUE);
ut_a(offset >= PAGE_NEW_SUPREMUM);
info_bits_diff = page[offset] ^ temp_page[offset]; offset -= 5/*REC_NEW_INFO_BITS*/;
if (info_bits_diff == REC_INFO_MIN_REC_FLAG) { info_bits_diff = page[offset] ^ temp_page[offset];
temp_page[offset] = page[offset];
if (info_bits_diff == REC_INFO_MIN_REC_FLAG) {
if (!memcmp(page + PAGE_HEADER, temp_page[offset] = page[offset];
temp_page + PAGE_HEADER,
UNIV_PAGE_SIZE - PAGE_HEADER if (!memcmp(page + PAGE_HEADER,
- FIL_PAGE_DATA_END)) { temp_page + PAGE_HEADER,
UNIV_PAGE_SIZE - PAGE_HEADER
/* Only the minimum record flag - FIL_PAGE_DATA_END)) {
differed. Let us ignore it. */
page_zip_fail(("page_zip_validate: " /* Only the minimum record flag
"min_rec_flag " differed. Let us ignore it. */
"(ignored, " page_zip_fail(("page_zip_validate: "
"%lu,%lu,0x%02lx)\n", "min_rec_flag "
page_get_space_id(page), "(%s"
page_get_page_no(page), "%lu,%lu,0x%02lx)\n",
(ulong) page[offset])); sloppy ? "ignored, " : "",
goto func_exit; page_get_space_id(page),
page_get_page_no(page),
(ulong) page[offset]));
valid = sloppy;
goto func_exit;
}
}
/* Compare the pointers in the PAGE_FREE list. */
rec = page_header_get_ptr(page, PAGE_FREE);
trec = page_header_get_ptr(temp_page, PAGE_FREE);
while (rec || trec) {
if (page_offset(rec) != page_offset(trec)) {
page_zip_fail(("page_zip_validate: "
"PAGE_FREE list: %u!=%u\n",
(unsigned) page_offset(rec),
(unsigned) page_offset(trec)));
valid = FALSE;
goto func_exit;
}
rec = page_rec_get_next_low(rec, TRUE);
trec = page_rec_get_next_low(trec, TRUE);
}
/* Compare the records. */
heap = NULL;
offsets = NULL;
rec = page_rec_get_next_low(
page + PAGE_NEW_INFIMUM, TRUE);
trec = page_rec_get_next_low(
temp_page + PAGE_NEW_INFIMUM, TRUE);
do {
if (page_offset(rec) != page_offset(trec)) {
page_zip_fail(("page_zip_validate: "
"record list: 0x%02x!=0x%02x\n",
(unsigned) page_offset(rec),
(unsigned) page_offset(trec)));
valid = FALSE;
break;
}
if (index) {
/* Compare the data. */
offsets = rec_get_offsets(
rec, index, offsets,
ULINT_UNDEFINED, &heap);
if (memcmp(rec - rec_offs_extra_size(offsets),
trec - rec_offs_extra_size(offsets),
rec_offs_size(offsets))) {
page_zip_fail(
("page_zip_validate: "
"record content: 0x%02x",
(unsigned) page_offset(rec)));
valid = FALSE;
break;
} }
} }
rec = page_rec_get_next_low(rec, TRUE);
trec = page_rec_get_next_low(trec, TRUE);
} while (rec || trec);
if (heap) {
mem_heap_free(heap);
} }
page_zip_fail(("page_zip_validate: content\n"));
valid = FALSE;
} }
func_exit: func_exit:
...@@ -3260,9 +3324,10 @@ ibool ...@@ -3260,9 +3324,10 @@ ibool
page_zip_validate( page_zip_validate(
/*==============*/ /*==============*/
const page_zip_des_t* page_zip,/*!< in: compressed page */ const page_zip_des_t* page_zip,/*!< in: compressed page */
const page_t* page) /*!< in: uncompressed page */ const page_t* page, /*!< in: uncompressed page */
const dict_index_t* index) /*!< in: index of the page, if known */
{ {
return(page_zip_validate_low(page_zip, page, return(page_zip_validate_low(page_zip, page, index,
recv_recovery_is_on())); recv_recovery_is_on()));
} }
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
...@@ -3593,7 +3658,7 @@ page_zip_write_rec( ...@@ -3593,7 +3658,7 @@ page_zip_write_rec(
page_zip->m_nonempty = TRUE; page_zip->m_nonempty = TRUE;
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(page_zip_validate(page_zip, page_align(rec))); ut_a(page_zip_validate(page_zip, page_align(rec), index));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
} }
...@@ -3640,7 +3705,7 @@ corrupt: ...@@ -3640,7 +3705,7 @@ corrupt:
} }
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(page_zip_validate(page_zip, page)); ut_a(page_zip_validate(page_zip, page, NULL));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
memcpy(page + offset, memcpy(page + offset,
...@@ -3649,7 +3714,7 @@ corrupt: ...@@ -3649,7 +3714,7 @@ corrupt:
ptr + 4, BTR_EXTERN_FIELD_REF_SIZE); ptr + 4, BTR_EXTERN_FIELD_REF_SIZE);
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(page_zip_validate(page_zip, page)); ut_a(page_zip_validate(page_zip, page, NULL));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
} }
...@@ -3716,7 +3781,7 @@ page_zip_write_blob_ptr( ...@@ -3716,7 +3781,7 @@ page_zip_write_blob_ptr(
memcpy(externs, field, BTR_EXTERN_FIELD_REF_SIZE); memcpy(externs, field, BTR_EXTERN_FIELD_REF_SIZE);
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(page_zip_validate(page_zip, page)); ut_a(page_zip_validate(page_zip, page, index));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
if (mtr) { if (mtr) {
...@@ -3787,7 +3852,7 @@ corrupt: ...@@ -3787,7 +3852,7 @@ corrupt:
} }
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(page_zip_validate(page_zip, page)); ut_a(page_zip_validate(page_zip, page, NULL));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
field = page + offset; field = page + offset;
...@@ -3808,7 +3873,7 @@ corrupt: ...@@ -3808,7 +3873,7 @@ corrupt:
memcpy(storage, ptr + 4, REC_NODE_PTR_SIZE); memcpy(storage, ptr + 4, REC_NODE_PTR_SIZE);
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(page_zip_validate(page_zip, page)); ut_a(page_zip_validate(page_zip, page, NULL));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
} }
...@@ -4035,7 +4100,7 @@ page_zip_clear_rec( ...@@ -4035,7 +4100,7 @@ page_zip_clear_rec(
} }
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(page_zip_validate(page_zip, page)); ut_a(page_zip_validate(page_zip, page, index));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
} }
...@@ -4059,7 +4124,7 @@ page_zip_rec_set_deleted( ...@@ -4059,7 +4124,7 @@ page_zip_rec_set_deleted(
*slot &= ~(PAGE_ZIP_DIR_SLOT_DEL >> 8); *slot &= ~(PAGE_ZIP_DIR_SLOT_DEL >> 8);
} }
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(page_zip_validate(page_zip, page_align(rec))); ut_a(page_zip_validate(page_zip, page_align(rec), NULL));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
} }
...@@ -4360,14 +4425,14 @@ corrupt: ...@@ -4360,14 +4425,14 @@ corrupt:
goto corrupt; goto corrupt;
} }
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(page_zip_validate(page_zip, page)); ut_a(page_zip_validate(page_zip, page, NULL));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
memcpy(page + offset, ptr, len); memcpy(page + offset, ptr, len);
memcpy(page_zip->data + offset, ptr, len); memcpy(page_zip->data + offset, ptr, len);
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(page_zip_validate(page_zip, page)); ut_a(page_zip_validate(page_zip, page, NULL));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
} }
...@@ -4442,7 +4507,7 @@ page_zip_reorganize( ...@@ -4442,7 +4507,7 @@ page_zip_reorganize(
ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX)); ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
ut_ad(page_is_comp(page)); ut_ad(page_is_comp(page));
ut_ad(!dict_index_is_ibuf(index)); ut_ad(!dict_index_is_ibuf(index));
/* Note that page_zip_validate(page_zip, page) may fail here. */ /* Note that page_zip_validate(page_zip, page, index) may fail here. */
UNIV_MEM_ASSERT_RW(page, UNIV_PAGE_SIZE); UNIV_MEM_ASSERT_RW(page, UNIV_PAGE_SIZE);
UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip)); UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip));
...@@ -4529,7 +4594,7 @@ page_zip_copy_recs( ...@@ -4529,7 +4594,7 @@ page_zip_copy_recs(
FIL_PAGE_PREV or PAGE_LEVEL, causing a temporary min_rec_flag FIL_PAGE_PREV or PAGE_LEVEL, causing a temporary min_rec_flag
mismatch. A strict page_zip_validate() will be executed later mismatch. A strict page_zip_validate() will be executed later
during the B-tree operations. */ during the B-tree operations. */
ut_a(page_zip_validate_low(src_zip, src, TRUE)); ut_a(page_zip_validate_low(src_zip, src, index, TRUE));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
ut_a(page_zip_get_size(page_zip) == page_zip_get_size(src_zip)); ut_a(page_zip_get_size(page_zip) == page_zip_get_size(src_zip));
if (UNIV_UNLIKELY(src_zip->n_blobs)) { if (UNIV_UNLIKELY(src_zip->n_blobs)) {
...@@ -4590,7 +4655,7 @@ page_zip_copy_recs( ...@@ -4590,7 +4655,7 @@ page_zip_copy_recs(
} }
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
ut_a(page_zip_validate(page_zip, page)); ut_a(page_zip_validate(page_zip, page, index));
#endif /* UNIV_ZIP_DEBUG */ #endif /* UNIV_ZIP_DEBUG */
btr_blob_dbg_add(page, index, "page_zip_copy_recs"); btr_blob_dbg_add(page, index, "page_zip_copy_recs");
......
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