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( ...@@ -3722,9 +3722,9 @@ btr_store_big_rec_extern_fields(
FIL_PAGE_TYPE_ZBLOB); FIL_PAGE_TYPE_ZBLOB);
c_stream.next_out = page c_stream.next_out = page
+ FIL_PAGE_ZBLOB_DATA; + FIL_PAGE_DATA;
c_stream.avail_out = page_zip->size c_stream.avail_out = page_zip->size
- FIL_PAGE_ZBLOB_DATA; - FIL_PAGE_DATA;
err = deflate(&c_stream, Z_FINISH); err = deflate(&c_stream, Z_FINISH);
ut_a(err == Z_OK || err == Z_STREAM_END); ut_a(err == Z_OK || err == Z_STREAM_END);
...@@ -3734,6 +3734,9 @@ btr_store_big_rec_extern_fields( ...@@ -3734,6 +3734,9 @@ btr_store_big_rec_extern_fields(
/* Write the "next BLOB page" pointer */ /* Write the "next BLOB page" pointer */
mlog_write_ulint(page + FIL_PAGE_NEXT, mlog_write_ulint(page + FIL_PAGE_NEXT,
FIL_NULL, MLOG_4BYTES, &mtr); 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. */ /* Zero out the unused part of the page. */
memset(page + page_zip->size memset(page + page_zip->size
- c_stream.avail_out, - c_stream.avail_out,
...@@ -4204,7 +4207,7 @@ btr_copy_externally_stored_field_prefix_low( ...@@ -4204,7 +4207,7 @@ btr_copy_externally_stored_field_prefix_low(
/* When the BLOB begins at page header, /* When the BLOB begins at page header,
the compressed data payload does not the compressed data payload does not
immediately follow the next page pointer. */ immediately follow the next page pointer. */
offset = FIL_PAGE_ZBLOB_DATA; offset = FIL_PAGE_DATA;
} else { } else {
offset += 4; offset += 4;
} }
......
...@@ -450,7 +450,8 @@ buf_page_print( ...@@ -450,7 +450,8 @@ buf_page_print(
(ulong) mach_read_from_4( (ulong) mach_read_from_4(
read_buf + FIL_PAGE_OFFSET), read_buf + FIL_PAGE_OFFSET),
(ulong) mach_read_from_4( (ulong) mach_read_from_4(
read_buf + FIL_PAGE_ZBLOB_SPACE_ID)); read_buf
+ FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID));
return; return;
default: default:
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
...@@ -1980,15 +1981,8 @@ buf_page_io_complete( ...@@ -1980,15 +1981,8 @@ buf_page_io_complete(
doublewrite buffer, then the page number and space id doublewrite buffer, then the page number and space id
should be the same as in block. */ should be the same as in block. */
read_page_no = mach_read_from_4(frame + FIL_PAGE_OFFSET); read_page_no = mach_read_from_4(frame + FIL_PAGE_OFFSET);
switch (fil_page_get_type(frame)) { read_space_id = mach_read_from_4(
case FIL_PAGE_TYPE_ZBLOB: frame + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
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 if (!block->space
&& trx_doublewrite_page_inside(block->offset)) { && trx_doublewrite_page_inside(block->offset)) {
......
...@@ -515,22 +515,6 @@ buf_flush_init_for_writing( ...@@ -515,22 +515,6 @@ buf_flush_init_for_writing(
ut_ad(zip_size <= UNIV_PAGE_SIZE); ut_ad(zip_size <= UNIV_PAGE_SIZE);
switch (UNIV_EXPECT(fil_page_get_type(page), FIL_PAGE_INDEX)) { 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_TYPE_ALLOCATED:
case FIL_PAGE_INODE: case FIL_PAGE_INODE:
case FIL_PAGE_IBUF_BITMAP: case FIL_PAGE_IBUF_BITMAP:
...@@ -539,6 +523,7 @@ buf_flush_init_for_writing( ...@@ -539,6 +523,7 @@ buf_flush_init_for_writing(
/* These are essentially uncompressed pages. */ /* These are essentially uncompressed pages. */
memcpy(page_zip->data, page, zip_size); memcpy(page_zip->data, page, zip_size);
/* fall through */ /* fall through */
case FIL_PAGE_TYPE_ZBLOB:
case FIL_PAGE_INDEX: case FIL_PAGE_INDEX:
mach_write_to_4(page mach_write_to_4(page
+ FIL_PAGE_OFFSET, page_no); + FIL_PAGE_OFFSET, page_no);
......
...@@ -62,8 +62,6 @@ extern fil_addr_t fil_addr_null; ...@@ -62,8 +62,6 @@ extern fil_addr_t fil_addr_null;
This field is not set on BLOB pages, This field is not set on BLOB pages,
which are stored as a singly-linked which are stored as a singly-linked
list. See also FIL_PAGE_NEXT. */ 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 #define FIL_PAGE_NEXT 12 /* if there is a 'natural' successor
of the page, its offset. of the page, its offset.
Otherwise FIL_NULL. Otherwise FIL_NULL.
...@@ -95,8 +93,6 @@ extern fil_addr_t fil_addr_null; ...@@ -95,8 +93,6 @@ extern fil_addr_t fil_addr_null;
first page in a data file: the file first page in a data file: the file
has been flushed to disk at least up has been flushed to disk at least up
to this lsn */ 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 #define FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID 34 /* starting from 4.1.x this
contains the space id of the page */ contains the space id of the page */
#define FIL_PAGE_DATA 38 /* start of the data on 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