Commit 2f435d29 authored by marko's avatar marko

branches/zip: Minor improvements.

page_dir_set_n_slots(): Add debug assertion that there will be enough space
available in the modification log of the compressed page.
page_trailer_get_len(): Simplify the formula.  Make more use of the function.
parent d8f576e7
......@@ -433,6 +433,17 @@ page_dir_set_n_slots(
uncompressed part will be updated, or NULL */
ulint n_slots)/* in: number of slots */
{
#ifdef UNIV_DEBUG
if (UNIV_LIKELY_NULL(page_zip)) {
/* Ensure that the modification log will not be overwritten. */
ulint n_slots_old = page_dir_get_n_slots(page);
if (n_slots > n_slots_old) {
ut_ad(page_zip_available(page_zip,
(n_slots - n_slots_old)
* PAGE_DIR_SLOT_SIZE));
}
}
#endif /* UNIV_DEBUG */
page_header_set_field(page, page_zip, PAGE_N_DIR_SLOTS, n_slots);
}
......@@ -445,9 +456,8 @@ page_trailer_get_len(
/* out: length of page trailer, in bytes */
const page_t* page) /* in: index page */
{
return(page + UNIV_PAGE_SIZE
- page_dir_get_nth_slot((page_t*) page,
page_dir_get_n_slots((page_t*) page) - 1));
return(PAGE_DIR + PAGE_DIR_SLOT_SIZE
* page_dir_get_n_slots((page_t*) page));
}
/*****************************************************************
......
......@@ -122,8 +122,7 @@ page_zip_alloc(
const page_t* page, /* in: uncompressed page */
ulint size) /* in: size of modification log entries */
{
ulint trailer_len = PAGE_DIR + PAGE_DIR_SLOT_SIZE
* page_dir_get_n_slots((page_t*) page_zip->data);
ulint trailer_len = page_trailer_get_len(page_zip->data);
ut_ad(page_zip_simple_validate(page_zip));
ut_ad(page_zip->m_end + trailer_len < page_zip->size);
......@@ -155,12 +154,10 @@ page_zip_available(
ulint size) /* in: requested size of
modification log entries */
{
ulint trailer_len = PAGE_DIR + PAGE_DIR_SLOT_SIZE
* page_dir_get_n_slots((page_t*) page_zip->data);
ulint trailer_len = page_trailer_get_len(page_zip->data);
ut_ad(page_zip_simple_validate(page_zip));
ut_ad(page_zip->m_end + trailer_len < page_zip->size);
ut_ad(size >= 3); /* modification log entries are >= 1+1+1 bytes */
ut_ad(size < page_zip->size);
return(UNIV_LIKELY(
......
......@@ -159,9 +159,7 @@ page_zip_decompress(
ulint trailer_len;
ut_ad(page_zip_simple_validate(page_zip));
trailer_len = PAGE_DIR
+ PAGE_DIR_SLOT_SIZE
* page_dir_get_n_slots((page_t*) page_zip->data);
trailer_len = page_trailer_get_len(page_zip->data);
ut_ad(trailer_len < page_zip->size - PAGE_DATA);
ut_ad(page_header_get_field((page_t*) page_zip->data, PAGE_HEAP_TOP)
<= UNIV_PAGE_SIZE - trailer_len);
......@@ -278,9 +276,7 @@ page_zip_write(
{
ulint pos = ut_align_offset(str, UNIV_PAGE_SIZE);
#ifdef UNIV_DEBUG
ulint trailer_len = PAGE_DIR
+ PAGE_DIR_SLOT_SIZE
* page_dir_get_n_slots((page_t*) page_zip->data);
ulint trailer_len = page_trailer_get_len(page_zip->data);
#endif /* UNIV_DEBUG */
ut_ad(buf_block_get_page_zip(buf_block_align((byte*)str)) == page_zip);
......
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