Commit 15d01d3e authored by marko's avatar marko

branches/zip: Add some more Valgrind instrumentation.

page_zip_write_rec(), page_zip_write_blob_ptr(), page_zip_write_node_ptr(),
page_zip_write_trx_id_and_roll_ptr(), page_zip_clear_rec(),
page_zip_rec_set_deleted(), page_zip_rec_set_owned(), page_zip_dir_insert(),
page_zip_dir_delete(), page_zip_dir_add_slot(), page_zip_reorganize(),
page_zip_copy(), page_zip_get_trailer_len(), page_zip_write_header():
Assert that the complete contents of the compressed page is defined.
parent f8e3c447
...@@ -215,6 +215,7 @@ page_zip_get_trailer_len( ...@@ -215,6 +215,7 @@ page_zip_get_trailer_len(
ulint uncompressed_size; ulint uncompressed_size;
ut_ad(page_zip_simple_validate(page_zip)); ut_ad(page_zip_simple_validate(page_zip));
UNIV_MEM_ASSERT_RW(page_zip, page_zip_get_size(page_zip));
if (UNIV_UNLIKELY(!page_is_leaf(page_zip->data))) { if (UNIV_UNLIKELY(!page_is_leaf(page_zip->data))) {
uncompressed_size = PAGE_ZIP_DIR_SLOT_SIZE uncompressed_size = PAGE_ZIP_DIR_SLOT_SIZE
...@@ -355,6 +356,7 @@ page_zip_write_header( ...@@ -355,6 +356,7 @@ page_zip_write_header(
ut_ad(buf_frame_get_page_zip(str) == page_zip); ut_ad(buf_frame_get_page_zip(str) == page_zip);
ut_ad(page_zip_simple_validate(page_zip)); ut_ad(page_zip_simple_validate(page_zip));
UNIV_MEM_ASSERT_RW(page_zip, page_zip_get_size(page_zip));
pos = page_offset(str); pos = page_offset(str);
......
...@@ -2888,6 +2888,7 @@ page_zip_write_rec( ...@@ -2888,6 +2888,7 @@ page_zip_write_rec(
ut_ad(page_zip_header_cmp(page_zip, page)); ut_ad(page_zip_header_cmp(page_zip, page));
ut_ad(page_simple_validate_new((page_t*) page)); ut_ad(page_simple_validate_new((page_t*) page));
UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip));
UNIV_MEM_ASSERT_RW(rec, rec_offs_data_size(offsets)); UNIV_MEM_ASSERT_RW(rec, rec_offs_data_size(offsets));
UNIV_MEM_ASSERT_RW(rec - rec_offs_extra_size(offsets), UNIV_MEM_ASSERT_RW(rec - rec_offs_extra_size(offsets),
rec_offs_extra_size(offsets)); rec_offs_extra_size(offsets));
...@@ -3141,6 +3142,7 @@ page_zip_write_blob_ptr( ...@@ -3141,6 +3142,7 @@ page_zip_write_blob_ptr(
ut_ad(page_is_leaf(page)); ut_ad(page_is_leaf(page));
ut_ad(dict_index_is_clust(index)); ut_ad(dict_index_is_clust(index));
UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip));
UNIV_MEM_ASSERT_RW(rec, rec_offs_data_size(offsets)); UNIV_MEM_ASSERT_RW(rec, rec_offs_data_size(offsets));
UNIV_MEM_ASSERT_RW(rec - rec_offs_extra_size(offsets), UNIV_MEM_ASSERT_RW(rec - rec_offs_extra_size(offsets),
rec_offs_extra_size(offsets)); rec_offs_extra_size(offsets));
...@@ -3289,6 +3291,9 @@ page_zip_write_node_ptr( ...@@ -3289,6 +3291,9 @@ page_zip_write_node_ptr(
ut_ad(!page_is_leaf(page)); ut_ad(!page_is_leaf(page));
UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip));
UNIV_MEM_ASSERT_RW(rec, size);
storage = page_zip->data + page_zip_get_size(page_zip) storage = page_zip->data + page_zip_get_size(page_zip)
- (page_dir_get_n_heap(page) - PAGE_HEAP_NO_USER_LOW) - (page_dir_get_n_heap(page) - PAGE_HEAP_NO_USER_LOW)
* PAGE_ZIP_DIR_SLOT_SIZE * PAGE_ZIP_DIR_SLOT_SIZE
...@@ -3354,6 +3359,8 @@ page_zip_write_trx_id_and_roll_ptr( ...@@ -3354,6 +3359,8 @@ page_zip_write_trx_id_and_roll_ptr(
ut_ad(page_is_leaf(page)); ut_ad(page_is_leaf(page));
UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip));
storage = page_zip->data + page_zip_get_size(page_zip) storage = page_zip->data + page_zip_get_size(page_zip)
- (page_dir_get_n_heap(page) - PAGE_HEAP_NO_USER_LOW) - (page_dir_get_n_heap(page) - PAGE_HEAP_NO_USER_LOW)
* PAGE_ZIP_DIR_SLOT_SIZE * PAGE_ZIP_DIR_SLOT_SIZE
...@@ -3384,6 +3391,7 @@ page_zip_write_trx_id_and_roll_ptr( ...@@ -3384,6 +3391,7 @@ page_zip_write_trx_id_and_roll_ptr(
UNIV_MEM_ASSERT_RW(rec, rec_offs_data_size(offsets)); UNIV_MEM_ASSERT_RW(rec, rec_offs_data_size(offsets));
UNIV_MEM_ASSERT_RW(rec - rec_offs_extra_size(offsets), UNIV_MEM_ASSERT_RW(rec - rec_offs_extra_size(offsets),
rec_offs_extra_size(offsets)); rec_offs_extra_size(offsets));
UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip));
} }
#ifdef UNIV_ZIP_DEBUG #ifdef UNIV_ZIP_DEBUG
...@@ -3418,6 +3426,7 @@ page_zip_clear_rec( ...@@ -3418,6 +3426,7 @@ page_zip_clear_rec(
heap_no = rec_get_heap_no_new(rec); heap_no = rec_get_heap_no_new(rec);
ut_ad(heap_no >= PAGE_HEAP_NO_USER_LOW); ut_ad(heap_no >= PAGE_HEAP_NO_USER_LOW);
UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip));
UNIV_MEM_ASSERT_RW(rec, rec_offs_data_size(offsets)); UNIV_MEM_ASSERT_RW(rec, rec_offs_data_size(offsets));
UNIV_MEM_ASSERT_RW(rec - rec_offs_extra_size(offsets), UNIV_MEM_ASSERT_RW(rec - rec_offs_extra_size(offsets),
rec_offs_extra_size(offsets)); rec_offs_extra_size(offsets));
...@@ -3513,6 +3522,7 @@ page_zip_rec_set_deleted( ...@@ -3513,6 +3522,7 @@ page_zip_rec_set_deleted(
{ {
byte* slot = page_zip_dir_find(page_zip, page_offset(rec)); byte* slot = page_zip_dir_find(page_zip, page_offset(rec));
ut_a(slot); ut_a(slot);
UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip));
if (flag) { if (flag) {
*slot |= (PAGE_ZIP_DIR_SLOT_DEL >> 8); *slot |= (PAGE_ZIP_DIR_SLOT_DEL >> 8);
} else { } else {
...@@ -3533,6 +3543,7 @@ page_zip_rec_set_owned( ...@@ -3533,6 +3543,7 @@ page_zip_rec_set_owned(
{ {
byte* slot = page_zip_dir_find(page_zip, page_offset(rec)); byte* slot = page_zip_dir_find(page_zip, page_offset(rec));
ut_a(slot); ut_a(slot);
UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip));
if (flag) { if (flag) {
*slot |= (PAGE_ZIP_DIR_SLOT_OWNED >> 8); *slot |= (PAGE_ZIP_DIR_SLOT_OWNED >> 8);
} else { } else {
...@@ -3560,6 +3571,8 @@ page_zip_dir_insert( ...@@ -3560,6 +3571,8 @@ page_zip_dir_insert(
ut_ad(page_rec_get_next((rec_t*) prev_rec) == rec); ut_ad(page_rec_get_next((rec_t*) prev_rec) == rec);
ut_ad(page_zip_simple_validate(page_zip)); ut_ad(page_zip_simple_validate(page_zip));
UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip));
if (page_rec_is_infimum(prev_rec)) { if (page_rec_is_infimum(prev_rec)) {
/* Use the first slot. */ /* Use the first slot. */
slot_rec = page_zip->data + page_zip_get_size(page_zip); slot_rec = page_zip->data + page_zip_get_size(page_zip);
...@@ -3637,6 +3650,7 @@ page_zip_dir_delete( ...@@ -3637,6 +3650,7 @@ page_zip_dir_delete(
ut_ad(rec_offs_validate(rec, index, offsets)); ut_ad(rec_offs_validate(rec, index, offsets));
ut_ad(rec_offs_comp(offsets)); ut_ad(rec_offs_comp(offsets));
UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip));
UNIV_MEM_ASSERT_RW(rec, rec_offs_data_size(offsets)); UNIV_MEM_ASSERT_RW(rec, rec_offs_data_size(offsets));
UNIV_MEM_ASSERT_RW(rec - rec_offs_extra_size(offsets), UNIV_MEM_ASSERT_RW(rec - rec_offs_extra_size(offsets),
rec_offs_extra_size(offsets)); rec_offs_extra_size(offsets));
...@@ -3728,6 +3742,7 @@ page_zip_dir_add_slot( ...@@ -3728,6 +3742,7 @@ page_zip_dir_add_slot(
byte* stored; byte* stored;
ut_ad(page_is_comp(page_zip->data)); ut_ad(page_is_comp(page_zip->data));
UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip));
/* Read the old n_dense (n_heap has already been incremented). */ /* Read the old n_dense (n_heap has already been incremented). */
n_dense = page_dir_get_n_heap(page_zip->data) n_dense = page_dir_get_n_heap(page_zip->data)
...@@ -3893,6 +3908,8 @@ page_zip_reorganize( ...@@ -3893,6 +3908,8 @@ 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));
/* Note that page_zip_validate(page_zip, page) may fail here. */ /* Note that page_zip_validate(page_zip, page) may fail here. */
UNIV_MEM_ASSERT_RW(page, UNIV_PAGE_SIZE);
UNIV_MEM_ASSERT_RW(page_zip->data, page_zip_get_size(page_zip));
/* Disable logging */ /* Disable logging */
log_mode = mtr_set_log_mode(mtr, MTR_LOG_NONE); log_mode = mtr_set_log_mode(mtr, MTR_LOG_NONE);
...@@ -3963,6 +3980,11 @@ page_zip_copy( ...@@ -3963,6 +3980,11 @@ page_zip_copy(
ut_a(dict_index_is_clust(index)); ut_a(dict_index_is_clust(index));
} }
UNIV_MEM_ASSERT_W(page, UNIV_PAGE_SIZE);
UNIV_MEM_ASSERT_W(page_zip->data, page_zip_get_size(page_zip));
UNIV_MEM_ASSERT_RW(src, UNIV_PAGE_SIZE);
UNIV_MEM_ASSERT_RW(src_zip->data, page_zip_get_size(page_zip));
/* Skip the file page header and trailer. */ /* Skip the file page header and trailer. */
memcpy(page + FIL_PAGE_DATA, src + FIL_PAGE_DATA, memcpy(page + FIL_PAGE_DATA, src + FIL_PAGE_DATA,
UNIV_PAGE_SIZE - FIL_PAGE_DATA UNIV_PAGE_SIZE - FIL_PAGE_DATA
......
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