Commit 71e8ea62 authored by marko's avatar marko

branches/zip: Replace FIL_PAGE_ZBLOB_SPACE_ID and FIL_PAGE_ZBLOB_DATA

with FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID and FIL_PAGE_DATA.  The doublewrite
buffer needs to read the space_id in order to determine the type of the page.
Because FIL_PAGE_TYPE could contain garbage in MySQL/InnoDB 5.0 and earlier
versions, we cannot trust fil_page_get_type().  Instead, we have to always
store the space_id at the same location.  This modification wastes 12 bytes
per compressed BLOB page (1.2% on 1-kilobyte pages).
parent 732d2f32
......@@ -3722,9 +3722,9 @@ btr_store_big_rec_extern_fields(
FIL_PAGE_TYPE_ZBLOB);
c_stream.next_out = page
+ FIL_PAGE_ZBLOB_DATA;
+ FIL_PAGE_DATA;
c_stream.avail_out = page_zip->size
- FIL_PAGE_ZBLOB_DATA;
- FIL_PAGE_DATA;
err = deflate(&c_stream, Z_FINISH);
ut_a(err == Z_OK || err == Z_STREAM_END);
......@@ -3734,6 +3734,9 @@ btr_store_big_rec_extern_fields(
/* Write the "next BLOB page" pointer */
mlog_write_ulint(page + FIL_PAGE_NEXT,
FIL_NULL, MLOG_4BYTES, &mtr);
/* Initialize the unused "prev page" pointer */
mlog_write_ulint(page + FIL_PAGE_PREV,
FIL_NULL, MLOG_4BYTES, &mtr);
/* Zero out the unused part of the page. */
memset(page + page_zip->size
- c_stream.avail_out,
......@@ -4204,7 +4207,7 @@ btr_copy_externally_stored_field_prefix_low(
/* When the BLOB begins at page header,
the compressed data payload does not
immediately follow the next page pointer. */
offset = FIL_PAGE_ZBLOB_DATA;
offset = FIL_PAGE_DATA;
} else {
offset += 4;
}
......
......@@ -450,7 +450,8 @@ buf_page_print(
(ulong) mach_read_from_4(
read_buf + FIL_PAGE_OFFSET),
(ulong) mach_read_from_4(
read_buf + FIL_PAGE_ZBLOB_SPACE_ID));
read_buf
+ FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID));
return;
default:
ut_print_timestamp(stderr);
......@@ -1980,15 +1981,8 @@ buf_page_io_complete(
doublewrite buffer, then the page number and space id
should be the same as in block. */
read_page_no = mach_read_from_4(frame + FIL_PAGE_OFFSET);
switch (fil_page_get_type(frame)) {
case FIL_PAGE_TYPE_ZBLOB:
read_space_id = mach_read_from_4(
frame + FIL_PAGE_ZBLOB_SPACE_ID);
break;
default:
read_space_id = mach_read_from_4(
frame + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
}
if (!block->space
&& trx_doublewrite_page_inside(block->offset)) {
......
......@@ -515,22 +515,6 @@ buf_flush_init_for_writing(
ut_ad(zip_size <= UNIV_PAGE_SIZE);
switch (UNIV_EXPECT(fil_page_get_type(page), FIL_PAGE_INDEX)) {
case FIL_PAGE_TYPE_ZBLOB:
ut_ad(fil_page_get_type(page_zip->data)
== FIL_PAGE_TYPE_ZBLOB);
mach_write_to_4(page_zip->data
+ FIL_PAGE_OFFSET, page_no);
mach_write_to_4(page_zip->data
+ FIL_PAGE_ZBLOB_SPACE_ID, space);
mach_write_to_8(page_zip->data
+ FIL_PAGE_LSN, newest_lsn);
mach_write_to_4(page_zip->data
+ FIL_PAGE_SPACE_OR_CHKSUM,
srv_use_checksums
? page_zip_calc_checksum(
page_zip->data, zip_size)
: BUF_NO_CHECKSUM_MAGIC);
return;
case FIL_PAGE_TYPE_ALLOCATED:
case FIL_PAGE_INODE:
case FIL_PAGE_IBUF_BITMAP:
......@@ -539,6 +523,7 @@ buf_flush_init_for_writing(
/* These are essentially uncompressed pages. */
memcpy(page_zip->data, page, zip_size);
/* fall through */
case FIL_PAGE_TYPE_ZBLOB:
case FIL_PAGE_INDEX:
mach_write_to_4(page
+ FIL_PAGE_OFFSET, page_no);
......
......@@ -62,8 +62,6 @@ extern fil_addr_t fil_addr_null;
This field is not set on BLOB pages,
which are stored as a singly-linked
list. See also FIL_PAGE_NEXT. */
#define FIL_PAGE_ZBLOB_SPACE_ID 8 /* space id of a compressed BLOB page,
4 bytes */
#define FIL_PAGE_NEXT 12 /* if there is a 'natural' successor
of the page, its offset.
Otherwise FIL_NULL.
......@@ -95,8 +93,6 @@ extern fil_addr_t fil_addr_null;
first page in a data file: the file
has been flushed to disk at least up
to this lsn */
#define FIL_PAGE_ZBLOB_DATA 26 /* start of data stream on a
FIL_PAGE_TYPE_ZBLOB page */
#define FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID 34 /* starting from 4.1.x this
contains the space id of the page */
#define FIL_PAGE_DATA 38 /* start of the data on the page */
......
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