Commit bb638768 authored by marko's avatar marko

branches/zip: Minor improvements.

buf_flush_init_for_writing(): Calculate the checksum with the actual zip_size.

buf_calc_zblob_page_checksum(): Skip the field FIL_PAGE_SPACE_OR_CHKSUM.

trx_sys_doublewrite_init_or_restore_page(): Use the actual zip_size.

page_cur_insert_rec_low(): If page_zip_alloc() fails, try compressing the
whole page afterwards.
parent 5d591705
......@@ -244,8 +244,8 @@ buf_calc_zblob_page_checksum(
const byte* page, /* in: compressed BLOB page */
ulint zip_size) /* in: size of the page, in bytes */
{
return(ut_fold_binary(page + FIL_PAGE_SPACE_OR_CHKSUM,
zip_size - FIL_PAGE_SPACE_OR_CHKSUM) & 0xFFFFFFFFUL);
return(ut_fold_binary(page + FIL_PAGE_OFFSET,
zip_size - FIL_PAGE_OFFSET) & 0xFFFFFFFFUL);
}
/************************************************************************
......
......@@ -454,8 +454,9 @@ buf_flush_init_for_writing(
ulint page_no) /* in: page number */
{
page_zip_des_t* page_zip = page_zip_;
ulint zip_size = fil_space_get_zip_size(space);
if (fil_space_get_zip_size(space)) {
if (zip_size) {
switch (fil_page_get_type(page)) {
case FIL_PAGE_TYPE_ZBLOB:
ut_ad(!page_zip);
......@@ -465,7 +466,7 @@ buf_flush_init_for_writing(
mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM,
srv_use_checksums
? buf_calc_zblob_page_checksum(
page, 16384/* TODO */)
page, zip_size)
: BUF_NO_CHECKSUM_MAGIC);
return;
case FIL_PAGE_INDEX:
......
......@@ -905,6 +905,7 @@ page_cur_insert_rec_low(
ulint heap_no; /* heap number of the inserted record */
rec_t* current_rec; /* current record after which the
new record is inserted */
page_zip_des_t* page_zip_orig = page_zip;
ut_ad(cursor && mtr);
ut_ad(rec_offs_validate(rec, index, offsets));
......@@ -923,7 +924,8 @@ page_cur_insert_rec_low(
if (UNIV_LIKELY_NULL(page_zip)
&& !page_zip_alloc(page_zip, page, index, rec_size, 1, mtr)) {
return(NULL);
/* Try compressing the whole page afterwards. */
page_zip = NULL;
}
insert_buf = page_header_get_ptr(page, PAGE_FREE);
......@@ -1107,6 +1109,15 @@ use_heap:
page_zip_dir_rewrite(page_zip, page);
page_zip_write_rec(page_zip, insert_rec, index, offsets, 1);
} else if (UNIV_LIKELY_NULL(page_zip_orig)) {
/* Recompress the page. */
if (!page_zip_compress(page_zip_orig, page, index)) {
/* Out of space: restore the page */
if (!page_zip_decompress(page_zip_orig, page)) {
ut_error; /* Memory corrupted? */
}
return(NULL);
}
}
/* 9. Write log record of the insert */
......
......@@ -472,9 +472,8 @@ trx_sys_doublewrite_init_or_restore_pages(
UNIV_PAGE_SIZE, read_buf, NULL);
/* Check if the page is corrupt */
if (space_id && fil_page_get_type(read_buf)
== FIL_PAGE_TYPE_ZBLOB) {
zip_size = 16384; /* TODO */
if (space_id) {
zip_size = fil_space_get_zip_size(space_id);
} else {
zip_size = 0;
}
......
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