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