mirror of
https://github.com/MariaDB/server.git
synced 2025-01-19 21:42:35 +01:00
branches/zip: page_zip_des_t: Rename "size" to "ssize" and reduce the
storage size from 16 to 3 bits. page_zip_get_size(), page_zip_set_size(): New functions. Replace direct references to page_zip_des_t:size with calls to buf_block_get_zip_size(), page_zip_get_size(), and page_zip_set_size().
This commit is contained in:
parent
109570b94a
commit
82dfd0f6c7
12 changed files with 166 additions and 84 deletions
|
@ -1096,7 +1096,9 @@ btr_root_raise_and_insert(
|
|||
new_page = buf_block_get_frame(new_block);
|
||||
new_page_zip = buf_block_get_page_zip(new_block);
|
||||
ut_a(!new_page_zip == !root_page_zip);
|
||||
ut_a(!new_page_zip || new_page_zip->size == root_page_zip->size);
|
||||
ut_a(!new_page_zip
|
||||
|| page_zip_get_size(new_page_zip)
|
||||
== page_zip_get_size(root_page_zip));
|
||||
|
||||
btr_page_create(new_block, new_page_zip, index, level, mtr);
|
||||
|
||||
|
@ -1335,7 +1337,8 @@ btr_page_get_sure_split_rec(
|
|||
if (UNIV_LIKELY_NULL(page_zip)) {
|
||||
/* Estimate the free space of an empty compressed page. */
|
||||
ulint free_space_zip = page_zip_empty_size(
|
||||
cursor->index->n_fields, page_zip->size);
|
||||
cursor->index->n_fields,
|
||||
page_zip_get_size(page_zip));
|
||||
|
||||
if (UNIV_LIKELY(free_space > (ulint) free_space_zip)) {
|
||||
free_space = (ulint) free_space_zip;
|
||||
|
|
|
@ -1077,8 +1077,8 @@ btr_cur_optimistic_insert(
|
|||
/* Calculate the record size when entry is converted to a record */
|
||||
rec_size = rec_get_converted_size(index, entry, ext, n_ext);
|
||||
|
||||
if (page_zip_rec_needs_ext(rec_size, page_is_comp(page),
|
||||
page_zip ? page_zip->size : 0)) {
|
||||
if (page_zip_rec_needs_ext(rec_size, page_is_comp(page), page_zip
|
||||
? page_zip_get_size(page_zip) : 0)) {
|
||||
|
||||
/* The record is so big that we have to store some fields
|
||||
externally on separate database pages */
|
||||
|
@ -2103,8 +2103,8 @@ btr_cur_pessimistic_update(
|
|||
if (page_zip_rec_needs_ext(rec_get_converted_size(index, new_entry,
|
||||
ext_vect,
|
||||
n_ext_vect),
|
||||
page_is_comp(page),
|
||||
page_zip ? page_zip->size : 0)) {
|
||||
page_is_comp(page), page_zip
|
||||
? page_zip_get_size(page_zip) : 0)) {
|
||||
big_rec_vec = dtuple_convert_big_rec(index, new_entry,
|
||||
ext_vect, n_ext_vect);
|
||||
if (UNIV_UNLIKELY(big_rec_vec == NULL)) {
|
||||
|
@ -3724,7 +3724,8 @@ btr_store_big_rec_extern_fields(
|
|||
|
||||
c_stream.next_out = page
|
||||
+ FIL_PAGE_DATA;
|
||||
c_stream.avail_out = page_zip->size
|
||||
c_stream.avail_out
|
||||
= page_zip_get_size(page_zip)
|
||||
- FIL_PAGE_DATA;
|
||||
|
||||
err = deflate(&c_stream, Z_FINISH);
|
||||
|
@ -3759,20 +3760,22 @@ btr_store_big_rec_extern_fields(
|
|||
MLOG_4BYTES, &mtr);
|
||||
|
||||
/* Zero out the unused part of the page. */
|
||||
memset(page + page_zip->size
|
||||
memset(page + page_zip_get_size(page_zip)
|
||||
- c_stream.avail_out,
|
||||
0, c_stream.avail_out);
|
||||
mlog_log_string(page + FIL_PAGE_TYPE,
|
||||
page_zip->size - FIL_PAGE_TYPE,
|
||||
page_zip_get_size(page_zip)
|
||||
- FIL_PAGE_TYPE,
|
||||
&mtr);
|
||||
/* Copy the page to compressed storage,
|
||||
because it will be flushed to disk
|
||||
from there. */
|
||||
blob_page_zip = buf_block_get_page_zip(block);
|
||||
ut_ad(blob_page_zip);
|
||||
ut_ad(blob_page_zip->size == page_zip->size);
|
||||
ut_ad(page_zip_get_size(blob_page_zip)
|
||||
== page_zip_get_size(page_zip));
|
||||
memcpy(blob_page_zip->data, page,
|
||||
page_zip->size);
|
||||
page_zip_get_size(page_zip));
|
||||
/* TODO: retain blob_page_zip, release page */
|
||||
|
||||
if (err == Z_OK && prev_page_no != FIL_NULL) {
|
||||
|
|
|
@ -2126,7 +2126,7 @@ buf_page_io_complete(
|
|||
ulint read_space_id;
|
||||
byte* frame;
|
||||
|
||||
if (block->page.zip.size) {
|
||||
if (buf_block_get_zip_size(block)) {
|
||||
ut_a(buf_block_get_space(block) != 0);
|
||||
|
||||
frame = block->page.zip.data;
|
||||
|
@ -2149,7 +2149,7 @@ buf_page_io_complete(
|
|||
case FIL_PAGE_TYPE_ZBLOB:
|
||||
/* Copy to uncompressed storage. */
|
||||
memcpy(block->frame, frame,
|
||||
block->page.zip.size);
|
||||
buf_block_get_zip_size(block));
|
||||
break;
|
||||
default:
|
||||
ut_print_timestamp(stderr);
|
||||
|
@ -2204,7 +2204,8 @@ buf_page_io_complete(
|
|||
/* From version 3.23.38 up we store the page checksum
|
||||
to the 4 first bytes of the page end lsn field */
|
||||
|
||||
if (buf_page_is_corrupted(frame, block->page.zip.size)) {
|
||||
if (buf_page_is_corrupted(frame,
|
||||
buf_block_get_zip_size(block))) {
|
||||
corrupt:
|
||||
fprintf(stderr,
|
||||
"InnoDB: Database page corruption on disk"
|
||||
|
@ -2213,7 +2214,7 @@ corrupt:
|
|||
"InnoDB: You may have to recover"
|
||||
" from a backup.\n",
|
||||
(ulong) block->page.offset);
|
||||
buf_page_print(frame, block->page.zip.size);
|
||||
buf_page_print(frame, buf_block_get_zip_size(block));
|
||||
fprintf(stderr,
|
||||
"InnoDB: Database page corruption on disk"
|
||||
" or a failed\n"
|
||||
|
|
|
@ -381,12 +381,12 @@ flush:
|
|||
for (i = 0; i < trx_doublewrite->first_free; i++) {
|
||||
block = trx_doublewrite->buf_block_arr[i];
|
||||
ut_a(buf_block_get_state(block) == BUF_BLOCK_FILE_PAGE);
|
||||
if (UNIV_UNLIKELY(block->page.zip.size)) {
|
||||
if (UNIV_UNLIKELY(buf_block_get_zip_size(block))) {
|
||||
fil_io(OS_FILE_WRITE | OS_AIO_SIMULATED_WAKE_LATER,
|
||||
FALSE, buf_block_get_space(block),
|
||||
block->page.zip.size,
|
||||
buf_block_get_zip_size(block),
|
||||
buf_block_get_page_no(block), 0,
|
||||
block->page.zip.size,
|
||||
buf_block_get_zip_size(block),
|
||||
(void*)block->page.zip.data,
|
||||
(void*)block);
|
||||
continue;
|
||||
|
@ -463,7 +463,7 @@ try_again:
|
|||
goto try_again;
|
||||
}
|
||||
|
||||
zip_size = block->page.zip.size;
|
||||
zip_size = buf_block_get_zip_size(block);
|
||||
|
||||
if (UNIV_UNLIKELY(zip_size)) {
|
||||
/* Copy the compressed page and clear the rest. */
|
||||
|
@ -508,7 +508,7 @@ buf_flush_init_for_writing(
|
|||
{
|
||||
if (page_zip_) {
|
||||
page_zip_des_t* page_zip = page_zip_;
|
||||
ulint zip_size = page_zip->size;
|
||||
ulint zip_size = page_zip_get_size(page_zip);
|
||||
ut_ad(zip_size);
|
||||
ut_ad(ut_is_2pow(zip_size));
|
||||
ut_ad(zip_size <= UNIV_PAGE_SIZE);
|
||||
|
@ -600,10 +600,12 @@ buf_flush_write_block_low(
|
|||
buf_block_get_page_zip(block),
|
||||
block->newest_modification);
|
||||
if (!srv_use_doublewrite_buf || !trx_doublewrite) {
|
||||
ulint zip_size = buf_block_get_zip_size(block);
|
||||
|
||||
fil_io(OS_FILE_WRITE | OS_AIO_SIMULATED_WAKE_LATER,
|
||||
FALSE, buf_block_get_space(block), block->page.zip.size,
|
||||
buf_block_get_page_no(block), 0, block->page.zip.size
|
||||
? block->page.zip.size : UNIV_PAGE_SIZE,
|
||||
FALSE, buf_block_get_space(block), zip_size,
|
||||
buf_block_get_page_no(block), 0,
|
||||
zip_size ? zip_size : UNIV_PAGE_SIZE,
|
||||
(void*)block->frame, (void*)block);
|
||||
} else {
|
||||
buf_flush_post_to_doublewrite_buf(block);
|
||||
|
|
|
@ -26,6 +26,7 @@ Created 11/5/1995 Heikki Tuuri
|
|||
#include "buf0rea.h"
|
||||
#include "btr0sea.h"
|
||||
#include "os0file.h"
|
||||
#include "page0zip.h"
|
||||
#include "log0recv.h"
|
||||
#include "srv0srv.h"
|
||||
|
||||
|
@ -444,8 +445,8 @@ loop:
|
|||
ut_a(buf_block_get_state(block) != BUF_BLOCK_FILE_PAGE);
|
||||
ut_a(!block->in_LRU_list);
|
||||
|
||||
if (block->page.zip.size != zip_size) {
|
||||
block->page.zip.size = zip_size;
|
||||
if (buf_block_get_zip_size(block) != zip_size) {
|
||||
page_zip_set_size(&block->page.zip, zip_size);
|
||||
block->page.zip.n_blobs = 0;
|
||||
block->page.zip.m_start = 0;
|
||||
block->page.zip.m_end = 0;
|
||||
|
@ -882,7 +883,7 @@ buf_LRU_block_free_non_file_page(
|
|||
/* TODO: return zip to an aligned pool */
|
||||
ut_free(block->page.zip.data);
|
||||
block->page.zip.data = NULL;
|
||||
block->page.zip.size = 0;
|
||||
page_zip_set_size(&block->page.zip, 0);
|
||||
}
|
||||
|
||||
UT_LIST_ADD_FIRST(free, buf_pool->free, block);
|
||||
|
|
|
@ -26,6 +26,7 @@ Created 10/25/1995 Heikki Tuuri
|
|||
#include "mtr0mtr.h"
|
||||
#include "mtr0log.h"
|
||||
#include "dict0dict.h"
|
||||
#include "page0zip.h"
|
||||
|
||||
|
||||
/*
|
||||
|
@ -2660,7 +2661,7 @@ error_exit2:
|
|||
ret = os_file_write(path, file, page, 0, 0, UNIV_PAGE_SIZE);
|
||||
} else {
|
||||
page_zip_des_t page_zip;
|
||||
page_zip.size = zip_size;
|
||||
page_zip_set_size(&page_zip, zip_size);
|
||||
page_zip.data = page + UNIV_PAGE_SIZE;
|
||||
page_zip.state = page_zip.n_blobs
|
||||
= page_zip.m_start = page_zip.m_end = 0;
|
||||
|
|
|
@ -19,7 +19,7 @@ Created 11/29/1995 Heikki Tuuri
|
|||
#include "fut0fut.h"
|
||||
#include "ut0byte.h"
|
||||
#include "srv0srv.h"
|
||||
#include "page0types.h"
|
||||
#include "page0zip.h"
|
||||
#include "ibuf0ibuf.h"
|
||||
#include "btr0btr.h"
|
||||
#include "btr0sea.h"
|
||||
|
@ -824,7 +824,7 @@ fsp_init_file_page_low(
|
|||
|
||||
if (UNIV_LIKELY_NULL(page_zip)) {
|
||||
memset(page, 0, UNIV_PAGE_SIZE);
|
||||
memset(page_zip->data, 0, page_zip->size);
|
||||
memset(page_zip->data, 0, page_zip_get_size(page_zip));
|
||||
mach_write_to_4(page + FIL_PAGE_OFFSET,
|
||||
buf_block_get_page_no(block));
|
||||
mach_write_to_4(page
|
||||
|
|
|
@ -220,7 +220,7 @@ buf_block_get_zip_size(
|
|||
/* out: compressed page size, or 0 */
|
||||
const buf_block_t* block) /* in: pointer to the control block */
|
||||
{
|
||||
return(block->page.zip.size);
|
||||
return(block->page.zip.ssize ? 512 << block->page.zip.ssize : 0);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
|
|
|
@ -33,13 +33,12 @@ struct page_zip_des_struct
|
|||
page_zip_t* data; /* compressed page data */
|
||||
ulint state:3; /* state of the control block
|
||||
(cf. enum buf_page_state) */
|
||||
ulint :1; /* reserved */
|
||||
ulint :11; /* reserved */
|
||||
ulint n_blobs:12; /* number of externally stored
|
||||
columns on the page; the maximum
|
||||
is 744 on a 16 KiB page */
|
||||
ulint size:16; /* compressed page size in bytes;
|
||||
must be a power of 2 and
|
||||
at least PAGE_ZIP_MIN_SIZE */
|
||||
ulint ssize:3; /* 0 or compressed page size;
|
||||
the size in bytes is 512<<ssize. */
|
||||
ulint m_start:16; /* start offset of modification log */
|
||||
ulint m_end:16; /* end offset of modification log */
|
||||
};
|
||||
|
|
|
@ -20,6 +20,24 @@ Created June 2005 by Marko Makela
|
|||
#include "dict0types.h"
|
||||
#include "ut0byte.h"
|
||||
|
||||
/**************************************************************************
|
||||
Determine the size of a compressed page in bytes. */
|
||||
UNIV_INLINE
|
||||
ulint
|
||||
page_zip_get_size(
|
||||
/*==============*/
|
||||
/* out: size in bytes */
|
||||
const page_zip_des_t* page_zip) /* in: compressed page */
|
||||
__attribute__((nonnull, const));
|
||||
/**************************************************************************
|
||||
Set the size of a compressed page in bytes. */
|
||||
UNIV_INLINE
|
||||
void
|
||||
page_zip_set_size(
|
||||
/*==============*/
|
||||
page_zip_des_t* page_zip, /* in/out: compressed page */
|
||||
ulint size); /* in: size in bytes */
|
||||
|
||||
/**************************************************************************
|
||||
Determine if a record is so big that it needs to be stored externally. */
|
||||
UNIV_INLINE
|
||||
|
|
|
@ -92,6 +92,52 @@ In summary, the compressed page looks like this:
|
|||
/* 'deleted' flag */
|
||||
#define PAGE_ZIP_DIR_SLOT_DEL 0x8000
|
||||
|
||||
/**************************************************************************
|
||||
Determine the size of a compressed page in bytes. */
|
||||
UNIV_INLINE
|
||||
ulint
|
||||
page_zip_get_size(
|
||||
/*==============*/
|
||||
/* out: size in bytes */
|
||||
const page_zip_des_t* page_zip) /* in: compressed page */
|
||||
{
|
||||
ulint size;
|
||||
|
||||
if (UNIV_UNLIKELY(!page_zip->ssize)) {
|
||||
return(0);
|
||||
}
|
||||
|
||||
size = 512 << page_zip->ssize;
|
||||
|
||||
ut_ad(size >= PAGE_ZIP_MIN_SIZE);
|
||||
ut_ad(size <= UNIV_PAGE_SIZE);
|
||||
|
||||
return(size);
|
||||
}
|
||||
/**************************************************************************
|
||||
Set the size of a compressed page in bytes. */
|
||||
UNIV_INLINE
|
||||
void
|
||||
page_zip_set_size(
|
||||
/*==============*/
|
||||
page_zip_des_t* page_zip, /* in/out: compressed page */
|
||||
ulint size) /* in: size in bytes */
|
||||
{
|
||||
if (size) {
|
||||
int ssize;
|
||||
|
||||
ut_ad(ut_is_2pow(size));
|
||||
|
||||
for (ssize = 1; size > (ulint) (512 << ssize); ssize++);
|
||||
|
||||
page_zip->ssize = ssize;
|
||||
} else {
|
||||
page_zip->ssize = 0;
|
||||
}
|
||||
|
||||
ut_ad(page_zip_get_size(page_zip) == size);
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
Determine if a record is so big that it needs to be stored externally. */
|
||||
UNIV_INLINE
|
||||
|
@ -142,12 +188,12 @@ page_zip_simple_validate(
|
|||
{
|
||||
ut_ad(page_zip);
|
||||
ut_ad(page_zip->data);
|
||||
ut_ad(ut_is_2pow(page_zip->size));
|
||||
ut_ad(page_zip->size <= UNIV_PAGE_SIZE);
|
||||
ut_ad(page_zip->size > PAGE_DATA + PAGE_ZIP_DIR_SLOT_SIZE);
|
||||
ut_ad(page_zip_get_size(page_zip)
|
||||
> PAGE_DATA + PAGE_ZIP_DIR_SLOT_SIZE);
|
||||
ut_ad(page_zip->m_start <= page_zip->m_end);
|
||||
ut_ad(page_zip->m_end < page_zip->size);
|
||||
ut_ad(page_zip->n_blobs < page_zip->size / BTR_EXTERN_FIELD_REF_SIZE);
|
||||
ut_ad(page_zip->m_end < page_zip_get_size(page_zip));
|
||||
ut_ad(page_zip->n_blobs
|
||||
< page_zip_get_size(page_zip) / BTR_EXTERN_FIELD_REF_SIZE);
|
||||
return(TRUE);
|
||||
}
|
||||
#endif /* UNIV_DEBUG */
|
||||
|
@ -231,7 +277,7 @@ page_zip_available(
|
|||
return(UNIV_LIKELY(length
|
||||
+ trailer_len
|
||||
+ page_zip->m_end
|
||||
< page_zip->size));
|
||||
< page_zip_get_size(page_zip)));
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
|
|
|
@ -147,7 +147,7 @@ page_zip_dir_find(
|
|||
page_zip_des_t* page_zip, /* in: compressed page */
|
||||
ulint offset) /* in: offset of user record */
|
||||
{
|
||||
byte* end = page_zip->data + page_zip->size;
|
||||
byte* end = page_zip->data + page_zip_get_size(page_zip);
|
||||
|
||||
ut_ad(page_zip_simple_validate(page_zip));
|
||||
|
||||
|
@ -167,7 +167,7 @@ page_zip_dir_find_free(
|
|||
page_zip_des_t* page_zip, /* in: compressed page */
|
||||
ulint offset) /* in: offset of user record */
|
||||
{
|
||||
byte* end = page_zip->data + page_zip->size;
|
||||
byte* end = page_zip->data + page_zip_get_size(page_zip);
|
||||
|
||||
ut_ad(page_zip_simple_validate(page_zip));
|
||||
|
||||
|
@ -193,7 +193,7 @@ page_zip_dir_get(
|
|||
{
|
||||
ut_ad(page_zip_simple_validate(page_zip));
|
||||
ut_ad(slot < page_zip_dir_size(page_zip) / PAGE_ZIP_DIR_SLOT_SIZE);
|
||||
return(mach_read_from_2(page_zip->data + page_zip->size
|
||||
return(mach_read_from_2(page_zip->data + page_zip_get_size(page_zip)
|
||||
- PAGE_ZIP_DIR_SLOT_SIZE * (slot + 1)));
|
||||
}
|
||||
|
||||
|
@ -236,7 +236,7 @@ page_zip_compress_write_log(
|
|||
#if FIL_PAGE_DATA > PAGE_DATA
|
||||
# error "FIL_PAGE_DATA > PAGE_DATA"
|
||||
#endif
|
||||
ut_a(page_zip->m_end + trailer_size <= page_zip->size);
|
||||
ut_a(page_zip->m_end + trailer_size <= page_zip_get_size(page_zip));
|
||||
|
||||
log_ptr = mlog_write_initial_log_record_fast((page_t*) page,
|
||||
MLOG_ZIP_PAGE_COMPRESS,
|
||||
|
@ -255,7 +255,7 @@ page_zip_compress_write_log(
|
|||
mlog_catenate_string(mtr, page_zip->data + FIL_PAGE_TYPE,
|
||||
page_zip->m_end - FIL_PAGE_TYPE);
|
||||
/* Write the uncompressed trailer of the compressed page. */
|
||||
mlog_catenate_string(mtr, page_zip->data + page_zip->size
|
||||
mlog_catenate_string(mtr, page_zip->data + page_zip_get_size(page_zip)
|
||||
- trailer_size, trailer_size);
|
||||
}
|
||||
|
||||
|
@ -974,11 +974,11 @@ page_zip_compress(
|
|||
}
|
||||
#endif /* UNIV_DEBUG || UNIV_ZIP_DEBUG */
|
||||
if (UNIV_UNLIKELY(n_dense * PAGE_ZIP_DIR_SLOT_SIZE
|
||||
>= page_zip->size)) {
|
||||
>= page_zip_get_size(page_zip))) {
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
heap = mem_heap_create(page_zip->size
|
||||
heap = mem_heap_create(page_zip_get_size(page_zip)
|
||||
+ n_fields * (2 + sizeof *offsets)
|
||||
+ n_dense * ((sizeof *recs)
|
||||
- PAGE_ZIP_DIR_SLOT_SIZE));
|
||||
|
@ -988,8 +988,8 @@ page_zip_compress(
|
|||
|
||||
fields = mem_heap_alloc(heap, (n_fields + 1) * 2);
|
||||
|
||||
buf = mem_heap_alloc(heap, page_zip->size - PAGE_DATA);
|
||||
buf_end = buf + page_zip->size - PAGE_DATA;
|
||||
buf = mem_heap_alloc(heap, page_zip_get_size(page_zip) - PAGE_DATA);
|
||||
buf_end = buf + page_zip_get_size(page_zip) - PAGE_DATA;
|
||||
|
||||
/* Compress the data payload. */
|
||||
c_stream.zalloc = page_zip_malloc;
|
||||
|
@ -1118,7 +1118,8 @@ zlib_error:
|
|||
memcpy(page_zip->data + FIL_PAGE_DATA, page + FIL_PAGE_DATA,
|
||||
PAGE_DATA - FIL_PAGE_DATA);
|
||||
/* Copy the rest of the compressed page */
|
||||
memcpy(page_zip->data + PAGE_DATA, buf, page_zip->size - PAGE_DATA);
|
||||
memcpy(page_zip->data + PAGE_DATA, buf,
|
||||
page_zip_get_size(page_zip) - PAGE_DATA);
|
||||
mem_heap_free(heap);
|
||||
#ifdef UNIV_ZIP_DEBUG
|
||||
ut_a(page_zip_validate(page_zip, page));
|
||||
|
@ -1773,11 +1774,11 @@ zlib_done:
|
|||
}
|
||||
page_zip->m_end = mod_log_ptr - page_zip->data;
|
||||
ut_a(page_zip_get_trailer_len(page_zip, index, NULL)
|
||||
+ page_zip->m_end < page_zip->size);
|
||||
+ page_zip->m_end < page_zip_get_size(page_zip));
|
||||
}
|
||||
|
||||
/* Restore the uncompressed columns in heap_no order. */
|
||||
storage = page_zip->data + page_zip->size
|
||||
storage = page_zip->data + page_zip_get_size(page_zip)
|
||||
- n_dense * PAGE_ZIP_DIR_SLOT_SIZE;
|
||||
|
||||
for (slot = 0; slot < n_dense; slot++) {
|
||||
|
@ -1908,7 +1909,7 @@ zlib_done:
|
|||
}
|
||||
page_zip->m_end = mod_log_ptr - page_zip->data;
|
||||
ut_a(page_zip_get_trailer_len(page_zip, index, NULL)
|
||||
+ page_zip->m_end < page_zip->size);
|
||||
+ page_zip->m_end < page_zip_get_size(page_zip));
|
||||
}
|
||||
|
||||
/* There are no uncompressed columns on leaf pages of
|
||||
|
@ -2142,10 +2143,10 @@ zlib_done:
|
|||
}
|
||||
page_zip->m_end = mod_log_ptr - page_zip->data;
|
||||
ut_a(page_zip_get_trailer_len(page_zip, index, NULL)
|
||||
+ page_zip->m_end < page_zip->size);
|
||||
+ page_zip->m_end < page_zip_get_size(page_zip));
|
||||
}
|
||||
|
||||
storage = page_zip->data + page_zip->size
|
||||
storage = page_zip->data + page_zip_get_size(page_zip)
|
||||
- n_dense * PAGE_ZIP_DIR_SLOT_SIZE;
|
||||
|
||||
externs = storage - n_dense
|
||||
|
@ -2230,7 +2231,7 @@ page_zip_decompress(
|
|||
/* The dense directory excludes the infimum and supremum records. */
|
||||
n_dense = page_dir_get_n_heap(page_zip->data) - PAGE_HEAP_NO_USER_LOW;
|
||||
if (UNIV_UNLIKELY(n_dense * PAGE_ZIP_DIR_SLOT_SIZE
|
||||
>= page_zip->size)) {
|
||||
>= page_zip_get_size(page_zip))) {
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
|
@ -2278,7 +2279,7 @@ zlib_error:
|
|||
d_stream.next_in = page_zip->data + PAGE_DATA;
|
||||
/* Subtract the space reserved for
|
||||
the page header and the end marker of the modification log. */
|
||||
d_stream.avail_in = page_zip->size - (PAGE_DATA + 1);
|
||||
d_stream.avail_in = page_zip_get_size(page_zip) - (PAGE_DATA + 1);
|
||||
|
||||
d_stream.next_out = page + PAGE_ZIP_START;
|
||||
d_stream.avail_out = UNIV_PAGE_SIZE - PAGE_ZIP_START;
|
||||
|
@ -2485,7 +2486,8 @@ page_zip_write_rec(
|
|||
|
||||
ut_ad(buf_frame_get_page_zip((byte*) rec) == page_zip);
|
||||
ut_ad(page_zip_simple_validate(page_zip));
|
||||
ut_ad(page_zip->size > PAGE_DATA + page_zip_dir_size(page_zip));
|
||||
ut_ad(page_zip_get_size(page_zip)
|
||||
> PAGE_DATA + page_zip_dir_size(page_zip));
|
||||
ut_ad(rec_offs_comp(offsets));
|
||||
ut_ad(rec_offs_validate(rec, index, offsets));
|
||||
|
||||
|
@ -2544,7 +2546,7 @@ page_zip_write_rec(
|
|||
}
|
||||
|
||||
/* Write the data bytes. Store the uncompressed bytes separately. */
|
||||
storage = page_zip->data + page_zip->size
|
||||
storage = page_zip->data + page_zip_get_size(page_zip)
|
||||
- (page_dir_get_n_heap(page) - PAGE_HEAP_NO_USER_LOW)
|
||||
* PAGE_ZIP_DIR_SLOT_SIZE;
|
||||
|
||||
|
@ -2698,7 +2700,7 @@ page_zip_write_rec(
|
|||
}
|
||||
|
||||
ut_a(!*data);
|
||||
ut_ad((ulint) (data - page_zip->data) < page_zip->size);
|
||||
ut_ad((ulint) (data - page_zip->data) < page_zip_get_size(page_zip));
|
||||
page_zip->m_end = data - page_zip->data;
|
||||
|
||||
#ifdef UNIV_ZIP_DEBUG
|
||||
|
@ -2790,7 +2792,8 @@ page_zip_write_blob_ptr(
|
|||
ut_ad(buf_frame_get_page_zip((byte*) rec) == page_zip);
|
||||
ut_ad(page_simple_validate_new(page));
|
||||
ut_ad(page_zip_simple_validate(page_zip));
|
||||
ut_ad(page_zip->size > PAGE_DATA + page_zip_dir_size(page_zip));
|
||||
ut_ad(page_zip_get_size(page_zip)
|
||||
> PAGE_DATA + page_zip_dir_size(page_zip));
|
||||
ut_ad(rec_offs_comp(offsets));
|
||||
ut_ad(rec_offs_validate(rec, NULL, offsets));
|
||||
ut_ad(rec_offs_nth_extern(offsets, n));
|
||||
|
@ -2805,7 +2808,7 @@ page_zip_write_blob_ptr(
|
|||
+ rec_get_n_extern_new(rec, index, n);
|
||||
ut_a(blob_no < page_zip->n_blobs);
|
||||
|
||||
externs = page_zip->data + page_zip->size
|
||||
externs = page_zip->data + page_zip_get_size(page_zip)
|
||||
- (page_dir_get_n_heap(page) - PAGE_HEAP_NO_USER_LOW)
|
||||
* (PAGE_ZIP_DIR_SLOT_SIZE
|
||||
+ DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN);
|
||||
|
@ -2893,7 +2896,7 @@ corrupt:
|
|||
field = page + offset;
|
||||
storage = page_zip->data + z_offset;
|
||||
|
||||
storage_end = page_zip->data + page_zip->size
|
||||
storage_end = page_zip->data + page_zip_get_size(page_zip)
|
||||
- (page_dir_get_n_heap(page) - PAGE_HEAP_NO_USER_LOW)
|
||||
* PAGE_ZIP_DIR_SLOT_SIZE;
|
||||
|
||||
|
@ -2936,7 +2939,8 @@ page_zip_write_node_ptr(
|
|||
ut_ad(buf_frame_get_page_zip(rec) == page_zip);
|
||||
ut_ad(page_simple_validate_new(page));
|
||||
ut_ad(page_zip_simple_validate(page_zip));
|
||||
ut_ad(page_zip->size > PAGE_DATA + page_zip_dir_size(page_zip));
|
||||
ut_ad(page_zip_get_size(page_zip)
|
||||
> PAGE_DATA + page_zip_dir_size(page_zip));
|
||||
ut_ad(page_rec_is_comp(rec));
|
||||
|
||||
ut_ad(page_zip->m_start >= PAGE_DATA);
|
||||
|
@ -2944,7 +2948,7 @@ page_zip_write_node_ptr(
|
|||
|
||||
ut_ad(!page_is_leaf(page));
|
||||
|
||||
storage = page_zip->data + page_zip->size
|
||||
storage = page_zip->data + page_zip_get_size(page_zip)
|
||||
- (page_dir_get_n_heap(page) - PAGE_HEAP_NO_USER_LOW)
|
||||
* PAGE_ZIP_DIR_SLOT_SIZE
|
||||
- (rec_get_heap_no_new(rec) - 1) * REC_NODE_PTR_SIZE;
|
||||
|
@ -2999,7 +3003,8 @@ page_zip_write_trx_id_and_roll_ptr(
|
|||
ut_ad(buf_frame_get_page_zip(rec) == page_zip);
|
||||
ut_ad(page_simple_validate_new(page));
|
||||
ut_ad(page_zip_simple_validate(page_zip));
|
||||
ut_ad(page_zip->size > PAGE_DATA + page_zip_dir_size(page_zip));
|
||||
ut_ad(page_zip_get_size(page_zip)
|
||||
> PAGE_DATA + page_zip_dir_size(page_zip));
|
||||
ut_ad(rec_offs_validate(rec, NULL, offsets));
|
||||
ut_ad(rec_offs_comp(offsets));
|
||||
|
||||
|
@ -3008,7 +3013,7 @@ page_zip_write_trx_id_and_roll_ptr(
|
|||
|
||||
ut_ad(page_is_leaf(page));
|
||||
|
||||
storage = page_zip->data + page_zip->size
|
||||
storage = page_zip->data + page_zip_get_size(page_zip)
|
||||
- (page_dir_get_n_heap(page) - PAGE_HEAP_NO_USER_LOW)
|
||||
* PAGE_ZIP_DIR_SLOT_SIZE
|
||||
- (rec_get_heap_no_new(rec) - 1)
|
||||
|
@ -3075,7 +3080,7 @@ page_zip_clear_rec(
|
|||
page_zip->m_end
|
||||
+ 1 + ((heap_no - 1) >= 64)/* size of the log entry */
|
||||
+ page_zip_get_trailer_len(page_zip, index, NULL)
|
||||
< page_zip->size) {
|
||||
< page_zip_get_size(page_zip)) {
|
||||
byte* data;
|
||||
|
||||
/* Clear only the data bytes, because the allocator and
|
||||
|
@ -3084,7 +3089,8 @@ page_zip_clear_rec(
|
|||
|
||||
if (!page_is_leaf(page)) {
|
||||
/* Clear node_ptr on the compressed page. */
|
||||
byte* storage = page_zip->data + page_zip->size
|
||||
byte* storage = page_zip->data
|
||||
+ page_zip_get_size(page_zip)
|
||||
- (page_dir_get_n_heap(page)
|
||||
- PAGE_HEAP_NO_USER_LOW)
|
||||
* PAGE_ZIP_DIR_SLOT_SIZE;
|
||||
|
@ -3093,7 +3099,8 @@ page_zip_clear_rec(
|
|||
0, REC_NODE_PTR_SIZE);
|
||||
} else if (dict_index_is_clust(index)) {
|
||||
/* Clear trx_id and roll_ptr on the compressed page. */
|
||||
byte* storage = page_zip->data + page_zip->size
|
||||
byte* storage = page_zip->data
|
||||
+ page_zip_get_size(page_zip)
|
||||
- (page_dir_get_n_heap(page)
|
||||
- PAGE_HEAP_NO_USER_LOW)
|
||||
* PAGE_ZIP_DIR_SLOT_SIZE;
|
||||
|
@ -3112,7 +3119,8 @@ page_zip_clear_rec(
|
|||
}
|
||||
*data++ = (heap_no - 1) << 1 | 1;
|
||||
ut_ad(!*data);
|
||||
ut_ad((ulint) (data - page_zip->data) < page_zip->size);
|
||||
ut_ad((ulint) (data - page_zip->data)
|
||||
< page_zip_get_size(page_zip));
|
||||
page_zip->m_end = data - page_zip->data;
|
||||
} else if (page_is_leaf(page) && dict_index_is_clust(index)) {
|
||||
/* Do not clear the record, because there is not enough space
|
||||
|
@ -3199,9 +3207,9 @@ page_zip_dir_insert(
|
|||
|
||||
if (page_rec_is_infimum(prev_rec)) {
|
||||
/* Use the first slot. */
|
||||
slot_rec = page_zip->data + page_zip->size;
|
||||
slot_rec = page_zip->data + page_zip_get_size(page_zip);
|
||||
} else {
|
||||
byte* end = page_zip->data + page_zip->size;
|
||||
byte* end = page_zip->data + page_zip_get_size(page_zip);
|
||||
byte* start = end - page_zip_dir_user_size(page_zip);
|
||||
|
||||
if (UNIV_LIKELY(!free_rec)) {
|
||||
|
@ -3240,7 +3248,7 @@ page_zip_dir_insert(
|
|||
+ PAGE_HEAP_NO_USER_LOW);
|
||||
|
||||
/* Shift to the end of the dense page directory. */
|
||||
slot_free = page_zip->data + page_zip->size
|
||||
slot_free = page_zip->data + page_zip_get_size(page_zip)
|
||||
- PAGE_ZIP_DIR_SLOT_SIZE * n_dense;
|
||||
}
|
||||
|
||||
|
@ -3284,7 +3292,7 @@ page_zip_dir_delete(
|
|||
|
||||
if (UNIV_UNLIKELY(!free)) {
|
||||
/* Make the last slot the start of the free list. */
|
||||
slot_free = page_zip->data + page_zip->size
|
||||
slot_free = page_zip->data + page_zip_get_size(page_zip)
|
||||
- PAGE_ZIP_DIR_SLOT_SIZE
|
||||
* (page_dir_get_n_heap(page_zip->data)
|
||||
- PAGE_HEAP_NO_USER_LOW);
|
||||
|
@ -3321,7 +3329,7 @@ page_zip_dir_delete(
|
|||
blob_no = page_zip_get_n_prev_extern(page_zip, rec, index);
|
||||
ut_a(blob_no + n_ext <= page_zip->n_blobs);
|
||||
|
||||
externs = page_zip->data + page_zip->size
|
||||
externs = page_zip->data + page_zip_get_size(page_zip)
|
||||
- (page_dir_get_n_heap(page) - PAGE_HEAP_NO_USER_LOW)
|
||||
* (PAGE_ZIP_DIR_SLOT_SIZE
|
||||
+ DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN);
|
||||
|
@ -3366,7 +3374,7 @@ page_zip_dir_add_slot(
|
|||
n_dense = page_dir_get_n_heap(page_zip->data)
|
||||
- (PAGE_HEAP_NO_USER_LOW + 1);
|
||||
|
||||
dir = page_zip->data + page_zip->size
|
||||
dir = page_zip->data + page_zip_get_size(page_zip)
|
||||
- PAGE_ZIP_DIR_SLOT_SIZE * n_dense;
|
||||
|
||||
if (!page_is_leaf(page_zip->data)) {
|
||||
|
@ -3585,7 +3593,7 @@ page_zip_copy(
|
|||
#ifdef UNIV_ZIP_DEBUG
|
||||
ut_a(page_zip_validate(src_zip, src));
|
||||
#endif /* UNIV_ZIP_DEBUG */
|
||||
ut_a(page_zip->size == src_zip->size);
|
||||
ut_a(page_zip_get_size(page_zip) == page_zip_get_size(src_zip));
|
||||
if (UNIV_UNLIKELY(src_zip->n_blobs)) {
|
||||
ut_a(page_is_leaf(src));
|
||||
ut_a(dict_index_is_clust(index));
|
||||
|
@ -3597,13 +3605,13 @@ page_zip_copy(
|
|||
- FIL_PAGE_DATA_END);
|
||||
memcpy(page_zip->data + FIL_PAGE_DATA,
|
||||
src_zip->data + FIL_PAGE_DATA,
|
||||
page_zip->size - FIL_PAGE_DATA);
|
||||
page_zip_get_size(page_zip) - FIL_PAGE_DATA);
|
||||
|
||||
page_zip->n_blobs = src_zip->n_blobs;
|
||||
page_zip->m_start = src_zip->m_start;
|
||||
page_zip->m_end = src_zip->m_end;
|
||||
ut_ad(page_zip_get_trailer_len(page_zip, index, NULL)
|
||||
+ page_zip->m_end < page_zip->size);
|
||||
+ page_zip->m_end < page_zip_get_size(page_zip));
|
||||
|
||||
if (!page_is_leaf(src)
|
||||
&& UNIV_UNLIKELY(mach_read_from_4(src + FIL_PAGE_PREV) == FIL_NULL)
|
||||
|
@ -3662,7 +3670,7 @@ page_zip_parse_compress(
|
|||
|
||||
if (page) {
|
||||
if (UNIV_UNLIKELY(!page_zip)
|
||||
|| UNIV_UNLIKELY(page_zip->size < size)) {
|
||||
|| UNIV_UNLIKELY(page_zip_get_size(page_zip) < size)) {
|
||||
corrupt:
|
||||
recv_sys->found_corrupt_log = TRUE;
|
||||
|
||||
|
@ -3673,10 +3681,10 @@ corrupt:
|
|||
memcpy(page_zip->data + FIL_PAGE_NEXT, ptr + 4, 4);
|
||||
memcpy(page_zip->data + FIL_PAGE_TYPE, ptr + 8, size);
|
||||
memset(page_zip->data + FIL_PAGE_TYPE + size, 0,
|
||||
page_zip->size - trailer_size
|
||||
page_zip_get_size(page_zip) - trailer_size
|
||||
- (FIL_PAGE_TYPE + size));
|
||||
memcpy(page_zip->data + page_zip->size - trailer_size,
|
||||
ptr + 8 + size, trailer_size);
|
||||
memcpy(page_zip->data + page_zip_get_size(page_zip)
|
||||
- trailer_size, ptr + 8 + size, trailer_size);
|
||||
|
||||
if (UNIV_UNLIKELY(!page_zip_decompress(page_zip, page))) {
|
||||
|
||||
|
|
Loading…
Reference in a new issue