1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-09 22:24:09 +03:00

MDEV-18493 Remove page_size_t

MySQL 5.7 introduced the class page_size_t and increased the size of
buffer pool page descriptors by introducing this object to them.

Maybe the intention of this exercise was to prepare for a future
where the buffer pool could accommodate multiple page sizes.
But that future never arrived, not even in MySQL 8.0. It is much
easier to manage a pool of a single page size, and typically all
storage devices of an InnoDB instance benefit from using the same
page size.

Let us remove page_size_t from MariaDB Server. This will make it
easier to remove support for ROW_FORMAT=COMPRESSED (or make it a
compile-time option) in the future, just by removing various
occurrences of zip_size.
This commit is contained in:
Marko Mäkelä
2019-02-06 19:50:11 +02:00
parent 10dac4293f
commit 0a1c3477bf
85 changed files with 1445 additions and 2151 deletions

View File

@@ -1,6 +1,6 @@
/*
Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2014, 2018, MariaDB Corporation.
Copyright (c) 2014, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -71,10 +71,8 @@ static my_bool per_page_details;
static ulint n_merge;
extern ulong srv_checksum_algorithm;
static ulint physical_page_size; /* Page size in bytes on disk. */
static ulint logical_page_size; /* Page size when uncompressed. */
ulong srv_page_size;
ulong srv_page_size_shift;
page_size_t univ_page_size(0, 0, false);
/* Current page number (0 based). */
unsigned long long cur_page_num;
/* Skip the checksum verification. */
@@ -276,13 +274,11 @@ void print_leaf_stats(
}
}
/** Get the page size of the filespace from the filespace header.
/** Get the ROW_FORMAT=COMPRESSED size from the filespace header.
@param[in] buf buffer used to read the page.
@return page size */
static
const page_size_t
get_page_size(
byte* buf)
@return ROW_FORMAT_COMPRESSED page size
@retval 0 if not ROW_FORMAT=COMPRESSED */
static ulint get_zip_size(const byte* buf)
{
const unsigned flags = mach_read_from_4(buf + FIL_PAGE_DATA
+ FSP_SPACE_FLAGS);
@@ -294,11 +290,14 @@ get_page_size(
: UNIV_PAGE_SIZE_SHIFT_ORIG;
srv_page_size = 1U << srv_page_size_shift;
univ_page_size.copy_from(
page_size_t(srv_page_size, srv_page_size, false));
return(page_size_t(flags));
ulint zip_size = FSP_FLAGS_GET_ZIP_SSIZE(flags);
if (zip_size) {
zip_size = (UNIV_ZIP_SIZE_MIN >> 1) << zip_size;
physical_page_size = zip_size;
} else {
physical_page_size = srv_page_size;
}
return zip_size;
}
#ifdef _WIN32
@@ -430,7 +429,7 @@ ulint read_file(
/** Check if page is corrupted or not.
@param[in] buf page frame
@param[in] page_size page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] is_encrypted true if page0 contained cryp_data
with crypt_scheme encrypted
@param[in] is_compressed true if page0 fsp_flags contained
@@ -440,7 +439,7 @@ static
bool
is_page_corrupted(
byte* buf,
const page_size_t& page_size,
ulint zip_size,
bool is_encrypted,
bool is_compressed)
{
@@ -465,12 +464,12 @@ is_page_corrupted(
return (false);
}
if (page_size.is_compressed()) {
if (!zip_size) {
/* check the stored log sequence numbers
for uncompressed tablespace. */
logseq = mach_read_from_4(buf + FIL_PAGE_LSN + 4);
logseqfield = mach_read_from_4(
buf + page_size.logical() -
buf + srv_page_size -
FIL_PAGE_END_LSN_OLD_CHKSUM + 4);
if (is_log_enabled) {
@@ -499,8 +498,7 @@ is_page_corrupted(
so if crypt checksum does not match we verify checksum using
normal method. */
if (is_encrypted && key_version != 0) {
is_corrupted = !fil_space_verify_crypt_checksum(buf,
page_size);
is_corrupted = !fil_space_verify_crypt_checksum(buf, zip_size);
if (is_corrupted && log_file) {
fprintf(log_file,
"Page " ULINTPF ":%llu may be corrupted;"
@@ -516,7 +514,7 @@ is_page_corrupted(
if (is_corrupted) {
is_corrupted = buf_page_is_corrupted(
true, buf, page_size, NULL);
true, buf, zip_size, NULL);
}
return(is_corrupted);
@@ -568,7 +566,6 @@ is_page_empty(
/********************************************************************//**
Rewrite the checksum for the page.
@param [in/out] page page buffer
@param [in] physical_page_size page size in bytes on disk.
@param [in] iscompressed Is compressed/Uncompressed Page.
@retval true : do rewrite
@@ -579,7 +576,6 @@ Rewrite the checksum for the page.
bool
update_checksum(
byte* page,
ulong physical_page_size,
bool iscompressed)
{
ib_uint32_t checksum = 0;
@@ -696,7 +692,6 @@ func_exit:
@param[in] compressed Enabled if tablespace is
compressed.
@param[in,out] pos current file position.
@param[in] page_size page size in bytes on disk.
@retval true if successfully written
@retval false if a non-recoverable error occurred
@@ -708,12 +703,11 @@ write_file(
FILE* file,
byte* buf,
bool compressed,
fpos_t* pos,
ulong page_size)
fpos_t* pos)
{
bool do_update;
do_update = update_checksum(buf, page_size, compressed);
do_update = update_checksum(buf, compressed);
if (file != stdin) {
if (do_update) {
@@ -733,8 +727,9 @@ write_file(
}
}
if (page_size
!= fwrite(buf, 1, page_size, file == stdin ? stdout : file)) {
if (physical_page_size
!= fwrite(buf, 1, physical_page_size,
file == stdin ? stdout : file)) {
fprintf(stderr, "Failed to write page::%llu to %s: %s\n",
cur_page_num, filename, strerror(errno));
@@ -757,7 +752,6 @@ Parse the page and collect/dump the information about page type
@param [in] page buffer page
@param [out] xdes extend descriptor page
@param [in] file file for diagnosis.
@param [in] page_size page_size
@param [in] is_encrypted tablespace is encrypted
*/
void
@@ -765,7 +759,6 @@ parse_page(
const byte* page,
byte* xdes,
FILE* file,
const page_size_t& page_size,
bool is_encrypted)
{
unsigned long long id;
@@ -824,8 +817,7 @@ parse_page(
}
size_range_id = (data_bytes * SIZE_RANGES_FOR_PAGE
+ page_size.logical() - 1) /
page_size.logical();
+ srv_page_size - 1) / srv_page_size;
if (size_range_id > SIZE_RANGES_FOR_PAGE + 1) {
/* data_bytes is bigger than logical_page_size */
@@ -844,7 +836,7 @@ parse_page(
it = index_ids.find(id);
per_index_stats &index = (it->second);
const byte* des = xdes + XDES_ARR_OFFSET
+ XDES_SIZE * ((page_no & (page_size.physical() - 1))
+ XDES_SIZE * ((page_no & (physical_page_size - 1))
/ FSP_EXTENT_SIZE);
if (xdes_get_bit(des, XDES_FREE_BIT,
page_no % FSP_EXTENT_SIZE)) {
@@ -1007,7 +999,7 @@ parse_page(
case FIL_PAGE_TYPE_FSP_HDR:
page_type.n_fil_page_type_fsp_hdr++;
memcpy(xdes, page, page_size.physical());
memcpy(xdes, page, physical_page_size);
if (page_type_dump) {
fprintf(file, "#::%llu\t\t|\t\tFile Space "
"Header\t\t|\t%s\n", cur_page_num, str);
@@ -1016,7 +1008,7 @@ parse_page(
case FIL_PAGE_TYPE_XDES:
page_type.n_fil_page_type_xdes++;
memcpy(xdes, page, page_size.physical());
memcpy(xdes, page, physical_page_size);
if (page_type_dump) {
fprintf(file, "#::%llu\t\t|\t\tExtent descriptor "
"page\t\t|\t%s\n", cur_page_num, str);
@@ -1384,18 +1376,13 @@ get_options(
/** Check from page 0 if table is encrypted.
@param[in] filename Filename
@param[in] page_size page size
@param[in] page Page 0
@retval true if tablespace is encrypted, false if not
*/
static
bool check_encryption(
const char* filename,
const page_size_t& page_size,
byte * page)
static bool check_encryption(const char* filename, const byte* page)
{
ulint offset = (FSP_HEADER_OFFSET + (XDES_ARR_OFFSET + XDES_SIZE *
(page_size.physical()) / FSP_EXTENT_SIZE));
ulint offset = FSP_HEADER_OFFSET + XDES_ARR_OFFSET + XDES_SIZE *
physical_page_size / FSP_EXTENT_SIZE;
if (memcmp(page + offset, CRYPT_MAGIC, MAGIC_SZ) != 0) {
return false;
@@ -1431,7 +1418,7 @@ bool check_encryption(
/**
Verify page checksum.
@param[in] buf page to verify
@param[in] page_size page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] is_encrypted true if tablespace is encrypted
@param[in] is_compressed true if tablespace is page compressed
@param[in,out] mismatch_count Number of pages failed in checksum verify
@@ -1440,7 +1427,7 @@ Verify page checksum.
static
int verify_checksum(
byte* buf,
const page_size_t& page_size,
ulint zip_size,
bool is_encrypted,
bool is_compressed,
unsigned long long* mismatch_count)
@@ -1449,7 +1436,7 @@ int verify_checksum(
bool is_corrupted = false;
is_corrupted = is_page_corrupted(
buf, page_size, is_encrypted, is_compressed);
buf, zip_size, is_encrypted, is_compressed);
if (is_corrupted) {
fprintf(stderr, "Fail: page::%llu invalid\n",
@@ -1477,7 +1464,7 @@ int verify_checksum(
@param[in] filename File name
@param[in] fil_in File pointer
@param[in] buf page
@param[in] page_size page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] pos File position
@param[in] is_encrypted true if tablespace is encrypted
@param[in] is_compressed true if tablespace is page compressed
@@ -1488,7 +1475,7 @@ rewrite_checksum(
const char* filename,
FILE* fil_in,
byte* buf,
const page_size_t& page_size,
ulint zip_size,
fpos_t* pos,
bool is_encrypted,
bool is_compressed)
@@ -1500,8 +1487,7 @@ rewrite_checksum(
!is_encrypted &&
!is_compressed
&& !write_file(filename, fil_in, buf,
page_size.is_compressed(), pos,
static_cast<ulong>(page_size.physical()))) {
zip_size, pos)) {
exit_status = 1;
}
@@ -1682,22 +1668,19 @@ int main(
/* Determine page size, zip_size and page compression
from fsp_flags and encryption metadata from page 0 */
const page_size_t& page_size = get_page_size(buf);
ulint zip_size = get_zip_size(buf);
ulint flags = mach_read_from_4(FSP_HEADER_OFFSET + FSP_SPACE_FLAGS + buf);
ulint zip_size = page_size.is_compressed() ? page_size.logical() : 0;
logical_page_size = page_size.is_compressed() ? zip_size : 0;
physical_page_size = page_size.physical();
bool is_compressed = FSP_FLAGS_HAS_PAGE_COMPRESSION(flags);
if (page_size.physical() > UNIV_ZIP_SIZE_MIN) {
if (physical_page_size > UNIV_ZIP_SIZE_MIN) {
/* Read rest of the page 0 to determine crypt_data */
bytes = read_file(buf, partial_page_read, page_size.physical(), fil_in);
if (bytes != page_size.physical()) {
bytes = read_file(buf, partial_page_read, physical_page_size, fil_in);
if (bytes != physical_page_size) {
fprintf(stderr, "Error: Was not able to read the "
"rest of the page ");
fprintf(stderr, "of " ULINTPF " bytes. Bytes read was " ULINTPF "\n",
page_size.physical() - UNIV_ZIP_SIZE_MIN, bytes);
physical_page_size - UNIV_ZIP_SIZE_MIN, bytes);
exit_status = 1;
goto my_exit;
@@ -1706,7 +1689,7 @@ int main(
}
/* Now that we have full page 0 in buffer, check encryption */
bool is_encrypted = check_encryption(filename, page_size, buf);
bool is_encrypted = check_encryption(filename, buf);
/* Verify page 0 contents. Note that we can't allow
checksum mismatch on page 0, because that would mean we
@@ -1715,7 +1698,7 @@ int main(
unsigned long long tmp_allow_mismatches = allow_mismatches;
allow_mismatches = 0;
exit_status = verify_checksum(buf, page_size, is_encrypted, is_compressed, &mismatch_count);
exit_status = verify_checksum(buf, zip_size, is_encrypted, is_compressed, &mismatch_count);
if (exit_status) {
fprintf(stderr, "Error: Page 0 checksum mismatch, can't continue. \n");
@@ -1725,7 +1708,7 @@ int main(
}
if ((exit_status = rewrite_checksum(filename, fil_in, buf,
page_size, &pos, is_encrypted, is_compressed))) {
zip_size, &pos, is_encrypted, is_compressed))) {
goto my_exit;
}
@@ -1748,10 +1731,10 @@ int main(
}
if (page_type_summary || page_type_dump) {
parse_page(buf, xdes, fil_page_type, page_size, is_encrypted);
parse_page(buf, xdes, fil_page_type, is_encrypted);
}
pages = (ulint) (size / page_size.physical());
pages = (ulint) (size / physical_page_size);
if (just_count) {
if (read_from_stdin) {
@@ -1788,12 +1771,9 @@ int main(
partial_page_read = false;
offset = (off_t) start_page
* (off_t) page_size.physical();
#ifdef _WIN32
if (_fseeki64(fil_in, offset, SEEK_SET)) {
#else
if (fseeko(fil_in, offset, SEEK_SET)) {
#endif /* _WIN32 */
* (off_t) physical_page_size;
if (IF_WIN(_fseeki64,fseeko)(fil_in, offset,
SEEK_SET)) {
perror("Error: Unable to seek to "
"necessary offset");
@@ -1825,8 +1805,7 @@ int main(
if partial_page_read is enable. */
bytes = read_file(buf,
partial_page_read,
static_cast<ulong>(
page_size.physical()),
physical_page_size,
fil_in);
partial_page_read = false;
@@ -1851,8 +1830,7 @@ int main(
while (!feof(fil_in)) {
bytes = read_file(buf, partial_page_read,
static_cast<ulong>(
page_size.physical()), fil_in);
physical_page_size, fil_in);
partial_page_read = false;
if (!bytes && feof(fil_in)) {
@@ -1861,17 +1839,17 @@ int main(
if (ferror(fil_in)) {
fprintf(stderr, "Error reading " ULINTPF " bytes",
page_size.physical());
physical_page_size);
perror(" ");
exit_status = 1;
goto my_exit;
}
if (bytes != page_size.physical()) {
if (bytes != physical_page_size) {
fprintf(stderr, "Error: bytes read (" ULINTPF ") "
"doesn't match page size (" ULINTPF ")\n",
bytes, page_size.physical());
bytes, physical_page_size);
exit_status = 1;
goto my_exit;
}
@@ -1896,13 +1874,13 @@ int main(
checksum verification.*/
if (!no_check
&& !skip_page
&& (exit_status = verify_checksum(buf, page_size,
&& (exit_status = verify_checksum(buf, zip_size,
is_encrypted, is_compressed, &mismatch_count))) {
goto my_exit;
}
if ((exit_status = rewrite_checksum(filename, fil_in, buf,
page_size, &pos, is_encrypted, is_compressed))) {
zip_size, &pos, is_encrypted, is_compressed))) {
goto my_exit;
}
@@ -1916,7 +1894,7 @@ int main(
}
if (page_type_summary || page_type_dump) {
parse_page(buf, xdes, fil_page_type, page_size, is_encrypted);
parse_page(buf, xdes, fil_page_type, is_encrypted);
}
/* do counter increase and progress printing */

View File

@@ -231,11 +231,11 @@ xb_fil_cur_open(
posix_fadvise(cursor->file, 0, 0, POSIX_FADV_SEQUENTIAL);
const page_size_t page_size(node->space->flags);
cursor->page_size = page_size;
cursor->page_size = node->space->physical_size();
cursor->zip_size = node->space->zip_size();
/* Allocate read buffer */
cursor->buf_size = XB_FIL_CUR_PAGES * page_size.physical();
cursor->buf_size = XB_FIL_CUR_PAGES * cursor->page_size;
cursor->orig_buf = static_cast<byte *>
(malloc(cursor->buf_size + srv_page_size));
cursor->buf = static_cast<byte *>
@@ -250,18 +250,17 @@ xb_fil_cur_open(
if (!node->space->crypt_data
&& os_file_read(IORequestRead,
node->handle, cursor->buf, 0,
page_size.physical())) {
cursor->page_size)) {
mutex_enter(&fil_system.mutex);
if (!node->space->crypt_data) {
node->space->crypt_data
= fil_space_read_crypt_data(page_size,
cursor->buf);
node->space->crypt_data = fil_space_read_crypt_data(
node->space->zip_size(), cursor->buf);
}
mutex_exit(&fil_system.mutex);
}
cursor->space_size = (ulint)(cursor->statinfo.st_size
/ page_size.physical());
/ cursor->page_size);
cursor->read_filter = read_filter;
cursor->read_filter->init(&cursor->read_filter_ctxt, cursor,
@@ -276,7 +275,7 @@ static bool page_is_corrupted(const byte *page, ulint page_no,
{
byte tmp_frame[UNIV_PAGE_SIZE_MAX];
byte tmp_page[UNIV_PAGE_SIZE_MAX];
const ulint page_size = cursor->page_size.physical();
const ulint page_size = cursor->page_size;
ulint page_type = mach_read_from_2(page + FIL_PAGE_TYPE);
/* We ignore the doublewrite buffer pages.*/
@@ -325,7 +324,7 @@ static bool page_is_corrupted(const byte *page, ulint page_no,
|| (space->crypt_data
&& space->crypt_data->type != CRYPT_SCHEME_UNENCRYPTED))) {
if (!fil_space_verify_crypt_checksum(page, cursor->page_size))
if (!fil_space_verify_crypt_checksum(page, space->zip_size()))
return true;
/* Compressed encrypted need to be decrypted
@@ -345,8 +344,7 @@ static bool page_is_corrupted(const byte *page, ulint page_no,
}
if (page_type != FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED) {
return buf_page_is_corrupted(true, tmp_page,
cursor->page_size, space);
return buf_page_is_corrupted(true, tmp_page, 0, space);
}
}
@@ -361,14 +359,14 @@ static bool page_is_corrupted(const byte *page, ulint page_no,
return (!decomp
|| (decomp != srv_page_size
&& cursor->page_size.is_compressed())
&& cursor->zip_size)
|| page_type == FIL_PAGE_PAGE_COMPRESSED
|| page_type == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED
|| buf_page_is_corrupted(true, tmp_page,
cursor->page_size, space));
space->zip_size(), space));
}
return buf_page_is_corrupted(true, page, cursor->page_size, space);
return buf_page_is_corrupted(true, page, space->zip_size(), space);
}
/************************************************************************
@@ -389,7 +387,7 @@ xb_fil_cur_read(
xb_fil_cur_result_t ret;
ib_int64_t offset;
ib_int64_t to_read;
const ulint page_size = cursor->page_size.physical();
const ulint page_size = cursor->page_size;
xb_ad(!cursor->is_system() || page_size == srv_page_size);
cursor->read_filter->get_next_batch(&cursor->read_filter_ctxt,
@@ -459,7 +457,7 @@ read_retry:
"10 retries. File %s seems to be "
"corrupted.", cursor->abs_path);
ret = XB_FIL_CUR_ERROR;
buf_page_print(page, cursor->page_size);
ut_print_buf(stderr, page, page_size);
break;
}
msg(cursor->thread_n, "Database page corruption detected at page "

View File

@@ -38,7 +38,9 @@ struct xb_fil_cur_t {
char abs_path[FN_REFLEN];
/*!< absolute file path */
MY_STAT statinfo; /*!< information about the file */
page_size_t page_size; /*!< page size */
ulint zip_size; /*!< compressed page size in bytes or 0
for uncompressed pages */
ulint page_size; /*!< physical page size */
xb_read_filt_t* read_filter; /*!< read filter */
xb_read_filt_ctxt_t read_filter_ctxt;
/*!< read filter context */
@@ -57,9 +59,6 @@ struct xb_fil_cur_t {
ulint space_id; /*!< ID of tablespace */
ulint space_size; /*!< space size in pages */
/** TODO: remove this default constructor */
xb_fil_cur_t() : page_size(0), read_filter(0), read_filter_ctxt() {}
/** @return whether this is not a file-per-table tablespace */
bool is_system() const
{

View File

@@ -127,7 +127,7 @@ rf_bitmap_get_next_batch(
of pages */
{
ulint start_page_id;
const ulint page_size = ctxt->page_size.physical();
const ulint page_size = ctxt->page_size;
start_page_id = (ulint)(ctxt->offset / page_size);

View File

@@ -41,7 +41,7 @@ struct xb_read_filt_ctxt_t {
/* Move these to union if any other filters are added in future */
xb_page_bitmap_range *bitmap_range; /*!< changed page bitmap range
iterator for space_id */
page_size_t page_size; /*!< page size */
ulint page_size; /*!< page size */
ulint filter_batch_end;/*!< the ending page id of the
current changed page block in
the bitmap */

View File

@@ -75,8 +75,7 @@ wf_incremental_init(xb_write_filt_ctxt_t *ctxt, char *dst_name,
ctxt->cursor = cursor;
/* allocate buffer for incremental backup (4096 pages) */
cp->delta_buf_size = (cursor->page_size.physical() / 4)
* cursor->page_size.physical();
cp->delta_buf_size = (cursor->page_size / 4) * cursor->page_size;
cp->delta_buf = (unsigned char *)os_mem_alloc_large(&cp->delta_buf_size);
if (!cp->delta_buf) {
@@ -88,7 +87,8 @@ wf_incremental_init(xb_write_filt_ctxt_t *ctxt, char *dst_name,
/* write delta meta info */
snprintf(meta_name, sizeof(meta_name), "%s%s", dst_name,
XB_DELTA_INFO_SUFFIX);
const xb_delta_info_t info(cursor->page_size, cursor->space_id);
const xb_delta_info_t info(cursor->page_size, cursor->zip_size,
cursor->space_id);
if (!xb_write_delta_metadata(meta_name, &info)) {
msg(cursor->thread_n,"Error: "
"failed to write meta info for %s",
@@ -116,8 +116,7 @@ wf_incremental_process(xb_write_filt_ctxt_t *ctxt, ds_file_t *dstfile)
ulint i;
xb_fil_cur_t *cursor = ctxt->cursor;
byte *page;
const ulint page_size
= cursor->page_size.physical();
const ulint page_size = cursor->page_size;
xb_wf_incremental_ctxt_t *cp = &(ctxt->u.wf_incremental_ctxt);
for (i = 0, page = cursor->buf; i < cursor->buf_npages;
@@ -162,8 +161,7 @@ static my_bool
wf_incremental_finalize(xb_write_filt_ctxt_t *ctxt, ds_file_t *dstfile)
{
xb_fil_cur_t *cursor = ctxt->cursor;
const ulint page_size
= cursor->page_size.physical();
const ulint page_size = cursor->page_size;
xb_wf_incremental_ctxt_t *cp = &(ctxt->u.wf_incremental_ctxt);
if (cp->npages != page_size / 4) {

View File

@@ -1861,11 +1861,6 @@ static bool innodb_init_param()
msg("innodb_data_file_path = %s",
innobase_data_file_path);
/* This is the first time univ_page_size is used.
It was initialized to 16k pages before srv_page_size was set */
univ_page_size.copy_from(
page_size_t(srv_page_size, srv_page_size, false));
srv_sys_space.set_space_id(TRX_SYS_SPACE);
srv_sys_space.set_name("innodb_system");
srv_sys_space.set_path(srv_data_home);
@@ -2173,8 +2168,7 @@ xb_read_delta_metadata(const char *filepath, xb_delta_info_t *info)
msg("page_size is required in %s", filepath);
r = FALSE;
} else {
info->page_size = page_size_t(zip_size ? zip_size : page_size,
page_size, zip_size != 0);
info->page_size = zip_size ? zip_size : page_size;
}
if (info->space_id == ULINT_UNDEFINED) {
@@ -2202,9 +2196,8 @@ xb_write_delta_metadata(const char *filename, const xb_delta_info_t *info)
"page_size = " ULINTPF "\n"
"zip_size = " ULINTPF " \n"
"space_id = " ULINTPF "\n",
info->page_size.logical(),
info->page_size.is_compressed()
? info->page_size.physical() : 0,
info->page_size,
info->zip_size,
info->space_id);
len = strlen(buf);
@@ -3107,7 +3100,7 @@ xb_load_single_table_tablespace(
ut_a(node_size != (os_offset_t) -1);
n_pages = node_size / page_size_t(file->flags()).physical();
n_pages = node_size / fil_space_t::physical_size(file->flags());
space = fil_space_create(
name, file->space_id(), file->flags(),
@@ -3312,7 +3305,7 @@ retry:
}
/* TRX_SYS page can't be compressed or encrypted. */
if (buf_page_is_corrupted(false, page, univ_page_size)) {
if (buf_page_is_corrupted(false, page, 0)) {
if (n_retries--) {
os_thread_sleep(1000);
goto retry;
@@ -4590,16 +4583,15 @@ xb_space_create_file(
fsp_header_init_fields(page, space_id, flags);
mach_write_to_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, space_id);
const page_size_t page_size(flags);
const ulint zip_size = fil_space_t::zip_size(flags);
if (!page_size.is_compressed()) {
if (!zip_size) {
buf_flush_init_for_writing(NULL, page, NULL, 0);
ret = os_file_write(IORequestWrite, path, *file, page, 0,
srv_page_size);
} else {
page_zip_des_t page_zip;
ulint zip_size = page_size.physical();
page_zip_set_size(&page_zip, zip_size);
page_zip.data = page + srv_page_size;
fprintf(stderr, "zip_size = " ULINTPF "\n", zip_size);
@@ -4776,19 +4768,20 @@ exit:
}
/* No matching space found. create the new one. */
const ulint flags = info.page_size.is_compressed()
? get_bit_shift(info.page_size.physical()
const ulint flags = info.zip_size
? get_bit_shift(info.page_size
>> (UNIV_ZIP_SIZE_SHIFT_MIN - 1))
<< FSP_FLAGS_POS_ZIP_SSIZE
| FSP_FLAGS_MASK_POST_ANTELOPE
| FSP_FLAGS_MASK_ATOMIC_BLOBS
| (info.page_size.logical() == UNIV_PAGE_SIZE_ORIG
| (srv_page_size == UNIV_PAGE_SIZE_ORIG
? 0
: get_bit_shift(info.page_size.logical()
: get_bit_shift(srv_page_size
>> (UNIV_ZIP_SIZE_SHIFT_MIN - 1))
<< FSP_FLAGS_POS_PAGE_SSIZE)
: FSP_FLAGS_PAGE_SSIZE();
ut_ad(page_size_t(flags).equals_to(info.page_size));
ut_ad(fil_space_t::zip_size(flags) == info.zip_size);
ut_ad(fil_space_t::physical_size(flags) == info.page_size);
if (fil_space_create(dest_space_name, info.space_id, flags,
FIL_TYPE_TABLESPACE, 0)) {
@@ -4825,7 +4818,7 @@ xtrabackup_apply_delta(
ulint page_in_buffer;
ulint incremental_buffers = 0;
xb_delta_info_t info(univ_page_size, SRV_TMP_SPACE_ID);
xb_delta_info_t info(srv_page_size, 0, SRV_TMP_SPACE_ID);
ulint page_size;
ulint page_size_shift;
byte* incremental_buffer_base = NULL;
@@ -4863,7 +4856,7 @@ xtrabackup_apply_delta(
goto error;
}
page_size = info.page_size.physical();
page_size = info.page_size;
page_size_shift = get_bit_shift(page_size);
msg("page size for %s is %zu bytes",
src_path, page_size);

View File

@@ -28,11 +28,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
struct xb_delta_info_t
{
xb_delta_info_t(page_size_t page_size, ulint space_id)
: page_size(page_size), space_id(space_id) {}
xb_delta_info_t(ulint page_size, ulint zip_size, ulint space_id)
: page_size(page_size), zip_size(zip_size), space_id(space_id) {}
page_size_t page_size;
ulint space_id;
ulint page_size;
ulint zip_size;
ulint space_id;
};
/* value of the --incremental option */

View File

@@ -2,7 +2,7 @@
Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
Copyright (c) 2014, 2018, MariaDB Corporation.
Copyright (c) 2014, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -225,7 +225,7 @@ btr_root_block_get(
buf_block_t* block = btr_block_get(
page_id_t(index->table->space_id, index->page),
page_size_t(index->table->space->flags), mode,
index->table->space->zip_size(), mode,
index, mtr);
if (!block) {
@@ -363,7 +363,7 @@ btr_root_adjust_on_import(
page_zip_des_t* page_zip;
dict_table_t* table = index->table;
const page_id_t page_id(table->space_id, index->page);
const page_size_t page_size(table->space->flags);
const ulint zip_size = table->space->zip_size();
DBUG_EXECUTE_IF("ib_import_trigger_corruption_3",
return(DB_CORRUPTION););
@@ -372,7 +372,7 @@ btr_root_adjust_on_import(
mtr_set_log_mode(&mtr, MTR_LOG_NO_REDO);
block = btr_block_get(page_id, page_size, RW_X_LATCH, index, &mtr);
block = btr_block_get(page_id, zip_size, RW_X_LATCH, index, &mtr);
page = buf_block_get_frame(block);
page_zip = buf_block_get_page_zip(block);
@@ -474,7 +474,7 @@ btr_page_alloc_for_ibuf(
new_block = buf_page_get(
page_id_t(index->table->space_id, node_addr.page),
page_size_t(index->table->space->flags),
index->table->space->zip_size(),
RW_X_LATCH, mtr);
new_page = buf_block_get_frame(new_block);
@@ -928,7 +928,7 @@ btr_node_ptr_get_child(
return btr_block_get(
page_id_t(index->table->space_id,
btr_node_ptr_get_child_page_no(node_ptr, offsets)),
page_size_t(index->table->space->flags),
index->table->space->zip_size(),
RW_SX_LATCH, index, mtr);
}
@@ -1137,7 +1137,7 @@ btr_free_root_invalidate(
/** Prepare to free a B-tree.
@param[in] page_id page id
@param[in] page_size page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] index_id PAGE_INDEX_ID contents
@param[in,out] mtr mini-transaction
@return root block, to invoke btr_free_but_not_root() and btr_free_root()
@@ -1146,7 +1146,7 @@ static MY_ATTRIBUTE((warn_unused_result))
buf_block_t*
btr_free_root_check(
const page_id_t page_id,
const page_size_t& page_size,
ulint zip_size,
index_id_t index_id,
mtr_t* mtr)
{
@@ -1154,7 +1154,7 @@ btr_free_root_check(
ut_ad(index_id != BTR_FREED_INDEX_ID);
buf_block_t* block = buf_page_get(
page_id, page_size, RW_X_LATCH, mtr);
page_id, zip_size, RW_X_LATCH, mtr);
if (block) {
buf_block_dbg_add_level(block, SYNC_TREE_NODE);
@@ -1368,18 +1368,18 @@ top_loop:
/** Free a persistent index tree if it exists.
@param[in] page_id root page id
@param[in] page_size page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] index_id PAGE_INDEX_ID contents
@param[in,out] mtr mini-transaction */
void
btr_free_if_exists(
const page_id_t page_id,
const page_size_t& page_size,
ulint zip_size,
index_id_t index_id,
mtr_t* mtr)
{
buf_block_t* root = btr_free_root_check(
page_id, page_size, index_id, mtr);
page_id, zip_size, index_id, mtr);
if (root == NULL) {
return;
@@ -1392,20 +1392,15 @@ btr_free_if_exists(
btr_free_root_invalidate(root, mtr);
}
/** Free an index tree in a temporary tablespace or during TRUNCATE TABLE.
@param[in] page_id root page id
@param[in] page_size page size */
void
btr_free(
const page_id_t page_id,
const page_size_t& page_size)
/** Free an index tree in a temporary tablespace.
@param[in] page_id root page id */
void btr_free(const page_id_t page_id)
{
mtr_t mtr;
mtr.start();
mtr.set_log_mode(MTR_LOG_NO_REDO);
buf_block_t* block = buf_page_get(
page_id, page_size, RW_X_LATCH, &mtr);
buf_block_t* block = buf_page_get(page_id, 0, RW_X_LATCH, &mtr);
if (block) {
ut_ad(page_is_root(block->frame));
@@ -1431,7 +1426,7 @@ btr_read_autoinc(dict_index_t* index)
ib_uint64_t autoinc;
if (buf_block_t* block = buf_page_get(
page_id_t(index->table->space_id, index->page),
page_size_t(index->table->space->flags),
index->table->space->zip_size(),
RW_S_LATCH, &mtr)) {
autoinc = page_get_autoinc(block->frame);
} else {
@@ -1463,7 +1458,7 @@ btr_read_autoinc_with_fallback(const dict_table_t* table, unsigned col_no)
mtr.start();
buf_block_t* block = buf_page_get(
page_id_t(index->table->space_id, index->page),
page_size_t(index->table->space->flags),
index->table->space->zip_size(),
RW_S_LATCH, &mtr);
ib_uint64_t autoinc = block ? page_get_autoinc(block->frame) : 0;
@@ -1508,7 +1503,7 @@ btr_write_autoinc(dict_index_t* index, ib_uint64_t autoinc, bool reset)
fil_space_t* space = index->table->space;
mtr.set_named_space(space);
page_set_autoinc(buf_page_get(page_id_t(space->id, index->page),
page_size_t(space->flags),
space->zip_size(),
RW_SX_LATCH, &mtr),
index, autoinc, &mtr, reset);
mtr.commit();
@@ -2683,12 +2678,12 @@ btr_attach_half_pages(
/* for consistency, both blocks should be locked, before change */
if (prev_page_no != FIL_NULL && direction == FSP_DOWN) {
prev_block = btr_block_get(
page_id_t(space, prev_page_no), block->page.size,
page_id_t(space, prev_page_no), block->zip_size(),
RW_X_LATCH, index, mtr);
}
if (next_page_no != FIL_NULL && direction != FSP_DOWN) {
next_block = btr_block_get(
page_id_t(space, next_page_no), block->page.size,
page_id_t(space, next_page_no), block->zip_size(),
RW_X_LATCH, index, mtr);
}
@@ -2838,7 +2833,7 @@ btr_insert_into_right_sibling(
const ulint space = block->page.id.space();
next_block = btr_block_get(
page_id_t(space, next_page_no), block->page.size,
page_id_t(space, next_page_no), block->zip_size(),
RW_X_LATCH, cursor->index, mtr);
next_page = buf_block_get_frame(next_block);
@@ -2864,7 +2859,7 @@ btr_insert_into_right_sibling(
if (rec == NULL) {
if (is_leaf
&& next_block->page.size.is_compressed()
&& next_block->page.zip.ssize
&& !dict_index_is_clust(cursor->index)
&& !cursor->index->table->is_temporary()) {
/* Reset the IBUF_BITMAP_FREE bits, because
@@ -2912,7 +2907,7 @@ btr_insert_into_right_sibling(
/* Update the free bits of the B-tree page in the
insert buffer bitmap. */
if (next_block->page.size.is_compressed()) {
if (next_block->page.zip.ssize) {
ibuf_update_free_bits_zip(next_block, mtr);
} else {
ibuf_update_free_bits_if_full(
@@ -3357,16 +3352,16 @@ func_exit:
return(rec);
}
/** Removes a page from the level list of pages.
/** Remove a page from the level list of pages.
@param[in] space space where removed
@param[in] page_size page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in,out] page page to remove
@param[in] index index tree
@param[in,out] mtr mini-transaction */
void
btr_level_list_remove_func(
ulint space,
const page_size_t& page_size,
ulint zip_size,
page_t* page,
dict_index_t* index,
mtr_t* mtr)
@@ -3385,7 +3380,7 @@ btr_level_list_remove_func(
if (prev_page_no != FIL_NULL) {
buf_block_t* prev_block
= btr_block_get(page_id_t(space, prev_page_no),
page_size, RW_X_LATCH, index, mtr);
zip_size, RW_X_LATCH, index, mtr);
page_t* prev_page
= buf_block_get_frame(prev_block);
@@ -3403,7 +3398,7 @@ btr_level_list_remove_func(
if (next_page_no != FIL_NULL) {
buf_block_t* next_block
= btr_block_get(
page_id_t(space, next_page_no), page_size,
page_id_t(space, next_page_no), zip_size,
RW_X_LATCH, index, mtr);
page_t* next_page
@@ -3774,7 +3769,7 @@ btr_compress(
ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
const page_size_t page_size(index->table->space->flags);
const ulint zip_size = index->table->space->zip_size();
MONITOR_INC(MONITOR_INDEX_MERGE_ATTEMPTS);
@@ -3932,7 +3927,7 @@ retry:
/* Remove the page from the level list */
btr_level_list_remove(index->table->space_id,
page_size, page, index, mtr);
zip_size, page, index, mtr);
if (dict_index_is_spatial(index)) {
rec_t* my_rec = father_cursor.page_cur.rec;
@@ -4062,7 +4057,7 @@ retry:
/* Remove the page from the level list */
btr_level_list_remove(index->table->space_id,
page_size, page, index, mtr);
zip_size, page, index, mtr);
ut_ad(btr_node_ptr_get_child_page_no(
btr_cur_get_rec(&father_cursor), offsets)
@@ -4170,7 +4165,7 @@ retry:
committed mini-transaction, because in crash recovery,
the free bits could momentarily be set too high. */
if (page_size.is_compressed()) {
if (zip_size) {
/* Because the free bits may be incremented
and we cannot update the insert buffer bitmap
in the same mini-transaction, the only safe
@@ -4230,7 +4225,7 @@ func_exit:
err_exit:
/* We play it safe and reset the free bits. */
if (page_size.is_compressed()
if (zip_size
&& merge_page
&& page_is_leaf(merge_page)
&& !dict_index_is_clust(index)) {
@@ -4405,12 +4400,12 @@ btr_discard_page(
left_page_no = btr_page_get_prev(buf_block_get_frame(block), mtr);
right_page_no = btr_page_get_next(buf_block_get_frame(block), mtr);
const page_size_t page_size(index->table->space->flags);
const ulint zip_size = index->table->space->zip_size();
if (left_page_no != FIL_NULL) {
merge_block = btr_block_get(
page_id_t(index->table->space_id, left_page_no),
page_size, RW_X_LATCH, index, mtr);
zip_size, RW_X_LATCH, index, mtr);
merge_page = buf_block_get_frame(merge_block);
#ifdef UNIV_BTR_DEBUG
@@ -4426,7 +4421,7 @@ btr_discard_page(
} else if (right_page_no != FIL_NULL) {
merge_block = btr_block_get(
page_id_t(index->table->space_id, right_page_no),
page_size, RW_X_LATCH, index, mtr);
zip_size, RW_X_LATCH, index, mtr);
merge_page = buf_block_get_frame(merge_block);
#ifdef UNIV_BTR_DEBUG
@@ -4474,7 +4469,7 @@ btr_discard_page(
}
/* Remove the page from the level list */
btr_level_list_remove(index->table->space_id, page_size,
btr_level_list_remove(index->table->space_id, zip_size,
page, index, mtr);
#ifdef UNIV_ZIP_DEBUG
@@ -5038,19 +5033,7 @@ btr_validate_level(
#endif
fil_space_t* space = index->table->space;
const page_size_t table_page_size(
dict_table_page_size(index->table));
const page_size_t space_page_size(space->flags);
if (!table_page_size.equals_to(space_page_size)) {
ib::warn() << "Flags mismatch: table=" << index->table->flags
<< ", tablespace=" << space->flags;
mtr_commit(&mtr);
return(false);
}
const ulint zip_size = space->zip_size();
while (level != btr_page_get_level(page)) {
const rec_t* node_ptr;
@@ -5103,7 +5086,7 @@ btr_validate_level(
block = btr_block_get(
page_id_t(index->table->space_id,
left_page_no),
table_page_size,
zip_size,
RW_SX_LATCH, index, &mtr);
page = buf_block_get_frame(block);
left_page_no = btr_page_get_prev(page, &mtr);
@@ -5174,7 +5157,7 @@ loop:
right_block = btr_block_get(
page_id_t(index->table->space_id, right_page_no),
table_page_size,
zip_size,
RW_SX_LATCH, index, &mtr);
right_page = buf_block_get_frame(right_block);
@@ -5352,13 +5335,13 @@ loop:
btr_block_get(
page_id_t(index->table->space_id,
parent_right_page_no),
table_page_size,
zip_size,
RW_SX_LATCH, index, &mtr);
right_block = btr_block_get(
page_id_t(index->table->space_id,
right_page_no),
table_page_size,
zip_size,
RW_SX_LATCH, index, &mtr);
}
@@ -5436,21 +5419,21 @@ node_ptr_fails:
page_id_t(
index->table->space_id,
parent_right_page_no),
table_page_size,
zip_size,
RW_SX_LATCH, index, &mtr);
}
} else if (parent_page_no != FIL_NULL) {
btr_block_get(
page_id_t(index->table->space_id,
parent_page_no),
table_page_size,
zip_size,
RW_SX_LATCH, index, &mtr);
}
}
block = btr_block_get(
page_id_t(index->table->space_id, right_page_no),
table_page_size,
zip_size,
RW_SX_LATCH, index, &mtr);
page = buf_block_get_frame(block);
@@ -5556,9 +5539,9 @@ btr_can_merge_with_page(
page = btr_cur_get_page(cursor);
const page_id_t page_id(index->table->space_id, page_no);
const page_size_t page_size(index->table->space->flags);
const ulint zip_size = index->table->space->zip_size();
mblock = btr_block_get(page_id, page_size, RW_X_LATCH, index, mtr);
mblock = btr_block_get(page_id, zip_size, RW_X_LATCH, index, mtr);
mpage = buf_block_get_frame(mblock);
n_recs = page_get_n_recs(page);
@@ -5574,7 +5557,7 @@ btr_can_merge_with_page(
/* If compression padding tells us that merging will result in
too packed up page i.e.: which is likely to cause compression
failure then don't merge the pages. */
if (page_size.is_compressed() && page_is_leaf(mpage)
if (zip_size && page_is_leaf(mpage)
&& (page_get_data_size(mpage) + data_size
>= dict_index_zip_pad_optimal_page_size(index))) {

View File

@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 2014, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2018, MariaDB Corporation.
Copyright (c) 2017, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -121,7 +121,7 @@ PageBulk::init()
} else {
new_block = btr_block_get(
page_id_t(m_index->table->space_id, m_page_no),
page_size_t(m_index->table->space->flags),
m_index->table->space->zip_size(),
RW_X_LATCH, m_index, &m_mtr);
new_page = buf_block_get_frame(new_block);
@@ -589,8 +589,9 @@ PageBulk::needExt(
const dtuple_t* tuple,
ulint rec_size)
{
return(page_zip_rec_needs_ext(rec_size, m_is_comp,
dtuple_get_n_fields(tuple), m_block->page.size));
return page_zip_rec_needs_ext(rec_size, m_is_comp,
dtuple_get_n_fields(tuple),
m_block->zip_size());
}
/** Store external record
@@ -664,7 +665,7 @@ PageBulk::latch()
__FILE__, __LINE__, &m_mtr)) {
m_block = buf_page_get_gen(
page_id_t(m_index->table->space_id, m_page_no),
page_size_t(m_index->table->space->flags),
m_index->table->space->zip_size(),
RW_X_LATCH, m_block, BUF_GET_IF_IN_POOL,
__FILE__, __LINE__, &m_mtr, &m_err);
@@ -1017,7 +1018,7 @@ BtrBulk::finish(dberr_t err)
ut_ad(last_page_no != FIL_NULL);
last_block = btr_block_get(
page_id_t(m_index->table->space_id, last_page_no),
page_size_t(m_index->table->space->flags),
m_index->table->space->zip_size(),
RW_X_LATCH, m_index, &mtr);
first_rec = page_rec_get_next(
page_get_infimum_rec(last_block->frame));

View File

@@ -210,6 +210,7 @@ btr_rec_free_externally_stored_fields(
/** Latches the leaf page or pages requested.
@param[in] block leaf page where the search converged
@param[in] page_id page id of the leaf
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] latch_mode BTR_SEARCH_LEAF, ...
@param[in] cursor cursor
@param[in] mtr mini-transaction
@@ -218,7 +219,7 @@ btr_latch_leaves_t
btr_cur_latch_leaves(
buf_block_t* block,
const page_id_t page_id,
const page_size_t& page_size,
ulint zip_size,
ulint latch_mode,
btr_cur_t* cursor,
mtr_t* mtr)
@@ -249,7 +250,7 @@ btr_cur_latch_leaves(
mode = latch_mode == BTR_MODIFY_LEAF ? RW_X_LATCH : RW_S_LATCH;
latch_leaves.savepoints[1] = mtr_set_savepoint(mtr);
get_block = btr_block_get(page_id, page_size, mode,
get_block = btr_block_get(page_id, zip_size, mode,
cursor->index, mtr);
latch_leaves.blocks[1] = get_block;
#ifdef UNIV_BTR_DEBUG
@@ -282,7 +283,7 @@ btr_cur_latch_leaves(
latch_leaves.savepoints[0] = mtr_set_savepoint(mtr);
get_block = btr_block_get(
page_id_t(page_id.space(), left_page_no),
page_size, RW_X_LATCH, cursor->index, mtr);
zip_size, RW_X_LATCH, cursor->index, mtr);
latch_leaves.blocks[0] = get_block;
if (spatial) {
@@ -298,7 +299,7 @@ btr_cur_latch_leaves(
latch_leaves.savepoints[1] = mtr_set_savepoint(mtr);
get_block = btr_block_get(
page_id, page_size, RW_X_LATCH, cursor->index, mtr);
page_id, zip_size, RW_X_LATCH, cursor->index, mtr);
latch_leaves.blocks[1] = get_block;
#ifdef UNIV_BTR_DEBUG
@@ -329,7 +330,7 @@ btr_cur_latch_leaves(
latch_leaves.savepoints[2] = mtr_set_savepoint(mtr);
get_block = btr_block_get(
page_id_t(page_id.space(), right_page_no),
page_size, RW_X_LATCH, cursor->index, mtr);
zip_size, RW_X_LATCH, cursor->index, mtr);
latch_leaves.blocks[2] = get_block;
#ifdef UNIV_BTR_DEBUG
ut_a(page_is_comp(get_block->frame)
@@ -357,7 +358,7 @@ btr_cur_latch_leaves(
latch_leaves.savepoints[0] = mtr_set_savepoint(mtr);
get_block = btr_block_get(
page_id_t(page_id.space(), left_page_no),
page_size, mode, cursor->index, mtr);
zip_size, mode, cursor->index, mtr);
latch_leaves.blocks[0] = get_block;
cursor->left_block = get_block;
#ifdef UNIV_BTR_DEBUG
@@ -369,7 +370,7 @@ btr_cur_latch_leaves(
}
latch_leaves.savepoints[1] = mtr_set_savepoint(mtr);
get_block = btr_block_get(page_id, page_size, mode,
get_block = btr_block_get(page_id, zip_size, mode,
cursor->index, mtr);
latch_leaves.blocks[1] = get_block;
#ifdef UNIV_BTR_DEBUG
@@ -509,7 +510,7 @@ incompatible:
buf_block_t* block = buf_page_get(
page_id_t(space->id,
mach_read_from_4(ptr + BTR_EXTERN_PAGE_NO)),
univ_page_size, RW_S_LATCH, mtr);
0, RW_S_LATCH, mtr);
buf_block_dbg_add_level(block, SYNC_EXTERN_STORAGE);
if (fil_page_get_type(block->frame) != FIL_PAGE_TYPE_BLOB
|| mach_read_from_4(&block->frame[FIL_PAGE_DATA
@@ -591,7 +592,7 @@ inconsistent:
} else {
col->def_val.data = btr_copy_externally_stored_field(
&col->def_val.len, data,
cur.page_cur.block->page.size,
cur.page_cur.block->zip_size(),
len, index->table->heap);
}
}
@@ -756,8 +757,7 @@ btr_cur_optimistic_latch_leaves(
cursor->left_block = btr_block_get(
page_id_t(cursor->index->table->space_id,
left_page_no),
page_size_t(cursor->index->table->space
->flags),
cursor->index->table->space->zip_size(),
mode, cursor->index, mtr);
} else {
cursor->left_block = NULL;
@@ -865,7 +865,7 @@ btr_cur_latch_for_root_leaf(
@param[in] lock_intention lock intention for the tree operation
@param[in] rec record (current node_ptr)
@param[in] rec_size size of the record or max size of node_ptr
@param[in] page_size page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] mtr mtr
@return true if tree modification is needed */
static
@@ -876,7 +876,7 @@ btr_cur_will_modify_tree(
btr_intention_t lock_intention,
const rec_t* rec,
ulint rec_size,
const page_size_t& page_size,
ulint zip_size,
mtr_t* mtr)
{
ut_ad(!page_is_leaf(page));
@@ -964,9 +964,8 @@ btr_cur_will_modify_tree(
This is based on the worst case, and we could invoke
page_zip_available() on the block->page.zip. */
/* needs 2 records' space also for worst compress rate. */
if (page_size.is_compressed()
&& page_zip_empty_size(index->n_fields,
page_size.physical())
if (zip_size
&& page_zip_empty_size(index->n_fields, zip_size)
<= rec_size * 2 + page_get_data_size(page)
+ page_dir_calc_reserved_space(n_recs + 2)) {
return(true);
@@ -1462,7 +1461,7 @@ btr_cur_search_to_nth_level_func(
page_cursor = btr_cur_get_page_cur(cursor);
const page_size_t page_size(index->table->space->flags);
const ulint zip_size = index->table->space->zip_size();
/* Start with the root page. */
page_id_t page_id(index->table->space_id, index->page);
@@ -1545,7 +1544,7 @@ search_loop:
retry_page_get:
ut_ad(n_blocks < BTR_MAX_LEVELS);
tree_savepoints[n_blocks] = mtr_set_savepoint(mtr);
block = buf_page_get_gen(page_id, page_size, rw_latch, guess,
block = buf_page_get_gen(page_id, zip_size, rw_latch, guess,
buf_mode, file, line, mtr, &err);
tree_blocks[n_blocks] = block;
@@ -1581,7 +1580,7 @@ retry_page_get:
ut_ad(!dict_index_is_spatial(index));
if (ibuf_insert(IBUF_OP_INSERT, tuple, index,
page_id, page_size, cursor->thr)) {
page_id, zip_size, cursor->thr)) {
cursor->flag = BTR_CUR_INSERT_TO_IBUF;
@@ -1594,7 +1593,7 @@ retry_page_get:
ut_ad(!dict_index_is_spatial(index));
if (ibuf_insert(IBUF_OP_DELETE_MARK, tuple,
index, page_id, page_size,
index, page_id, zip_size,
cursor->thr)) {
cursor->flag = BTR_CUR_DEL_MARK_IBUF;
@@ -1614,7 +1613,7 @@ retry_page_get:
/* The record cannot be purged yet. */
cursor->flag = BTR_CUR_DELETE_REF;
} else if (ibuf_insert(IBUF_OP_DELETE, tuple,
index, page_id, page_size,
index, page_id, zip_size,
cursor->thr)) {
/* The purge was buffered. */
@@ -1661,7 +1660,7 @@ retry_page_get:
= mtr_set_savepoint(mtr);
get_block = buf_page_get_gen(
page_id_t(page_id.space(), left_page_no),
page_size, rw_latch, NULL, buf_mode,
zip_size, rw_latch, NULL, buf_mode,
file, line, mtr, &err);
prev_tree_blocks[prev_n_blocks] = get_block;
prev_n_blocks++;
@@ -1691,7 +1690,7 @@ retry_page_get:
tree_blocks[n_blocks]);
tree_savepoints[n_blocks] = mtr_set_savepoint(mtr);
block = buf_page_get_gen(page_id, page_size, rw_latch, NULL,
block = buf_page_get_gen(page_id, zip_size, rw_latch, NULL,
buf_mode, file, line, mtr, &err);
tree_blocks[n_blocks] = block;
@@ -1789,7 +1788,7 @@ retry_page_get:
if (rw_latch == RW_NO_LATCH) {
latch_leaves = btr_cur_latch_leaves(
block, page_id, page_size, latch_mode,
block, page_id, zip_size, latch_mode,
cursor, mtr);
}
@@ -2153,7 +2152,7 @@ need_opposite_intention:
&& latch_mode == BTR_MODIFY_TREE
&& !btr_cur_will_modify_tree(
index, page, lock_intention, node_ptr,
node_ptr_max_size, page_size, mtr)
node_ptr_max_size, zip_size, mtr)
&& !rtree_parent_modified) {
ut_ad(upper_rw_latch == RW_X_LATCH);
ut_ad(n_releases <= n_blocks);
@@ -2351,12 +2350,12 @@ need_opposite_intention:
if (latch_mode == BTR_CONT_MODIFY_TREE) {
child_block = btr_block_get(
page_id, page_size, RW_X_LATCH,
page_id, zip_size, RW_X_LATCH,
index, mtr);
} else {
ut_ad(latch_mode == BTR_CONT_SEARCH_TREE);
child_block = btr_block_get(
page_id, page_size, RW_SX_LATCH,
page_id, zip_size, RW_SX_LATCH,
index, mtr);
}
@@ -2574,7 +2573,7 @@ btr_cur_open_at_index_side_func(
cursor->index = index;
page_id_t page_id(index->table->space_id, index->page);
const page_size_t page_size(index->table->space->flags);
const ulint zip_size = index->table->space->zip_size();
if (root_leaf_rw_latch == RW_X_LATCH) {
node_ptr_max_size = btr_node_ptr_max_size(index);
@@ -2597,7 +2596,7 @@ btr_cur_open_at_index_side_func(
}
tree_savepoints[n_blocks] = mtr_set_savepoint(mtr);
block = buf_page_get_gen(page_id, page_size, rw_latch, NULL,
block = buf_page_get_gen(page_id, zip_size, rw_latch, NULL,
BUF_GET, file, line, mtr, &err);
ut_ad((block != NULL) == (err == DB_SUCCESS));
tree_blocks[n_blocks] = block;
@@ -2653,12 +2652,12 @@ btr_cur_open_at_index_side_func(
if (height == level) {
if (srv_read_only_mode) {
btr_cur_latch_leaves(
block, page_id, page_size,
block, page_id, zip_size,
latch_mode, cursor, mtr);
} else if (height == 0) {
if (rw_latch == RW_NO_LATCH) {
btr_cur_latch_leaves(
block, page_id, page_size,
block, page_id, zip_size,
latch_mode, cursor, mtr);
}
/* In versions <= 3.23.52 we had
@@ -2789,7 +2788,7 @@ btr_cur_open_at_index_side_func(
if (latch_mode == BTR_MODIFY_TREE
&& !btr_cur_will_modify_tree(
cursor->index, page, lock_intention, node_ptr,
node_ptr_max_size, page_size, mtr)) {
node_ptr_max_size, zip_size, mtr)) {
ut_ad(upper_rw_latch == RW_X_LATCH);
ut_ad(n_releases <= n_blocks);
@@ -2931,7 +2930,7 @@ btr_cur_open_at_rnd_pos_func(
cursor->index = index;
page_id_t page_id(index->table->space_id, index->page);
const page_size_t page_size(index->table->space->flags);
const ulint zip_size = index->table->space->zip_size();
dberr_t err = DB_SUCCESS;
if (root_leaf_rw_latch == RW_X_LATCH) {
@@ -2955,7 +2954,7 @@ btr_cur_open_at_rnd_pos_func(
}
tree_savepoints[n_blocks] = mtr_set_savepoint(mtr);
block = buf_page_get_gen(page_id, page_size, rw_latch, NULL,
block = buf_page_get_gen(page_id, zip_size, rw_latch, NULL,
BUF_GET, file, line, mtr, &err);
tree_blocks[n_blocks] = block;
@@ -3008,7 +3007,7 @@ btr_cur_open_at_rnd_pos_func(
if (rw_latch == RW_NO_LATCH
|| srv_read_only_mode) {
btr_cur_latch_leaves(
block, page_id, page_size,
block, page_id, zip_size,
latch_mode, cursor, mtr);
}
@@ -3084,7 +3083,7 @@ btr_cur_open_at_rnd_pos_func(
if (latch_mode == BTR_MODIFY_TREE
&& !btr_cur_will_modify_tree(
cursor->index, page, lock_intention, node_ptr,
node_ptr_max_size, page_size, mtr)) {
node_ptr_max_size, zip_size, mtr)) {
ut_ad(upper_rw_latch == RW_X_LATCH);
ut_ad(n_releases <= n_blocks);
@@ -3297,12 +3296,12 @@ btr_cur_prefetch_siblings(
if (left_page_no != FIL_NULL) {
buf_read_page_background(
page_id_t(block->page.id.space(), left_page_no),
block->page.size, false);
block->zip_size(), false);
}
if (right_page_no != FIL_NULL) {
buf_read_page_background(
page_id_t(block->page.id.space(), right_page_no),
block->page.size, false);
block->zip_size(), false);
}
if (left_page_no != FIL_NULL
|| right_page_no != FIL_NULL) {
@@ -3369,12 +3368,11 @@ btr_cur_optimistic_insert(
|| (flags & BTR_CREATE_FLAG));
ut_ad(dtuple_check_typed(entry));
const page_size_t& page_size = block->page.size;
#ifdef UNIV_DEBUG_VALGRIND
if (page_size.is_compressed()) {
UNIV_MEM_ASSERT_RW(page, page_size.logical());
UNIV_MEM_ASSERT_RW(block->page.zip.data, page_size.physical());
if (block->page.zip.data) {
UNIV_MEM_ASSERT_RW(page, srv_page_size);
UNIV_MEM_ASSERT_RW(block->page.zip.data,
block->zip_size());
}
#endif /* UNIV_DEBUG_VALGRIND */
@@ -3389,7 +3387,8 @@ btr_cur_optimistic_insert(
rec_size = rec_get_converted_size(index, entry, n_ext);
if (page_zip_rec_needs_ext(rec_size, page_is_comp(page),
dtuple_get_n_fields(entry), page_size)) {
dtuple_get_n_fields(entry),
block->zip_size())) {
convert_big_rec:
/* The record is so big that we have to store some fields
externally on separate database pages */
@@ -3403,7 +3402,7 @@ convert_big_rec:
rec_size = rec_get_converted_size(index, entry, n_ext);
}
if (page_size.is_compressed() && page_zip_is_too_big(index, entry)) {
if (block->page.zip.data && page_zip_is_too_big(index, entry)) {
if (big_rec_vec != NULL) {
dtuple_convert_back_big_rec(index, entry, big_rec_vec);
}
@@ -3414,7 +3413,7 @@ convert_big_rec:
LIMIT_OPTIMISTIC_INSERT_DEBUG(page_get_n_recs(page),
goto fail);
if (leaf && page_size.is_compressed()
if (block->page.zip.data && leaf
&& (page_get_data_size(page) + rec_size
>= dict_index_zip_pad_optimal_page_size(index))) {
/* If compression padding tells us that insertion will
@@ -3457,7 +3456,7 @@ fail_err:
we have to split the page to reserve enough free space for
future updates of records. */
if (leaf && !page_size.is_compressed() && dict_index_is_clust(index)
if (leaf && !block->page.zip.data && dict_index_is_clust(index)
&& page_get_n_recs(page) >= 2
&& dict_index_get_space_reserve() + rec_size > max_size
&& (btr_page_get_split_rec_to_right(cursor, &dummy)
@@ -3520,7 +3519,7 @@ fail_err:
}
if (*rec) {
} else if (page_size.is_compressed()) {
} else if (block->page.zip.data) {
ut_ad(!index->table->is_temporary());
/* Reset the IBUF_BITMAP_FREE bits, because
page_cur_tuple_insert() will have attempted page
@@ -3596,7 +3595,7 @@ fail_err:
committed mini-transaction, because in crash recovery,
the free bits could momentarily be set too high. */
if (page_size.is_compressed()) {
if (block->page.zip.data) {
/* Update the bits in the same mini-transaction. */
ibuf_update_free_bits_zip(block, mtr);
} else {
@@ -3696,7 +3695,7 @@ btr_cur_pessimistic_insert(
if (page_zip_rec_needs_ext(rec_get_converted_size(index, entry, n_ext),
index->table->not_redundant(),
dtuple_get_n_fields(entry),
btr_cur_get_block(cursor)->page.size)
btr_cur_get_block(cursor)->zip_size())
|| UNIV_UNLIKELY(entry->is_alter_metadata()
&& !dfield_is_ext(
dtuple_get_nth_field(
@@ -4337,7 +4336,7 @@ static void btr_cur_trim_alter_metadata(dtuple_t* entry,
buf_block_t* block = buf_page_get(
page_id_t(index->table->space->id,
mach_read_from_4(ptr + BTR_EXTERN_PAGE_NO)),
univ_page_size, RW_S_LATCH, &mtr);
0, RW_S_LATCH, &mtr);
buf_block_dbg_add_level(block, SYNC_EXTERN_STORAGE);
ut_ad(fil_page_get_type(block->frame) == FIL_PAGE_TYPE_BLOB);
ut_ad(mach_read_from_4(&block->frame[FIL_PAGE_DATA
@@ -4570,7 +4569,7 @@ any_extern:
if (page_zip_rec_needs_ext(new_rec_size, page_is_comp(page),
dict_index_get_n_fields(index),
block->page.size)) {
block->zip_size())) {
goto any_extern;
}
@@ -4749,7 +4748,8 @@ btr_cur_pess_upd_restore_supremum(
const page_id_t page_id(block->page.id.space(), prev_page_no);
ut_ad(prev_page_no != FIL_NULL);
prev_block = buf_page_get_with_no_latch(page_id, block->page.size, mtr);
prev_block = buf_page_get_with_no_latch(page_id, block->zip_size(),
mtr);
#ifdef UNIV_BTR_DEBUG
ut_a(btr_page_get_next(prev_block->frame, mtr)
== page_get_page_no(page));
@@ -4938,7 +4938,7 @@ btr_cur_pessimistic_update(
rec_get_converted_size(index, new_entry, n_ext),
page_is_comp(page),
dict_index_get_n_fields(index),
block->page.size)
block->zip_size())
|| (UNIV_UNLIKELY(update->is_alter_metadata())
&& !dfield_is_ext(dtuple_get_nth_field(
new_entry,
@@ -6062,7 +6062,7 @@ discard_page:
|| btr_cur_will_modify_tree(
index, page, BTR_INTENTION_DELETE, rec,
btr_node_ptr_max_size(index),
block->page.size, mtr);
block->zip_size(), mtr);
page_cur_delete_rec(btr_cur_get_page_cur(cursor), index,
offsets, mtr);
#ifdef UNIV_ZIP_DEBUG
@@ -6212,7 +6212,7 @@ btr_estimate_n_rows_in_range_on_level(
const fil_space_t* space = index->table->space;
page_id_t page_id(space->id, slot1->page_no);
const page_size_t page_size(space->flags);
const ulint zip_size = space->zip_size();
level = slot1->page_level;
@@ -6229,7 +6229,7 @@ btr_estimate_n_rows_in_range_on_level(
attempting to read a page that is no longer part of
the B-tree. We pass BUF_GET_POSSIBLY_FREED in order to
silence a debug assertion about this. */
block = buf_page_get_gen(page_id, page_size, RW_S_LATCH,
block = buf_page_get_gen(page_id, zip_size, RW_S_LATCH,
NULL, BUF_GET_POSSIBLY_FREED,
__FILE__, __LINE__, &mtr, &err);
@@ -7450,7 +7450,7 @@ struct btr_blob_log_check_t {
mtr_x_lock(dict_index_get_lock(index), m_mtr);
m_pcur->btr_cur.page_cur.block = btr_block_get(
page_id_t(index->table->space_id, page_no),
page_size_t(index->table->space->flags),
index->table->space->zip_size(),
RW_X_LATCH, index, m_mtr);
m_pcur->btr_cur.page_cur.rec
= m_pcur->btr_cur.page_cur.block->frame
@@ -7538,9 +7538,6 @@ btr_store_big_rec_extern_fields(
ut_ad(buf_block_get_frame(rec_block) == page_align(rec));
ut_a(dict_index_is_clust(index));
ut_ad(dict_table_page_size(index->table)
.equals_to(rec_block->page.size));
btr_blob_log_check_t redo_log(pcur, btr_mtr, offsets, &rec_block,
&rec, op);
page_zip = buf_block_get_page_zip(rec_block);
@@ -7585,7 +7582,7 @@ btr_store_big_rec_extern_fields(
#endif /* UNIV_DEBUG || UNIV_BLOB_LIGHT_DEBUG */
/* Space available in compressed page to carry blob data */
const ulint payload_size_zip = rec_block->page.size.physical()
const ulint payload_size_zip = rec_block->physical_size()
- FIL_PAGE_DATA;
/* Space available in uncompressed page to carry blob data */
@@ -7646,7 +7643,7 @@ btr_store_big_rec_extern_fields(
mtr.set_flush_observer(btr_mtr->get_flush_observer());
buf_page_get(rec_block->page.id,
rec_block->page.size, RW_X_LATCH, &mtr);
rec_block->zip_size(), RW_X_LATCH, &mtr);
if (prev_page_no == FIL_NULL) {
hint_page_no = 1 + rec_page_no;
@@ -7694,7 +7691,7 @@ btr_store_big_rec_extern_fields(
prev_block = buf_page_get(
page_id_t(space_id, prev_page_no),
rec_block->page.size,
rec_block->zip_size(),
RW_X_LATCH, &mtr);
buf_block_dbg_add_level(prev_block,
@@ -8057,10 +8054,9 @@ btr_free_externally_stored_field(
ut_ad(space_id == index->table->space->id);
ut_ad(space_id == index->table->space_id);
const page_size_t ext_page_size(dict_table_page_size(index->table));
const page_size_t& rec_page_size(rec == NULL
? univ_page_size
: ext_page_size);
const ulint ext_zip_size = index->table->space->zip_size();
const ulint rec_zip_size = rec ? ext_zip_size : 0;
if (rec == NULL) {
/* This is a call from row_purge_upd_exist_or_extern(). */
ut_ad(!page_zip);
@@ -8087,7 +8083,7 @@ btr_free_externally_stored_field(
#ifdef UNIV_DEBUG
rec_block =
#endif /* UNIV_DEBUG */
buf_page_get(page_id, rec_page_size, RW_X_LATCH, &mtr);
buf_page_get(page_id, rec_zip_size, RW_X_LATCH, &mtr);
buf_block_dbg_add_level(rec_block, SYNC_NO_ORDER_CHECK);
page_no = mach_read_from_4(field_ref + BTR_EXTERN_PAGE_NO);
@@ -8113,13 +8109,13 @@ btr_free_externally_stored_field(
}
ext_block = buf_page_get(
page_id_t(space_id, page_no), ext_page_size,
page_id_t(space_id, page_no), ext_zip_size,
RW_X_LATCH, &mtr);
buf_block_dbg_add_level(ext_block, SYNC_EXTERN_STORAGE);
page = buf_block_get_frame(ext_block);
if (ext_page_size.is_compressed()) {
if (ext_zip_size) {
/* Note that page_zip will be NULL
in row_purge_upd_exist_or_extern(). */
switch (fil_page_get_type(page)) {
@@ -8294,7 +8290,7 @@ btr_copy_blob_prefix(
mtr_start(&mtr);
block = buf_page_get(page_id_t(space_id, page_no),
univ_page_size, RW_S_LATCH, &mtr);
0, RW_S_LATCH, &mtr);
buf_block_dbg_add_level(block, SYNC_EXTERN_STORAGE);
page = buf_block_get_frame(block);
@@ -8332,7 +8328,7 @@ by a lock or a page latch.
@param[out] buf the externally stored part of the field,
or a prefix of it
@param[in] len length of buf, in bytes
@param[in] page_size compressed BLOB page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size
@param[in] space_id space id of the BLOB pages
@param[in] offset offset on the first BLOB page
@return number of bytes written to buf */
@@ -8341,7 +8337,7 @@ ulint
btr_copy_zblob_prefix(
byte* buf,
ulint len,
const page_size_t& page_size,
ulint zip_size,
ulint space_id,
ulint page_no,
ulint offset)
@@ -8361,7 +8357,8 @@ btr_copy_zblob_prefix(
heap = mem_heap_create(40000);
page_zip_set_alloc(&d_stream, heap);
ut_ad(page_size.is_compressed());
ut_ad(zip_size);
ut_ad(ut_is_2pow(zip_size));
ut_ad(space_id);
err = inflateInit(&d_stream);
@@ -8376,7 +8373,7 @@ btr_copy_zblob_prefix(
is being held on the clustered index record, or,
in row_merge_copy_blobs(), by an exclusive table lock. */
bpage = buf_page_get_zip(page_id_t(space_id, page_no),
page_size);
zip_size);
if (UNIV_UNLIKELY(!bpage)) {
ib::error() << "Cannot load compressed BLOB "
@@ -8408,8 +8405,7 @@ btr_copy_zblob_prefix(
}
d_stream.next_in = bpage->zip.data + offset;
d_stream.avail_in = static_cast<uInt>(page_size.physical()
- offset);
d_stream.avail_in = uInt(zip_size - offset);
err = inflate(&d_stream, Z_NO_FLUSH);
switch (err) {
@@ -8479,7 +8475,7 @@ by a lock or a page latch.
@param[out] buf the externally stored part of the
field, or a prefix of it
@param[in] len length of buf, in bytes
@param[in] page_size BLOB page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] space_id space id of the first BLOB page
@param[in] page_no page number of the first BLOB page
@param[in] offset offset on the first BLOB page
@@ -8489,7 +8485,7 @@ ulint
btr_copy_externally_stored_field_prefix_low(
byte* buf,
ulint len,
const page_size_t& page_size,
ulint zip_size,
ulint space_id,
ulint page_no,
ulint offset)
@@ -8498,11 +8494,10 @@ btr_copy_externally_stored_field_prefix_low(
return(0);
}
if (page_size.is_compressed()) {
return(btr_copy_zblob_prefix(buf, len, page_size,
if (zip_size) {
return(btr_copy_zblob_prefix(buf, len, zip_size,
space_id, page_no, offset));
} else {
ut_ad(page_size.equals_to(univ_page_size));
return(btr_copy_blob_prefix(buf, len, space_id,
page_no, offset));
}
@@ -8512,7 +8507,7 @@ btr_copy_externally_stored_field_prefix_low(
The clustered index record must be protected by a lock or a page latch.
@param[out] buf the field, or a prefix of it
@param[in] len length of buf, in bytes
@param[in] page_size BLOB page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] data 'internally' stored part of the field
containing also the reference to the external part; must be protected by
a lock or a page latch
@@ -8523,7 +8518,7 @@ ulint
btr_copy_externally_stored_field_prefix(
byte* buf,
ulint len,
const page_size_t& page_size,
ulint zip_size,
const byte* data,
ulint local_len)
{
@@ -8562,7 +8557,7 @@ btr_copy_externally_stored_field_prefix(
return(local_len
+ btr_copy_externally_stored_field_prefix_low(buf + local_len,
len - local_len,
page_size,
zip_size,
space_id, page_no,
offset));
}
@@ -8573,7 +8568,7 @@ The clustered index record must be protected by a lock or a page latch.
@param[in] data 'internally' stored part of the field
containing also the reference to the external part; must be protected by
a lock or a page latch
@param[in] page_size BLOB page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] local_len length of data
@param[in,out] heap mem heap
@return the whole field copied to heap */
@@ -8581,7 +8576,7 @@ byte*
btr_copy_externally_stored_field(
ulint* len,
const byte* data,
const page_size_t& page_size,
ulint zip_size,
ulint local_len,
mem_heap_t* heap)
{
@@ -8612,7 +8607,7 @@ btr_copy_externally_stored_field(
*len = local_len
+ btr_copy_externally_stored_field_prefix_low(buf + local_len,
extern_len,
page_size,
zip_size,
space_id,
page_no, offset);
@@ -8623,7 +8618,7 @@ btr_copy_externally_stored_field(
@param[in] rec record in a clustered index; must be
protected by a lock or a page latch
@param[in] offset array returned by rec_get_offsets()
@param[in] page_size BLOB page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] no field number
@param[out] len length of the field
@param[in,out] heap mem heap
@@ -8632,7 +8627,7 @@ byte*
btr_rec_copy_externally_stored_field(
const rec_t* rec,
const ulint* offsets,
const page_size_t& page_size,
ulint zip_size,
ulint no,
ulint* len,
mem_heap_t* heap)
@@ -8666,5 +8661,5 @@ btr_rec_copy_externally_stored_field(
}
return(btr_copy_externally_stored_field(len, data,
page_size, local_len, heap));
zip_size, local_len, heap));
}

View File

@@ -167,7 +167,7 @@ btr_defragment_add_index(
// Load index rood page.
buf_block_t* block = btr_block_get(
page_id_t(index->table->space_id, index->page),
page_size_t(index->table->space->flags),
index->table->space->zip_size(),
RW_NO_LATCH, index, &mtr);
page_t* page = NULL;
@@ -376,7 +376,7 @@ btr_defragment_merge_pages(
dict_index_t* index, /*!< in: index tree */
buf_block_t* from_block, /*!< in: origin of merge */
buf_block_t* to_block, /*!< in: destination of merge */
const page_size_t page_size, /*!< in: page size of the block */
ulint zip_size, /*!< in: ROW_FORMAT=COMPRESSED size */
ulint reserved_space, /*!< in: space reserved for future
insert to avoid immediate page split */
ulint* max_data_size, /*!< in/out: max data size to
@@ -404,7 +404,7 @@ btr_defragment_merge_pages(
// Estimate how many records can be moved from the from_page to
// the to_page.
if (page_size.is_compressed()) {
if (zip_size) {
ulint page_diff = srv_page_size - *max_data_size;
max_ins_size_to_use = (max_ins_size_to_use > page_diff)
? max_ins_size_to_use - page_diff : 0;
@@ -472,7 +472,7 @@ btr_defragment_merge_pages(
// Set ibuf free bits if necessary.
if (!dict_index_is_clust(index)
&& page_is_leaf(to_page)) {
if (page_size.is_compressed()) {
if (zip_size) {
ibuf_reset_free_bits(to_block);
} else {
ibuf_update_free_bits_if_full(
@@ -489,7 +489,7 @@ btr_defragment_merge_pages(
btr_search_drop_page_hash_index(from_block);
btr_level_list_remove(
index->table->space_id,
page_size, from_page, index, mtr);
zip_size, from_page, index, mtr);
btr_node_ptr_delete(index, from_block, mtr);
/* btr_blob_dbg_remove(from_page, index,
"btr_defragment_n_pages"); */
@@ -573,7 +573,7 @@ btr_defragment_n_pages(
}
first_page = buf_block_get_frame(block);
const page_size_t page_size(index->table->space->flags);
const ulint zip_size = index->table->space->zip_size();
/* 1. Load the pages and calculate the total data size. */
blocks[0] = block;
@@ -589,7 +589,7 @@ btr_defragment_n_pages(
}
blocks[i] = btr_block_get(page_id_t(index->table->space_id,
page_no), page_size,
page_no), zip_size,
RW_X_LATCH, index, mtr);
}
@@ -615,7 +615,7 @@ btr_defragment_n_pages(
optimal_page_size = page_get_free_space_of_empty(
page_is_comp(first_page));
// For compressed pages, we take compression failures into account.
if (page_size.is_compressed()) {
if (zip_size) {
ulint size = 0;
uint i = 0;
// We estimate the optimal data size of the index use samples of
@@ -658,7 +658,7 @@ btr_defragment_n_pages(
// Start from the second page.
for (uint i = 1; i < n_pages; i ++) {
buf_block_t* new_block = btr_defragment_merge_pages(
index, blocks[i], current_block, page_size,
index, blocks[i], current_block, zip_size,
reserved_space, &max_data_size, heap, mtr);
if (new_block != current_block) {
n_defragmented ++;

View File

@@ -476,7 +476,7 @@ btr_pcur_move_to_next_page(
next_block = btr_block_get(
page_id_t(block->page.id.space(), next_page_no),
block->page.size, mode,
block->zip_size(), mode,
btr_pcur_get_btr_cur(cursor)->index, mtr);
if (UNIV_UNLIKELY(!next_block)) {

View File

@@ -434,7 +434,7 @@ btr_pessimistic_scrub(
const ulint page_no = mach_read_from_4(page + FIL_PAGE_OFFSET);
const ulint left_page_no = mach_read_from_4(page + FIL_PAGE_PREV);
const ulint right_page_no = mach_read_from_4(page + FIL_PAGE_NEXT);
const page_size_t page_size(index->table->space->flags);
const ulint zip_size = index->table->space->zip_size();
/**
* When splitting page, we need X-latches on left/right brothers
@@ -449,16 +449,16 @@ btr_pessimistic_scrub(
*/
mtr->release_block_at_savepoint(scrub_data->savepoint, block);
buf_block_t* get_block __attribute__((unused)) = btr_block_get(
btr_block_get(
page_id_t(index->table->space_id, left_page_no),
page_size, RW_X_LATCH, index, mtr);
zip_size, RW_X_LATCH, index, mtr);
/**
* Refetch block and re-initialize page
*/
block = btr_block_get(
page_id_t(index->table->space_id, page_no),
page_size, RW_X_LATCH, index, mtr);
zip_size, RW_X_LATCH, index, mtr);
page = buf_block_get_frame(block);
@@ -470,9 +470,9 @@ btr_pessimistic_scrub(
}
if (right_page_no != FIL_NULL) {
buf_block_t* get_block __attribute__((unused))= btr_block_get(
btr_block_get(
page_id_t(index->table->space_id, right_page_no),
page_size, RW_X_LATCH, index, mtr);
zip_size, RW_X_LATCH, index, mtr);
}
/* arguments to btr_page_split_and_insert */
@@ -842,13 +842,15 @@ btr_scrub_start_space(
ulint space, /*!< in: space */
btr_scrub_t* scrub_data) /*!< in/out: scrub data */
{
bool found;
scrub_data->space = space;
scrub_data->current_table = NULL;
scrub_data->current_index = NULL;
const page_size_t page_size = fil_space_get_page_size(space, &found);
scrub_data->compressed = page_size.is_compressed();
if (fil_space_t* s = fil_space_acquire_silent(space)) {
scrub_data->compressed = s->zip_size();
s->release();
} else {
scrub_data->compressed = 0;
}
scrub_data->scrubbing = check_scrub_setting(scrub_data);
return scrub_data->scrubbing;
}

View File

@@ -1287,7 +1287,7 @@ void btr_search_drop_page_hash_when_freed(const page_id_t page_id)
are possibly holding, we cannot s-latch the page, but must
(recursively) x-latch it, even though we are only reading. */
block = buf_page_get_gen(page_id, univ_page_size, RW_X_LATCH, NULL,
block = buf_page_get_gen(page_id, 0, RW_X_LATCH, NULL,
BUF_PEEK_IF_IN_POOL, __FILE__, __LINE__,
&mtr, &err);

View File

@@ -2,7 +2,7 @@
Copyright (c) 1995, 2018, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
Copyright (c) 2013, 2018, MariaDB Corporation.
Copyright (c) 2013, 2019, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
@@ -33,7 +33,6 @@ Created 11/5/1995 Heikki Tuuri
#include "mtr0types.h"
#include "mach0data.h"
#include "page0size.h"
#include "buf0buf.h"
#include "buf0checksum.h"
#include <string.h>
@@ -517,7 +516,8 @@ decompress_with_slot:
+ dst_frame)) {
/* Verify encryption checksum before we even try to
decrypt. */
if (!fil_space_verify_crypt_checksum(dst_frame, bpage->size)) {
if (!fil_space_verify_crypt_checksum(
dst_frame, space->zip_size())) {
decrypt_failed:
ib::error() << "Encrypted page " << bpage->id
<< " in file " << space->chain.start->name
@@ -889,14 +889,14 @@ buf_page_is_checksum_valid_none(
/** Check if a page is corrupt.
@param[in] check_lsn whether the LSN should be checked
@param[in] read_buf database page
@param[in] page_size page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] space tablespace
@return whether the page is corrupted */
bool
buf_page_is_corrupted(
bool check_lsn,
const byte* read_buf,
const page_size_t& page_size,
ulint zip_size,
#ifndef UNIV_INNOCHECKSUM
const fil_space_t* space)
#else
@@ -931,9 +931,9 @@ buf_page_is_corrupted(
return(false);
}
if (!page_size.is_compressed()
if (!zip_size
&& memcmp(read_buf + FIL_PAGE_LSN + 4,
read_buf + page_size.logical()
read_buf + srv_page_size
- FIL_PAGE_END_LSN_OLD_CHKSUM + 4, 4)) {
/* Stored log sequence numbers at the start and the end
@@ -980,16 +980,15 @@ buf_page_is_corrupted(
return(false);
}
if (page_size.is_compressed()) {
return(!page_zip_verify_checksum(read_buf,
page_size.physical()));
if (zip_size) {
return !page_zip_verify_checksum(read_buf, zip_size);
}
checksum_field1 = mach_read_from_4(
read_buf + FIL_PAGE_SPACE_OR_CHKSUM);
checksum_field2 = mach_read_from_4(
read_buf + page_size.logical() - FIL_PAGE_END_LSN_OLD_CHKSUM);
read_buf + srv_page_size - FIL_PAGE_END_LSN_OLD_CHKSUM);
compile_time_assert(!(FIL_PAGE_LSN % 8));
@@ -1000,7 +999,7 @@ buf_page_is_corrupted(
read_buf + FIL_PAGE_LSN) == 0) {
/* make sure that the page is really empty */
for (ulint i = 0; i < page_size.logical(); i++) {
for (ulint i = 0; i < srv_page_size; i++) {
if (read_buf[i] != 0) {
return(true);
}
@@ -1198,20 +1197,19 @@ buf_madvise_do_dump()
/** Dump a page to stderr.
@param[in] read_buf database page
@param[in] page_size page size */
UNIV_INTERN
void
buf_page_print(const byte* read_buf, const page_size_t& page_size)
@param[in] zip_size compressed page size, or 0 */
void buf_page_print(const byte* read_buf, ulint zip_size)
{
const ulint size = zip_size ? zip_size : srv_page_size;
dict_index_t* index;
ib::info() << "Page dump in ascii and hex ("
<< page_size.physical() << " bytes):";
<< size << " bytes):";
ut_print_buf(stderr, read_buf, page_size.physical());
ut_print_buf(stderr, read_buf, size);
fputs("\nInnoDB: End of page dump\n", stderr);
if (page_size.is_compressed()) {
if (zip_size) {
/* Print compressed page. */
ib::info() << "Compressed page type ("
<< fil_page_get_type(read_buf)
@@ -1223,21 +1221,21 @@ buf_page_print(const byte* read_buf, const page_size_t& page_size)
SRV_CHECKSUM_ALGORITHM_CRC32)
<< " "
<< page_zip_calc_checksum(
read_buf, page_size.physical(),
read_buf, zip_size,
SRV_CHECKSUM_ALGORITHM_CRC32)
<< ", "
<< buf_checksum_algorithm_name(
SRV_CHECKSUM_ALGORITHM_INNODB)
<< " "
<< page_zip_calc_checksum(
read_buf, page_size.physical(),
read_buf, zip_size,
SRV_CHECKSUM_ALGORITHM_INNODB)
<< ", "
<< buf_checksum_algorithm_name(
SRV_CHECKSUM_ALGORITHM_NONE)
<< " "
<< page_zip_calc_checksum(
read_buf, page_size.physical(),
read_buf, zip_size,
SRV_CHECKSUM_ALGORITHM_NONE)
<< "; page LSN "
<< mach_read_from_8(read_buf + FIL_PAGE_LSN)
@@ -1270,7 +1268,7 @@ buf_page_print(const byte* read_buf, const page_size_t& page_size)
SRV_CHECKSUM_ALGORITHM_NONE) << " "
<< BUF_NO_CHECKSUM_MAGIC
<< ", stored checksum in field2 "
<< mach_read_from_4(read_buf + page_size.logical()
<< mach_read_from_4(read_buf + srv_page_size
- FIL_PAGE_END_LSN_OLD_CHKSUM)
<< ", calculated checksums for field2: "
<< buf_checksum_algorithm_name(
@@ -1289,7 +1287,7 @@ buf_page_print(const byte* read_buf, const page_size_t& page_size)
<< " "
<< mach_read_from_4(read_buf + FIL_PAGE_LSN + 4)
<< ", low 4 bytes of LSN at page end "
<< mach_read_from_4(read_buf + page_size.logical()
<< mach_read_from_4(read_buf + srv_page_size
- FIL_PAGE_END_LSN_OLD_CHKSUM + 4)
<< ", page number (if stored to page already) "
<< mach_read_from_4(read_buf + FIL_PAGE_OFFSET)
@@ -3718,12 +3716,9 @@ be implemented at a higher level. In other words, all possible
accesses to a given page through this function must be protected by
the same set of mutexes or latches.
@param[in] page_id page id
@param[in] page_size page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size
@return pointer to the block */
buf_page_t*
buf_page_get_zip(
const page_id_t page_id,
const page_size_t& page_size)
buf_page_t* buf_page_get_zip(const page_id_t page_id, ulint zip_size)
{
buf_page_t* bpage;
BPageMutex* block_mutex;
@@ -3732,6 +3727,8 @@ buf_page_get_zip(
ibool must_read;
buf_pool_t* buf_pool = buf_pool_get(page_id);
ut_ad(zip_size);
ut_ad(ut_is_2pow(zip_size));
buf_pool->stat.n_page_gets++;
for (;;) {
@@ -3749,7 +3746,7 @@ lookup:
/* Page not in buf_pool: needs to be read from file */
ut_ad(!hash_lock);
dberr_t err = buf_read_page(page_id, page_size);
dberr_t err = buf_read_page(page_id, zip_size);
if (err != DB_SUCCESS) {
ib::error() << "Reading compressed page " << page_id
@@ -3900,7 +3897,7 @@ buf_zip_decompress(
&& (!crypt_data->is_default_encryption()
|| srv_encrypt_tables);
ut_ad(block->page.size.is_compressed());
ut_ad(block->zip_size());
ut_a(block->page.id.space() != 0);
if (UNIV_UNLIKELY(check && !page_zip_verify_checksum(frame, size))) {
@@ -3945,7 +3942,7 @@ buf_zip_decompress(
case FIL_PAGE_TYPE_ZBLOB:
case FIL_PAGE_TYPE_ZBLOB2:
/* Copy to uncompressed storage. */
memcpy(block->frame, frame, block->page.size.physical());
memcpy(block->frame, frame, block->zip_size());
if (space) {
space->release_for_io();
}
@@ -4162,6 +4159,7 @@ buf_wait_for_read(
/** This is the general function used to get access to a database page.
@param[in] page_id page id
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] rw_latch RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH
@param[in] guess guessed block or NULL
@param[in] mode BUF_GET, BUF_GET_IF_IN_POOL,
@@ -4169,11 +4167,12 @@ BUF_PEEK_IF_IN_POOL, BUF_GET_NO_LATCH, or BUF_GET_IF_IN_POOL_OR_WATCH
@param[in] file file name
@param[in] line line where called
@param[in] mtr mini-transaction
@param[out] err DB_SUCCESS or error code
@return pointer to the block or NULL */
buf_block_t*
buf_page_get_gen(
const page_id_t page_id,
const page_size_t& page_size,
ulint zip_size,
ulint rw_latch,
buf_block_t* guess,
ulint mode,
@@ -4221,16 +4220,15 @@ buf_page_get_gen(
case BUF_GET_IF_IN_POOL:
case BUF_GET_IF_IN_POOL_OR_WATCH:
case BUF_GET_POSSIBLY_FREED:
bool found;
const page_size_t& space_page_size
= fil_space_get_page_size(page_id.space(), &found);
ut_ad(found);
ut_ad(page_size.equals_to(space_page_size));
fil_space_t* s = fil_space_acquire_for_io(page_id.space());
ut_ad(s);
ut_ad(s->zip_size() == zip_size);
s->release_for_io();
}
#endif /* UNIV_DEBUG */
ut_ad(!mtr || !ibuf_inside(mtr)
|| ibuf_page_low(page_id, page_size, FALSE, file, line, NULL));
|| ibuf_page_low(page_id, zip_size, FALSE, file, line, NULL));
buf_pool->stat.n_page_gets++;
hash_lock = buf_page_hash_lock_get(buf_pool, page_id);
@@ -4339,10 +4337,10 @@ loop:
corrupted, or if an encrypted page with a valid
checksum cannot be decypted. */
dberr_t local_err = buf_read_page(page_id, page_size);
dberr_t local_err = buf_read_page(page_id, zip_size);
if (local_err == DB_SUCCESS) {
buf_read_ahead_random(page_id, page_size,
buf_read_ahead_random(page_id, zip_size,
ibuf_inside(mtr));
retries = 0;
@@ -4423,8 +4421,10 @@ loop:
rw_lock_s_unlock(hash_lock);
got_block:
switch (mode) {
default:
ut_ad(block->zip_size() == zip_size);
break;
case BUF_GET_IF_IN_POOL:
case BUF_PEEK_IF_IN_POOL:
case BUF_EVICT_IF_IN_POOL:
@@ -4633,7 +4633,7 @@ evict_from_pool:
#endif /* UNIV_IBUF_COUNT_DEBUG */
} else {
ibuf_merge_or_delete_for_page(
block, page_id, &page_size, TRUE);
block, block->page.id, zip_size, true);
}
}
@@ -4833,7 +4833,7 @@ evict_from_pool:
/* In the case of a first access, try to apply linear
read-ahead */
buf_read_ahead_linear(page_id, page_size, ibuf_inside(mtr));
buf_read_ahead_linear(page_id, zip_size, ibuf_inside(mtr));
}
#ifdef UNIV_IBUF_COUNT_DEBUG
@@ -4889,7 +4889,7 @@ buf_page_optimistic_get(
buf_page_make_young_if_needed(&block->page);
ut_ad(!ibuf_inside(mtr)
|| ibuf_page(block->page.id, block->page.size, NULL));
|| ibuf_page(block->page.id, block->physical_size(), NULL));
mtr_memo_type_t fix_type;
@@ -4949,7 +4949,7 @@ buf_page_optimistic_get(
if (!access_time) {
/* In the case of a first access, try to apply linear
read-ahead */
buf_read_ahead_linear(block->page.id, block->page.size,
buf_read_ahead_linear(block->page.id, block->zip_size(),
ibuf_inside(mtr));
}
@@ -5189,13 +5189,14 @@ buf_page_init_low(
/** Inits a page to the buffer buf_pool.
@param[in,out] buf_pool buffer pool
@param[in] page_id page id
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in,out] block block to init */
static
void
buf_page_init(
buf_pool_t* buf_pool,
const page_id_t page_id,
const page_size_t& page_size,
ulint zip_size,
buf_block_t* block)
{
buf_page_t* hash_page;
@@ -5263,14 +5264,11 @@ buf_page_init(
ut_d(block->page.in_page_hash = TRUE);
block->page.id = page_id;
block->page.size.copy_from(page_size);
HASH_INSERT(buf_page_t, hash, buf_pool->page_hash,
page_id.fold(), &block->page);
if (page_size.is_compressed()) {
page_zip_set_size(&block->page.zip, page_size.physical());
}
page_zip_set_size(&block->page.zip, zip_size);
}
/** Initialize a page for read to the buffer buf_pool. If the page is
@@ -5284,6 +5282,7 @@ and the lock released later.
@param[out] err DB_SUCCESS or DB_TABLESPACE_DELETED
@param[in] mode BUF_READ_IBUF_PAGES_ONLY, ...
@param[in] page_id page id
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] unzip whether the uncompressed page is
requested (for ROW_FORMAT=COMPRESSED)
@return pointer to the block
@@ -5293,7 +5292,7 @@ buf_page_init_for_read(
dberr_t* err,
ulint mode,
const page_id_t page_id,
const page_size_t& page_size,
ulint zip_size,
bool unzip)
{
buf_block_t* block;
@@ -5312,12 +5311,12 @@ buf_page_init_for_read(
if (mode == BUF_READ_IBUF_PAGES_ONLY) {
/* It is a read-ahead within an ibuf routine */
ut_ad(!ibuf_bitmap_page(page_id, page_size));
ut_ad(!ibuf_bitmap_page(page_id, zip_size));
ibuf_mtr_start(&mtr);
if (!recv_no_ibuf_operations &&
!ibuf_page(page_id, page_size, &mtr)) {
if (!recv_no_ibuf_operations
&& !ibuf_page(page_id, zip_size, &mtr)) {
ibuf_mtr_commit(&mtr);
@@ -5327,7 +5326,7 @@ buf_page_init_for_read(
ut_ad(mode == BUF_READ_ANY_PAGE);
}
if (page_size.is_compressed() && !unzip && !recv_recovery_is_on()) {
if (zip_size && !unzip && !recv_recovery_is_on()) {
block = NULL;
} else {
block = buf_LRU_get_free_block(buf_pool);
@@ -5362,7 +5361,7 @@ buf_page_init_for_read(
ut_ad(buf_pool_from_bpage(bpage) == buf_pool);
buf_page_init(buf_pool, page_id, page_size, block);
buf_page_init(buf_pool, page_id, zip_size, block);
/* Note: We are using the hash_lock for protection. This is
safe because no other thread can lookup the block from the
@@ -5386,7 +5385,7 @@ buf_page_init_for_read(
rw_lock_x_lock_gen(&block->lock, BUF_IO_READ);
if (page_size.is_compressed()) {
if (zip_size) {
/* buf_pool->mutex may be released and
reacquired by buf_buddy_alloc(). Thus, we
must release block->mutex in order not to
@@ -5396,8 +5395,7 @@ buf_page_init_for_read(
been added to buf_pool->LRU and
buf_pool->page_hash. */
buf_page_mutex_exit(block);
data = buf_buddy_alloc(buf_pool, page_size.physical(),
&lru);
data = buf_buddy_alloc(buf_pool, zip_size, &lru);
buf_page_mutex_enter(block);
block->page.zip.data = (page_zip_t*) data;
@@ -5418,7 +5416,7 @@ buf_page_init_for_read(
control block (bpage), in order to avoid the
invocation of buf_buddy_relocate_block() on
uninitialized data. */
data = buf_buddy_alloc(buf_pool, page_size.physical(), &lru);
data = buf_buddy_alloc(buf_pool, zip_size, &lru);
rw_lock_x_lock(hash_lock);
@@ -5436,8 +5434,7 @@ buf_page_init_for_read(
/* The block was added by some other thread. */
rw_lock_x_unlock(hash_lock);
watch_page = NULL;
buf_buddy_free(buf_pool, data,
page_size.physical());
buf_buddy_free(buf_pool, data, zip_size);
bpage = NULL;
goto func_exit;
@@ -5450,13 +5447,11 @@ buf_page_init_for_read(
bpage->buf_pool_index = buf_pool_index(buf_pool);
page_zip_des_init(&bpage->zip);
page_zip_set_size(&bpage->zip, page_size.physical());
page_zip_set_size(&bpage->zip, zip_size);
bpage->zip.data = (page_zip_t*) data;
bpage->size.copy_from(page_size);
mutex_enter(&buf_pool->zip_mutex);
UNIV_MEM_DESC(bpage->zip.data, bpage->size.physical());
UNIV_MEM_DESC(bpage->zip.data, zip_size);
buf_page_init_low(bpage);
@@ -5520,18 +5515,18 @@ func_exit:
return(bpage);
}
/** Initializes a page to the buffer buf_pool. The page is usually not read
/** Initialize a page in the buffer pool. The page is usually not read
from a file even if it cannot be found in the buffer buf_pool. This is one
of the functions which perform to a block a state transition NOT_USED =>
FILE_PAGE (the other is buf_page_get_gen).
@param[in] page_id page id
@param[in] page_size page size
@param[in] mtr mini-transaction
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in,out] mtr mini-transaction
@return pointer to the block, page bufferfixed */
buf_block_t*
buf_page_create(
const page_id_t page_id,
const page_size_t& page_size,
ulint zip_size,
mtr_t* mtr)
{
buf_frame_t* frame;
@@ -5541,7 +5536,7 @@ buf_page_create(
rw_lock_t* hash_lock;
ut_ad(mtr->is_active());
ut_ad(page_id.space() != 0 || !page_size.is_compressed());
ut_ad(page_id.space() != 0 || !zip_size);
free_block = buf_LRU_get_free_block(buf_pool);
@@ -5568,7 +5563,7 @@ buf_page_create(
buf_block_free(free_block);
return(buf_page_get_with_no_latch(page_id, page_size, mtr));
return buf_page_get_with_no_latch(page_id, zip_size, mtr);
}
/* If we get here, the page was not in buf_pool: init it there */
@@ -5580,7 +5575,7 @@ buf_page_create(
buf_page_mutex_enter(block);
buf_page_init(buf_pool, page_id, page_size, block);
buf_page_init(buf_pool, page_id, zip_size, block);
rw_lock_x_unlock(hash_lock);
@@ -5590,7 +5585,7 @@ buf_page_create(
buf_block_buf_fix_inc(block, __FILE__, __LINE__);
buf_pool->stat.n_pages_created++;
if (page_size.is_compressed()) {
if (zip_size) {
void* data;
bool lru;
@@ -5608,7 +5603,7 @@ buf_page_create(
the reacquisition of buf_pool->mutex. We also must
defer this operation until after the block descriptor
has been added to buf_pool->LRU and buf_pool->page_hash. */
data = buf_buddy_alloc(buf_pool, page_size.physical(), &lru);
data = buf_buddy_alloc(buf_pool, zip_size, &lru);
buf_page_mutex_enter(block);
block->page.zip.data = (page_zip_t*) data;
@@ -5634,7 +5629,7 @@ buf_page_create(
/* Delete possible entries for the page from the insert buffer:
such can exist if the page belonged to an index which was dropped */
ibuf_merge_or_delete_for_page(NULL, page_id, &page_size, TRUE);
ibuf_merge_or_delete_for_page(NULL, page_id, zip_size, true);
frame = block->frame;
@@ -5844,13 +5839,14 @@ static dberr_t buf_page_check_corrupt(buf_page_t* bpage, fil_space_t* space)
&& space->crypt_data
&& space->crypt_data->type != CRYPT_SCHEME_UNENCRYPTED
&& !bpage->encrypted
&& fil_space_verify_crypt_checksum(dst_frame, bpage->size);
&& fil_space_verify_crypt_checksum(dst_frame,
bpage->zip_size());
if (!still_encrypted) {
/* If traditional checksums match, we assume that page is
not anymore encrypted. */
corrupted = buf_page_is_corrupted(
true, dst_frame, bpage->size, space);
true, dst_frame, bpage->zip_size(), space);
if (!corrupted) {
bpage->encrypted = false;
@@ -5921,7 +5917,7 @@ buf_page_io_complete(buf_page_t* bpage, bool dblwr, bool evict)
io_type = buf_page_get_io_fix(bpage);
ut_ad(io_type == BUF_IO_READ || io_type == BUF_IO_WRITE);
ut_ad(bpage->size.is_compressed() == (bpage->zip.data != NULL));
ut_ad(!!bpage->zip.ssize == (bpage->zip.data != NULL));
ut_ad(uncompressed || bpage->zip.data);
if (io_type == BUF_IO_READ) {
@@ -6021,7 +6017,7 @@ database_corrupted:
<< ". You may have to recover from "
<< "a backup.";
buf_page_print(frame, bpage->size);
buf_page_print(frame, bpage->zip_size());
ib::info()
<< "It is also possible that your"
@@ -6085,7 +6081,7 @@ database_corrupted:
ibuf_merge_or_delete_for_page(
(buf_block_t*) bpage, bpage->id,
&bpage->size, TRUE);
bpage->zip_size(), true);
}
}
@@ -7314,7 +7310,7 @@ buf_page_encrypt_before_write(
return src_frame;
}
ut_ad(!bpage->size.is_compressed() || !page_compressed);
ut_ad(!bpage->zip_size() || !page_compressed);
buf_pool_t* buf_pool = buf_pool_from_bpage(bpage);
/* Find free slot from temporary memory array */
buf_tmp_buffer_t* slot = buf_pool_reserve_tmp_slot(buf_pool);
@@ -7382,7 +7378,7 @@ bool
buf_page_should_punch_hole(
const buf_page_t* bpage)
{
return (bpage->real_size != bpage->size.physical());
return bpage->real_size != bpage->physical_size();
}
/**
@@ -7395,6 +7391,6 @@ buf_page_get_trim_length(
const buf_page_t* bpage,
ulint write_length)
{
return (bpage->size.physical() - write_length);
return bpage->physical_size() - write_length;
}
#endif /* !UNIV_INNOCHECKSUM */

View File

@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 2018, MariaDB Corporation.
Copyright (c) 2013, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -85,7 +85,7 @@ buf_dblwr_get(
buf_block_t* block;
block = buf_page_get(page_id_t(TRX_SYS_SPACE, TRX_SYS_PAGE_NO),
univ_page_size, RW_X_LATCH, mtr);
0, RW_X_LATCH, mtr);
buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK);
@@ -580,12 +580,13 @@ buf_dblwr_process()
continue;
}
const page_size_t page_size(space->flags);
ut_ad(!buf_page_is_zeroes(page, page_size.physical()));
const ulint physical_size = space->physical_size();
const ulint zip_size = space->zip_size();
ut_ad(!buf_page_is_zeroes(page, physical_size));
/* We want to ensure that for partial reads the
unread portion of the page is NUL. */
memset(read_buf, 0x0, page_size.physical());
memset(read_buf, 0x0, physical_size);
IORequest request;
@@ -594,8 +595,8 @@ buf_dblwr_process()
/* Read in the actual page from the file */
dberr_t err = fil_io(
request, true,
page_id, page_size,
0, page_size.physical(), read_buf, NULL);
page_id, zip_size,
0, physical_size, read_buf, NULL);
if (err != DB_SUCCESS) {
ib::warn()
@@ -605,7 +606,7 @@ buf_dblwr_process()
}
const bool is_all_zero = buf_page_is_zeroes(
read_buf, page_size.physical());
read_buf, physical_size);
const bool expect_encrypted = space->crypt_data
&& space->crypt_data->type != CRYPT_SCHEME_UNENCRYPTED;
@@ -618,8 +619,7 @@ buf_dblwr_process()
/* Decompress the page before
validating the checksum. */
ulint decomp = fil_page_decompress(buf, read_buf);
if (!decomp || (decomp != srv_page_size
&& page_size.is_compressed())) {
if (!decomp || (zip_size && decomp != srv_page_size)) {
goto bad;
}
@@ -627,9 +627,9 @@ buf_dblwr_process()
read_buf
+ FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION)
? fil_space_verify_crypt_checksum(read_buf,
page_size)
zip_size)
: !buf_page_is_corrupted(true, read_buf,
page_size, space)) {
zip_size, space)) {
/* The page is good; there is no need
to consult the doublewrite buffer. */
continue;
@@ -644,15 +644,14 @@ bad:
}
ulint decomp = fil_page_decompress(buf, page);
if (!decomp || (decomp != srv_page_size
&& page_size.is_compressed())) {
if (!decomp || (zip_size && decomp != srv_page_size)) {
goto bad_doublewrite;
}
if (expect_encrypted && mach_read_from_4(
page + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION)
? !fil_space_verify_crypt_checksum(page, page_size)
: buf_page_is_corrupted(true, page, page_size, space)) {
? !fil_space_verify_crypt_checksum(page, zip_size)
: buf_page_is_corrupted(true, page, zip_size, space)) {
if (!is_all_zero) {
bad_doublewrite:
ib::warn() << "A doublewrite copy of page "
@@ -686,8 +685,8 @@ bad_doublewrite:
IORequest write_request(IORequest::WRITE);
fil_io(write_request, true, page_id, page_size,
0, page_size.physical(),
fil_io(write_request, true, page_id, zip_size,
0, physical_size,
const_cast<byte*>(page), NULL);
ib::info() << "Recovered page " << page_id
@@ -834,7 +833,7 @@ buf_dblwr_assert_on_corrupt_block(
/*==============================*/
const buf_block_t* block) /*!< in: block to check */
{
buf_page_print(block->frame, univ_page_size);
buf_page_print(block->frame);
ib::fatal() << "Apparent corruption of an index page "
<< block->page.id
@@ -924,14 +923,14 @@ buf_dblwr_write_block_to_datafile(
void * frame = buf_page_get_frame(bpage);
if (bpage->zip.data != NULL) {
ut_ad(bpage->size.is_compressed());
ut_ad(bpage->zip_size());
fil_io(request, sync, bpage->id, bpage->size, 0,
bpage->size.physical(),
fil_io(request, sync, bpage->id, bpage->zip_size(), 0,
bpage->zip_size(),
(void*) frame,
(void*) bpage);
} else {
ut_ad(!bpage->size.is_compressed());
ut_ad(!bpage->zip_size());
/* Our IO API is common for both reads and writes and is
therefore geared towards a non-const parameter. */
@@ -943,8 +942,8 @@ buf_dblwr_write_block_to_datafile(
buf_dblwr_check_page_lsn(block->frame);
fil_io(request,
sync, bpage->id, bpage->size, 0, bpage->real_size,
frame, block);
sync, bpage->id, bpage->zip_size(), 0, bpage->real_size,
frame, block);
}
}
@@ -1045,7 +1044,7 @@ try_again:
buf_dblwr->first_free) << srv_page_size_shift;
fil_io(IORequestWrite, true,
page_id_t(TRX_SYS_SPACE, buf_dblwr->block1), univ_page_size,
page_id_t(TRX_SYS_SPACE, buf_dblwr->block1), 0,
0, len, (void*) write_buf, NULL);
if (buf_dblwr->first_free <= TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) {
@@ -1061,7 +1060,7 @@ try_again:
+ (TRX_SYS_DOUBLEWRITE_BLOCK_SIZE << srv_page_size_shift);
fil_io(IORequestWrite, true,
page_id_t(TRX_SYS_SPACE, buf_dblwr->block2), univ_page_size,
page_id_t(TRX_SYS_SPACE, buf_dblwr->block2), 0,
0, len, (void*) write_buf, NULL);
flush:
@@ -1146,21 +1145,16 @@ try_again:
encryption and/or page compression */
void * frame = buf_page_get_frame(bpage);
if (bpage->size.is_compressed()) {
UNIV_MEM_ASSERT_RW(bpage->zip.data, bpage->size.physical());
if (auto zip_size = bpage->zip_size()) {
UNIV_MEM_ASSERT_RW(bpage->zip.data, zip_size);
/* Copy the compressed page and clear the rest. */
memcpy(p, frame, bpage->size.physical());
memset(p + bpage->size.physical(), 0x0,
srv_page_size - bpage->size.physical());
memcpy(p, frame, zip_size);
memset(p + zip_size, 0x0, srv_page_size - zip_size);
} else {
ut_a(buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE);
UNIV_MEM_ASSERT_RW(frame,
bpage->size.logical());
memcpy(p, frame, bpage->size.logical());
UNIV_MEM_ASSERT_RW(frame, srv_page_size);
memcpy(p, frame, srv_page_size);
}
buf_dblwr->buf_block_arr[buf_dblwr->first_free] = bpage;
@@ -1282,18 +1276,18 @@ retry:
encryption and/or page compression */
void * frame = buf_page_get_frame(bpage);
if (bpage->size.is_compressed()) {
if (auto zip_size = bpage->zip_size()) {
memcpy(buf_dblwr->write_buf + srv_page_size * i,
frame, bpage->size.physical());
frame, zip_size);
memset(buf_dblwr->write_buf + srv_page_size * i
+ bpage->size.physical(), 0x0,
srv_page_size - bpage->size.physical());
+ zip_size, 0x0,
srv_page_size - zip_size);
fil_io(IORequestWrite,
true,
page_id_t(TRX_SYS_SPACE, offset),
univ_page_size,
0,
0,
srv_page_size,
(void *)(buf_dblwr->write_buf + srv_page_size * i),
@@ -1304,7 +1298,7 @@ retry:
fil_io(IORequestWrite,
true,
page_id_t(TRX_SYS_SPACE, offset),
univ_page_size,
0,
0,
srv_page_size,
(void*) frame,

View File

@@ -672,7 +672,7 @@ buf_load()
so all pages from a given tablespace are consecutive. */
ulint cur_space_id = BUF_DUMP_SPACE(dump[0]);
fil_space_t* space = fil_space_acquire_silent(cur_space_id);
page_size_t page_size(space ? space->flags : 0);
ulint zip_size = space ? space->zip_size() : 0;
/* JAN: TODO: MySQL 5.7 PSI
#ifdef HAVE_PSI_STAGE_INTERFACE
@@ -703,9 +703,7 @@ buf_load()
space = fil_space_acquire_silent(cur_space_id);
if (space != NULL) {
const page_size_t cur_page_size(
space->flags);
page_size.copy_from(cur_page_size);
zip_size = space->zip_size();
}
}
@@ -720,7 +718,7 @@ buf_load()
buf_read_page_background(
page_id_t(this_space_id, BUF_DUMP_PAGE(dump[i])),
page_size, true);
zip_size, true);
if (i % 64 == 63) {
os_aio_simulated_wake_handler_threads();

View File

@@ -211,7 +211,7 @@ incr_flush_list_size_in_bytes(
{
ut_ad(buf_flush_list_mutex_own(buf_pool));
buf_pool->stat.flush_list_bytes += block->page.size.physical();
buf_pool->stat.flush_list_bytes += block->physical_size();
ut_ad(buf_pool->stat.flush_list_bytes <= buf_pool->curr_pool_size);
}
@@ -433,7 +433,7 @@ buf_flush_insert_into_flush_list(
block->page.oldest_modification = lsn;
UNIV_MEM_ASSERT_RW(block->page.zip.data
? block->page.zip.data : block->frame,
block->page.size.physical());
block->physical_size());
incr_flush_list_size_in_bytes(block, buf_pool);
if (UNIV_LIKELY_NULL(buf_pool->flush_rbt)) {
@@ -601,7 +601,7 @@ buf_flush_remove(
because we assert on in_flush_list in comparison function. */
ut_d(bpage->in_flush_list = FALSE);
buf_pool->stat.flush_list_bytes -= bpage->size.physical();
buf_pool->stat.flush_list_bytes -= bpage->physical_size();
bpage->oldest_modification = 0;
@@ -977,7 +977,7 @@ buf_flush_write_block_low(
mach_write_to_8(frame + FIL_PAGE_LSN,
bpage->newest_modification);
ut_a(page_zip_verify_checksum(frame, bpage->size.physical()));
ut_a(page_zip_verify_checksum(frame, bpage->zip_size()));
break;
case BUF_BLOCK_FILE_PAGE:
frame = bpage->zip.data;
@@ -1004,7 +1004,8 @@ buf_flush_write_block_low(
/* TODO: pass the tablespace to fil_io() */
fil_io(request,
sync, bpage->id, bpage->size, 0, bpage->size.physical(),
sync, bpage->id, bpage->zip_size(), 0,
bpage->physical_size(),
frame, bpage);
} else {
ut_ad(!srv_read_only_mode);

View File

@@ -166,7 +166,7 @@ incr_LRU_size_in_bytes(
{
ut_ad(buf_pool_mutex_own(buf_pool));
buf_pool->stat.LRU_bytes += bpage->size.physical();
buf_pool->stat.LRU_bytes += bpage->physical_size();
ut_ad(buf_pool->stat.LRU_bytes <= buf_pool->curr_pool_size);
}
@@ -1389,7 +1389,7 @@ buf_LRU_remove_block(
UT_LIST_REMOVE(buf_pool->LRU, bpage);
ut_d(bpage->in_LRU_list = FALSE);
buf_pool->stat.LRU_bytes -= bpage->size.physical();
buf_pool->stat.LRU_bytes -= bpage->physical_size();
buf_unzip_LRU_remove_block_if_needed(bpage);
@@ -1661,9 +1661,9 @@ func_exit:
? BUF_BLOCK_ZIP_DIRTY
: BUF_BLOCK_ZIP_PAGE;
ut_ad(b->size.is_compressed());
ut_ad(b->zip_size());
UNIV_MEM_DESC(b->zip.data, b->size.physical());
UNIV_MEM_DESC(b->zip.data, b->zip_size());
/* The fields in_page_hash and in_LRU_list of
the to-be-freed block descriptor should have
@@ -1742,10 +1742,6 @@ func_exit:
page_zip_set_size(&bpage->zip, 0);
bpage->size.copy_from(page_size_t(bpage->size.logical(),
bpage->size.logical(),
false));
mutex_exit(block_mutex);
/* Prevent buf_page_get_gen() from
@@ -1785,11 +1781,11 @@ func_exit:
buf_pool->page_hash, thus inaccessible by any
other thread. */
ut_ad(b->size.is_compressed());
ut_ad(b->zip_size());
const uint32_t checksum = page_zip_calc_checksum(
b->zip.data,
b->size.physical(),
b->zip_size(),
static_cast<srv_checksum_algorithm_t>(
srv_checksum_algorithm));
@@ -1856,19 +1852,14 @@ buf_LRU_block_free_non_file_page(
buf_page_mutex_exit(block);
buf_pool_mutex_exit_forbid(buf_pool);
ut_ad(block->page.size.is_compressed());
ut_ad(block->zip_size());
buf_buddy_free(buf_pool, data, block->page.size.physical());
buf_buddy_free(buf_pool, data, block->zip_size());
buf_pool_mutex_exit_allow(buf_pool);
buf_page_mutex_enter(block);
page_zip_set_size(&block->page.zip, 0);
block->page.size.copy_from(
page_size_t(block->page.size.logical(),
block->page.size.logical(),
false));
}
if (buf_pool->curr_size < buf_pool->old_size
@@ -1939,7 +1930,7 @@ buf_LRU_block_remove_hashed(
const page_t* page = ((buf_block_t*) bpage)->frame;
ut_a(!zip || bpage->oldest_modification == 0);
ut_ad(bpage->size.is_compressed());
ut_ad(bpage->zip_size());
switch (fil_page_get_type(page)) {
case FIL_PAGE_TYPE_ALLOCATED:
@@ -1954,7 +1945,7 @@ buf_LRU_block_remove_hashed(
to the compressed page, which will
be preserved. */
memcpy(bpage->zip.data, page,
bpage->size.physical());
bpage->zip_size());
}
break;
case FIL_PAGE_TYPE_ZBLOB:
@@ -1971,14 +1962,13 @@ buf_LRU_block_remove_hashed(
default:
ib::error() << "The compressed page to be"
" evicted seems corrupt:";
ut_print_buf(stderr, page,
bpage->size.logical());
ut_print_buf(stderr, page, srv_page_size);
ib::error() << "Possibly older version of"
" the page:";
ut_print_buf(stderr, bpage->zip.data,
bpage->size.physical());
bpage->zip_size());
putc('\n', stderr);
ut_error;
}
@@ -1988,10 +1978,7 @@ buf_LRU_block_remove_hashed(
/* fall through */
case BUF_BLOCK_ZIP_PAGE:
ut_a(bpage->oldest_modification == 0);
if (bpage->size.is_compressed()) {
UNIV_MEM_ASSERT_W(bpage->zip.data,
bpage->size.physical());
}
UNIV_MEM_ASSERT_W(bpage->zip.data, bpage->zip_size());
break;
case BUF_BLOCK_POOL_WATCH:
case BUF_BLOCK_ZIP_DIRTY:
@@ -2007,25 +1994,16 @@ buf_LRU_block_remove_hashed(
if (bpage != hashed_bpage) {
ib::error() << "Page " << bpage->id
<< " not found in the hash table";
#ifdef UNIV_DEBUG
ib::error()
#ifdef UNIV_DEBUG
<< "in_page_hash:" << bpage->in_page_hash
<< " in_zip_hash:" << bpage->in_zip_hash
// << " in_free_list:"<< bpage->in_fee_list
<< " in_flush_list:" << bpage->in_flush_list
<< " in_LRU_list:" << bpage->in_LRU_list
<< " zip.data:" << bpage->zip.data
<< " zip_size:" << bpage->size.logical()
<< " page_state:" << buf_page_get_state(bpage);
#else
ib::error()
<< " zip.data:" << bpage->zip.data
<< " zip_size:" << bpage->size.logical()
<< " page_state:" << buf_page_get_state(bpage);
#endif
<< " zip.data:" << bpage->zip.data
<< " zip_size:" << bpage->zip_size()
<< " page_state:" << buf_page_get_state(bpage);
if (hashed_bpage) {
@@ -2059,7 +2037,7 @@ buf_LRU_block_remove_hashed(
ut_ad(!bpage->in_flush_list);
ut_ad(!bpage->in_LRU_list);
ut_a(bpage->zip.data);
ut_a(bpage->size.is_compressed());
ut_a(bpage->zip.ssize);
#if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG
UT_LIST_REMOVE(buf_pool->zip_clean, bpage);
@@ -2069,8 +2047,7 @@ buf_LRU_block_remove_hashed(
rw_lock_x_unlock(hash_lock);
buf_pool_mutex_exit_forbid(buf_pool);
buf_buddy_free(buf_pool, bpage->zip.data,
bpage->size.physical());
buf_buddy_free(buf_pool, bpage->zip.data, bpage->zip_size());
buf_pool_mutex_exit_allow(buf_pool);
buf_page_free_descriptor(bpage);
@@ -2117,16 +2094,11 @@ buf_LRU_block_remove_hashed(
ut_ad(!bpage->in_LRU_list);
buf_pool_mutex_exit_forbid(buf_pool);
buf_buddy_free(buf_pool, data, bpage->size.physical());
buf_buddy_free(buf_pool, data, bpage->zip_size());
buf_pool_mutex_exit_allow(buf_pool);
page_zip_set_size(&bpage->zip, 0);
bpage->size.copy_from(
page_size_t(bpage->size.logical(),
bpage->size.logical(),
false));
}
return(true);
@@ -2484,7 +2456,7 @@ buf_LRU_print_instance(
fprintf(stderr, "\ntype %u size " ULINTPF
" index id " IB_ID_FMT "\n",
fil_page_get_type(frame),
bpage->size.physical(),
bpage->zip_size(),
btr_page_get_index_id(frame));
break;

View File

@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2015, 2018, MariaDB Corporation.
Copyright (c) 2015, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -102,6 +102,7 @@ flag is cleared and the x-lock released by an i/o-handler thread.
@param[in] type IO type, SIMULATED, IGNORE_MISSING
@param[in] mode BUF_READ_IBUF_PAGES_ONLY, ...,
@param[in] page_id page id
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] unzip true=request uncompressed page
@param[in] ignore_missing_space true=ignore missing space when reading
@return 1 if a read request was queued, 0 if the page already resided
@@ -116,7 +117,7 @@ buf_read_page_low(
ulint type,
ulint mode,
const page_id_t page_id,
const page_size_t& page_size,
ulint zip_size,
bool unzip,
bool ignore_missing_space = false)
{
@@ -132,7 +133,7 @@ buf_read_page_low(
return(0);
}
if (ibuf_bitmap_page(page_id, page_size) || trx_sys_hdr_page(page_id)) {
if (ibuf_bitmap_page(page_id, zip_size) || trx_sys_hdr_page(page_id)) {
/* Trx sys header is so low in the latching order that we play
safe and do not leave the i/o-completion to an asynchronous
@@ -147,7 +148,7 @@ buf_read_page_low(
or is being dropped; if we succeed in initing the page in the buffer
pool for read, then DISCARD cannot proceed until the read has
completed */
bpage = buf_page_init_for_read(err, mode, page_id, page_size, unzip);
bpage = buf_page_init_for_read(err, mode, page_id, zip_size, unzip);
if (bpage == NULL) {
@@ -155,7 +156,7 @@ buf_read_page_low(
}
DBUG_LOG("ib_buf",
"read page " << page_id << " size=" << page_size.physical()
"read page " << page_id << " zip_size=" << zip_size
<< " unzip=" << unzip << ',' << (sync ? "sync" : "async"));
ut_ad(buf_page_in_file(bpage));
@@ -166,7 +167,7 @@ buf_read_page_low(
void* dst;
if (page_size.is_compressed()) {
if (zip_size) {
dst = bpage->zip.data;
} else {
ut_a(buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE);
@@ -177,7 +178,8 @@ buf_read_page_low(
IORequest request(type | IORequest::READ);
*err = fil_io(
request, sync, page_id, page_size, 0, page_size.physical(),
request, sync, page_id, zip_size, 0,
zip_size ? zip_size : srv_page_size,
dst, bpage, ignore_missing_space);
if (sync) {
@@ -218,16 +220,13 @@ performed by ibuf routines, a situation which could result in a deadlock if
the OS does not support asynchronous i/o.
@param[in] page_id page id of a page which the current thread
wants to access
@param[in] page_size page size
@param[in] inside_ibuf TRUE if we are inside ibuf routine
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] ibuf whether we are inside ibuf routine
@return number of page read requests issued; NOTE that if we read ibuf
pages, it may happen that the page at the given page number does not
get read even if we return a positive value! */
ulint
buf_read_ahead_random(
const page_id_t page_id,
const page_size_t& page_size,
ibool inside_ibuf)
buf_read_ahead_random(const page_id_t page_id, ulint zip_size, bool ibuf)
{
buf_pool_t* buf_pool = buf_pool_get(page_id);
ulint recent_blocks = 0;
@@ -249,7 +248,7 @@ buf_read_ahead_random(
return(0);
}
if (ibuf_bitmap_page(page_id, page_size) || trx_sys_hdr_page(page_id)) {
if (ibuf_bitmap_page(page_id, zip_size) || trx_sys_hdr_page(page_id)) {
/* If it is an ibuf bitmap page or trx sys hdr, we do
no read-ahead, as that could break the ibuf page access
@@ -264,14 +263,14 @@ buf_read_ahead_random(
high = (page_id.page_no() / buf_read_ahead_random_area + 1)
* buf_read_ahead_random_area;
/* Remember the tablespace version before we ask the tablespace size
below: if DISCARD + IMPORT changes the actual .ibd file meanwhile, we
/* If DISCARD + IMPORT changes the actual .ibd file meanwhile, we
do not try to read outside the bounds of the tablespace! */
if (fil_space_t* space = fil_space_acquire(page_id.space())) {
#ifdef UNIV_DEBUG
if (srv_file_per_table) {
ulint size = 0;
const ulint physical_size = space->physical_size();
for (const fil_node_t* node =
UT_LIST_GET_FIRST(space->chain);
@@ -279,7 +278,7 @@ buf_read_ahead_random(
node = UT_LIST_GET_NEXT(chain, node)) {
size += ulint(os_file_get_size(node->handle)
/ page_size.physical());
/ physical_size);
}
ut_ad(size == space->size);
@@ -332,12 +331,7 @@ buf_read_ahead_random(
read_ahead:
/* Read all the suitable blocks within the area */
if (inside_ibuf) {
ibuf_mode = BUF_READ_IBUF_PAGES_ONLY;
} else {
ibuf_mode = BUF_READ_ANY_PAGE;
}
ibuf_mode = ibuf ? BUF_READ_IBUF_PAGES_ONLY : BUF_READ_ANY_PAGE;
count = 0;
for (i = low; i < high; i++) {
@@ -346,12 +340,12 @@ read_ahead:
const page_id_t cur_page_id(page_id.space(), i);
if (!ibuf_bitmap_page(cur_page_id, page_size)) {
if (!ibuf_bitmap_page(cur_page_id, zip_size)) {
count += buf_read_page_low(
&err, false,
IORequest::DO_NOT_WAKE,
ibuf_mode,
cur_page_id, page_size, false);
cur_page_id, zip_size, false);
switch (err) {
case DB_SUCCESS:
@@ -396,16 +390,13 @@ buffer buf_pool if it is not already there. Sets the io_fix flag and sets
an exclusive lock on the buffer frame. The flag is cleared and the x-lock
released by the i/o-handler thread.
@param[in] page_id page id
@param[in] page_size page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@retval DB_SUCCESS if the page was read and is not corrupted,
@retval DB_PAGE_CORRUPTED if page based on checksum check is corrupted,
@retval DB_DECRYPTION_FAILED if page post encryption checksum matches but
after decryption normal page checksum does not match.
@retval DB_TABLESPACE_DELETED if tablespace .ibd file is missing */
dberr_t
buf_read_page(
const page_id_t page_id,
const page_size_t& page_size)
dberr_t buf_read_page(const page_id_t page_id, ulint zip_size)
{
ulint count;
dberr_t err = DB_SUCCESS;
@@ -418,7 +409,7 @@ buf_read_page(
count = buf_read_page_low(
&err, true,
0, BUF_READ_ANY_PAGE, page_id, page_size, false);
0, BUF_READ_ANY_PAGE, page_id, zip_size, false);
srv_stats.buf_pool_reads.add(count);
@@ -438,13 +429,10 @@ buffer buf_pool if it is not already there. Sets the io_fix flag and sets
an exclusive lock on the buffer frame. The flag is cleared and the x-lock
released by the i/o-handler thread.
@param[in] page_id page id
@param[in] page_size page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] sync true if synchronous aio is desired */
void
buf_read_page_background(
const page_id_t page_id,
const page_size_t& page_size,
bool sync)
buf_read_page_background(const page_id_t page_id, ulint zip_size, bool sync)
{
ulint count;
dberr_t err;
@@ -453,7 +441,7 @@ buf_read_page_background(
&err, sync,
IORequest::DO_NOT_WAKE | IORequest::IGNORE_MISSING,
BUF_READ_ANY_PAGE,
page_id, page_size, false);
page_id, zip_size, false);
switch (err) {
case DB_SUCCESS:
@@ -508,14 +496,11 @@ NOTE 3: the calling thread must want access to the page given: this rule is
set to prevent unintended read-aheads performed by ibuf routines, a situation
which could result in a deadlock if the OS does not support asynchronous io.
@param[in] page_id page id; see NOTE 3 above
@param[in] page_size page size
@param[in] inside_ibuf TRUE if we are inside ibuf routine
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] ibuf whether if we are inside ibuf routine
@return number of page read requests issued */
ulint
buf_read_ahead_linear(
const page_id_t page_id,
const page_size_t& page_size,
ibool inside_ibuf)
buf_read_ahead_linear(const page_id_t page_id, ulint zip_size, bool ibuf)
{
buf_pool_t* buf_pool = buf_pool_get(page_id);
buf_page_t* bpage;
@@ -554,7 +539,7 @@ buf_read_ahead_linear(
return(0);
}
if (ibuf_bitmap_page(page_id, page_size) || trx_sys_hdr_page(page_id)) {
if (ibuf_bitmap_page(page_id, zip_size) || trx_sys_hdr_page(page_id)) {
/* If it is an ibuf bitmap page or trx sys hdr, we do
no read-ahead, as that could break the ibuf page access
@@ -715,9 +700,7 @@ buf_read_ahead_linear(
/* If we got this far, read-ahead can be sensible: do it */
ulint ibuf_mode;
ibuf_mode = inside_ibuf ? BUF_READ_IBUF_PAGES_ONLY : BUF_READ_ANY_PAGE;
ulint ibuf_mode = ibuf ? BUF_READ_IBUF_PAGES_ONLY : BUF_READ_ANY_PAGE;
/* Since Windows XP seems to schedule the i/o handler thread
very eagerly, and consequently it does not wait for the
@@ -731,11 +714,11 @@ buf_read_ahead_linear(
const page_id_t cur_page_id(page_id.space(), i);
if (!ibuf_bitmap_page(cur_page_id, page_size)) {
if (!ibuf_bitmap_page(cur_page_id, zip_size)) {
count += buf_read_page_low(
&err, false,
IORequest::DO_NOT_WAKE,
ibuf_mode, cur_page_id, page_size, false);
ibuf_mode, cur_page_id, zip_size, false);
switch (err) {
case DB_SUCCESS:
@@ -801,11 +784,8 @@ buf_read_ibuf_merge_pages(
#endif
for (ulint i = 0; i < n_stored; i++) {
bool found;
const page_size_t page_size(fil_space_get_page_size(
space_ids[i], &found));
if (!found) {
fil_space_t* s = fil_space_acquire_for_io(space_ids[i]);
if (!s) {
tablespace_deleted:
/* The tablespace was not found: remove all
entries for it */
@@ -817,6 +797,9 @@ tablespace_deleted:
continue;
}
const ulint zip_size = s->zip_size();
s->release_for_io();
const page_id_t page_id(space_ids[i], page_nos[i]);
buf_pool_t* buf_pool = buf_pool_get(page_id);
@@ -831,7 +814,7 @@ tablespace_deleted:
buf_read_page_low(&err,
sync && (i + 1 == n_stored),
0,
BUF_READ_ANY_PAGE, page_id, page_size,
BUF_READ_ANY_PAGE, page_id, zip_size,
true, true /* ignore_missing_space */);
switch(err) {
@@ -882,7 +865,7 @@ buf_read_recv_pages(
fil_space_open_if_needed(space);
const page_size_t page_size(space->flags);
const ulint zip_size = space->zip_size();
for (ulint i = 0; i < n_stored; i++) {
buf_pool_t* buf_pool;
@@ -915,13 +898,13 @@ buf_read_recv_pages(
&err, true,
0,
BUF_READ_ANY_PAGE,
cur_page_id, page_size, true);
cur_page_id, zip_size, true);
} else {
buf_read_page_low(
&err, false,
IORequest::DO_NOT_WAKE,
BUF_READ_ANY_PAGE,
cur_page_id, page_size, true);
cur_page_id, zip_size, true);
}
if (err == DB_DECRYPTION_FAILED || err == DB_PAGE_CORRUPTED) {

View File

@@ -610,6 +610,12 @@ dtuple_convert_big_rec(
return(NULL);
}
if (!index->table->space) {
return NULL;
}
const auto zip_size = index->table->space->zip_size();
ut_ad(index->n_uniq > 0);
ut_a(dtuple_check_typed_no_assert(entry));
@@ -660,7 +666,7 @@ dtuple_convert_big_rec(
*n_ext),
index->table->not_redundant(),
dict_index_get_n_fields(index),
dict_table_page_size(index->table))) {
zip_size)) {
longest_i = 0;
for (ulint i = index->first_user_field(), longest = 0;
i + mblob < entry->n_fields; i++) {

View File

@@ -47,7 +47,7 @@ dict_hdr_get(
dict_hdr_t* header;
block = buf_page_get(page_id_t(DICT_HDR_SPACE, DICT_HDR_PAGE_NO),
univ_page_size, RW_X_LATCH, mtr);
0, RW_X_LATCH, mtr);
header = DICT_HDR + buf_block_get_frame(block);
buf_block_dbg_add_level(block, SYNC_DICT_HEADER);

View File

@@ -960,21 +960,19 @@ dict_drop_index_tree(
ut_ad(len == 8);
bool found;
const page_size_t page_size(fil_space_get_page_size(space,
&found));
if (!found) {
/* It is a single table tablespace and the .ibd file is
missing: do nothing */
return(false);
if (fil_space_t* s = fil_space_acquire_silent(space)) {
/* Ensure that the tablespace file exists
in order to avoid a crash in buf_page_get_gen(). */
if (s->size || fil_space_get_size(space)) {
btr_free_if_exists(page_id_t(space, root_page_no),
s->zip_size(),
mach_read_from_8(ptr), mtr);
}
s->release();
return true;
}
btr_free_if_exists(page_id_t(space, root_page_no), page_size,
mach_read_from_8(ptr), mtr);
return(true);
return false;
}
/*******************************************************************//**

View File

@@ -2118,10 +2118,9 @@ dict_index_too_big_for_tree(
comp = dict_table_is_comp(table);
const page_size_t page_size(dict_tf_get_page_size(table->flags));
const ulint zip_size = dict_tf_get_zip_size(table->flags);
if (page_size.is_compressed()
&& page_size.physical() < srv_page_size) {
if (zip_size && zip_size < srv_page_size) {
/* On a compressed page, two records must fit in the
uncompressed page modification log. On compressed pages
with size.physical() == srv_page_size,
@@ -2132,7 +2131,7 @@ dict_index_too_big_for_tree(
number in the page modification log. The maximum
allowed node pointer size is half that. */
page_rec_max = page_zip_empty_size(new_index->n_fields,
page_size.physical());
zip_size);
if (page_rec_max) {
page_rec_max--;
}
@@ -7073,52 +7072,3 @@ dict_space_get_id(
return(id);
}
/** Determine the extent size (in pages) for the given table
@param[in] table the table whose extent size is being
calculated.
@return extent size in pages (256, 128 or 64) */
ulint
dict_table_extent_size(
const dict_table_t* table)
{
const ulint mb_1 = 1024 * 1024;
const ulint mb_2 = 2 * mb_1;
const ulint mb_4 = 4 * mb_1;
page_size_t page_size = dict_table_page_size(table);
ulint pages_in_extent = FSP_EXTENT_SIZE;
if (page_size.is_compressed()) {
ulint disk_page_size = page_size.physical();
switch (disk_page_size) {
case 1024:
pages_in_extent = mb_1/1024;
break;
case 2048:
pages_in_extent = mb_1/2048;
break;
case 4096:
pages_in_extent = mb_1/4096;
break;
case 8192:
pages_in_extent = mb_1/8192;
break;
case 16384:
pages_in_extent = mb_1/16384;
break;
case 32768:
pages_in_extent = mb_2/32768;
break;
case 65536:
pages_in_extent = mb_4/65536;
break;
default:
ut_ad(0);
}
}
return(pages_in_extent);
}

View File

@@ -1505,7 +1505,7 @@ dict_stats_analyze_index_below_cur(
page_id_t page_id(index->table->space_id,
btr_node_ptr_get_child_page_no(
rec, offsets_rec));
const page_size_t page_size(index->table->space->flags);
const ulint zip_size = index->table->space->zip_size();
/* assume no external pages by default - in case we quit from this
function without analyzing any leaf pages */
@@ -1518,7 +1518,7 @@ dict_stats_analyze_index_below_cur(
dberr_t err = DB_SUCCESS;
block = buf_page_get_gen(page_id, page_size, RW_S_LATCH,
block = buf_page_get_gen(page_id, zip_size, RW_S_LATCH,
NULL /* no guessed block */,
BUF_GET, __FILE__, __LINE__, &mtr, &err);

View File

@@ -1,6 +1,6 @@
/*****************************************************************************
Copyright (C) 2013, 2015, Google Inc. All Rights Reserved.
Copyright (c) 2014, 2018, MariaDB Corporation. All Rights Reserved.
Copyright (c) 2014, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -274,16 +274,14 @@ fil_space_merge_crypt_data(
}
/** Initialize encryption parameters from a tablespace header page.
@param[in] page_size page size of the tablespace
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] page first page of the tablespace
@return crypt data from page 0
@retval NULL if not present or not valid */
UNIV_INTERN
fil_space_crypt_t*
fil_space_read_crypt_data(const page_size_t& page_size, const byte* page)
fil_space_crypt_t* fil_space_read_crypt_data(ulint zip_size, const byte* page)
{
const ulint offset = FSP_HEADER_OFFSET
+ fsp_header_get_encryption_offset(page_size);
+ fsp_header_get_encryption_offset(zip_size);
if (memcmp(page + offset, CRYPT_MAGIC, MAGIC_SZ) != 0) {
/* Crypt data is not stored. */
@@ -371,7 +369,7 @@ fil_space_crypt_t::write_page0(
ut_ad(this == space->crypt_data);
const uint len = sizeof(iv);
const ulint offset = FSP_HEADER_OFFSET
+ fsp_header_get_encryption_offset(page_size_t(space->flags));
+ fsp_header_get_encryption_offset(space->zip_size());
page0_offset = offset;
/*
@@ -545,7 +543,7 @@ fil_parse_write_crypt_data(
@param[in] offset Page offset
@param[in] lsn Log sequence number
@param[in] src_frame Page to encrypt
@param[in] page_size Page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in,out] dst_frame Output buffer
@return encrypted buffer or NULL */
UNIV_INTERN
@@ -556,10 +554,10 @@ fil_encrypt_buf(
ulint offset,
lsn_t lsn,
const byte* src_frame,
const page_size_t& page_size,
ulint zip_size,
byte* dst_frame)
{
uint size = uint(page_size.physical());
uint size = uint(zip_size ? zip_size : srv_page_size);
uint key_version = fil_crypt_get_latest_key_version(crypt_data);
ut_a(key_version != ENCRYPTION_KEY_VERSION_INVALID);
@@ -601,24 +599,24 @@ fil_encrypt_buf(
to sector boundary is written. */
if (!page_compressed) {
/* FIL page trailer is also not encrypted */
memcpy(dst_frame + page_size.physical() - FIL_PAGE_DATA_END,
src_frame + page_size.physical() - FIL_PAGE_DATA_END,
memcpy(dst_frame + size - FIL_PAGE_DATA_END,
src_frame + size - FIL_PAGE_DATA_END,
FIL_PAGE_DATA_END);
} else {
/* Clean up rest of buffer */
memset(dst_frame+header_len+srclen, 0,
page_size.physical() - (header_len + srclen));
size - (header_len + srclen));
}
/* handle post encryption checksum */
ib_uint32_t checksum = 0;
checksum = fil_crypt_calculate_checksum(page_size, dst_frame);
checksum = fil_crypt_calculate_checksum(zip_size, dst_frame);
// store the post-encryption checksum after the key-version
mach_write_to_4(dst_frame + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION + 4, checksum);
ut_ad(fil_space_verify_crypt_checksum(dst_frame, page_size));
ut_ad(fil_space_verify_crypt_checksum(dst_frame, zip_size));
srv_stats.pages_encrypted.inc();
@@ -657,10 +655,10 @@ fil_space_encrypt(
}
fil_space_crypt_t* crypt_data = space->crypt_data;
const page_size_t page_size(space->flags);
const ulint zip_size = space->zip_size();
ut_ad(space->pending_io());
byte* tmp = fil_encrypt_buf(crypt_data, space->id, offset, lsn,
src_frame, page_size, dst_frame);
src_frame, zip_size, dst_frame);
#ifdef UNIV_DEBUG
if (tmp) {
@@ -681,8 +679,9 @@ fil_space_encrypt(
}
}
ut_ad(!buf_page_is_corrupted(true, src, page_size, space));
ut_ad(fil_space_decrypt(crypt_data, tmp_mem, page_size, tmp,
ut_ad(!buf_page_is_corrupted(true, src, zip_size, space));
ut_ad(fil_space_decrypt(crypt_data, tmp_mem,
space->physical_size(), tmp,
&err));
ut_ad(err == DB_SUCCESS);
@@ -696,7 +695,7 @@ fil_space_encrypt(
memcpy(tmp_mem + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION,
src + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION, 8);
ut_ad(!memcmp(src, tmp_mem, page_size.physical()));
ut_ad(!memcmp(src, tmp_mem, space->physical_size()));
}
#endif /* UNIV_DEBUG */
@@ -706,7 +705,7 @@ fil_space_encrypt(
/** Decrypt a page.
@param[in] crypt_data crypt_data
@param[in] tmp_frame Temporary buffer
@param[in] page_size Page size
@param[in] physical_size page size
@param[in,out] src_frame Page to decrypt
@param[out] err DB_SUCCESS or DB_DECRYPTION_FAILED
@return true if page decrypted, false if not.*/
@@ -715,7 +714,7 @@ bool
fil_space_decrypt(
fil_space_crypt_t* crypt_data,
byte* tmp_frame,
const page_size_t& page_size,
ulint physical_size,
byte* src_frame,
dberr_t* err)
{
@@ -748,8 +747,7 @@ fil_space_decrypt(
const byte* src = src_frame + header_len;
byte* dst = tmp_frame + header_len;
uint32 dstlen = 0;
uint srclen = uint(page_size.physical())
- header_len - FIL_PAGE_DATA_END;
uint srclen = uint(physical_size) - header_len - FIL_PAGE_DATA_END;
if (page_compressed) {
srclen = mach_read_from_2(src_frame + FIL_PAGE_DATA);
@@ -779,8 +777,8 @@ fil_space_decrypt(
to sector boundary is written. */
if (!page_compressed) {
/* Copy FIL trailer */
memcpy(tmp_frame + page_size.physical() - FIL_PAGE_DATA_END,
src_frame + page_size.physical() - FIL_PAGE_DATA_END,
memcpy(tmp_frame + physical_size - FIL_PAGE_DATA_END,
src_frame + physical_size - FIL_PAGE_DATA_END,
FIL_PAGE_DATA_END);
}
@@ -807,21 +805,21 @@ fil_space_decrypt(
{
dberr_t err = DB_SUCCESS;
byte* res = NULL;
const page_size_t page_size(space->flags);
const ulint physical_size = space->physical_size();
*decrypted = false;
ut_ad(space->crypt_data != NULL && space->crypt_data->is_encrypted());
ut_ad(space->pending_io());
bool encrypted = fil_space_decrypt(space->crypt_data, tmp_frame,
page_size, src_frame, &err);
physical_size, src_frame, &err);
if (err == DB_SUCCESS) {
if (encrypted) {
*decrypted = true;
/* Copy the decrypted page back to page buffer, not
really any other options. */
memcpy(src_frame, tmp_frame, page_size.physical());
memcpy(src_frame, tmp_frame, physical_size);
}
res = src_frame;
@@ -830,21 +828,18 @@ fil_space_decrypt(
return res;
}
/******************************************************************
/**
Calculate post encryption checksum
@param[in] page_size page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] dst_frame Block where checksum is calculated
@return page checksum
not needed. */
UNIV_INTERN
uint32_t
fil_crypt_calculate_checksum(
const page_size_t& page_size,
const byte* dst_frame)
fil_crypt_calculate_checksum(ulint zip_size, const byte* dst_frame)
{
/* For encrypted tables we use only crc32 and strict_crc32 */
return page_size.is_compressed()
? page_zip_calc_checksum(dst_frame, page_size.physical(),
return zip_size
? page_zip_calc_checksum(dst_frame, zip_size,
SRV_CHECKSUM_ALGORITHM_CRC32)
: buf_calc_page_crc32(dst_frame);
}
@@ -952,15 +947,15 @@ fil_crypt_read_crypt_data(fil_space_t* space)
return;
}
const page_size_t page_size(space->flags);
const ulint zip_size = space->zip_size();
mtr_t mtr;
mtr.start();
if (buf_block_t* block = buf_page_get(page_id_t(space->id, 0),
page_size, RW_S_LATCH, &mtr)) {
zip_size, RW_S_LATCH, &mtr)) {
mutex_enter(&fil_system.mutex);
if (!space->crypt_data) {
space->crypt_data = fil_space_read_crypt_data(
page_size, block->frame);
zip_size, block->frame);
}
mutex_exit(&fil_system.mutex);
}
@@ -1034,7 +1029,7 @@ fil_crypt_start_encrypting_space(
/* 2 - get page 0 */
dberr_t err = DB_SUCCESS;
buf_block_t* block = buf_page_get_gen(
page_id_t(space->id, 0), page_size_t(space->flags),
page_id_t(space->id, 0), space->zip_size(),
RW_X_LATCH, NULL, BUF_GET,
__FILE__, __LINE__,
&mtr, &err);
@@ -1623,7 +1618,7 @@ fil_crypt_get_page_throttle_func(
unsigned line)
{
fil_space_t* space = state->space;
const page_size_t page_size = page_size_t(space->flags);
const ulint zip_size = space->zip_size();
const page_id_t page_id(space->id, offset);
ut_ad(space->referenced());
@@ -1634,7 +1629,7 @@ fil_crypt_get_page_throttle_func(
}
dberr_t err = DB_SUCCESS;
buf_block_t* block = buf_page_get_gen(page_id, page_size, RW_X_LATCH,
buf_block_t* block = buf_page_get_gen(page_id, zip_size, RW_X_LATCH,
NULL,
BUF_PEEK_IF_IN_POOL, file, line,
mtr, &err);
@@ -1651,7 +1646,7 @@ fil_crypt_get_page_throttle_func(
state->crypt_stat.pages_read_from_disk++;
uintmax_t start = ut_time_us(NULL);
block = buf_page_get_gen(page_id, page_size,
block = buf_page_get_gen(page_id, zip_size,
RW_X_LATCH,
NULL, BUF_GET_POSSIBLY_FREED,
file, line, mtr, &err);
@@ -2020,7 +2015,7 @@ fil_crypt_flush_space(
dberr_t err;
if (buf_block_t* block = buf_page_get_gen(
page_id_t(space->id, 0), page_size_t(space->flags),
page_id_t(space->id, 0), space->zip_size(),
RW_X_LATCH, NULL, BUF_GET,
__FILE__, __LINE__, &mtr, &err)) {
mtr.set_named_space(space);
@@ -2527,10 +2522,9 @@ calculated checksum as if it does page could be valid unencrypted,
encrypted, or corrupted.
@param[in,out] page page frame (checksum is temporarily modified)
@param[in] page_size page size
@return whether the encrypted page is OK */
bool
fil_space_verify_crypt_checksum(const byte* page, const page_size_t& page_size)
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@return true if page is encrypted AND OK, false otherwise */
bool fil_space_verify_crypt_checksum(const byte* page, ulint zip_size)
{
ut_ad(mach_read_from_4(page + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION));
@@ -2551,10 +2545,9 @@ fil_space_verify_crypt_checksum(const byte* page, const page_size_t& page_size)
switch (srv_checksum_algorithm_t(srv_checksum_algorithm)) {
case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32:
if (page_size.is_compressed()) {
if (zip_size) {
return checksum == page_zip_calc_checksum(
page, page_size.physical(),
SRV_CHECKSUM_ALGORITHM_CRC32);
page, zip_size, SRV_CHECKSUM_ALGORITHM_CRC32);
}
return checksum == buf_calc_page_crc32(page);
@@ -2575,12 +2568,12 @@ fil_space_verify_crypt_checksum(const byte* page, const page_size_t& page_size)
if (checksum == BUF_NO_CHECKSUM_MAGIC) {
return true;
}
if (page_size.is_compressed()) {
if (zip_size) {
return checksum == page_zip_calc_checksum(
page, page_size.physical(),
page, zip_size,
SRV_CHECKSUM_ALGORITHM_CRC32)
|| checksum == page_zip_calc_checksum(
page, page_size.physical(),
page, zip_size,
SRV_CHECKSUM_ALGORITHM_INNODB);
}

View File

@@ -261,7 +261,7 @@ fil_node_complete_io(fil_node_t* node, const IORequest& type);
blocks at the end of file are ignored: they are not taken into account when
calculating the byte offset within a space.
@param[in] page_id page id
@param[in] page_size page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] byte_offset remainder of offset in bytes; in aio this
must be divisible by the OS block size
@param[in] len how many bytes to read; this must not cross a
@@ -274,12 +274,12 @@ UNIV_INLINE
dberr_t
fil_read(
const page_id_t page_id,
const page_size_t& page_size,
ulint zip_size,
ulint byte_offset,
ulint len,
void* buf)
{
return(fil_io(IORequestRead, true, page_id, page_size,
return(fil_io(IORequestRead, true, page_id, zip_size,
byte_offset, len, buf, NULL));
}
@@ -287,7 +287,7 @@ fil_read(
blocks at the end of file are ignored: they are not taken into account when
calculating the byte offset within a space.
@param[in] page_id page id
@param[in] page_size page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] byte_offset remainder of offset in bytes; in aio this
must be divisible by the OS block size
@param[in] len how many bytes to write; this must not cross
@@ -300,14 +300,14 @@ UNIV_INLINE
dberr_t
fil_write(
const page_id_t page_id,
const page_size_t& page_size,
ulint zip_size,
ulint byte_offset,
ulint len,
void* buf)
{
ut_ad(!srv_read_only_mode);
return(fil_io(IORequestWrite, true, page_id, page_size,
return(fil_io(IORequestWrite, true, page_id, zip_size,
byte_offset, len, buf, NULL));
}
@@ -389,8 +389,7 @@ void fil_space_t::set_imported()
const fil_node_t* node = UT_LIST_GET_FIRST(chain);
atomic_write_supported = node->atomic_write
&& srv_use_atomic_writes
&& my_test_if_atomic_write(node->handle,
int(page_size_t(flags).physical()));
&& my_test_if_atomic_write(node->handle, physical_size());
purpose = FIL_TYPE_TABLESPACE;
}
@@ -477,8 +476,7 @@ bool fil_node_t::read_page0(bool first)
{
ut_ad(mutex_own(&fil_system.mutex));
ut_a(space->purpose != FIL_TYPE_LOG);
const page_size_t page_size(space->flags);
const ulint psize = page_size.physical();
const ulint psize = space->physical_size();
os_offset_t size_bytes = os_file_get_size(handle);
ut_a(size_bytes != (os_offset_t) -1);
@@ -507,12 +505,6 @@ bool fil_node_t::read_page0(bool first)
const ulint free_limit = fsp_header_get_field(page, FSP_FREE_LIMIT);
const ulint free_len = flst_get_len(FSP_HEADER_OFFSET + FSP_FREE
+ page);
/* Try to read crypt_data from page 0 if it is not yet read. */
if (!space->crypt_data) {
space->crypt_data = fil_space_read_crypt_data(page_size, page);
}
ut_free(buf2);
if (!fsp_flags_is_valid(flags, space->id)) {
ulint cflags = fsp_flags_convert_from_101(flags);
if (cflags == ULINT_UNDEFINED
@@ -522,12 +514,20 @@ bool fil_node_t::read_page0(bool first)
<< ib::hex(space->flags)
<< " but found " << ib::hex(flags)
<< " in the file " << name;
ut_free(buf2);
return false;
}
flags = cflags;
}
/* Try to read crypt_data from page 0 if it is not yet read. */
if (!space->crypt_data) {
space->crypt_data = fil_space_read_crypt_data(
fil_space_t::zip_size(flags), page);
}
ut_free(buf2);
if (UNIV_UNLIKELY(space_id != space->id)) {
ib::error() << "Expected tablespace id " << space->id
<< " but found " << space_id
@@ -647,9 +647,7 @@ retry:
|| (node->atomic_write
&& srv_use_atomic_writes
&& my_test_if_atomic_write(
node->handle,
int(page_size_t(space->flags)
.physical())));
node->handle, space->physical_size()));
}
ut_a(success);
@@ -921,8 +919,7 @@ fil_space_extend_must_retry(
node->handle, node->name);
}
const page_size_t pageSize(space->flags);
const ulint page_size = pageSize.physical();
const ulint page_size = space->physical_size();
/* fil_read_first_page() expects srv_page_size bytes.
fil_node_open_file() expects at least 4 * srv_page_size bytes.*/
@@ -982,7 +979,6 @@ fil_space_extend_must_retry(
srv_tmp_space.set_last_file_size(pages_in_MiB);
return(false);
}
}
/*******************************************************************//**
@@ -1637,28 +1633,6 @@ void fil_space_t::close()
mutex_exit(&fil_system.mutex);
}
/** Returns the page size of the space and whether it is compressed or not.
The tablespace must be cached in the memory cache.
@param[in] id space id
@param[out] found true if tablespace was found
@return page size */
const page_size_t
fil_space_get_page_size(
ulint id,
bool* found)
{
const ulint flags = fil_space_get_flags(id);
if (flags == ULINT_UNDEFINED) {
*found = false;
return(univ_page_size);
}
*found = true;
return(page_size_t(flags));
}
void fil_system_t::create(ulint hash_size)
{
ut_ad(this == &fil_system);
@@ -1896,13 +1870,11 @@ fil_write_flushed_lsn(
const page_id_t page_id(TRX_SYS_SPACE, 0);
err = fil_read(page_id, univ_page_size, 0, srv_page_size,
buf);
err = fil_read(page_id, 0, 0, srv_page_size, buf);
if (err == DB_SUCCESS) {
mach_write_to_8(buf + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION, lsn);
err = fil_write(page_id, univ_page_size, 0,
srv_page_size, buf);
err = fil_write(page_id, 0, 0, srv_page_size, buf);
fil_flush_file_spaces(FIL_TYPE_TABLESPACE);
}
@@ -3050,18 +3022,9 @@ err_exit:
fsp_header_init_fields(page, space_id, flags);
mach_write_to_4(page + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID, space_id);
const page_size_t page_size(flags);
IORequest request(IORequest::WRITE);
if (!page_size.is_compressed()) {
buf_flush_init_for_writing(NULL, page, NULL, 0);
*err = os_file_write(
request, path, file, page, 0, page_size.physical());
} else {
if (ulint zip_size = fil_space_t::zip_size(flags)) {
page_zip_des_t page_zip;
page_zip_set_size(&page_zip, page_size.physical());
page_zip_set_size(&page_zip, zip_size);
page_zip.data = page + srv_page_size;
#ifdef UNIV_DEBUG
page_zip.m_start =
@@ -3072,8 +3035,12 @@ err_exit:
buf_flush_init_for_writing(NULL, page, &page_zip, 0);
*err = os_file_write(
request, path, file, page_zip.data, 0,
page_size.physical());
IORequestWrite, path, file, page_zip.data, 0, zip_size);
} else {
buf_flush_init_for_writing(NULL, page, NULL, 0);
*err = os_file_write(
IORequestWrite, path, file, page, 0, srv_page_size);
}
ut_free(buf2);
@@ -3487,7 +3454,8 @@ skip_validate:
df_remote.get_first_page();
fil_space_crypt_t* crypt_data = first_page
? fil_space_read_crypt_data(page_size_t(flags), first_page)
? fil_space_read_crypt_data(fil_space_t::zip_size(flags),
first_page)
: NULL;
fil_space_t* space = fil_space_create(
@@ -3835,7 +3803,8 @@ fil_ibd_load(
const byte* first_page = file.get_first_page();
fil_space_crypt_t* crypt_data = first_page
? fil_space_read_crypt_data(page_size_t(flags), first_page)
? fil_space_read_crypt_data(fil_space_t::zip_size(flags),
first_page)
: NULL;
space = fil_space_create(
file.name(), space_id, flags, FIL_TYPE_TABLESPACE, crypt_data);
@@ -3909,7 +3878,7 @@ void fsp_flags_try_adjust(fil_space_t* space, ulint flags)
mtr_t mtr;
mtr.start();
if (buf_block_t* b = buf_page_get(
page_id_t(space->id, 0), page_size_t(flags),
page_id_t(space->id, 0), space->zip_size(),
RW_X_LATCH, &mtr)) {
ulint f = fsp_header_get_flags(b->frame);
/* Suppress the message if only the DATA_DIR flag to differs. */
@@ -4110,7 +4079,7 @@ fil_report_invalid_page_access(
@param[in,out] type IO context
@param[in] sync true if synchronous aio is desired
@param[in] page_id page id
@param[in] page_size page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] byte_offset remainder of offset in bytes; in aio this
must be divisible by the OS block size
@param[in] len how many bytes to read or write; this must
@@ -4129,7 +4098,7 @@ fil_io(
const IORequest& type,
bool sync,
const page_id_t page_id,
const page_size_t& page_size,
ulint zip_size,
ulint byte_offset,
ulint len,
void* buf,
@@ -4143,7 +4112,7 @@ fil_io(
ut_ad(len > 0);
ut_ad(byte_offset < srv_page_size);
ut_ad(!page_size.is_compressed() || byte_offset == 0);
ut_ad(!zip_size || byte_offset == 0);
ut_ad(srv_page_size == 1UL << srv_page_size_shift);
compile_time_assert((1U << UNIV_PAGE_SIZE_SHIFT_MAX)
== UNIV_PAGE_SIZE_MAX);
@@ -4154,7 +4123,7 @@ fil_io(
/* ibuf bitmap pages must be read in the sync AIO mode: */
ut_ad(recv_no_ibuf_operations
|| req_type.is_write()
|| !ibuf_bitmap_page(page_id, page_size)
|| !ibuf_bitmap_page(page_id, zip_size)
|| sync
|| req_type.is_log());
@@ -4170,7 +4139,7 @@ fil_io(
} else if (req_type.is_read()
&& !recv_no_ibuf_operations
&& ibuf_page(page_id, page_size, NULL)) {
&& ibuf_page(page_id, zip_size, NULL)) {
mode = OS_AIO_IBUF;
@@ -4312,37 +4281,10 @@ fil_io(
/* Now we have made the changes in the data structures of fil_system */
mutex_exit(&fil_system.mutex);
/* Calculate the low 32 bits and the high 32 bits of the file offset */
if (!zip_size) zip_size = srv_page_size;
if (!page_size.is_compressed()) {
offset = ((os_offset_t) cur_page_no
<< srv_page_size_shift) + byte_offset;
ut_a(node->size - cur_page_no
>= ((byte_offset + len + (srv_page_size - 1))
>> srv_page_size_shift));
} else {
ulint size_shift;
switch (page_size.physical()) {
case 1024: size_shift = 10; break;
case 2048: size_shift = 11; break;
case 4096: size_shift = 12; break;
case 8192: size_shift = 13; break;
case 16384: size_shift = 14; break;
case 32768: size_shift = 15; break;
case 65536: size_shift = 16; break;
default: ut_error;
}
offset = ((os_offset_t) cur_page_no << size_shift)
+ byte_offset;
ut_a(node->size - cur_page_no
>= (len + (page_size.physical() - 1))
/ page_size.physical());
}
offset = os_offset_t(cur_page_no) * zip_size + byte_offset;
ut_ad(node->size - cur_page_no >= (len + (zip_size - 1)) / zip_size);
/* Do AIO */

View File

@@ -250,8 +250,7 @@ success:
page_t page[UNIV_PAGE_SIZE_MAX];
memcpy(page, out_buf, srv_page_size);
ut_ad(fil_page_decompress(tmp_buf, page));
ut_ad(!buf_page_is_corrupted(false, page, univ_page_size,
NULL));
ut_ad(!buf_page_is_corrupted(false, page, 0, NULL));
}
#endif /* UNIV_DEBUG */

View File

@@ -356,8 +356,14 @@ Datafile::read_first_page(bool read_only_mode)
}
}
const page_size_t ps(m_flags);
if (ps.physical() > page_size) {
ulint ssize = FSP_FLAGS_GET_PAGE_SSIZE(m_flags);
if (!ssize) ssize = UNIV_PAGE_SSIZE_ORIG;
const ulint zip_ssize = FSP_FLAGS_GET_ZIP_SSIZE(m_flags);
const size_t logical_size = ((UNIV_ZIP_SIZE_MIN >> 1) << ssize);
const size_t physical_size = zip_ssize
? (UNIV_ZIP_SIZE_MIN >> 1) << zip_ssize : logical_size;
if (physical_size > page_size) {
ib::error() << "File " << m_filepath
<< " should be longer than "
<< page_size << " bytes";
@@ -543,13 +549,13 @@ err_exit:
goto err_exit;
}
const page_size_t page_size(m_flags);
ulint logical_size = fil_space_t::logical_size(m_flags);
if (srv_page_size != page_size.logical()) {
if (srv_page_size != logical_size) {
/* Logical size must be innodb_page_size. */
ib::error()
<< "Data file '" << m_filepath << "' uses page size "
<< page_size.logical() << ", but the innodb_page_size"
<< logical_size << ", but the innodb_page_size"
" start-up parameter is "
<< srv_page_size;
free_first_page();
@@ -568,7 +574,8 @@ err_exit:
goto err_exit;
}
if (buf_page_is_corrupted(false, m_first_page, page_size)) {
if (buf_page_is_corrupted(false, m_first_page,
fil_space_t::zip_size(m_flags))) {
/* Look for checksum and other corruptions. */
error_txt = "Checksum mismatch";
goto err_exit;
@@ -630,7 +637,6 @@ Datafile::find_space_id()
for (ulint page_size = UNIV_ZIP_SIZE_MIN;
page_size <= UNIV_PAGE_SIZE_MAX;
page_size <<= 1) {
/* map[space_id] = count of pages */
typedef std::map<
ulint,
@@ -681,27 +687,16 @@ Datafile::find_space_id()
equal to srv_page_size. */
if (page_size == srv_page_size) {
noncompressed_ok = !buf_page_is_corrupted(
false, page, univ_page_size, NULL);
false, page, 0, NULL);
}
bool compressed_ok = false;
/* file-per-table tablespaces can be compressed with
the same physical and logical page size. General
tablespaces must have different physical and logical
page sizes in order to be compressed. For this check,
assume the page is compressed if univ_page_size.
logical() is equal to or less than 16k and the
page_size we are checking is equal to or less than
srv_page_size. */
if (srv_page_size <= UNIV_PAGE_SIZE_DEF
&& page_size <= srv_page_size) {
const page_size_t compr_page_size(
page_size, srv_page_size,
true);
compressed_ok = !buf_page_is_corrupted(
false, page, compr_page_size, NULL);
false, page,
page_size, NULL);
}
if (noncompressed_ok || compressed_ok) {
@@ -801,21 +796,21 @@ Datafile::restore_from_doublewrite()
/* The flags on the page should be converted later. */
}
const page_size_t page_size(flags);
ulint physical_size = fil_space_t::physical_size(flags);
ut_a(page_get_page_no(page) == page_id.page_no());
ib::info() << "Restoring page " << page_id
<< " of datafile '" << m_filepath
<< "' from the doublewrite buffer. Writing "
<< page_size.physical() << " bytes into file '"
<< physical_size << " bytes into file '"
<< m_filepath << "'";
IORequest request(IORequest::WRITE);
return(os_file_write(
request,
m_filepath, m_handle, page, 0, page_size.physical())
m_filepath, m_handle, page, 0, physical_size)
!= DB_SUCCESS);
}

File diff suppressed because it is too large Load Diff

View File

@@ -3273,7 +3273,7 @@ fts_fetch_doc_from_rec(
doc->text.f_str =
btr_rec_copy_externally_stored_field(
clust_rec, offsets,
btr_pcur_get_block(pcur)->page.size,
btr_pcur_get_block(pcur)->zip_size(),
clust_pos, &doc->text.f_len,
static_cast<mem_heap_t*>(
doc->self_heap->arg));
@@ -7456,7 +7456,7 @@ fts_init_recover_doc(
doc.text.f_str = btr_copy_externally_stored_field(
&doc.text.f_len,
static_cast<byte*>(dfield_get_data(dfield)),
dict_table_page_size(table), len,
table->space->zip_size(), len,
static_cast<mem_heap_t*>(doc.self_heap->arg));
} else {
doc.text.f_str = static_cast<byte*>(

View File

@@ -206,7 +206,7 @@ struct fts_phrase_t {
distance(0),
charset(NULL),
heap(NULL),
page_size(dict_table_page_size(table)),
zip_size(table->space->zip_size()),
proximity_pos(NULL),
parser(NULL)
{
@@ -230,8 +230,8 @@ struct fts_phrase_t {
/** Heap for word processing */
mem_heap_t* heap;
/** Row page size */
const page_size_t page_size;
/** ROW_FORMAT=COMPRESSED page size, or 0 */
const ulint zip_size;
/** Position info for proximity search verification. Records the
min and max position of words matched */
@@ -2013,7 +2013,7 @@ fts_query_fetch_document(
if (dfield_is_ext(dfield)) {
data = btr_copy_externally_stored_field(
&cur_len, data, phrase->page_size,
&cur_len, data, phrase->zip_size,
dfield_get_len(dfield), phrase->heap);
} else {
cur_len = dfield_get_len(dfield);

View File

@@ -120,13 +120,11 @@ flst_add_last(
if (last_addr.page == node_addr.page) {
last_node = page_align(node) + last_addr.boffset;
} else {
bool found;
const page_size_t& page_size
= fil_space_get_page_size(space, &found);
fil_space_t* s = fil_space_acquire_silent(space);
ulint zip_size = s ? s->zip_size() : 0;
if (s) s->release();
ut_ad(found);
last_node = fut_get_ptr(space, page_size, last_addr,
last_node = fut_get_ptr(space, zip_size, last_addr,
RW_SX_LATCH, mtr);
}
@@ -170,13 +168,11 @@ flst_add_first(
if (first_addr.page == node_addr.page) {
first_node = page_align(node) + first_addr.boffset;
} else {
bool found;
const page_size_t& page_size
= fil_space_get_page_size(space, &found);
fil_space_t* s = fil_space_acquire_silent(space);
ulint zip_size = s ? s->zip_size() : 0;
if (s) s->release();
ut_ad(found);
first_node = fut_get_ptr(space, page_size, first_addr,
first_node = fut_get_ptr(space, zip_size, first_addr,
RW_SX_LATCH, mtr);
}
@@ -230,13 +226,11 @@ flst_insert_after(
if (!fil_addr_is_null(node3_addr)) {
/* Update prev field of node3 */
bool found;
const page_size_t& page_size
= fil_space_get_page_size(space, &found);
fil_space_t* s = fil_space_acquire_silent(space);
ulint zip_size = s ? s->zip_size() : 0;
if (s) s->release();
ut_ad(found);
node3 = fut_get_ptr(space, page_size,
node3 = fut_get_ptr(space, zip_size,
node3_addr, RW_SX_LATCH, mtr);
flst_write_addr(node3 + FLST_PREV, node2_addr, mtr);
} else {
@@ -294,14 +288,12 @@ flst_insert_before(
flst_write_addr(node2 + FLST_NEXT, node3_addr, mtr);
if (!fil_addr_is_null(node1_addr)) {
bool found;
const page_size_t& page_size
= fil_space_get_page_size(space, &found);
ut_ad(found);
fil_space_t* s = fil_space_acquire_silent(space);
ulint zip_size = s ? s->zip_size() : 0;
if (s) s->release();
/* Update next field of node1 */
node1 = fut_get_ptr(space, page_size, node1_addr,
node1 = fut_get_ptr(space, zip_size, node1_addr,
RW_SX_LATCH, mtr);
flst_write_addr(node1 + FLST_NEXT, node2_addr, mtr);
} else {
@@ -344,11 +336,9 @@ flst_remove(
buf_ptr_get_fsp_addr(node2, &space, &node2_addr);
bool found;
const page_size_t& page_size = fil_space_get_page_size(space,
&found);
ut_ad(found);
fil_space_t* s = fil_space_acquire_silent(space);
ulint zip_size = s ? s->zip_size() : 0;
if (s) s->release();
node1_addr = flst_get_prev_addr(node2, mtr);
node3_addr = flst_get_next_addr(node2, mtr);
@@ -361,7 +351,7 @@ flst_remove(
node1 = page_align(node2) + node1_addr.boffset;
} else {
node1 = fut_get_ptr(space, page_size,
node1 = fut_get_ptr(space, zip_size,
node1_addr, RW_SX_LATCH, mtr);
}
@@ -380,7 +370,7 @@ flst_remove(
node3 = page_align(node2) + node3_addr.boffset;
} else {
node3 = fut_get_ptr(space, page_size,
node3 = fut_get_ptr(space, zip_size,
node3_addr, RW_SX_LATCH, mtr);
}
@@ -431,11 +421,9 @@ flst_validate(
/* Find out the space id */
buf_ptr_get_fsp_addr(base, &space, &base_addr);
bool found;
const page_size_t& page_size = fil_space_get_page_size(space,
&found);
ut_ad(found);
fil_space_t* s = fil_space_acquire_silent(space);
ulint zip_size = s ? s->zip_size() : 0;
if (s) s->release();
len = flst_get_len(base);
node_addr = flst_get_first(base, mtr1);
@@ -443,7 +431,7 @@ flst_validate(
for (i = 0; i < len; i++) {
mtr_start(&mtr2);
node = fut_get_ptr(space, page_size,
node = fut_get_ptr(space, zip_size,
node_addr, RW_SX_LATCH, &mtr2);
node_addr = flst_get_next_addr(node, &mtr2);
@@ -458,7 +446,7 @@ flst_validate(
for (i = 0; i < len; i++) {
mtr_start(&mtr2);
node = fut_get_ptr(space, page_size,
node = fut_get_ptr(space, zip_size,
node_addr, RW_SX_LATCH, &mtr2);
node_addr = flst_get_prev_addr(node, &mtr2);

View File

@@ -746,14 +746,14 @@ rtr_adjust_upper_level(
prev_page_no = btr_page_get_prev(page, mtr);
next_page_no = btr_page_get_next(page, mtr);
space = block->page.id.space();
ut_ad(block->page.size.equals_to(dict_table_page_size(index->table)));
ut_ad(block->zip_size() == index->table->space->zip_size());
/* Update page links of the level */
if (prev_page_no != FIL_NULL) {
page_id_t prev_page_id(space, prev_page_no);
buf_block_t* prev_block = btr_block_get(
prev_page_id, block->page.size, RW_X_LATCH,
prev_page_id, block->zip_size(), RW_X_LATCH,
index, mtr);
#ifdef UNIV_BTR_DEBUG
ut_a(page_is_comp(prev_block->frame) == page_is_comp(page));
@@ -770,7 +770,7 @@ rtr_adjust_upper_level(
page_id_t next_page_id(space, next_page_no);
buf_block_t* next_block = btr_block_get(
next_page_id, block->page.size, RW_X_LATCH,
next_page_id, block->zip_size(), RW_X_LATCH,
index, mtr);
#ifdef UNIV_BTR_DEBUG
ut_a(page_is_comp(next_block->frame) == page_is_comp(page));
@@ -1875,7 +1875,7 @@ rtr_estimate_n_rows_in_range(
buf_block_t* block = btr_block_get(
page_id_t(index->table->space_id, index->page),
page_size_t(index->table->space->flags),
index->table->space->zip_size(),
RW_S_LATCH, index, &mtr);
const page_t* page = buf_block_get_frame(block);
const unsigned n_recs = page_header_get_field(page, PAGE_N_RECS);

View File

@@ -145,7 +145,7 @@ rtr_pcur_getnext_from_path(
| MTR_MEMO_X_LOCK));
}
const page_size_t page_size(index->table->space->flags);
const ulint zip_size = index->table->space->zip_size();
/* Pop each node/page to be searched from "path" structure
and do a search on it. Please note, any pages that are in
@@ -269,7 +269,7 @@ rtr_pcur_getnext_from_path(
block = buf_page_get_gen(
page_id_t(index->table->space_id,
next_rec.page_no), page_size,
next_rec.page_no), zip_size,
rw_latch, NULL, BUF_GET, __FILE__, __LINE__, mtr, &err);
if (block == NULL) {
@@ -424,7 +424,7 @@ rtr_pcur_getnext_from_path(
block,
page_id_t(index->table->space_id,
block->page.id.page_no()),
page_size, BTR_MODIFY_TREE,
zip_size, BTR_MODIFY_TREE,
btr_cur, mtr);
}
@@ -1344,8 +1344,7 @@ rtr_cur_restore_position(
page_cur_t* page_cursor;
node_visit_t* node = rtr_get_parent_node(btr_cur, level, false);
node_seq_t path_ssn = node->seq_no;
const page_size_t page_size(index->table->space->flags);
const ulint zip_size = index->table->space->zip_size();
ulint page_no = node->page_no;
heap = mem_heap_create(256);
@@ -1361,7 +1360,7 @@ search_again:
block = buf_page_get_gen(
page_id_t(index->table->space_id, page_no),
page_size, RW_X_LATCH, NULL,
zip_size, RW_X_LATCH, NULL,
BUF_GET, __FILE__, __LINE__, mtr, &err);
ut_ad(block);

View File

@@ -3842,11 +3842,6 @@ static int innodb_init_params()
DBUG_RETURN(HA_ERR_INITIALIZATION);
}
/* This is the first time univ_page_size is used.
It was initialized to 16k pages before srv_page_size was set */
univ_page_size.copy_from(
page_size_t(srv_page_size, srv_page_size, false));
srv_sys_space.set_space_id(TRX_SYS_SPACE);
srv_sys_space.set_flags(FSP_FLAGS_PAGE_SSIZE());
srv_sys_space.set_name("innodb_system");
@@ -13834,7 +13829,7 @@ fsp_get_available_space_in_free_extents(const fil_space_t& space)
ulint n_free_up =
(size_in_header - space.free_limit) / FSP_EXTENT_SIZE;
const ulint size = page_size_t(space.flags).physical();
const ulint size = space.physical_size();
if (n_free_up > 0) {
n_free_up--;
n_free_up -= n_free_up / (size / FSP_EXTENT_SIZE);
@@ -13984,8 +13979,7 @@ ha_innobase::info_low(
stats.records = (ha_rows) n_rows;
stats.deleted = 0;
if (fil_space_t* space = ib_table->space) {
const ulint size = page_size_t(space->flags)
.physical();
const ulint size = space->physical_size();
stats.data_file_length
= ulonglong(stat_clustered_index_size)
* size;
@@ -17446,7 +17440,7 @@ innodb_make_page_dirty(THD*, st_mysql_sys_var*, void*, const void* save)
buf_block_t* block = buf_page_get(
page_id_t(space_id, srv_saved_page_number_debug),
page_size_t(space->flags), RW_X_LATCH, &mtr);
space->zip_size(), RW_X_LATCH, &mtr);
if (block != NULL) {
byte* page = block->frame;
@@ -20637,9 +20631,9 @@ innobase_get_computed_value(
dfield_t* field;
ulint len;
const page_size_t page_size = (old_table == NULL)
? dict_table_page_size(index->table)
: dict_table_page_size(old_table);
const ulint zip_size = old_table
? old_table->space->zip_size()
: dict_tf_get_zip_size(index->table->flags);
ulint ret = 0;
@@ -20691,7 +20685,7 @@ innobase_get_computed_value(
}
data = btr_copy_externally_stored_field(
&len, data, page_size,
&len, data, zip_size,
dfield_get_len(row_field), *local_heap);
}

View File

@@ -10216,7 +10216,7 @@ commit_cache_norebuild(
mtr.start();
if (buf_block_t* b = buf_page_get(
page_id_t(space->id, 0),
page_size_t(space->flags),
space->zip_size(),
RW_X_LATCH, &mtr)) {
mtr.set_named_space(space);
mlog_write_ulint(

View File

@@ -5978,7 +5978,7 @@ i_s_dict_fill_sys_tables(
ulint compact = DICT_TF_GET_COMPACT(table->flags);
ulint atomic_blobs = DICT_TF_HAS_ATOMIC_BLOBS(
table->flags);
const page_size_t& page_size = dict_tf_get_page_size(table->flags);
const ulint zip_size = dict_tf_get_zip_size(table->flags);
const char* row_format;
if (!compact) {
@@ -6007,10 +6007,7 @@ i_s_dict_fill_sys_tables(
OK(field_store_string(fields[SYS_TABLES_ROW_FORMAT], row_format));
OK(fields[SYS_TABLES_ZIP_PAGE_SIZE]->store(
page_size.is_compressed()
? page_size.physical()
: 0, true));
OK(fields[SYS_TABLES_ZIP_PAGE_SIZE]->store(zip_size, true));
OK(field_store_string(fields[SYS_TABLES_SPACE_TYPE],
table->space_id ? "Single" : "System"));
@@ -8003,13 +8000,11 @@ i_s_dict_fill_sys_tablespaces(
DBUG_RETURN(0);
}
const page_size_t page_size(cflags);
OK(fields[SYS_TABLESPACES_PAGE_SIZE]->store(
page_size.logical(), true));
fil_space_t::logical_size(cflags), true));
OK(fields[SYS_TABLESPACES_ZIP_PAGE_SIZE]->store(
page_size.physical(), true));
fil_space_t::physical_size(cflags), true));
char* filepath = NULL;
if (FSP_FLAGS_HAS_DATA_DIR(cflags)) {

View File

@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2016, 2018, MariaDB Corporation.
Copyright (c) 2016, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -363,8 +363,7 @@ ibuf_header_page_get(
block = buf_page_get(
page_id_t(IBUF_SPACE_ID, FSP_IBUF_HEADER_PAGE_NO),
univ_page_size, RW_X_LATCH, mtr);
0, RW_X_LATCH, mtr);
if (!block->page.encrypted) {
buf_block_dbg_add_level(block, SYNC_IBUF_HEADER);
@@ -395,7 +394,7 @@ ibuf_tree_root_get(
/* only segment list access is exclusive each other */
block = buf_page_get(
page_id_t(IBUF_SPACE_ID, FSP_IBUF_TREE_ROOT_PAGE_NO),
univ_page_size, RW_SX_LATCH, mtr);
0, RW_SX_LATCH, mtr);
buf_block_dbg_add_level(block, SYNC_IBUF_TREE_NODE_NEW);
@@ -539,7 +538,7 @@ ibuf_init_at_db_start(void)
block = buf_page_get(
page_id_t(IBUF_SPACE_ID, FSP_IBUF_TREE_ROOT_PAGE_NO),
univ_page_size, RW_X_LATCH, &mtr);
0, RW_X_LATCH, &mtr);
buf_block_dbg_add_level(block, SYNC_IBUF_TREE_NODE);
@@ -602,7 +601,7 @@ ibuf_bitmap_page_init(
/* Write all zeros to the bitmap */
compile_time_assert(!(IBUF_BITS_PER_PAGE % 2));
byte_offset = UT_BITS_IN_BYTES(block->page.size.physical()
byte_offset = UT_BITS_IN_BYTES(block->physical_size()
* IBUF_BITS_PER_PAGE);
memset(page + IBUF_BITMAP, 0, byte_offset);
@@ -636,31 +635,31 @@ ibuf_parse_bitmap_init(
/** Gets the desired bits for a given page from a bitmap page.
@param[in] page bitmap page
@param[in] page_id page id whose bits to get
@param[in] page_size page id whose bits to get
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] bit IBUF_BITMAP_FREE, IBUF_BITMAP_BUFFERED, ...
@param[in,out] mtr mini-transaction holding an x-latch on the
bitmap page
@return value of bits */
# define ibuf_bitmap_page_get_bits(page, page_id, page_size, bit, mtr) \
ibuf_bitmap_page_get_bits_low(page, page_id, page_size, \
# define ibuf_bitmap_page_get_bits(page, page_id, zip_size, bit, mtr) \
ibuf_bitmap_page_get_bits_low(page, page_id, zip_size, \
MTR_MEMO_PAGE_X_FIX, mtr, bit)
# else /* UNIV_DEBUG */
/** Gets the desired bits for a given page from a bitmap page.
@param[in] page bitmap page
@param[in] page_id page id whose bits to get
@param[in] page_size page id whose bits to get
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] bit IBUF_BITMAP_FREE, IBUF_BITMAP_BUFFERED, ...
@param[in,out] mtr mini-transaction holding an x-latch on the
bitmap page
@return value of bits */
# define ibuf_bitmap_page_get_bits(page, page_id, page_size, bit, mtr) \
ibuf_bitmap_page_get_bits_low(page, page_id, page_size, bit)
# define ibuf_bitmap_page_get_bits(page, page_id, zip_size, bit, mtr) \
ibuf_bitmap_page_get_bits_low(page, page_id, zip_size, bit)
# endif /* UNIV_DEBUG */
/** Gets the desired bits for a given page from a bitmap page.
@param[in] page bitmap page
@param[in] page_id page id whose bits to get
@param[in] page_size page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] latch_type MTR_MEMO_PAGE_X_FIX, MTR_MEMO_BUF_FIX, ...
@param[in,out] mtr mini-transaction holding latch_type on the
bitmap page
@@ -671,7 +670,7 @@ ulint
ibuf_bitmap_page_get_bits_low(
const page_t* page,
const page_id_t page_id,
const page_size_t& page_size,
ulint zip_size,
#ifdef UNIV_DEBUG
ulint latch_type,
mtr_t* mtr,
@@ -682,12 +681,14 @@ ibuf_bitmap_page_get_bits_low(
ulint bit_offset;
ulint map_byte;
ulint value;
const ulint size = zip_size ? zip_size : srv_page_size;
ut_ad(ut_is_2pow(zip_size));
ut_ad(bit < IBUF_BITS_PER_PAGE);
compile_time_assert(!(IBUF_BITS_PER_PAGE % 2));
ut_ad(mtr_memo_contains_page(mtr, page, latch_type));
bit_offset = (page_id.page_no() % page_size.physical())
bit_offset = (page_id.page_no() & (size - 1))
* IBUF_BITS_PER_PAGE + bit;
byte_offset = bit_offset / 8;
@@ -711,7 +712,7 @@ ibuf_bitmap_page_get_bits_low(
/** Sets the desired bit for a given page in a bitmap page.
@param[in,out] page bitmap page
@param[in] page_id page id whose bits to set
@param[in] page_size page size
@param[in] physical_size page size
@param[in] bit IBUF_BITMAP_FREE, IBUF_BITMAP_BUFFERED, ...
@param[in] val value to set
@param[in,out] mtr mtr containing an x-latch to the bitmap page */
@@ -720,7 +721,7 @@ void
ibuf_bitmap_page_set_bits(
page_t* page,
const page_id_t page_id,
const page_size_t& page_size,
ulint physical_size,
ulint bit,
ulint val,
mtr_t* mtr)
@@ -738,7 +739,7 @@ ibuf_bitmap_page_set_bits(
|| (0 == ibuf_count_get(page_id)));
#endif
bit_offset = (page_id.page_no() % page_size.physical())
bit_offset = (page_id.page_no() % physical_size)
* IBUF_BITS_PER_PAGE + bit;
byte_offset = bit_offset / 8;
@@ -765,26 +766,20 @@ ibuf_bitmap_page_set_bits(
/** Calculates the bitmap page number for a given page number.
@param[in] page_id page id
@param[in] page_size page size
@param[in] size page size
@return the bitmap page id where the file page is mapped */
UNIV_INLINE
const page_id_t
ibuf_bitmap_page_no_calc(
const page_id_t page_id,
const page_size_t& page_size)
inline page_id_t ibuf_bitmap_page_no_calc(const page_id_t page_id, ulint size)
{
ulint bitmap_page_no;
if (!size) size = srv_page_size;
bitmap_page_no = FSP_IBUF_BITMAP_OFFSET
+ (page_id.page_no() & ~(page_size.physical() - 1));
return(page_id_t(page_id.space(), bitmap_page_no));
return page_id_t(page_id.space(), FSP_IBUF_BITMAP_OFFSET
+ (page_id.page_no() & ~(size - 1)));
}
/** Gets the ibuf bitmap page where the bits describing a given file page are
stored.
@param[in] page_id page id of the file page
@param[in] page_size page size of the file page
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] file file name
@param[in] line line where called
@param[in,out] mtr mini-transaction
@@ -795,7 +790,7 @@ static
page_t*
ibuf_bitmap_get_map_page_func(
const page_id_t page_id,
const page_size_t& page_size,
ulint zip_size,
const char* file,
unsigned line,
mtr_t* mtr)
@@ -803,8 +798,8 @@ ibuf_bitmap_get_map_page_func(
buf_block_t* block = NULL;
dberr_t err = DB_SUCCESS;
block = buf_page_get_gen(ibuf_bitmap_page_no_calc(page_id, page_size),
page_size, RW_X_LATCH, NULL, BUF_GET,
block = buf_page_get_gen(ibuf_bitmap_page_no_calc(page_id, zip_size),
zip_size, RW_X_LATCH, NULL, BUF_GET,
file, line, mtr, &err);
if (err != DB_SUCCESS) {
@@ -820,13 +815,13 @@ ibuf_bitmap_get_map_page_func(
/** Gets the ibuf bitmap page where the bits describing a given file page are
stored.
@param[in] page_id page id of the file page
@param[in] page_size page size of the file page
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in,out] mtr mini-transaction
@return bitmap page where the file page is mapped, that is, the bitmap
page containing the descriptor bits for the file page; the bitmap page
is x-latched */
#define ibuf_bitmap_get_map_page(page_id, page_size, mtr) \
ibuf_bitmap_get_map_page_func(page_id, page_size, \
#define ibuf_bitmap_get_map_page(page_id, zip_size, mtr) \
ibuf_bitmap_get_map_page_func(page_id, zip_size, \
__FILE__, __LINE__, mtr)
/************************************************************************//**
@@ -860,14 +855,14 @@ ibuf_set_free_bits_low(
}
bitmap_page = ibuf_bitmap_get_map_page(block->page.id,
block->page.size, mtr);
block->zip_size(), mtr);
#ifdef UNIV_IBUF_DEBUG
ut_a(val <= ibuf_index_page_calc_free(block));
#endif /* UNIV_IBUF_DEBUG */
ibuf_bitmap_page_set_bits(
bitmap_page, block->page.id, block->page.size,
bitmap_page, block->page.id, block->physical_size(),
IBUF_BITMAP_FREE, val, mtr);
}
@@ -904,7 +899,7 @@ ibuf_set_free_bits_func(
block->page.id.space());
bitmap_page = ibuf_bitmap_get_map_page(block->page.id,
block->page.size, &mtr);
block->zip_size(), &mtr);
switch (space->purpose) {
case FIL_TYPE_LOG:
@@ -946,7 +941,7 @@ ibuf_set_free_bits_func(
#endif /* UNIV_IBUF_DEBUG */
ibuf_bitmap_page_set_bits(
bitmap_page, block->page.id, block->page.size,
bitmap_page, block->page.id, block->physical_size(),
IBUF_BITMAP_FREE, val, &mtr);
mtr_commit(&mtr);
@@ -996,7 +991,7 @@ ibuf_update_free_bits_low(
ut_a(!buf_block_get_page_zip(block));
ut_ad(mtr->is_named_space(block->page.id.space()));
before = ibuf_index_page_calc_free_bits(block->page.size.logical(),
before = ibuf_index_page_calc_free_bits(srv_page_size,
max_ins_size);
after = ibuf_index_page_calc_free(block);
@@ -1031,10 +1026,10 @@ ibuf_update_free_bits_zip(
buf_frame_t* frame = buf_block_get_frame(block);
ut_a(frame);
ut_a(page_is_leaf(frame));
ut_a(block->page.size.is_compressed());
ut_a(block->zip_size());
bitmap_page = ibuf_bitmap_get_map_page(block->page.id,
block->page.size, mtr);
block->zip_size(), mtr);
after = ibuf_index_page_calc_free_zip(block);
@@ -1048,7 +1043,7 @@ ibuf_update_free_bits_zip(
}
ibuf_bitmap_page_set_bits(
bitmap_page, block->page.id, block->page.size,
bitmap_page, block->page.id, block->physical_size(),
IBUF_BITMAP_FREE, after, mtr);
}
@@ -1090,23 +1085,19 @@ ibuf_update_free_bits_for_two_pages_low(
/** Returns TRUE if the page is one of the fixed address ibuf pages.
@param[in] page_id page id
@param[in] page_size page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@return TRUE if a fixed address ibuf i/o page */
UNIV_INLINE
ibool
ibuf_fixed_addr_page(
const page_id_t page_id,
const page_size_t& page_size)
inline bool ibuf_fixed_addr_page(const page_id_t page_id, ulint zip_size)
{
return((page_id.space() == IBUF_SPACE_ID
&& page_id.page_no() == IBUF_TREE_ROOT_PAGE_NO)
|| ibuf_bitmap_page(page_id, page_size));
|| ibuf_bitmap_page(page_id, zip_size));
}
/** Checks if a page is a level 2 or 3 page in the ibuf hierarchy of pages.
Must not be called when recv_no_ibuf_operations==true.
@param[in] page_id page id
@param[in] page_size page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] x_latch FALSE if relaxed check (avoid latching the
bitmap page)
@param[in] file file name
@@ -1115,12 +1106,12 @@ bitmap page)
bitmap page if the page is not one of the fixed address ibuf pages, or NULL,
in which case a new transaction is created.
@return TRUE if level 2 or level 3 page */
ibool
bool
ibuf_page_low(
const page_id_t page_id,
const page_size_t& page_size,
ulint zip_size,
#ifdef UNIV_DEBUG
ibool x_latch,
bool x_latch,
#endif /* UNIV_DEBUG */
const char* file,
unsigned line,
@@ -1133,12 +1124,10 @@ ibuf_page_low(
ut_ad(!recv_no_ibuf_operations);
ut_ad(x_latch || mtr == NULL);
if (ibuf_fixed_addr_page(page_id, page_size)) {
return(TRUE);
if (ibuf_fixed_addr_page(page_id, zip_size)) {
return(true);
} else if (page_id.space() != IBUF_SPACE_ID) {
return(FALSE);
return(false);
}
compile_time_assert(IBUF_SPACE_ID == 0);
@@ -1161,14 +1150,14 @@ ibuf_page_low(
dberr_t err = DB_SUCCESS;
buf_block_t* block = buf_page_get_gen(
ibuf_bitmap_page_no_calc(page_id, page_size),
page_size, RW_NO_LATCH, NULL, BUF_GET_NO_LATCH,
file, line, &local_mtr, &err);
ibuf_bitmap_page_no_calc(page_id, zip_size),
zip_size, RW_NO_LATCH, NULL, BUF_GET_NO_LATCH,
file, line, &local_mtr, &err);
bitmap_page = buf_block_get_frame(block);
ret = ibuf_bitmap_page_get_bits_low(
bitmap_page, page_id, page_size,
bitmap_page, page_id, zip_size,
MTR_MEMO_BUF_FIX, &local_mtr, IBUF_BITMAP_IBUF);
mtr_commit(&local_mtr);
@@ -1181,10 +1170,10 @@ ibuf_page_low(
mtr_start(mtr);
}
bitmap_page = ibuf_bitmap_get_map_page_func(page_id, page_size,
bitmap_page = ibuf_bitmap_get_map_page_func(page_id, zip_size,
file, line, mtr);
ret = ibuf_bitmap_page_get_bits(bitmap_page, page_id, page_size,
ret = ibuf_bitmap_page_get_bits(bitmap_page, page_id, zip_size,
IBUF_BITMAP_IBUF, mtr);
if (mtr == &local_mtr) {
@@ -2057,11 +2046,11 @@ ibuf_add_free_page(void)
(level 2 page) */
const page_id_t page_id(IBUF_SPACE_ID, block->page.id.page_no());
bitmap_page = ibuf_bitmap_get_map_page(page_id, univ_page_size, &mtr);
bitmap_page = ibuf_bitmap_get_map_page(page_id, 0, &mtr);
mutex_exit(&ibuf_mutex);
ibuf_bitmap_page_set_bits(bitmap_page, page_id, univ_page_size,
ibuf_bitmap_page_set_bits(bitmap_page, page_id, srv_page_size,
IBUF_BITMAP_IBUF, TRUE, &mtr);
ibuf_mtr_commit(&mtr);
@@ -2149,7 +2138,7 @@ ibuf_remove_free_page(void)
{
buf_block_t* block;
block = buf_page_get(page_id, univ_page_size, RW_X_LATCH, &mtr);
block = buf_page_get(page_id, 0, RW_X_LATCH, &mtr);
buf_block_dbg_add_level(block, SYNC_IBUF_TREE_NODE);
@@ -2169,13 +2158,13 @@ ibuf_remove_free_page(void)
/* Set the bit indicating that this page is no more an ibuf tree page
(level 2 page) */
bitmap_page = ibuf_bitmap_get_map_page(page_id, univ_page_size, &mtr);
bitmap_page = ibuf_bitmap_get_map_page(page_id, 0, &mtr);
mutex_exit(&ibuf_mutex);
ibuf_bitmap_page_set_bits(
bitmap_page, page_id, univ_page_size, IBUF_BITMAP_IBUF, FALSE,
&mtr);
bitmap_page, page_id, srv_page_size,
IBUF_BITMAP_IBUF, FALSE, &mtr);
ut_d(buf_page_set_file_page_was_freed(page_id));
@@ -3025,7 +3014,7 @@ ibuf_get_volume_buffered(
block = buf_page_get(
page_id_t(IBUF_SPACE_ID, prev_page_no),
univ_page_size, RW_X_LATCH, mtr);
0, RW_X_LATCH, mtr);
buf_block_dbg_add_level(block, SYNC_IBUF_TREE_NODE);
@@ -3097,7 +3086,7 @@ count_later:
block = buf_page_get(
page_id_t(IBUF_SPACE_ID, next_page_no),
univ_page_size, RW_X_LATCH, mtr);
0, RW_X_LATCH, mtr);
buf_block_dbg_add_level(block, SYNC_IBUF_TREE_NODE);
@@ -3310,6 +3299,24 @@ ibuf_get_entry_counter_func(
}
}
/** Translates the ibuf free bits to the free space on a page in bytes.
@param[in] physical_size page_size
@param[in] bits value for ibuf bitmap bits
@return maximum insert size after reorganize for the page */
inline ulint
ibuf_index_page_calc_free_from_bits(ulint physical_size, ulint bits)
{
ut_ad(bits < 4);
ut_ad(physical_size > IBUF_PAGE_SIZE_PER_FREE_SPACE);
if (bits == 3) {
bits = 4;
}
return bits * physical_size / IBUF_PAGE_SIZE_PER_FREE_SPACE;
}
/** Buffer an operation in the insert/delete buffer, instead of doing it
directly to the disk page, if this is possible.
@param[in] mode BTR_MODIFY_PREV or BTR_MODIFY_TREE
@@ -3321,7 +3328,7 @@ buffering
@param[in,out] index index where to insert; must not be unique
or clustered
@param[in] page_id page id where to insert
@param[in] page_size page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in,out] thr query thread
@return DB_SUCCESS, DB_STRONG_FAIL or other error */
static MY_ATTRIBUTE((warn_unused_result))
@@ -3334,7 +3341,7 @@ ibuf_insert_low(
ulint entry_size,
dict_index_t* index,
const page_id_t page_id,
const page_size_t& page_size,
ulint zip_size,
que_thr_t* thr)
{
big_rec_t* dummy_big_rec;
@@ -3444,6 +3451,8 @@ ibuf_insert_low(
? &min_n_recs
: NULL, &mtr);
const ulint physical_size = zip_size ? zip_size : srv_page_size;
if (op == IBUF_OP_DELETE
&& (min_n_recs < 2 || buf_pool_watch_occurred(page_id))) {
/* The page could become empty after the record is
@@ -3488,8 +3497,7 @@ fail_exit:
ibuf_mtr_start(&bitmap_mtr);
index->set_modified(bitmap_mtr);
bitmap_page = ibuf_bitmap_get_map_page(page_id, page_size,
&bitmap_mtr);
bitmap_page = ibuf_bitmap_get_map_page(page_id, zip_size, &bitmap_mtr);
/* We check if the index page is suitable for buffered entries */
@@ -3503,11 +3511,12 @@ fail_exit:
if (op == IBUF_OP_INSERT) {
ulint bits = ibuf_bitmap_page_get_bits(
bitmap_page, page_id, page_size, IBUF_BITMAP_FREE,
bitmap_page, page_id, physical_size, IBUF_BITMAP_FREE,
&bitmap_mtr);
if (buffered + entry_size + page_dir_calc_reserved_space(1)
> ibuf_index_page_calc_free_from_bits(page_size, bits)) {
> ibuf_index_page_calc_free_from_bits(physical_size,
bits)) {
/* Release the bitmap page latch early. */
ibuf_mtr_commit(&bitmap_mtr);
@@ -3550,11 +3559,11 @@ fail_exit:
buffered entries for this index page, if the bit is not set yet */
old_bit_value = ibuf_bitmap_page_get_bits(
bitmap_page, page_id, page_size,
bitmap_page, page_id, physical_size,
IBUF_BITMAP_BUFFERED, &bitmap_mtr);
if (!old_bit_value) {
ibuf_bitmap_page_set_bits(bitmap_page, page_id, page_size,
ibuf_bitmap_page_set_bits(bitmap_page, page_id, physical_size,
IBUF_BITMAP_BUFFERED, TRUE,
&bitmap_mtr);
}
@@ -3659,23 +3668,23 @@ func_exit:
return(err);
}
/** Buffer an operation in the insert/delete buffer, instead of doing it
directly to the disk page, if this is possible. Does not do it if the index
/** Buffer an operation in the change buffer, instead of applying it
directly to the file page, if this is possible. Does not do it if the index
is clustered or unique.
@param[in] op operation type
@param[in] entry index entry to insert
@param[in,out] index index where to insert
@param[in] page_id page id where to insert
@param[in] page_size page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in,out] thr query thread
@return TRUE if success */
ibool
@return true if success */
bool
ibuf_insert(
ibuf_op_t op,
const dtuple_t* entry,
dict_index_t* index,
const page_id_t page_id,
const page_size_t& page_size,
ulint zip_size,
que_thr_t* thr)
{
dberr_t err;
@@ -3703,7 +3712,7 @@ ibuf_insert(
case IBUF_USE_NONE:
case IBUF_USE_DELETE:
case IBUF_USE_DELETE_MARK:
DBUG_RETURN(FALSE);
DBUG_RETURN(false);
case IBUF_USE_INSERT:
case IBUF_USE_INSERT_DELETE_MARK:
case IBUF_USE_ALL:
@@ -3714,7 +3723,7 @@ ibuf_insert(
switch (use) {
case IBUF_USE_NONE:
case IBUF_USE_INSERT:
DBUG_RETURN(FALSE);
DBUG_RETURN(false);
case IBUF_USE_DELETE_MARK:
case IBUF_USE_DELETE:
case IBUF_USE_INSERT_DELETE_MARK:
@@ -3728,7 +3737,7 @@ ibuf_insert(
case IBUF_USE_NONE:
case IBUF_USE_INSERT:
case IBUF_USE_INSERT_DELETE_MARK:
DBUG_RETURN(FALSE);
DBUG_RETURN(false);
case IBUF_USE_DELETE_MARK:
case IBUF_USE_DELETE:
case IBUF_USE_ALL:
@@ -3768,7 +3777,7 @@ check_watch:
is being buffered, have this request executed
directly on the page in the buffer pool after the
buffered entries for this page have been merged. */
DBUG_RETURN(FALSE);
DBUG_RETURN(false);
}
}
@@ -3779,30 +3788,22 @@ skip_watch:
>= page_get_free_space_of_empty(dict_table_is_comp(index->table))
/ 2) {
DBUG_RETURN(FALSE);
DBUG_RETURN(false);
}
err = ibuf_insert_low(BTR_MODIFY_PREV, op, no_counter,
entry, entry_size,
index, page_id, page_size, thr);
index, page_id, zip_size, thr);
if (err == DB_FAIL) {
err = ibuf_insert_low(BTR_MODIFY_TREE | BTR_LATCH_FOR_INSERT,
op, no_counter, entry, entry_size,
index, page_id, page_size, thr);
index, page_id, zip_size, thr);
}
if (err == DB_SUCCESS) {
#ifdef UNIV_IBUF_DEBUG
/* fprintf(stderr, "Ibuf insert for page no %lu of index %s\n",
page_no, index->name); */
#endif
DBUG_RETURN(TRUE);
ut_a(err == DB_SUCCESS || err == DB_STRONG_FAIL
|| err == DB_TOO_BIG_RECORD);
} else {
ut_a(err == DB_STRONG_FAIL || err == DB_TOO_BIG_RECORD);
DBUG_RETURN(FALSE);
}
DBUG_RETURN(err == DB_SUCCESS);
}
/********************************************************************//**
@@ -3866,13 +3867,13 @@ ibuf_insert_to_index_page_low(
"InnoDB: that table.\n", stderr);
bitmap_page = ibuf_bitmap_get_map_page(block->page.id,
block->page.size, mtr);
block->zip_size(), mtr);
old_bits = ibuf_bitmap_page_get_bits(
bitmap_page, block->page.id, block->page.size,
bitmap_page, block->page.id, block->zip_size(),
IBUF_BITMAP_FREE, mtr);
ib::error() << "page " << block->page.id << ", size "
<< block->page.size.physical() << ", bitmap bits " << old_bits;
<< block->physical_size() << ", bitmap bits " << old_bits;
ib::error() << BUG_REPORT_MSG;
@@ -4398,15 +4399,16 @@ subsequently was dropped.
@param[in,out] block if page has been read from disk,
pointer to the page x-latched, else NULL
@param[in] page_id page id of the index page
@param[in] update_ibuf_bitmap normally this is set to TRUE, but
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] update_ibuf_bitmap normally this is set, but
if we have deleted or are deleting the tablespace, then we naturally do not
want to update a non-existent bitmap page */
void
ibuf_merge_or_delete_for_page(
buf_block_t* block,
const page_id_t page_id,
const page_size_t* page_size,
ibool update_ibuf_bitmap)
ulint zip_size,
bool update_ibuf_bitmap)
{
mem_heap_t* heap;
btr_pcur_t pcur;
@@ -4431,38 +4433,23 @@ ibuf_merge_or_delete_for_page(
return;
}
/* We cannot refer to page_size in the following, because it is passed
as NULL (it is unknown) when buf_read_ibuf_merge_pages() is merging
(discarding) changes for a dropped tablespace. When block != NULL or
update_ibuf_bitmap is specified, then page_size must be known.
That is why we will repeat the check below, with page_size in
place of univ_page_size. Passing univ_page_size assumes that the
uncompressed page size always is a power-of-2 multiple of the
compressed page size. */
const ulint physical_size = zip_size ? zip_size : srv_page_size;
if (ibuf_fixed_addr_page(page_id, univ_page_size)
|| fsp_descr_page(page_id, univ_page_size)) {
if (ibuf_fixed_addr_page(page_id, physical_size)
|| fsp_descr_page(page_id, physical_size)) {
return;
}
fil_space_t* space;
if (update_ibuf_bitmap) {
ut_ad(page_size != NULL);
if (ibuf_fixed_addr_page(page_id, *page_size)
|| fsp_descr_page(page_id, *page_size)) {
return;
}
space = fil_space_acquire_silent(page_id.space());
if (UNIV_UNLIKELY(!space)) {
/* Do not try to read the bitmap page from the
non-existent tablespace, delete the ibuf records */
block = NULL;
update_ibuf_bitmap = FALSE;
update_ibuf_bitmap = false;
} else {
page_t* bitmap_page = NULL;
ulint bitmap_bits = 0;
@@ -4470,12 +4457,12 @@ ibuf_merge_or_delete_for_page(
ibuf_mtr_start(&mtr);
bitmap_page = ibuf_bitmap_get_map_page(
page_id, *page_size, &mtr);
page_id, zip_size, &mtr);
if (bitmap_page &&
fil_page_get_type(bitmap_page) != FIL_PAGE_TYPE_ALLOCATED) {
bitmap_bits = ibuf_bitmap_page_get_bits(
bitmap_page, page_id, *page_size,
bitmap_page, page_id, zip_size,
IBUF_BITMAP_BUFFERED, &mtr);
}
@@ -4489,8 +4476,8 @@ ibuf_merge_or_delete_for_page(
}
}
} else if (block != NULL
&& (ibuf_fixed_addr_page(page_id, *page_size)
|| fsp_descr_page(page_id, *page_size))) {
&& (ibuf_fixed_addr_page(page_id, physical_size)
|| fsp_descr_page(page_id, physical_size))) {
return;
} else {
@@ -4723,23 +4710,23 @@ reset_bit:
if (update_ibuf_bitmap) {
page_t* bitmap_page;
bitmap_page = ibuf_bitmap_get_map_page(page_id, *page_size,
bitmap_page = ibuf_bitmap_get_map_page(page_id, zip_size,
&mtr);
ibuf_bitmap_page_set_bits(
bitmap_page, page_id, *page_size,
bitmap_page, page_id, physical_size,
IBUF_BITMAP_BUFFERED, FALSE, &mtr);
if (block != NULL) {
ulint old_bits = ibuf_bitmap_page_get_bits(
bitmap_page, page_id, *page_size,
bitmap_page, page_id, zip_size,
IBUF_BITMAP_FREE, &mtr);
ulint new_bits = ibuf_index_page_calc_free(block);
if (old_bits != new_bits) {
ibuf_bitmap_page_set_bits(
bitmap_page, page_id, *page_size,
bitmap_page, page_id, physical_size,
IBUF_BITMAP_FREE, new_bits, &mtr);
}
}
@@ -4922,9 +4909,9 @@ ibuf_print(
@param[in] read_buf database page
@param[in] size page size
@return whether the page is all zeroes */
static bool buf_page_is_zeroes(const byte* read_buf, const page_size_t& size)
static bool buf_page_is_zeroes(const byte* read_buf, ulint size)
{
for (ulint i = 0; i < size.physical(); i++) {
for (ulint i = 0; i < size; i++) {
if (read_buf[i] != 0) {
return false;
}
@@ -4941,7 +4928,9 @@ dberr_t ibuf_check_bitmap_on_import(const trx_t* trx, fil_space_t* space)
ulint page_no;
ut_ad(trx->mysql_thd);
ut_ad(space->purpose == FIL_TYPE_IMPORT);
const page_size_t page_size(space->flags);
const ulint zip_size = space->zip_size();
const ulint physical_size = space->physical_size();
/* fil_space_t::size and fil_space_t::free_limit would still be 0
at this point. So, we will have to read page 0. */
ut_ad(!space->free_limit);
@@ -4950,7 +4939,8 @@ dberr_t ibuf_check_bitmap_on_import(const trx_t* trx, fil_space_t* space)
mtr_t mtr;
ulint size;
mtr.start();
if (buf_block_t* sp = buf_page_get(page_id_t(space->id, 0), page_size,
if (buf_block_t* sp = buf_page_get(page_id_t(space->id, 0),
zip_size,
RW_S_LATCH, &mtr)) {
size = std::min(
mach_read_from_4(FSP_HEADER_OFFSET + FSP_FREE_LIMIT
@@ -4974,7 +4964,7 @@ dberr_t ibuf_check_bitmap_on_import(const trx_t* trx, fil_space_t* space)
below page_no is measured in number of pages since the beginning of
the space, as usual. */
for (page_no = 0; page_no < size; page_no += page_size.physical()) {
for (page_no = 0; page_no < size; page_no += physical_size) {
page_t* bitmap_page;
ulint i;
@@ -4990,21 +4980,21 @@ dberr_t ibuf_check_bitmap_on_import(const trx_t* trx, fil_space_t* space)
ibuf_enter(&mtr);
bitmap_page = ibuf_bitmap_get_map_page(
page_id_t(space->id, page_no), page_size, &mtr);
page_id_t(space->id, page_no), zip_size, &mtr);
if (buf_page_is_zeroes(bitmap_page, page_size)) {
if (buf_page_is_zeroes(bitmap_page, physical_size)) {
/* This means we got all-zero page instead of
ibuf bitmap page. The subsequent page should be
all-zero pages. */
#ifdef UNIV_DEBUG
for (ulint curr_page = page_no + 1;
curr_page < page_size.physical(); curr_page++) {
curr_page < physical_size; curr_page++) {
buf_block_t* block = buf_page_get(
page_id_t(space->id, curr_page),
page_size, RW_S_LATCH, &mtr);
zip_size, RW_S_LATCH, &mtr);
page_t* page = buf_block_get_frame(block);
ut_ad(buf_page_is_zeroes(page, page_size));
ut_ad(buf_page_is_zeroes(page, physical_size));
}
#endif /* UNIV_DEBUG */
ibuf_exit(&mtr);
@@ -5017,17 +5007,13 @@ dberr_t ibuf_check_bitmap_on_import(const trx_t* trx, fil_space_t* space)
return DB_CORRUPTION;
}
for (i = FSP_IBUF_BITMAP_OFFSET + 1;
i < page_size.physical();
i++) {
for (i = FSP_IBUF_BITMAP_OFFSET + 1; i < physical_size; i++) {
const ulint offset = page_no + i;
const page_id_t cur_page_id(space->id, offset);
if (ibuf_bitmap_page_get_bits(
bitmap_page, cur_page_id, page_size,
IBUF_BITMAP_IBUF, &mtr)) {
bitmap_page, cur_page_id, zip_size,
IBUF_BITMAP_IBUF, &mtr)) {
mutex_exit(&ibuf_mutex);
ibuf_exit(&mtr);
@@ -5044,7 +5030,7 @@ dberr_t ibuf_check_bitmap_on_import(const trx_t* trx, fil_space_t* space)
}
if (ibuf_bitmap_page_get_bits(
bitmap_page, cur_page_id, page_size,
bitmap_page, cur_page_id, zip_size,
IBUF_BITMAP_BUFFERED, &mtr)) {
ib_errf(trx->mysql_thd,
@@ -5059,7 +5045,8 @@ dberr_t ibuf_check_bitmap_on_import(const trx_t* trx, fil_space_t* space)
slightly corrupted tables can be
imported and dumped. Clear the bit. */
ibuf_bitmap_page_set_bits(
bitmap_page, cur_page_id, page_size,
bitmap_page, cur_page_id,
physical_size,
IBUF_BITMAP_BUFFERED, FALSE, &mtr);
}
}
@@ -5089,18 +5076,18 @@ ibuf_set_bitmap_for_bulk_load(
free_val = ibuf_index_page_calc_free(block);
mtr_start(&mtr);
mtr.set_named_space_id(block->page.id.space());
fil_space_t* space = mtr.set_named_space_id(block->page.id.space());
bitmap_page = ibuf_bitmap_get_map_page(block->page.id,
block->page.size, &mtr);
space->zip_size(), &mtr);
free_val = reset ? 0 : ibuf_index_page_calc_free(block);
ibuf_bitmap_page_set_bits(
bitmap_page, block->page.id, block->page.size,
bitmap_page, block->page.id, block->physical_size(),
IBUF_BITMAP_FREE, free_val, &mtr);
ibuf_bitmap_page_set_bits(
bitmap_page, block->page.id, block->page.size,
bitmap_page, block->page.id, block->physical_size(),
IBUF_BITMAP_BUFFERED, FALSE, &mtr);
mtr_commit(&mtr);

View File

@@ -2,7 +2,7 @@
Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
Copyright (c) 2014, 2018, MariaDB Corporation.
Copyright (c) 2014, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -219,6 +219,7 @@ btr_height_get(
/** Gets a buffer page and declares its latching order level.
@param[in] page_id page id
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] mode latch mode
@param[in] file file name
@param[in] line line where called
@@ -230,7 +231,7 @@ UNIV_INLINE
buf_block_t*
btr_block_get_func(
const page_id_t page_id,
const page_size_t& page_size,
ulint zip_size,
ulint mode,
const char* file,
unsigned line,
@@ -240,28 +241,28 @@ btr_block_get_func(
# ifdef UNIV_DEBUG
/** Gets a buffer page and declares its latching order level.
@param page_id tablespace/page identifier
@param page_size page size
@param zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param mode latch mode
@param index index tree, may be NULL if not the insert buffer tree
@param mtr mini-transaction handle
@return the block descriptor */
# define btr_block_get(page_id, page_size, mode, index, mtr) \
btr_block_get_func(page_id, page_size, mode, \
# define btr_block_get(page_id, zip_size, mode, index, mtr) \
btr_block_get_func(page_id, zip_size, mode, \
__FILE__, __LINE__, (dict_index_t*)index, mtr)
# else /* UNIV_DEBUG */
/** Gets a buffer page and declares its latching order level.
@param page_id tablespace/page identifier
@param page_size page size
@param zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param mode latch mode
@param index index tree, may be NULL if not the insert buffer tree
@param mtr mini-transaction handle
@return the block descriptor */
# define btr_block_get(page_id, page_size, mode, index, mtr) \
btr_block_get_func(page_id, page_size, mode, __FILE__, __LINE__, (dict_index_t*)index, mtr)
# define btr_block_get(page_id, zip_size, mode, index, mtr) \
btr_block_get_func(page_id, zip_size, mode, __FILE__, __LINE__, (dict_index_t*)index, mtr)
# endif /* UNIV_DEBUG */
/** Gets a buffer page and declares its latching order level.
@param page_id tablespace/page identifier
@param page_size page size
@param zip_size compressed page size in bytes or 0 for uncompressed pages
@param mode latch mode
@param index index tree, may be NULL if not the insert buffer tree
@param mtr mini-transaction handle
@@ -269,9 +270,8 @@ btr_block_get_func(
UNIV_INLINE
page_t*
btr_page_get(
/*=========*/
const page_id_t page_id,
const page_size_t& page_size,
ulint zip_size,
ulint mode,
dict_index_t* index,
mtr_t* mtr)
@@ -367,23 +367,19 @@ btr_create(
/** Free a persistent index tree if it exists.
@param[in] page_id root page id
@param[in] page_size page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] index_id PAGE_INDEX_ID contents
@param[in,out] mtr mini-transaction */
void
btr_free_if_exists(
const page_id_t page_id,
const page_size_t& page_size,
ulint zip_size,
index_id_t index_id,
mtr_t* mtr);
/** Free an index tree in a temporary tablespace or during TRUNCATE TABLE.
@param[in] page_id root page id
@param[in] page_size page size */
void
btr_free(
const page_id_t page_id,
const page_size_t& page_size);
/** Free an index tree in a temporary tablespace.
@param[in] page_id root page id */
void btr_free(const page_id_t page_id);
/** Read the last used AUTO_INCREMENT value from PAGE_ROOT_AUTO_INC.
@param[in,out] index clustered index
@@ -807,17 +803,20 @@ btr_validate_index(
const trx_t* trx) /*!< in: transaction or 0 */
MY_ATTRIBUTE((warn_unused_result));
/*************************************************************//**
Removes a page from the level list of pages. */
UNIV_INTERN
/** Remove a page from the level list of pages.
@param[in] space space where removed
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in,out] page page to remove
@param[in] index index tree
@param[in,out] mtr mini-transaction */
void
btr_level_list_remove_func(
/*=======================*/
ulint space, /*!< in: space where removed */
const page_size_t& page_size,/*!< in: page size */
page_t* page, /*!< in/out: page to remove */
dict_index_t* index, /*!< in: index tree */
mtr_t* mtr); /*!< in/out: mini-transaction */
ulint space,
ulint zip_size,
page_t* page,
dict_index_t* index,
mtr_t* mtr);
/*************************************************************//**
Removes a page from the level list of pages.
@param space in: space where removed

View File

@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2015, 2017, MariaDB Corporation.
Copyright (c) 2015, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -31,6 +31,7 @@ Created 6/2/1994 Heikki Tuuri
/** Gets a buffer page and declares its latching order level.
@param[in] page_id page id
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] mode latch mode
@param[in] file file name
@param[in] line line where called
@@ -42,7 +43,7 @@ UNIV_INLINE
buf_block_t*
btr_block_get_func(
const page_id_t page_id,
const page_size_t& page_size,
ulint zip_size,
ulint mode,
const char* file,
unsigned line,
@@ -53,7 +54,7 @@ btr_block_get_func(
dberr_t err=DB_SUCCESS;
block = buf_page_get_gen(
page_id, page_size, mode, NULL, BUF_GET, file, line, mtr, &err);
page_id, zip_size, mode, NULL, BUF_GET, file, line, mtr, &err);
if (err == DB_DECRYPTION_FAILED) {
if (index && index->table) {
@@ -96,7 +97,7 @@ btr_page_set_index_id(
}
/** Gets a buffer page and declares its latching order level.
@param space tablespace identifier
@param page_id tablespace/page identifier
@param zip_size compressed page size in bytes or 0 for uncompressed pages
@param page_no page number
@param mode latch mode
@@ -106,9 +107,8 @@ btr_page_set_index_id(
UNIV_INLINE
page_t*
btr_page_get(
/*=========*/
const page_id_t page_id,
const page_size_t& page_size,
ulint zip_size,
ulint mode,
dict_index_t* index,
mtr_t* mtr)
@@ -116,7 +116,7 @@ btr_page_get(
buf_block_t* block=NULL;
buf_frame_t* frame=NULL;
block = btr_block_get(page_id, page_size, mode, index, mtr);
block = btr_block_get(page_id, zip_size, mode, index, mtr);
if (block) {
frame = buf_block_get_frame(block);

View File

@@ -723,11 +723,12 @@ btr_free_externally_stored_field(
ignored if rec == NULL */
bool rollback, /*!< in: performing rollback? */
mtr_t* local_mtr); /*!< in: mtr containing the latch */
/** Copies the prefix of an externally stored field of a record.
The clustered index record must be protected by a lock or a page latch.
@param[out] buf the field, or a prefix of it
@param[in] len length of buf, in bytes
@param[in] page_size BLOB page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] data 'internally' stored part of the field
containing also the reference to the external part; must be protected by
a lock or a page latch
@@ -738,7 +739,7 @@ ulint
btr_copy_externally_stored_field_prefix(
byte* buf,
ulint len,
const page_size_t& page_size,
ulint zip_size,
const byte* data,
ulint local_len);
@@ -748,7 +749,7 @@ The clustered index record must be protected by a lock or a page latch.
@param[in] data 'internally' stored part of the field
containing also the reference to the external part; must be protected by
a lock or a page latch
@param[in] page_size BLOB page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] local_len length of data
@param[in,out] heap mem heap
@return the whole field copied to heap */
@@ -756,7 +757,7 @@ byte*
btr_copy_externally_stored_field(
ulint* len,
const byte* data,
const page_size_t& page_size,
ulint zip_size,
ulint local_len,
mem_heap_t* heap);
@@ -764,7 +765,7 @@ btr_copy_externally_stored_field(
@param[in] rec record in a clustered index; must be
protected by a lock or a page latch
@param[in] offset array returned by rec_get_offsets()
@param[in] page_size BLOB page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] no field number
@param[out] len length of the field
@param[in,out] heap mem heap
@@ -773,7 +774,7 @@ byte*
btr_rec_copy_externally_stored_field(
const rec_t* rec,
const ulint* offsets,
const page_size_t& page_size,
ulint zip_size,
ulint no,
ulint* len,
mem_heap_t* heap);
@@ -816,6 +817,7 @@ btr_rec_set_deleted_flag(
/** Latches the leaf page or pages requested.
@param[in] block leaf page where the search converged
@param[in] page_id page id of the leaf
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] latch_mode BTR_SEARCH_LEAF, ...
@param[in] cursor cursor
@param[in] mtr mini-transaction
@@ -824,7 +826,7 @@ btr_latch_leaves_t
btr_cur_latch_leaves(
buf_block_t* block,
const page_id_t page_id,
const page_size_t& page_size,
ulint zip_size,
ulint latch_mode,
btr_cur_t* cursor,
mtr_t* mtr);

View File

@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2018, MariaDB Corporation.
Copyright (c) 2018, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -28,7 +28,6 @@ Created 2/17/1996 Heikki Tuuri
#define btr0types_h
#include "page0types.h"
#include "page0size.h"
#include "rem0types.h"
/** Persistent cursor */
@@ -50,10 +49,17 @@ extern ulong btr_ahi_parts;
/** The size of a reference to data stored on a different page.
The reference is stored at the end of the prefix of the field
in the index record. */
#define FIELD_REF_SIZE 20U
#define BTR_EXTERN_FIELD_REF_SIZE FIELD_REF_SIZE
/** If the data don't exceed the size, the data are stored locally. */
#define BTR_EXTERN_LOCAL_STORED_MAX_SIZE \
(BTR_EXTERN_FIELD_REF_SIZE * 2)
/** A field reference full of zero, for use in assertions and checks,
and dummy default values of instantly dropped columns.
Initially, BLOB field references are set to zero, in
dtuple_convert_big_rec(). */
extern const byte field_ref_zero[UNIV_PAGE_SIZE_MAX];
#endif

View File

@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 2018, MariaDB Corporation.
Copyright (c) 2013, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -488,15 +488,13 @@ be implemented at a higher level. In other words, all possible
accesses to a given page through this function must be protected by
the same set of mutexes or latches.
@param[in] page_id page id
@param[in] page_size page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size
@return pointer to the block */
buf_page_t*
buf_page_get_zip(
const page_id_t page_id,
const page_size_t& page_size);
buf_page_t* buf_page_get_zip(const page_id_t page_id, ulint zip_size);
/** This is the general function used to get access to a database page.
@param[in] page_id page id
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] rw_latch RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH
@param[in] guess guessed block or NULL
@param[in] mode BUF_GET, BUF_GET_IF_IN_POOL,
@@ -509,7 +507,7 @@ BUF_PEEK_IF_IN_POOL, BUF_GET_NO_LATCH, or BUF_GET_IF_IN_POOL_OR_WATCH
buf_block_t*
buf_page_get_gen(
const page_id_t page_id,
const page_size_t& page_size,
ulint zip_size,
ulint rw_latch,
buf_block_t* guess,
ulint mode,
@@ -518,18 +516,18 @@ buf_page_get_gen(
mtr_t* mtr,
dberr_t* err);
/** Initializes a page to the buffer buf_pool. The page is usually not read
/** Initialize a page in the buffer pool. The page is usually not read
from a file even if it cannot be found in the buffer buf_pool. This is one
of the functions which perform to a block a state transition NOT_USED =>
FILE_PAGE (the other is buf_page_get_gen).
@param[in] page_id page id
@param[in] page_size page size
@param[in] mtr mini-transaction
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in,out] mtr mini-transaction
@return pointer to the block, page bufferfixed */
buf_block_t*
buf_page_create(
const page_id_t page_id,
const page_size_t& page_size,
ulint zip_size,
mtr_t* mtr);
/********************************************************************//**
@@ -719,14 +717,14 @@ buf_page_is_checksum_valid_none(
/** Check if a page is corrupt.
@param[in] check_lsn whether the LSN should be checked
@param[in] read_buf database page
@param[in] page_size page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] space tablespace
@return whether the page is corrupted */
bool
buf_page_is_corrupted(
bool check_lsn,
const byte* read_buf,
const page_size_t& page_size,
ulint zip_size,
#ifndef UNIV_INNOCHECKSUM
const fil_space_t* space = NULL)
#else
@@ -795,10 +793,8 @@ buf_print(void);
/** Dump a page to stderr.
@param[in] read_buf database page
@param[in] page_size page size */
UNIV_INTERN
void
buf_page_print(const byte* read_buf, const page_size_t& page_size)
@param[in] zip_size compressed page size, or 0 */
void buf_page_print(const byte* read_buf, ulint zip_size = 0)
ATTRIBUTE_COLD __attribute__((nonnull));
/********************************************************************//**
Decompress a block.
@@ -1157,6 +1153,7 @@ and the lock released later.
@param[out] err DB_SUCCESS or DB_TABLESPACE_DELETED
@param[in] mode BUF_READ_IBUF_PAGES_ONLY, ...
@param[in] page_id page id
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] unzip whether the uncompressed page is
requested (for ROW_FORMAT=COMPRESSED)
@return pointer to the block
@@ -1166,7 +1163,7 @@ buf_page_init_for_read(
dberr_t* err,
ulint mode,
const page_id_t page_id,
const page_size_t& page_size,
ulint zip_size,
bool unzip);
/** Complete a read or write request of a file page to or from the buffer pool.
@@ -1458,9 +1455,6 @@ public:
buf_pool->page_hash or
buf_pool->zip_hash */
/** Page size. Protected by buf_pool mutex. */
page_size_t size;
/** Count of how manyfold this block is currently bufferfixed. */
Atomic_counter<uint32_t> buf_fix_count;
@@ -1622,6 +1616,19 @@ public:
ut_ad(count != 0);
return count - 1;
}
/** @return the physical size, in bytes */
ulint physical_size() const
{
return zip.ssize ? (UNIV_ZIP_SIZE_MIN >> 1) << zip.ssize : srv_page_size;
}
/** @return the ROW_FORMAT=COMPRESSED physical size, in bytes
@retval 0 if not compressed */
ulint zip_size() const
{
return zip.ssize ? (UNIV_ZIP_SIZE_MIN >> 1) << zip.ssize : 0;
}
};
/** The buffer control block structure */
@@ -1788,6 +1795,13 @@ struct buf_block_t{
void fix() { page.fix(); }
uint32_t unfix() { return page.unfix(); }
/** @return the physical size, in bytes */
ulint physical_size() const { return page.physical_size(); }
/** @return the ROW_FORMAT=COMPRESSED physical size, in bytes
@retval 0 if not compressed */
ulint zip_size() const { return page.zip_size(); }
};
/** Check if a buf_block_t object is in a valid state

View File

@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2015, 2017, MariaDB Corporation.
Copyright (c) 2015, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -34,30 +34,23 @@ buffer buf_pool if it is not already there. Sets the io_fix flag and sets
an exclusive lock on the buffer frame. The flag is cleared and the x-lock
released by the i/o-handler thread.
@param[in] page_id page id
@param[in] page_size page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@retval DB_SUCCESS if the page was read and is not corrupted,
@retval DB_PAGE_CORRUPTED if page based on checksum check is corrupted,
@retval DB_DECRYPTION_FAILED if page post encryption checksum matches but
after decryption normal page checksum does not match.
@retval DB_TABLESPACE_DELETED if tablespace .ibd file is missing */
dberr_t
buf_read_page(
const page_id_t page_id,
const page_size_t& page_size);
dberr_t buf_read_page(const page_id_t page_id, ulint zip_size);
/********************************************************************//**
High-level function which reads a page asynchronously from a file to the
/** High-level function which reads a page asynchronously from a file to the
buffer buf_pool if it is not already there. Sets the io_fix flag and sets
an exclusive lock on the buffer frame. The flag is cleared and the x-lock
released by the i/o-handler thread.
@param[in] page_id page id
@param[in] page_size page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] sync true if synchronous aio is desired */
void
buf_read_page_background(
const page_id_t page_id,
const page_size_t& page_size,
bool sync);
buf_read_page_background(const page_id_t page_id, ulint zip_size, bool sync);
/** Applies a random read-ahead in buf_pool if there are at least a threshold
value of accessed pages from the random read-ahead area. Does not read any
@@ -70,16 +63,13 @@ performed by ibuf routines, a situation which could result in a deadlock if
the OS does not support asynchronous i/o.
@param[in] page_id page id of a page which the current thread
wants to access
@param[in] page_size page size
@param[in] inside_ibuf TRUE if we are inside ibuf routine
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] ibuf whether we are inside ibuf routine
@return number of page read requests issued; NOTE that if we read ibuf
pages, it may happen that the page at the given page number does not
get read even if we return a positive value! */
ulint
buf_read_ahead_random(
const page_id_t page_id,
const page_size_t& page_size,
ibool inside_ibuf);
buf_read_ahead_random(const page_id_t page_id, ulint zip_size, bool ibuf);
/** Applies linear read-ahead if in the buf_pool the page is a border page of
a linear read-ahead area and all the pages in the area have been accessed.
@@ -104,14 +94,11 @@ NOTE 3: the calling thread must want access to the page given: this rule is
set to prevent unintended read-aheads performed by ibuf routines, a situation
which could result in a deadlock if the OS does not support asynchronous io.
@param[in] page_id page id; see NOTE 3 above
@param[in] page_size page size
@param[in] inside_ibuf TRUE if we are inside ibuf routine
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] ibuf whether if we are inside ibuf routine
@return number of page read requests issued */
ulint
buf_read_ahead_linear(
const page_id_t page_id,
const page_size_t& page_size,
ibool inside_ibuf);
buf_read_ahead_linear(const page_id_t page_id, ulint zip_size, bool ibuf);
/********************************************************************//**
Issues read requests for pages which the ibuf module wants to read in, in

View File

@@ -2,7 +2,7 @@
Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
Copyright (c) 2013, 2018, MariaDB Corporation.
Copyright (c) 2013, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -887,25 +887,33 @@ ulint
dict_tf_to_fsp_flags(ulint table_flags)
MY_ATTRIBUTE((const));
/** Extract the page size from table flags.
/** Extract the ROW_FORMAT=COMPRESSED page size from table flags.
@param[in] flags flags
@return compressed page size, or 0 if not compressed */
UNIV_INLINE
const page_size_t
dict_tf_get_page_size(
ulint flags)
MY_ATTRIBUTE((const));
@return ROW_FORMAT=COMPRESSED page size
@retval 0 if not compressed */
inline ulint dict_tf_get_zip_size(ulint flags)
{
flags &= DICT_TF_MASK_ZIP_SSIZE;
return flags
? (UNIV_ZIP_SIZE_MIN >> 1)
<< (FSP_FLAGS_GET_ZIP_SSIZE(flags >> DICT_TF_POS_ZIP_SSIZE
<< FSP_FLAGS_POS_ZIP_SSIZE))
: 0;
}
/** Determine the extent size (in pages) for the given table
@param[in] table the table whose extent size is being
calculated.
@return extent size in pages (256, 128 or 64) */
ulint
dict_table_extent_size(
const dict_table_t* table);
inline ulint dict_table_extent_size(const dict_table_t* table)
{
if (ulint zip_size = table->space->zip_size()) {
return (1ULL << 20) / zip_size;
}
/** Get the table page size. */
#define dict_table_page_size(table) page_size_t(table->space->flags)
return FSP_EXTENT_SIZE;
}
/*********************************************************************//**
Obtain exclusive locks on all index trees of the table. This is to prevent

View File

@@ -711,28 +711,6 @@ dict_tf_to_sys_tables_type(
return(type);
}
/** Extract the page size info from table flags.
@param[in] flags flags
@return a structure containing the compressed and uncompressed
page sizes and a boolean indicating if the page is compressed. */
UNIV_INLINE
const page_size_t
dict_tf_get_page_size(
ulint flags)
{
const ulint zip_ssize = DICT_TF_GET_ZIP_SSIZE(flags);
if (zip_ssize == 0) {
return(univ_page_size);
}
const ulint zip_size = (UNIV_ZIP_SIZE_MIN >> 1) << zip_ssize;
ut_ad(zip_size <= UNIV_ZIP_SIZE_MAX);
return(page_size_t(zip_size, srv_page_size, true));
}
/*********************************************************************//**
Obtain exclusive locks on all index trees of the table. This is to prevent
accessing index trees while InnoDB is updating internal metadata for

View File

@@ -1,6 +1,6 @@
/*****************************************************************************
Copyright (C) 2013, 2015, Google Inc. All Rights Reserved.
Copyright (c) 2015, 2018, MariaDB Corporation.
Copyright (c) 2015, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -273,13 +273,11 @@ fil_space_merge_crypt_data(
const fil_space_crypt_t* src);
/** Initialize encryption parameters from a tablespace header page.
@param[in] page_size page size of the tablespace
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] page first page of the tablespace
@return crypt data from page 0
@retval NULL if not present or not valid */
UNIV_INTERN
fil_space_crypt_t*
fil_space_read_crypt_data(const page_size_t& page_size, const byte* page)
fil_space_crypt_t* fil_space_read_crypt_data(ulint zip_size, const byte* page)
MY_ATTRIBUTE((nonnull, warn_unused_result));
/**
@@ -310,9 +308,10 @@ fil_parse_write_crypt_data(
@param[in] offset Page offset
@param[in] lsn Log sequence number
@param[in] src_frame Page to encrypt
@param[in] page_size Page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in,out] dst_frame Output buffer
@return encrypted buffer or NULL */
UNIV_INTERN
byte*
fil_encrypt_buf(
fil_space_crypt_t* crypt_data,
@@ -320,7 +319,7 @@ fil_encrypt_buf(
ulint offset,
lsn_t lsn,
const byte* src_frame,
const page_size_t& page_size,
ulint zip_size,
byte* dst_frame)
MY_ATTRIBUTE((warn_unused_result));
@@ -343,20 +342,20 @@ fil_space_encrypt(
byte* dst_frame)
MY_ATTRIBUTE((warn_unused_result));
/**
Decrypt a page.
@param[in,out] crypt_data crypt_data
/** Decrypt a page.
@param[in] crypt_data crypt_data
@param[in] tmp_frame Temporary buffer
@param[in] page_size Page size
@param[in] physical_size page size
@param[in,out] src_frame Page to decrypt
@param[out] err DB_SUCCESS or error
@param[out] err DB_SUCCESS or DB_DECRYPTION_FAILED
@return true if page decrypted, false if not.*/
UNIV_INTERN
bool
fil_space_decrypt(
fil_space_crypt_t* crypt_data,
byte* tmp_frame,
const page_size_t& page_size,
ulint physical_size,
byte* src_frame,
dberr_t* err);
@@ -377,17 +376,14 @@ fil_space_decrypt(
bool* decrypted)
MY_ATTRIBUTE((warn_unused_result));
/******************************************************************
/**
Calculate post encryption checksum
@param[in] page_size page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] dst_frame Block where checksum is calculated
@return page checksum or BUF_NO_CHECKSUM_MAGIC
@return page checksum
not needed. */
UNIV_INTERN
uint32_t
fil_crypt_calculate_checksum(
const page_size_t& page_size,
const byte* dst_frame)
fil_crypt_calculate_checksum(ulint zip_size, const byte* dst_frame)
MY_ATTRIBUTE((warn_unused_result));
/*********************************************************************
@@ -485,10 +481,9 @@ calculated checksum as if it does page could be valid unencrypted,
encrypted, or corrupted.
@param[in,out] page page frame (checksum is temporarily modified)
@param[in] page_size page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@return true if page is encrypted AND OK, false otherwise */
bool
fil_space_verify_crypt_checksum(const byte* page, const page_size_t& page_size)
bool fil_space_verify_crypt_checksum(const byte* page, ulint zip_size)
MY_ATTRIBUTE((warn_unused_result));
#endif /* fil0crypt_h */

View File

@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 2018, MariaDB Corporation.
Copyright (c) 2013, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -27,7 +27,7 @@ Created 10/25/1995 Heikki Tuuri
#ifndef fil0fil_h
#define fil0fil_h
#include "page0size.h"
#include "fsp0types.h"
#ifndef UNIV_INNOCHECKSUM
@@ -120,8 +120,7 @@ struct fil_space_t {
or if the size change was implemented */
ulint flags; /*!< FSP_SPACE_FLAGS and FSP_FLAGS_MEM_ flags;
see fsp0types.h,
fsp_flags_is_valid(),
page_size_t(ulint) (constructor) */
fsp_flags_is_valid() */
ulint n_reserved_extents;
/*!< number of reserved free extents for
ongoing operations like B-tree page split */
@@ -256,6 +255,44 @@ struct fil_space_t {
void release_for_io() { ut_ad(pending_io()); n_pending_ios--; }
/** @return whether I/O is pending */
bool pending_io() const { return n_pending_ios; }
/** Determine the logical page size.
@param flags tablespace flags (FSP_FLAGS)
@return the logical page size
@retval 0 if the flags are invalid */
static ulint logical_size(ulint flags) {
switch (FSP_FLAGS_GET_PAGE_SSIZE(flags)) {
case 3: return 4096;
case 4: return 8192;
case 0: return 16384;
case 6: return 32768;
case 7: return 65536;
default: return 0;
}
}
/** Determine the ROW_FORMAT=COMPRESSED page size.
@param flags tablespace flags (FSP_FLAGS)
@return the ROW_FORMAT=COMPRESSED page size
@retval 0 if ROW_FORMAT=COMPRESSED is not used */
static ulint zip_size(ulint flags) {
ulint zip_ssize = FSP_FLAGS_GET_ZIP_SSIZE(flags);
return zip_ssize
? (UNIV_ZIP_SIZE_MIN >> 1) << zip_ssize : 0;
}
/** Determine the physical page size.
@param flags tablespace flags (FSP_FLAGS)
@return the physical page size */
static ulint physical_size(ulint flags) {
ulint zip_ssize = FSP_FLAGS_GET_ZIP_SSIZE(flags);
return zip_ssize
? (UNIV_ZIP_SIZE_MIN >> 1) << zip_ssize
: srv_page_size;
}
/** @return the ROW_FORMAT=COMPRESSED page size
@retval 0 if ROW_FORMAT=COMPRESSED is not used */
ulint zip_size() const { return zip_size(flags); }
/** @return the physical page size */
ulint physical_size() const { return physical_size(flags); }
};
/** Value of fil_space_t::magic_n */
@@ -688,16 +725,6 @@ fil_space_get_flags(
/*================*/
ulint id); /*!< in: space id */
/** Returns the page size of the space and whether it is compressed or not.
The tablespace must be cached in the memory cache.
@param[in] id space id
@param[out] found true if tablespace was found
@return page size */
const page_size_t
fil_space_get_page_size(
ulint id,
bool* found);
/*******************************************************************//**
Opens all log files and system tablespace data files. They stay open until the
database server shutdown. This should be called at a server startup after the
@@ -1033,7 +1060,7 @@ fil_space_extend(
@param[in] type IO context
@param[in] sync true if synchronous aio is desired
@param[in] page_id page id
@param[in] page_size page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] byte_offset remainder of offset in bytes; in aio this
must be divisible by the OS block size
@param[in] len how many bytes to read or write; this must
@@ -1052,7 +1079,7 @@ fil_io(
const IORequest& type,
bool sync,
const page_id_t page_id,
const page_size_t& page_size,
ulint zip_size,
ulint byte_offset,
ulint len,
void* buf,

View File

@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 2018, MariaDB Corporation.
Copyright (c) 2013, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -201,11 +201,6 @@ typedef byte fseg_inode_t;
(16 + 3 * FLST_BASE_NODE_SIZE \
+ FSEG_FRAG_ARR_N_SLOTS * FSEG_FRAG_SLOT_SIZE)
#define FSP_SEG_INODES_PER_PAGE(page_size) \
((page_size.physical() - FSEG_ARR_OFFSET - 10) / FSEG_INODE_SIZE)
/* Number of segment inodes which fit on a
single page */
#define FSEG_MAGIC_N_VALUE 97937874
#define FSEG_FILLFACTOR 8 /* If this value is x, then if
@@ -290,33 +285,6 @@ the extent are free and which contain old tuple version to clean. */
#ifndef UNIV_INNOCHECKSUM
/* @} */
/** Calculate the number of pages to extend a datafile.
We extend single-table tablespaces first one extent at a time,
but 4 at a time for bigger tablespaces. It is not enough to extend always
by one extent, because we need to add at least one extent to FSP_FREE.
A single extent descriptor page will track many extents. And the extent
that uses its extent descriptor page is put onto the FSP_FREE_FRAG list.
Extents that do not use their extent descriptor page are added to FSP_FREE.
The physical page size is used to determine how many extents are tracked
on one extent descriptor page. See xdes_calc_descriptor_page().
@param[in] page_size page_size of the datafile
@param[in] size current number of pages in the datafile
@return number of pages to extend the file. */
ulint
fsp_get_pages_to_extend_ibd(
const page_size_t& page_size,
ulint size);
/** Calculate the number of physical pages in an extent for this file.
@param[in] page_size page_size of the datafile
@return number of pages in an extent for this file. */
UNIV_INLINE
ulint
fsp_get_extent_size_in_pages(const page_size_t& page_size)
{
return (FSP_EXTENT_SIZE << srv_page_size_shift) / page_size.physical();
}
/**********************************************************************//**
Reads the space id from the first page of a tablespace.
@return space id, ULINT UNDEFINED if error */
@@ -347,13 +315,15 @@ fsp_header_get_flags(const page_t* page)
}
/** Get the byte offset of encryption information in page 0.
@param[in] ps page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@return byte offset relative to FSP_HEADER_OFFSET */
inline MY_ATTRIBUTE((pure, warn_unused_result))
ulint
fsp_header_get_encryption_offset(const page_size_t& ps)
ulint fsp_header_get_encryption_offset(ulint zip_size)
{
return XDES_ARR_OFFSET + XDES_SIZE * ps.physical() / FSP_EXTENT_SIZE;
return zip_size
? XDES_ARR_OFFSET + XDES_SIZE * zip_size / FSP_EXTENT_SIZE
: XDES_ARR_OFFSET + (XDES_SIZE << srv_page_size_shift)
/ FSP_EXTENT_SIZE;
}
/** Check the encryption key from the first page of a tablespace.
@@ -619,13 +589,12 @@ fil_block_check_type(
/** Checks if a page address is an extent descriptor page address.
@param[in] page_id page id
@param[in] page_size page size
@return TRUE if a descriptor page */
UNIV_INLINE
ibool
fsp_descr_page(
const page_id_t page_id,
const page_size_t& page_size);
@param[in] physical_size page size
@return whether a descriptor page */
inline bool fsp_descr_page(const page_id_t page_id, ulint physical_size)
{
return (page_id.page_no() & (physical_size - 1)) == FSP_XDES_OFFSET;
}
/***********************************************************//**
Parses a redo log record of a file page init.
@@ -776,16 +745,6 @@ fsp_flags_match(ulint expected, ulint actual)
return(actual == expected);
}
/** Calculates the descriptor index within a descriptor page.
@param[in] page_size page size
@param[in] offset page offset
@return descriptor index */
UNIV_INLINE
ulint
xdes_calc_descriptor_index(
const page_size_t& page_size,
ulint offset);
/**********************************************************************//**
Gets a descriptor bit of a page.
@return TRUE if free */
@@ -798,15 +757,40 @@ xdes_get_bit(
ulint offset);/*!< in: page offset within extent:
0 ... FSP_EXTENT_SIZE - 1 */
/** Calculates the page where the descriptor of a page resides.
@param[in] page_size page size
/** Determine the descriptor index within a descriptor page.
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] offset page offset
@return descriptor index */
inline ulint xdes_calc_descriptor_index(ulint zip_size, ulint offset)
{
return(ut_2pow_remainder(offset, zip_size ? zip_size : srv_page_size)
/ FSP_EXTENT_SIZE);
}
/** Determine the descriptor page number for a page.
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] offset page offset
@return descriptor page offset */
UNIV_INLINE
ulint
xdes_calc_descriptor_page(
const page_size_t& page_size,
ulint offset);
inline ulint xdes_calc_descriptor_page(ulint zip_size, ulint offset)
{
compile_time_assert(UNIV_PAGE_SIZE_MAX > XDES_ARR_OFFSET
+ (UNIV_PAGE_SIZE_MAX / FSP_EXTENT_SIZE_MAX)
* XDES_SIZE_MAX);
compile_time_assert(UNIV_PAGE_SIZE_MIN > XDES_ARR_OFFSET
+ (UNIV_PAGE_SIZE_MIN / FSP_EXTENT_SIZE_MIN)
* XDES_SIZE_MIN);
ut_ad(srv_page_size > XDES_ARR_OFFSET
+ (srv_page_size / FSP_EXTENT_SIZE)
* XDES_SIZE);
ut_ad(UNIV_ZIP_SIZE_MIN > XDES_ARR_OFFSET
+ (UNIV_ZIP_SIZE_MIN / FSP_EXTENT_SIZE)
* XDES_SIZE);
ut_ad(!zip_size
|| zip_size > XDES_ARR_OFFSET
+ (zip_size / FSP_EXTENT_SIZE) * XDES_SIZE);
return ut_2pow_round(offset, zip_size ? zip_size : srv_page_size);
}
#endif /* UNIV_INNOCHECKSUM */

View File

@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 2017, MariaDB Corporation.
Copyright (c) 2013, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -24,37 +24,6 @@ File space management
Created 12/18/1995 Heikki Tuuri
*******************************************************/
#ifndef UNIV_INNOCHECKSUM
/** Checks if a page address is an extent descriptor page address.
@param[in] page_id page id
@param[in] page_size page size
@return TRUE if a descriptor page */
UNIV_INLINE
ibool
fsp_descr_page(
const page_id_t page_id,
const page_size_t& page_size)
{
return((page_id.page_no() & (page_size.physical() - 1))
== FSP_XDES_OFFSET);
}
/** Calculates the descriptor index within a descriptor page.
@param[in] page_size page size
@param[in] offset page offset
@return descriptor index */
UNIV_INLINE
ulint
xdes_calc_descriptor_index(
const page_size_t& page_size,
ulint offset)
{
return(ut_2pow_remainder(offset, page_size.physical())
/ FSP_EXTENT_SIZE);
}
#endif /*!UNIV_INNOCHECKSUM */
/**********************************************************************//**
Gets a descriptor bit of a page.
@return TRUE if free */
@@ -80,39 +49,3 @@ xdes_get_bit(
MLOG_1BYTE),
bit_index));
}
#ifndef UNIV_INNOCHECKSUM
/** Calculates the page where the descriptor of a page resides.
@param[in] page_size page size
@param[in] offset page offset
@return descriptor page offset */
UNIV_INLINE
ulint
xdes_calc_descriptor_page(
const page_size_t& page_size,
ulint offset)
{
compile_time_assert(UNIV_PAGE_SIZE_MAX > XDES_ARR_OFFSET
+ (UNIV_PAGE_SIZE_MAX / FSP_EXTENT_SIZE_MAX)
* XDES_SIZE_MAX);
compile_time_assert(UNIV_PAGE_SIZE_MIN > XDES_ARR_OFFSET
+ (UNIV_PAGE_SIZE_MIN / FSP_EXTENT_SIZE_MIN)
* XDES_SIZE_MIN);
ut_ad(srv_page_size > XDES_ARR_OFFSET
+ (srv_page_size / FSP_EXTENT_SIZE)
* XDES_SIZE);
ut_ad(UNIV_ZIP_SIZE_MIN > XDES_ARR_OFFSET
+ (UNIV_ZIP_SIZE_MIN / FSP_EXTENT_SIZE)
* XDES_SIZE);
#ifdef UNIV_DEBUG
if (page_size.is_compressed()) {
ut_a(page_size.physical() > XDES_ARR_OFFSET
+ (page_size.physical() / FSP_EXTENT_SIZE) * XDES_SIZE);
}
#endif /* UNIV_DEBUG */
return(ut_2pow_round(offset, page_size.physical()));
}
#endif /* !UNIV_INNOCHECKSUM */

View File

@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -31,7 +32,7 @@ Created 12/13/1995 Heikki Tuuri
/** Gets a pointer to a file address and latches the page.
@param[in] space space id
@param[in] page_size page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] addr file address
@param[in] rw_latch RW_S_LATCH, RW_X_LATCH, RW_SX_LATCH
@param[out] ptr_block file page
@@ -42,13 +43,32 @@ UNIV_INLINE
byte*
fut_get_ptr(
ulint space,
const page_size_t& page_size,
ulint zip_size,
fil_addr_t addr,
rw_lock_type_t rw_latch,
mtr_t* mtr,
buf_block_t** ptr_block = NULL)
MY_ATTRIBUTE((warn_unused_result));
{
buf_block_t* block;
byte* ptr = NULL;
#include "fut0fut.ic"
ut_ad(addr.boffset < srv_page_size);
ut_ad((rw_latch == RW_S_LATCH)
|| (rw_latch == RW_X_LATCH)
|| (rw_latch == RW_SX_LATCH));
block = buf_page_get(page_id_t(space, addr.page), zip_size,
rw_latch, mtr);
ptr = buf_block_get_frame(block) + addr.boffset;
buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK);
if (ptr_block != NULL) {
*ptr_block = block;
}
return(ptr);
}
#endif /* fut0fut_h */

View File

@@ -1,68 +0,0 @@
/*****************************************************************************
Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*****************************************************************************/
/******************************************************************//**
@file include/fut0fut.ic
File-based utilities
Created 12/13/1995 Heikki Tuuri
***********************************************************************/
#include "sync0rw.h"
#include "buf0buf.h"
/** Gets a pointer to a file address and latches the page.
@param[in] space space id
@param[in] page_size page size
@param[in] addr file address
@param[in] rw_latch RW_S_LATCH, RW_X_LATCH, RW_SX_LATCH
@param[in,out] mtr mini-transaction
@param[out] ptr_block file page
@return pointer to a byte in (*ptr_block)->frame; the *ptr_block is
bufferfixed and latched */
UNIV_INLINE
byte*
fut_get_ptr(
ulint space,
const page_size_t& page_size,
fil_addr_t addr,
rw_lock_type_t rw_latch,
mtr_t* mtr,
buf_block_t** ptr_block)
{
buf_block_t* block;
byte* ptr = NULL;
ut_ad(addr.boffset < srv_page_size);
ut_ad((rw_latch == RW_S_LATCH)
|| (rw_latch == RW_X_LATCH)
|| (rw_latch == RW_SX_LATCH));
block = buf_page_get(page_id_t(space, addr.page), page_size,
rw_latch, mtr);
ptr = buf_block_get_frame(block) + addr.boffset;
buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK);
if (ptr_block != NULL) {
*ptr_block = block;
}
return(ptr);
}

View File

@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2016, 2018, MariaDB Corporation.
Copyright (c) 2016, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -241,18 +241,19 @@ ibuf_inside(
/** Checks if a page address is an ibuf bitmap page (level 3 page) address.
@param[in] page_id page id
@param[in] page_size page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@return TRUE if a bitmap page */
UNIV_INLINE
ibool
ibuf_bitmap_page(
const page_id_t page_id,
const page_size_t& page_size);
inline bool ibuf_bitmap_page(const page_id_t page_id, ulint zip_size)
{
ut_ad(ut_is_2pow(zip_size));
ulint size = zip_size ? zip_size : srv_page_size;
return (page_id.page_no() & (size - 1)) == FSP_IBUF_BITMAP_OFFSET;
}
/** Checks if a page is a level 2 or 3 page in the ibuf hierarchy of pages.
Must not be called when recv_no_ibuf_operations==true.
@param[in] page_id page id
@param[in] page_size page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] x_latch FALSE if relaxed check (avoid latching the
bitmap page)
@param[in] file file name
@@ -260,13 +261,13 @@ bitmap page)
@param[in,out] mtr mtr which will contain an x-latch to the
bitmap page if the page is not one of the fixed address ibuf pages, or NULL,
in which case a new transaction is created.
@return TRUE if level 2 or level 3 page */
ibool
@return true if level 2 or level 3 page */
bool
ibuf_page_low(
const page_id_t page_id,
const page_size_t& page_size,
ulint zip_size,
#ifdef UNIV_DEBUG
ibool x_latch,
bool x_latch,
#endif /* UNIV_DEBUG */
const char* file,
unsigned line,
@@ -278,22 +279,22 @@ ibuf_page_low(
/** Checks if a page is a level 2 or 3 page in the ibuf hierarchy of pages.
Must not be called when recv_no_ibuf_operations==true.
@param[in] page_id tablespace/page identifier
@param[in] page_size page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in,out] mtr mini-transaction or NULL
@return TRUE if level 2 or level 3 page */
# define ibuf_page(page_id, page_size, mtr) \
ibuf_page_low(page_id, page_size, TRUE, __FILE__, __LINE__, mtr)
# define ibuf_page(page_id, zip_size, mtr) \
ibuf_page_low(page_id, zip_size, true, __FILE__, __LINE__, mtr)
#else /* UVIV_DEBUG */
/** Checks if a page is a level 2 or 3 page in the ibuf hierarchy of pages.
Must not be called when recv_no_ibuf_operations==true.
@param[in] page_id tablespace/page identifier
@param[in] page_size page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in,out] mtr mini-transaction or NULL
@return TRUE if level 2 or level 3 page */
# define ibuf_page(page_id, page_size, mtr) \
ibuf_page_low(page_id, page_size, __FILE__, __LINE__, mtr)
# define ibuf_page(page_id, zip_size, mtr) \
ibuf_page_low(page_id, zip_size, __FILE__, __LINE__, mtr)
#endif /* UVIV_DEBUG */
/***********************************************************************//**
@@ -304,23 +305,23 @@ void
ibuf_free_excess_pages(void);
/*========================*/
/** Buffer an operation in the insert/delete buffer, instead of doing it
directly to the disk page, if this is possible. Does not do it if the index
/** Buffer an operation in the change buffer, instead of applying it
directly to the file page, if this is possible. Does not do it if the index
is clustered or unique.
@param[in] op operation type
@param[in] entry index entry to insert
@param[in,out] index index where to insert
@param[in] page_id page id where to insert
@param[in] page_size page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in,out] thr query thread
@return TRUE if success */
ibool
@return true if success */
bool
ibuf_insert(
ibuf_op_t op,
const dtuple_t* entry,
dict_index_t* index,
const page_id_t page_id,
const page_size_t& page_size,
ulint zip_size,
que_thr_t* thr);
/** When an index page is read from a disk to the buffer pool, this function
@@ -332,15 +333,16 @@ subsequently was dropped.
@param[in,out] block if page has been read from disk,
pointer to the page x-latched, else NULL
@param[in] page_id page id of the index page
@param[in] update_ibuf_bitmap normally this is set to TRUE, but
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] update_ibuf_bitmap normally this is set, but
if we have deleted or are deleting the tablespace, then we naturally do not
want to update a non-existent bitmap page */
void
ibuf_merge_or_delete_for_page(
buf_block_t* block,
const page_id_t page_id,
const page_size_t* page_size,
ibool update_ibuf_bitmap);
ulint zip_size,
bool update_ibuf_bitmap);
/*********************************************************************//**
Deletes all entries in the insert buffer for a given space id. This is used

View File

@@ -150,20 +150,6 @@ ibuf_inside(
return(mtr->is_inside_ibuf());
}
/** Checks if a page address is an ibuf bitmap page (level 3 page) address.
@param[in] page_id page id
@param[in] page_size page size
@return TRUE if a bitmap page */
UNIV_INLINE
ibool
ibuf_bitmap_page(
const page_id_t page_id,
const page_size_t& page_size)
{
return((page_id.page_no() & (page_size.physical() - 1))
== FSP_IBUF_BITMAP_OFFSET);
}
/** Translates the free space on a page to a value in the ibuf bitmap.
@param[in] page_size page size in bytes
@param[in] max_ins_size maximum insert size after reorganize for
@@ -192,29 +178,6 @@ ibuf_index_page_calc_free_bits(
return(n);
}
/** Translates the ibuf free bits to the free space on a page in bytes.
@param[in] page_size page_size
@param[in] bits value for ibuf bitmap bits
@return maximum insert size after reorganize for the page */
UNIV_INLINE
ulint
ibuf_index_page_calc_free_from_bits(
const page_size_t& page_size,
ulint bits)
{
ut_ad(bits < 4);
ut_ad(!page_size.is_compressed()
|| page_size.physical() > IBUF_PAGE_SIZE_PER_FREE_SPACE);
if (bits == 3) {
return(4 * page_size.physical()
/ IBUF_PAGE_SIZE_PER_FREE_SPACE);
}
return(bits * (page_size.physical()
/ IBUF_PAGE_SIZE_PER_FREE_SPACE));
}
/*********************************************************************//**
Translates the free space on a compressed page to a value in the ibuf bitmap.
@return value for ibuf bitmap bits */
@@ -228,7 +191,7 @@ ibuf_index_page_calc_free_zip(
const page_zip_des_t* page_zip;
lint zip_max_ins;
ut_ad(block->page.size.is_compressed());
ut_ad(block->page.zip.data);
/* Consider the maximum insert size on the uncompressed page
without reorganizing the page. We must not assume anything
@@ -251,7 +214,7 @@ ibuf_index_page_calc_free_zip(
max_ins_size = (ulint) zip_max_ins;
}
return(ibuf_index_page_calc_free_bits(block->page.size.physical(),
return(ibuf_index_page_calc_free_bits(block->physical_size(),
max_ins_size));
}
@@ -264,14 +227,14 @@ ibuf_index_page_calc_free(
/*======================*/
const buf_block_t* block) /*!< in: buffer block */
{
if (!block->page.size.is_compressed()) {
if (!block->page.zip.data) {
ulint max_ins_size;
max_ins_size = page_get_max_insert_size_after_reorganize(
buf_block_get_frame(block), 1);
return(ibuf_index_page_calc_free_bits(
block->page.size.physical(), max_ins_size));
block->physical_size(), max_ins_size));
} else {
return(ibuf_index_page_calc_free_zip(block));
}
@@ -312,12 +275,12 @@ ibuf_update_free_bits_if_full(
ut_ad(buf_block_get_page_zip(block) == NULL);
before = ibuf_index_page_calc_free_bits(
block->page.size.physical(), max_ins_size);
srv_page_size, max_ins_size);
if (max_ins_size >= increase) {
compile_time_assert(ULINT32_UNDEFINED > UNIV_PAGE_SIZE_MAX);
after = ibuf_index_page_calc_free_bits(
block->page.size.physical(), max_ins_size - increase);
srv_page_size, max_ins_size - increase);
#ifdef UNIV_IBUF_DEBUG
ut_a(after <= ibuf_index_page_calc_free(block));
#endif

View File

@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1994, 2014, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, MariaDB Corporation.
Copyright (c) 2017, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -212,7 +212,7 @@ mem_heap_alloc(
mem_block_set_free(block, free + MEM_SPACE_NEEDED(n));
UNIV_MEM_ALLOC(buf, n);
TRASH_ALLOC(buf, n);
return(buf);
}

View File

@@ -36,7 +36,7 @@ Created 10/21/1995 Heikki Tuuri
#ifndef os0file_h
#define os0file_h
#include "page0size.h"
#include "fsp0types.h"
#include "os0api.h"
#ifndef _WIN32

View File

@@ -1,197 +0,0 @@
/*****************************************************************************
Copyright (c) 2013, 2015, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
*****************************************************************************/
/**************************************************//**
@file include/page0size.h
A class describing a page size.
Created Nov 14, 2013 Vasil Dimov
*******************************************************/
#ifndef page0size_t
#define page0size_t
#include "fsp0types.h"
#define FIELD_REF_SIZE 20U
/** A BLOB field reference full of zero, for use in assertions and
tests.Initially, BLOB field references are set to zero, in
dtuple_convert_big_rec(). */
extern const byte field_ref_zero[UNIV_PAGE_SIZE_MAX];
#define PAGE_SIZE_T_SIZE_BITS 17
/** Page size descriptor. Contains the physical and logical page size, as well
as whether the page is compressed or not. */
class page_size_t {
public:
/** Constructor from (physical, logical, is_compressed).
@param[in] physical physical (on-disk/zipped) page size
@param[in] logical logical (in-memory/unzipped) page size
@param[in] is_compressed whether the page is compressed */
page_size_t(ulint physical, ulint logical, bool is_compressed)
{
if (physical == 0) {
physical = UNIV_PAGE_SIZE_ORIG;
}
if (logical == 0) {
logical = UNIV_PAGE_SIZE_ORIG;
}
m_physical = static_cast<unsigned>(physical);
m_logical = static_cast<unsigned>(logical);
m_is_compressed = static_cast<unsigned>(is_compressed);
ut_ad(physical <= (1 << PAGE_SIZE_T_SIZE_BITS));
ut_ad(logical <= (1 << PAGE_SIZE_T_SIZE_BITS));
ut_ad(ut_is_2pow(physical));
ut_ad(ut_is_2pow(logical));
ut_ad(logical <= UNIV_PAGE_SIZE_MAX);
ut_ad(logical >= physical);
ut_ad(!is_compressed || physical <= UNIV_ZIP_SIZE_MAX);
}
/** Constructor from (fsp_flags).
@param[in] fsp_flags filespace flags */
explicit page_size_t(ulint fsp_flags)
{
ulint ssize = FSP_FLAGS_GET_PAGE_SSIZE(fsp_flags);
/* If the logical page size is zero in fsp_flags, then use the
legacy 16k page size. */
ssize = (0 == ssize) ? UNIV_PAGE_SSIZE_ORIG : ssize;
/* Convert from a 'log2 minus 9' to a page size in bytes. */
const unsigned size = ((UNIV_ZIP_SIZE_MIN >> 1) << ssize);
ut_ad(size <= UNIV_PAGE_SIZE_MAX);
ut_ad(size <= (1 << PAGE_SIZE_T_SIZE_BITS));
m_logical = size;
ssize = FSP_FLAGS_GET_ZIP_SSIZE(fsp_flags);
/* If the fsp_flags have zero in the zip_ssize field, then it means
that the tablespace does not have compressed pages and the physical
page size is the same as the logical page size. */
if (ssize == 0) {
m_is_compressed = false;
m_physical = m_logical;
} else {
m_is_compressed = true;
/* Convert from a 'log2 minus 9' to a page size
in bytes. */
const unsigned phy
= ((UNIV_ZIP_SIZE_MIN >> 1) << ssize);
ut_ad(phy <= UNIV_ZIP_SIZE_MAX);
ut_ad(phy <= (1 << PAGE_SIZE_T_SIZE_BITS));
m_physical = phy;
}
}
/** Retrieve the physical page size (on-disk).
@return physical page size in bytes */
inline ulint physical() const
{
ut_ad(m_physical > 0);
return(m_physical);
}
/** Retrieve the logical page size (in-memory).
@return logical page size in bytes */
inline ulint logical() const
{
ut_ad(m_logical > 0);
return(m_logical);
}
/** Check whether the page is compressed on disk.
@return true if compressed */
inline bool is_compressed() const
{
return(m_is_compressed);
}
/** Copy the values from a given page_size_t object.
@param[in] src page size object whose values to fetch */
inline void copy_from(const page_size_t& src)
{
*this = src;
}
/** Check if a given page_size_t object is equal to the current one.
@param[in] a page_size_t object to compare
@return true if equal */
inline bool equals_to(const page_size_t& a) const
{
return(a.physical() == m_physical
&& a.logical() == m_logical
&& a.is_compressed() == m_is_compressed);
}
private:
/* For non compressed tablespaces, physical page size is equal to
the logical page size and the data is stored in buf_page_t::frame
(and is also always equal to univ_page_size (--innodb-page-size=)).
For compressed tablespaces, physical page size is the compressed
page size as stored on disk and in buf_page_t::zip::data. The logical
page size is the uncompressed page size in memory - the size of
buf_page_t::frame (currently also always equal to univ_page_size
(--innodb-page-size=)). */
/** Physical page size. */
unsigned m_physical:PAGE_SIZE_T_SIZE_BITS;
/** Logical page size. */
unsigned m_logical:PAGE_SIZE_T_SIZE_BITS;
/** Flag designating whether the physical page is compressed, which is
true IFF the whole tablespace where the page belongs is compressed. */
unsigned m_is_compressed:1;
};
/* Overloading the global output operator to conveniently print an object
of type the page_size_t.
@param[in,out] out the output stream
@param[in] obj an object of type page_size_t to be printed
@retval the output stream */
inline
std::ostream&
operator<<(
std::ostream& out,
const page_size_t& obj)
{
out << "[page size: physical=" << obj.physical()
<< ", logical=" << obj.logical()
<< ", compressed=" << obj.is_compressed() << "]";
return(out);
}
extern page_size_t univ_page_size;
#endif /* page0size_t */

View File

@@ -2,7 +2,7 @@
Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
Copyright (c) 2017, 2018, MariaDB Corporation.
Copyright (c) 2017, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -86,15 +86,10 @@ page_zip_set_size(
@param[in] comp nonzero=compact format
@param[in] n_fields number of fields in the record; ignored if
tablespace is not compressed
@param[in] page_size page size
@return FALSE if the entire record can be stored locally on the page */
UNIV_INLINE
ibool
page_zip_rec_needs_ext(
ulint rec_size,
ulint comp,
ulint n_fields,
const page_size_t& page_size)
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@return false if the entire record can be stored locally on the page */
inline bool page_zip_rec_needs_ext(ulint rec_size, ulint comp, ulint n_fields,
ulint zip_size)
MY_ATTRIBUTE((warn_unused_result));
/**********************************************************************//**

View File

@@ -2,7 +2,7 @@
Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
Copyright (c) 2017, MariaDB Corporation.
Copyright (c) 2017, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -149,19 +149,14 @@ page_zip_set_size(
@param[in] comp nonzero=compact format
@param[in] n_fields number of fields in the record; ignored if
tablespace is not compressed
@param[in] page_size page size
@return FALSE if the entire record can be stored locally on the page */
UNIV_INLINE
ibool
page_zip_rec_needs_ext(
ulint rec_size,
ulint comp,
ulint n_fields,
const page_size_t& page_size)
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@return false if the entire record can be stored locally on the page */
inline bool page_zip_rec_needs_ext(ulint rec_size, ulint comp, ulint n_fields,
ulint zip_size)
{
ut_ad(rec_size
> ulint(comp ? REC_N_NEW_EXTRA_BYTES : REC_N_OLD_EXTRA_BYTES));
ut_ad(comp || !page_size.is_compressed());
ut_ad(comp || !zip_size);
#if UNIV_PAGE_SIZE_MAX > COMPRESSED_REC_MAX_DATA_SIZE
if (comp ? rec_size >= COMPRESSED_REC_MAX_DATA_SIZE :
@@ -170,7 +165,7 @@ page_zip_rec_needs_ext(
}
#endif
if (page_size.is_compressed()) {
if (zip_size) {
ut_ad(comp);
/* On a compressed page, there is a two-byte entry in
the dense page directory for every record. But there
@@ -179,7 +174,7 @@ page_zip_rec_needs_ext(
the encoded heap number. Check also the available space
on the uncompressed page. */
return(rec_size - (REC_N_NEW_EXTRA_BYTES - 2 - 1)
>= page_zip_empty_size(n_fields, page_size.physical())
>= page_zip_empty_size(n_fields, zip_size)
|| rec_size >= page_get_free_space_of_empty(TRUE) / 2);
}

View File

@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 2006, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -29,7 +30,7 @@ Created September 2006 Marko Makela
#include "data0types.h"
#include "mem0mem.h"
#include "dict0types.h"
#include "page0size.h"
#include "fsp0types.h"
#include "row0types.h"
/********************************************************************//**
@@ -43,7 +44,7 @@ row_ext_create(
in the InnoDB table object, as reported by
dict_col_get_no(); NOT relative to the records
in the clustered index */
ulint flags, /*!< in: table->flags */
const dict_table_t& table, /*!< in: table */
const dtuple_t* tuple, /*!< in: data tuple containing the field
references of the externally stored
columns; must be indexed by col_no;
@@ -91,9 +92,7 @@ struct row_ext_t{
REC_ANTELOPE_MAX_INDEX_COL_LEN or
REC_VERSION_56_MAX_INDEX_COL_LEN depending
on row format */
page_size_t page_size;
/*!< page size of the externally stored
columns */
ulint zip_size;/*!< ROW_FORMAT=COMPRESSED page size, or 0 */
ulint len[1]; /*!< prefix lengths; 0 if not cached */
};

View File

@@ -41,7 +41,7 @@ trx_rsegf_get(fil_space_t* space, ulint page_no, mtr_t* mtr)
|| !srv_was_started);
buf_block_t* block = buf_page_get(page_id_t(space->id, page_no),
univ_page_size, RW_X_LATCH, mtr);
0, RW_X_LATCH, mtr);
buf_block_dbg_add_level(block, SYNC_RSEG_HEADER);
@@ -67,8 +67,7 @@ trx_rsegf_get_new(
|| !srv_was_started);
ut_ad(space <= TRX_SYS_MAX_UNDO_SPACES || space == SRV_TMP_SPACE_ID);
block = buf_page_get(
page_id_t(space, page_no), univ_page_size, RW_X_LATCH, mtr);
block = buf_page_get(page_id_t(space, page_no), 0, RW_X_LATCH, mtr);
buf_block_dbg_add_level(block, SYNC_RSEG_HEADER_NEW);

View File

@@ -74,7 +74,7 @@ trx_sysf_get(mtr_t* mtr, bool rw = true)
{
buf_block_t* block = buf_page_get(
page_id_t(TRX_SYS_SPACE, TRX_SYS_PAGE_NO),
univ_page_size, rw ? RW_X_LATCH : RW_S_LATCH, mtr);
0, rw ? RW_X_LATCH : RW_S_LATCH, mtr);
if (block) {
buf_block_dbg_add_level(block, SYNC_TRX_SYS_HEADER);
}

View File

@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2018, MariaDB Corporation.
Copyright (c) 2017, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -111,8 +111,7 @@ UNIV_INLINE
page_t*
trx_undo_page_get(const page_id_t page_id, mtr_t* mtr)
{
buf_block_t* block = buf_page_get(page_id, univ_page_size,
RW_X_LATCH, mtr);
buf_block_t* block = buf_page_get(page_id, 0, RW_X_LATCH, mtr);
buf_block_dbg_add_level(block, SYNC_TRX_UNDO_PAGE);
@@ -127,8 +126,7 @@ UNIV_INLINE
page_t*
trx_undo_page_get_s_latched(const page_id_t page_id, mtr_t* mtr)
{
buf_block_t* block = buf_page_get(page_id, univ_page_size,
RW_S_LATCH, mtr);
buf_block_t* block = buf_page_get(page_id, 0, RW_S_LATCH, mtr);
buf_block_dbg_add_level(block, SYNC_TRX_UNDO_PAGE);

View File

@@ -5176,7 +5176,7 @@ lock_rec_block_validate(
block = buf_page_get_gen(
page_id_t(space_id, page_no),
page_size_t(space->flags),
space->zip_size(),
RW_X_LATCH, NULL,
BUF_GET_POSSIBLY_FREED,
__FILE__, __LINE__, &mtr, &err);

View File

@@ -719,7 +719,7 @@ log_file_header_flush(
fil_io(IORequestLogWrite, true,
page_id_t(SRV_LOG_SPACE_FIRST_ID, page_no),
univ_page_size,
0,
ulint(dest_offset & (srv_page_size - 1)),
OS_FILE_LOG_BLOCK_SIZE, buf, NULL);
@@ -838,7 +838,7 @@ loop:
fil_io(IORequestLogWrite, true,
page_id_t(SRV_LOG_SPACE_FIRST_ID, page_no),
univ_page_size,
0,
ulint(next_offset & (srv_page_size - 1)), write_len, buf, NULL);
srv_stats.os_log_pending_writes.dec();
@@ -1341,7 +1341,7 @@ log_group_checkpoint(lsn_t end_lsn)
fil_io(IORequestLogWrite, false,
page_id_t(SRV_LOG_SPACE_FIRST_ID, 0),
univ_page_size,
0,
(log_sys.next_checkpoint_no & 1)
? LOG_CHECKPOINT_2 : LOG_CHECKPOINT_1,
OS_FILE_LOG_BLOCK_SIZE,
@@ -1361,7 +1361,7 @@ void log_header_read(ulint header)
fil_io(IORequestLogRead, true,
page_id_t(SRV_LOG_SPACE_FIRST_ID,
header >> srv_page_size_shift),
univ_page_size, header & (srv_page_size - 1),
0, header & (srv_page_size - 1),
OS_FILE_LOG_BLOCK_SIZE, log_sys.checkpoint_buf, NULL);
}

View File

@@ -780,7 +780,7 @@ loop:
fil_io(IORequestLogRead, true,
page_id_t(SRV_LOG_SPACE_FIRST_ID, page_no),
univ_page_size,
0,
ulint(source_offset & (srv_page_size - 1)),
len, buf, NULL);
@@ -997,7 +997,7 @@ static dberr_t recv_log_format_0_recover(lsn_t lsn, bool crypt)
fil_io(IORequestLogRead, true,
page_id_t(SRV_LOG_SPACE_FIRST_ID, page_no),
univ_page_size,
0,
ulint((source_offset & ~(OS_FILE_LOG_BLOCK_SIZE - 1))
& (srv_page_size - 1)),
OS_FILE_LOG_BLOCK_SIZE, buf, NULL);
@@ -2081,19 +2081,21 @@ void recv_apply_hashed_log_recs(bool last_batch)
if (recv_addr->state == RECV_DISCARDED
|| !UT_LIST_GET_LEN(recv_addr->rec_list)) {
not_found:
ut_a(recv_sys->n_addrs);
recv_sys->n_addrs--;
continue;
}
fil_space_t* space = fil_space_acquire_for_io(
recv_addr->space);
if (!space) {
goto not_found;
}
const page_id_t page_id(recv_addr->space,
recv_addr->page_no);
bool found;
const page_size_t& page_size
= fil_space_get_page_size(recv_addr->space,
&found);
ut_ad(found);
const ulint zip_size = space->zip_size();
if (recv_addr->state == RECV_NOT_PROCESSED) {
mutex_exit(&recv_sys->mutex);
@@ -2103,7 +2105,7 @@ void recv_apply_hashed_log_recs(bool last_batch)
mtr.start();
buf_block_t* block = buf_page_get(
page_id, page_size,
page_id, zip_size,
RW_X_LATCH, &mtr);
buf_block_dbg_add_level(
@@ -2117,6 +2119,8 @@ void recv_apply_hashed_log_recs(bool last_batch)
mutex_enter(&recv_sys->mutex);
}
space->release_for_io();
}
}

View File

@@ -142,7 +142,7 @@ struct FindPage
slot->object);
if (m_ptr < block->frame
|| m_ptr >= block->frame + block->page.size.logical()) {
|| m_ptr >= block->frame + srv_page_size) {
return(true);
}

View File

@@ -3511,8 +3511,6 @@ static WinIoInit win_io_init;
/** Free storage space associated with a section of the file.
@param[in] fh Open file handle
@param[in] page_size Tablespace page size
@param[in] block_size File system block size
@param[in] off Starting offset (SEEK_SET)
@param[in] len Size of the hole
@return 0 on success or errno */

View File

@@ -26,19 +26,19 @@ Created June 2005 by Marko Makela
*******************************************************/
#include "page0zip.h"
#include "page0size.h"
#include "fsp0types.h"
#include "page0page.h"
#include "buf0checksum.h"
#include "ut0crc32.h"
#include "zlib.h"
#ifndef UNIV_INNOCHECKSUM
/** A BLOB field reference full of zero, for use in assertions and tests.
Initially, BLOB field references are set to zero, in
dtuple_convert_big_rec(). */
const byte field_ref_zero[UNIV_PAGE_SIZE_MAX] = { 0, };
#include "ut0crc32.h"
#include "zlib.h"
#ifndef UNIV_INNOCHECKSUM
#include "mtr0log.h"
#include "dict0dict.h"
#include "btr0cur.h"
@@ -170,18 +170,17 @@ page_zip_is_too_big(
const dict_index_t* index,
const dtuple_t* entry)
{
const page_size_t& page_size =
dict_table_page_size(index->table);
const ulint zip_size = index->table->space->zip_size();
/* Estimate the free space of an empty compressed page.
Subtract one byte for the encoded heap_no in the
modification log. */
ulint free_space_zip = page_zip_empty_size(
index->n_fields, page_size.physical());
index->n_fields, zip_size);
ulint n_uniq = dict_index_get_n_unique_in_tree(index);
ut_ad(dict_table_is_comp(index->table));
ut_ad(page_size.is_compressed());
ut_ad(zip_size);
if (free_space_zip == 0) {
return(true);

View File

@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 2006, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -29,14 +30,14 @@ Created September 2006 Marko Makela
/** Fills the column prefix cache of an externally stored column.
@param[in,out] ext column prefix cache
@param[in] i index of ext->ext[]
@param[in] page_size page size
@param[in] space tablespace
@param[in] dfield data field */
static
void
row_ext_cache_fill(
row_ext_t* ext,
ulint i,
const page_size_t& page_size,
fil_space_t* space,
const dfield_t* dfield)
{
const byte* field = static_cast<const byte*>(
@@ -75,7 +76,8 @@ row_ext_cache_fill(
crashed during the execution of
btr_free_externally_stored_field(). */
ext->len[i] = btr_copy_externally_stored_field_prefix(
buf, ext->max_len, page_size, field, f_len);
buf, ext->max_len, ext->zip_size,
field, f_len);
}
}
}
@@ -91,7 +93,7 @@ row_ext_create(
in the InnoDB table object, as reported by
dict_col_get_no(); NOT relative to the records
in the clustered index */
ulint flags, /*!< in: table->flags */
const dict_table_t& table, /*!< in: table */
const dtuple_t* tuple, /*!< in: data tuple containing the field
references of the externally stored
columns; must be indexed by col_no;
@@ -100,36 +102,30 @@ row_ext_create(
to prevent deletion (rollback or purge). */
mem_heap_t* heap) /*!< in: heap where created */
{
ulint i;
const page_size_t& page_size = dict_tf_get_page_size(flags);
row_ext_t* ret;
if (!table.space) {
return NULL;
}
ut_ad(n_ext > 0);
ret = static_cast<row_ext_t*>(
row_ext_t* ret = static_cast<row_ext_t*>(
mem_heap_alloc(heap,
(sizeof *ret) + (n_ext - 1) * sizeof ret->len));
ret->n_ext = n_ext;
ret->ext = ext;
ret->max_len = DICT_MAX_FIELD_LEN_BY_FORMAT_FLAG(flags);
ret->page_size.copy_from(page_size);
ret->max_len = DICT_MAX_FIELD_LEN_BY_FORMAT_FLAG(table.flags);
ret->zip_size = dict_tf_get_zip_size(table.flags);
ret->buf = static_cast<byte*>(
mem_heap_alloc(heap, n_ext * ret->max_len));
#ifdef UNIV_DEBUG
memset(ret->buf, 0xaa, n_ext * ret->max_len);
UNIV_MEM_ALLOC(ret->buf, n_ext * ret->max_len);
#endif
/* Fetch the BLOB prefixes */
for (i = 0; i < n_ext; i++) {
for (ulint i = 0; i < n_ext; i++) {
const dfield_t* dfield;
dfield = dtuple_get_nth_field(tuple, ext[i]);
row_ext_cache_fill(ret, i, page_size, dfield);
row_ext_cache_fill(ret, i, table.space, dfield);
}
return(ret);

View File

@@ -808,7 +808,7 @@ DECLARE_THREAD(fts_parallel_tokenization)(
block = psort_info->merge_block;
crypt_block = psort_info->crypt_block;
const page_size_t& page_size = dict_table_page_size(table);
const ulint zip_size = table->space->zip_size();
row_merge_fts_get_next_doc_item(psort_info, &doc_item);
@@ -838,7 +838,7 @@ loop:
doc.text.f_str =
btr_copy_externally_stored_field(
&doc.text.f_len, data,
page_size, data_len, blob_heap);
zip_size, data_len, blob_heap);
} else {
doc.text.f_str = data;
doc.text.f_len = data_len;

View File

@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 2012, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2015, 2018, MariaDB Corporation.
Copyright (c) 2015, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -53,7 +53,7 @@ Created 2012-02-08 by Sunny Bains.
/** The size of the buffer to use for IO.
@param n physical page size
@return number of pages */
#define IO_BUFFER_SIZE(n) ((1024 * 1024) / n)
#define IO_BUFFER_SIZE(n) ((1024 * 1024) / (n))
/** For gathering stats on records during phase I */
struct row_stats_t {
@@ -115,7 +115,7 @@ struct row_import {
m_hostname(NULL),
m_table_name(NULL),
m_autoinc(0),
m_page_size(0, 0, false),
m_zip_size(0),
m_flags(0),
m_n_cols(0),
m_cols(NULL),
@@ -196,7 +196,8 @@ struct row_import {
ib_uint64_t m_autoinc; /*!< Next autoinc value */
page_size_t m_page_size; /*!< Tablespace page size */
ulint m_zip_size; /*!< ROW_FORMAT=COMPRESSED
page size, or 0 */
ulint m_flags; /*!< Table flags */
@@ -356,7 +357,7 @@ public:
@param trx covering transaction */
AbstractCallback(trx_t* trx, ulint space_id)
:
m_page_size(0, 0, false),
m_zip_size(0),
m_trx(trx),
m_space(space_id),
m_xdes(),
@@ -380,7 +381,7 @@ public:
/** @return true if compressed table. */
bool is_compressed_table() const UNIV_NOTHROW
{
return(get_page_size().is_compressed());
return get_zip_size();
}
/** @return the tablespace flags */
@@ -400,7 +401,11 @@ public:
m_filepath = filename;
}
const page_size_t& get_page_size() const { return m_page_size; }
ulint get_zip_size() const { return m_zip_size; }
ulint physical_size() const
{
return m_zip_size ? m_zip_size : srv_page_size;
}
const char* filename() const { return m_filepath; }
@@ -439,7 +444,7 @@ protected:
{
ulint offset;
offset = xdes_calc_descriptor_index(get_page_size(), page_no);
offset = xdes_calc_descriptor_index(get_zip_size(), page_no);
return(page + XDES_ARR_OFFSET + XDES_SIZE * offset);
}
@@ -467,9 +472,11 @@ protected:
state = mach_read_ulint(xdesc + XDES_STATE, MLOG_4BYTES);
if (state != XDES_FREE) {
const ulint physical_size = m_zip_size
? m_zip_size : srv_page_size;
m_xdes = UT_NEW_ARRAY_NOKEY(xdes_t,
m_page_size.physical());
physical_size);
/* Trigger OOM */
DBUG_EXECUTE_IF(
@@ -482,7 +489,7 @@ protected:
return(DB_OUT_OF_MEMORY);
}
memcpy(m_xdes, page, m_page_size.physical());
memcpy(m_xdes, page, physical_size);
}
return(DB_SUCCESS);
@@ -493,7 +500,7 @@ protected:
@return true if the page is marked as free */
bool is_free(ulint page_no) const UNIV_NOTHROW
{
ut_a(xdes_calc_descriptor_page(get_page_size(), page_no)
ut_a(xdes_calc_descriptor_page(get_zip_size(), page_no)
== m_xdes_page_no);
if (m_xdes != 0) {
@@ -508,8 +515,8 @@ protected:
}
protected:
/** The tablespace page size. */
page_size_t m_page_size;
/** The ROW_FORMAT=COMPRESSED page size, or 0. */
ulint m_zip_size;
/** File handle to the tablespace */
pfs_os_file_t m_file;
@@ -568,21 +575,23 @@ AbstractCallback::init(
/* Clear the DATA_DIR flag, which is basically garbage. */
m_space_flags &= ~(1U << FSP_FLAGS_POS_RESERVED);
m_page_size.copy_from(page_size_t(m_space_flags));
m_zip_size = fil_space_t::zip_size(m_space_flags);
const ulint logical_size = fil_space_t::logical_size(m_space_flags);
const ulint physical_size = fil_space_t::physical_size(m_space_flags);
if (!is_compressed_table() && !m_page_size.equals_to(univ_page_size)) {
if (logical_size != srv_page_size) {
ib::error() << "Page size " << m_page_size.physical()
ib::error() << "Page size " << logical_size
<< " of ibd file is not the same as the server page"
" size " << srv_page_size;
return(DB_CORRUPTION);
} else if (file_size % m_page_size.physical() != 0) {
} else if (file_size & (physical_size - 1)) {
ib::error() << "File size " << file_size << " is not a"
" multiple of the page size "
<< m_page_size.physical();
<< physical_size;
return(DB_CORRUPTION);
}
@@ -694,7 +703,7 @@ FetchIndexRootPages::build_row_import(row_import* cfg) const UNIV_NOTHROW
Indexes::const_iterator end = m_indexes.end();
ut_a(cfg->m_table == m_table);
cfg->m_page_size.copy_from(m_page_size);
cfg->m_zip_size = m_zip_size;
cfg->m_n_indexes = m_indexes.size();
if (cfg->m_n_indexes == 0) {
@@ -1980,7 +1989,7 @@ dberr_t PageConverter::operator()(buf_block_t* block) UNIV_NOTHROW
/* If we already had an old page with matching number
in the buffer pool, evict it now, because
we no longer evict the pages on DISCARD TABLESPACE. */
buf_page_get_gen(block->page.id, get_page_size(),
buf_page_get_gen(block->page.id, get_zip_size(),
RW_NO_LATCH, NULL, BUF_EVICT_IF_IN_POOL,
__FILE__, __LINE__, NULL, NULL);
@@ -2000,7 +2009,7 @@ dberr_t PageConverter::operator()(buf_block_t* block) UNIV_NOTHROW
/* Calculate and update the checksum of non-index
pages for ROW_FORMAT=COMPRESSED tables. */
buf_flush_update_zip_checksum(
block->page.zip.data, get_page_size().physical(),
block->page.zip.data, block->zip_size(),
m_current_lsn);
}
@@ -2904,10 +2913,7 @@ row_import_read_v1(
cfg->m_flags = mach_read_from_4(ptr);
ptr += sizeof(ib_uint32_t);
cfg->m_page_size.copy_from(dict_tf_get_page_size(cfg->m_flags));
ut_a(logical_page_size == cfg->m_page_size.logical());
cfg->m_zip_size = dict_tf_get_zip_size(cfg->m_flags);
cfg->m_n_cols = mach_read_from_4(ptr);
if (!dict_tf_is_valid(cfg->m_flags)) {
@@ -3265,7 +3271,7 @@ fil_iterate(
AbstractCallback& callback)
{
os_offset_t offset;
const ulint size = callback.get_page_size().physical();
const ulint size = callback.physical_size();
ulint n_bytes = iter.n_io_buffers * size;
const ulint buf_size = srv_page_size
@@ -3390,13 +3396,13 @@ not_encrypted:
}
} else {
if (!fil_space_verify_crypt_checksum(
src, callback.get_page_size())) {
src, callback.get_zip_size())) {
goto page_corrupted;
}
decrypted = fil_space_decrypt(
iter.crypt_data, dst,
callback.get_page_size(), src, &err);
callback.physical_size(), src, &err);
if (err != DB_SUCCESS) {
goto func_exit;
@@ -3423,7 +3429,7 @@ not_encrypted:
false,
encrypted && !frame_changed
? dst : src,
callback.get_page_size(), NULL)) {
callback.get_zip_size(), NULL)) {
goto page_corrupted;
}
@@ -3500,7 +3506,7 @@ not_encrypted:
block->page.id.space(),
block->page.id.page_no(),
mach_read_from_8(src + FIL_PAGE_LSN),
src, callback.get_page_size(), dest);
src, block->zip_size(), dest);
if (tmp == src) {
/* TODO: remove unnecessary memcpy's */
@@ -3625,10 +3631,8 @@ fil_tablespace_iterate(
if (err == DB_SUCCESS) {
block->page.id = page_id_t(callback.get_space_id(), 0);
block->page.size.copy_from(callback.get_page_size());
if (block->page.size.is_compressed()) {
page_zip_set_size(&block->page.zip,
callback.get_page_size().physical());
if (ulint zip_size = callback.get_zip_size()) {
page_zip_set_size(&block->page.zip, zip_size);
/* ROW_FORMAT=COMPRESSED is not optimised for block IO
for now. We do the IMPORT page by page. */
n_io_buffers = 1;
@@ -3638,7 +3642,7 @@ fil_tablespace_iterate(
/* read (optional) crypt data */
iter.crypt_data = fil_space_read_crypt_data(
callback.get_page_size(), page);
callback.get_zip_size(), page);
/* If tablespace is encrypted, it needs extra buffers */
if (iter.crypt_data && n_io_buffers > 1) {
@@ -3819,12 +3823,12 @@ row_import_for_mysql(
ut_a(err == DB_FAIL);
cfg.m_page_size.copy_from(univ_page_size);
cfg.m_zip_size = 0;
FetchIndexRootPages fetchIndexRootPages(table, trx);
err = fil_tablespace_iterate(
table, IO_BUFFER_SIZE(cfg.m_page_size.physical()),
table, IO_BUFFER_SIZE(srv_page_size),
fetchIndexRootPages);
if (err == DB_SUCCESS) {
@@ -3862,7 +3866,8 @@ row_import_for_mysql(
/* Set the IO buffer size in pages. */
err = fil_tablespace_iterate(
table, IO_BUFFER_SIZE(cfg.m_page_size.physical()), converter);
table, IO_BUFFER_SIZE(cfg.m_zip_size ? cfg.m_zip_size
: srv_page_size), converter);
DBUG_EXECUTE_IF("ib_import_reset_space_and_lsn_failure",
err = DB_TOO_MANY_CONCURRENT_TRXS;);

View File

@@ -1139,7 +1139,7 @@ ALTER TABLE)
table
@param[in] offsets rec_get_offsets(rec)
@param[in] i rec field corresponding to col
@param[in] page_size page size of the old table
@param[in] zip_size ROW_FORMAT=COMPRESSED size of the old table
@param[in] max_len maximum length of dfield
@param[in] log row log for the table
@retval DB_INVALID_NULL if a NULL value is encountered
@@ -1153,7 +1153,7 @@ row_log_table_get_pk_col(
const rec_t* rec,
const ulint* offsets,
ulint i,
const page_size_t& page_size,
ulint zip_size,
ulint max_len,
const row_log_t* log)
{
@@ -1192,7 +1192,7 @@ row_log_table_get_pk_col(
mem_heap_alloc(heap, field_len));
len = btr_copy_externally_stored_field_prefix(
blob_field, field_len, page_size, field, len);
blob_field, field_len, zip_size, field, len);
if (len >= max_len + 1) {
return(DB_TOO_BIG_INDEX_COL);
}
@@ -1307,8 +1307,7 @@ row_log_table_get_pk(
const ulint max_len = DICT_MAX_FIELD_LEN_BY_FORMAT(new_table);
const page_size_t& page_size
= dict_table_page_size(index->table);
const ulint zip_size = index->table->space->zip_size();
for (ulint new_i = 0; new_i < new_n_uniq; new_i++) {
dict_field_t* ifield;
@@ -1335,7 +1334,8 @@ row_log_table_get_pk(
log->error = row_log_table_get_pk_col(
ifield, dfield, *heap,
rec, offsets, i, page_size, max_len, log);
rec, offsets, i, zip_size, max_len,
log);
if (log->error != DB_SUCCESS) {
err_exit:
@@ -1602,7 +1602,7 @@ row_log_table_apply_convert_mrec(
data = btr_rec_copy_externally_stored_field(
mrec, offsets,
dict_table_page_size(index->table),
index->table->space->zip_size(),
i, &len, heap);
ut_a(data);
dfield_set_data(dfield, data, len);
@@ -2676,8 +2676,8 @@ ulint
row_log_progress_inc_per_block()
{
/* We must increment the progress once per page (as in
univ_page_size, usually 16KiB). One block here is srv_sort_buf_size
(usually 1MiB). */
srv_page_size, default = innodb_page_size=16KiB).
One block here is srv_sort_buf_size (usually 1MiB). */
const ulint pages_per_block = std::max<ulint>(
ulint(srv_sort_buf_size >> srv_page_size_shift), 1);

View File

@@ -442,7 +442,7 @@ row_merge_buf_redundant_convert(
const dfield_t* row_field,
dfield_t* field,
ulint len,
const page_size_t& page_size,
ulint zip_size,
mem_heap_t* heap)
{
ut_ad(field->type.mbminlen == 1);
@@ -462,7 +462,7 @@ row_merge_buf_redundant_convert(
field_ref_zero, BTR_EXTERN_FIELD_REF_SIZE));
byte* data = btr_copy_externally_stored_field(
&ext_len, field_data, page_size, field_len, heap);
&ext_len, field_data, zip_size, field_len, heap);
ut_ad(ext_len < len);
@@ -704,7 +704,7 @@ row_merge_buf_add(
if (conv_heap != NULL) {
row_merge_buf_redundant_convert(
row_field, field, col->len,
dict_table_page_size(old_table),
old_table->space->zip_size(),
conv_heap);
} else {
/* Field length mismatch should not
@@ -2036,7 +2036,7 @@ end_of_index:
block = btr_block_get(
page_id_t(block->page.id.space(),
next_page_no),
block->page.size,
block->zip_size(),
BTR_SEARCH_LEAF,
clust_index, &mtr);
@@ -3424,7 +3424,7 @@ void
row_merge_copy_blobs(
const mrec_t* mrec,
const ulint* offsets,
const page_size_t& page_size,
ulint zip_size,
dtuple_t* tuple,
mem_heap_t* heap)
{
@@ -3462,10 +3462,10 @@ row_merge_copy_blobs(
BTR_EXTERN_FIELD_REF_SIZE));
data = btr_copy_externally_stored_field(
&len, field_data, page_size, field_len, heap);
&len, field_data, zip_size, field_len, heap);
} else {
data = btr_rec_copy_externally_stored_field(
mrec, offsets, page_size, i, &len, heap);
mrec, offsets, zip_size, i, &len, heap);
}
/* Because we have locked the table, any records
@@ -3663,8 +3663,7 @@ row_merge_insert_index_tuples(
row_log_table_blob_alloc() and
row_log_table_blob_free(). */
row_merge_copy_blobs(
mrec, offsets,
dict_table_page_size(old_table),
mrec, offsets, old_table->space->zip_size(),
dtuple, tuple_heap);
}

View File

@@ -3361,8 +3361,7 @@ row_drop_table_for_mysql(
for (dict_index_t* index = dict_table_get_first_index(table);
index != NULL;
index = dict_table_get_next_index(index)) {
btr_free(page_id_t(SRV_TMP_SPACE_ID, index->page),
univ_page_size);
btr_free(page_id_t(SRV_TMP_SPACE_ID, index->page));
}
/* Remove the pointer to this table object from the list
of modified tables by the transaction because the object

View File

@@ -992,7 +992,7 @@ skip_secondaries:
block = buf_page_get(
page_id_t(rseg->space->id, page_no),
univ_page_size, RW_X_LATCH, &mtr);
0, RW_X_LATCH, &mtr);
buf_block_dbg_add_level(block, SYNC_TRX_UNDO_PAGE);

View File

@@ -151,7 +151,7 @@ static bool row_build_spatial_index_key(
temp_heap = mem_heap_create(1000);
dptr = btr_copy_externally_stored_field(
&dlen, dptr, ext ? ext->page_size : page_size_t(space->flags),
&dlen, dptr, ext ? ext->zip_size : space->zip_size(),
flen, temp_heap);
write_mbr:
@@ -593,7 +593,7 @@ row_build_low(
row_log_table_delete(). */
} else if (j) {
*ext = row_ext_create(j, ext_cols, index->table->flags, row,
*ext = row_ext_create(j, ext_cols, *index->table, row,
heap);
} else {
*ext = NULL;

View File

@@ -2,7 +2,7 @@
Copyright (c) 1997, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
Copyright (c) 2015, 2018, MariaDB Corporation.
Copyright (c) 2015, 2019, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
@@ -127,7 +127,7 @@ row_sel_sec_rec_is_for_blob(
}
len = btr_copy_externally_stored_field_prefix(
buf, prefix_len, page_size_t(table->space->flags),
buf, prefix_len, table->space->zip_size(),
clust_field, clust_len);
if (len == 0) {
@@ -308,8 +308,7 @@ row_sel_sec_rec_is_for_clust_rec(
if (rec_offs_nth_extern(clust_offs, clust_pos)) {
dptr = btr_copy_externally_stored_field(
&clust_len, dptr,
page_size_t(clust_index->table->space
->flags),
clust_index->table->space->zip_size(),
len, heap);
}
@@ -532,7 +531,7 @@ row_sel_fetch_columns(
data = btr_rec_copy_externally_stored_field(
rec, offsets,
dict_table_page_size(index->table),
index->table->space->zip_size(),
field_no, &len, heap);
/* data == NULL means that the
@@ -1135,7 +1134,7 @@ re_scan:
cur_block = buf_page_get_gen(
page_id_t(index->table->space_id, page_no),
page_size_t(index->table->space->flags),
index->table->space->zip_size(),
RW_X_LATCH, NULL, BUF_GET,
__FILE__, __LINE__, mtr, &err);
} else {
@@ -2933,8 +2932,7 @@ row_sel_store_mysql_field(
causes an assert */
data = btr_rec_copy_externally_stored_field(
rec, offsets,
dict_table_page_size(prebuilt->table),
rec, offsets, prebuilt->table->space->zip_size(),
field_no, &len, heap);
if (UNIV_UNLIKELY(!data)) {
@@ -3308,7 +3306,7 @@ row_sel_get_clust_rec_for_mysql(
and is it not unsafe to use RW_NO_LATCH here? */
buf_block_t* block = buf_page_get_gen(
btr_pcur_get_block(prebuilt->pcur)->page.id,
btr_pcur_get_block(prebuilt->pcur)->page.size,
btr_pcur_get_block(prebuilt->pcur)->zip_size(),
RW_NO_LATCH, NULL, BUF_GET,
__FILE__, __LINE__, mtr, &err);
mem_heap_t* heap = mem_heap_create(256);

View File

@@ -1131,7 +1131,7 @@ of the column and must not be poisoned with the new values.
@param[in] data 'internally' stored part of the field
containing also the reference to the external part
@param[in] local_len length of data, in bytes
@param[in] page_size BLOB page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in,out] len input - length of prefix to
fetch; output: fetched length of the prefix
@param[in,out] heap heap where to allocate
@@ -1141,14 +1141,14 @@ byte*
row_upd_ext_fetch(
const byte* data,
ulint local_len,
const page_size_t& page_size,
ulint zip_size,
ulint* len,
mem_heap_t* heap)
{
byte* buf = static_cast<byte*>(mem_heap_alloc(heap, *len));
*len = btr_copy_externally_stored_field_prefix(
buf, *len, page_size, data, local_len);
buf, *len, zip_size, data, local_len);
/* We should never update records containing a half-deleted BLOB. */
ut_a(*len);
@@ -1164,7 +1164,7 @@ the given index entry field.
@param[in] uf update field
@param[in,out] heap memory heap for allocating and copying
the new value
@param[in] page_size page size */
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0 */
static
void
row_upd_index_replace_new_col_val(
@@ -1173,7 +1173,7 @@ row_upd_index_replace_new_col_val(
const dict_col_t* col,
const upd_field_t* uf,
mem_heap_t* heap,
const page_size_t& page_size)
ulint zip_size)
{
ulint len;
const byte* data;
@@ -1197,7 +1197,7 @@ row_upd_index_replace_new_col_val(
len = field->prefix_len;
data = row_upd_ext_fetch(data, l, page_size,
data = row_upd_ext_fetch(data, l, zip_size,
&len, heap);
}
@@ -1270,7 +1270,7 @@ row_upd_index_replace_metadata(
ut_ad(update->is_alter_metadata());
ut_ad(entry->info_bits == update->info_bits);
ut_ad(entry->n_fields == ulint(index->n_fields) + 1);
const page_size_t& page_size = dict_table_page_size(index->table);
const ulint zip_size = index->table->space->zip_size();
const ulint first = index->first_user_field();
ut_d(bool found_mblob = false);
@@ -1298,7 +1298,7 @@ row_upd_index_replace_metadata(
f -= f > first;
const dict_field_t* field = dict_index_get_nth_field(index, f);
row_upd_index_replace_new_col_val(dfield, field, field->col,
uf, heap, page_size);
uf, heap, zip_size);
}
ut_ad(found_mblob);
@@ -1326,7 +1326,7 @@ row_upd_index_replace_new_col_vals_index_pos(
return;
}
const page_size_t& page_size = dict_table_page_size(index->table);
const ulint zip_size = index->table->space->zip_size();
dtuple_set_info_bits(entry, update->info_bits);
@@ -1352,7 +1352,7 @@ row_upd_index_replace_new_col_vals_index_pos(
if (uf) {
row_upd_index_replace_new_col_val(
dtuple_get_nth_field(entry, i),
field, col, uf, heap, page_size);
field, col, uf, heap, zip_size);
}
}
}
@@ -1378,7 +1378,7 @@ row_upd_index_replace_new_col_vals(
ulint i;
const dict_index_t* clust_index
= dict_table_get_first_index(index->table);
const page_size_t& page_size = dict_table_page_size(index->table);
const ulint zip_size = index->table->space->zip_size();
ut_ad(!index->table->skip_alter_undo);
@@ -1408,7 +1408,7 @@ row_upd_index_replace_new_col_vals(
if (uf) {
row_upd_index_replace_new_col_val(
dtuple_get_nth_field(entry, i),
field, col, uf, heap, page_size);
field, col, uf, heap, zip_size);
}
}
}
@@ -1632,8 +1632,7 @@ row_upd_replace(
}
if (n_ext_cols) {
*ext = row_ext_create(n_ext_cols, ext_cols, table->flags, row,
heap);
*ext = row_ext_create(n_ext_cols, ext_cols, *table, row, heap);
} else {
*ext = NULL;
}
@@ -1741,11 +1740,9 @@ row_upd_changes_ord_field_binary_func(
mem_heap_t* temp_heap = NULL;
const dfield_t* new_field = &upd_field->new_val;
const page_size_t page_size
= (ext != NULL)
? ext->page_size
: dict_table_page_size(
index->table);
const ulint zip_size = ext
? ext->zip_size
: index->table->space->zip_size();
ut_ad(dfield->data != NULL
&& dfield->len > GEO_DATA_HEADER_SIZE);
@@ -1762,7 +1759,7 @@ row_upd_changes_ord_field_binary_func(
dptr = btr_copy_externally_stored_field(
&dlen, dptr,
page_size,
zip_size,
flen,
temp_heap);
} else {
@@ -1825,7 +1822,7 @@ row_upd_changes_ord_field_binary_func(
dptr = btr_copy_externally_stored_field(
&dlen, dptr,
page_size,
zip_size,
flen,
temp_heap);
} else {

View File

@@ -194,8 +194,6 @@ ulong srv_page_size_shift;
/** innodb_log_write_ahead_size */
ulong srv_log_write_ahead_size;
page_size_t univ_page_size(0, 0, false);
/** innodb_adaptive_flushing; try to flush dirty pages so as to avoid
IO bursts at the checkpoints. */
my_bool srv_adaptive_flushing;

View File

@@ -1887,7 +1887,7 @@ files_checked:
/* New data file(s) were added */
mtr.start();
buf_block_t* block = buf_page_get(
page_id_t(0, 0), univ_page_size,
page_id_t(0, 0), 0,
RW_SX_LATCH, &mtr);
ulint size = mach_read_from_4(
FSP_HEADER_OFFSET + FSP_SIZE
@@ -1911,8 +1911,7 @@ files_checked:
#ifdef UNIV_DEBUG
{
mtr.start();
buf_block_t* block = buf_page_get(page_id_t(0, 0),
univ_page_size,
buf_block_t* block = buf_page_get(page_id_t(0, 0), 0,
RW_S_LATCH, &mtr);
ut_ad(mach_read_from_4(FSP_SIZE + FSP_HEADER_OFFSET
+ block->frame)
@@ -2075,24 +2074,24 @@ files_checked:
block = buf_page_get(
page_id_t(IBUF_SPACE_ID,
FSP_IBUF_HEADER_PAGE_NO),
univ_page_size, RW_X_LATCH, &mtr);
0, RW_X_LATCH, &mtr);
fil_block_check_type(*block, FIL_PAGE_TYPE_SYS, &mtr);
/* Already MySQL 3.23.53 initialized
FSP_IBUF_TREE_ROOT_PAGE_NO to
FIL_PAGE_INDEX. No need to reset that one. */
block = buf_page_get(
page_id_t(TRX_SYS_SPACE, TRX_SYS_PAGE_NO),
univ_page_size, RW_X_LATCH, &mtr);
0, RW_X_LATCH, &mtr);
fil_block_check_type(*block, FIL_PAGE_TYPE_TRX_SYS,
&mtr);
block = buf_page_get(
page_id_t(TRX_SYS_SPACE,
FSP_FIRST_RSEG_PAGE_NO),
univ_page_size, RW_X_LATCH, &mtr);
0, RW_X_LATCH, &mtr);
fil_block_check_type(*block, FIL_PAGE_TYPE_SYS, &mtr);
block = buf_page_get(
page_id_t(TRX_SYS_SPACE, FSP_DICT_HDR_PAGE_NO),
univ_page_size, RW_X_LATCH, &mtr);
0, RW_X_LATCH, &mtr);
fil_block_check_type(*block, FIL_PAGE_TYPE_SYS, &mtr);
mtr.commit();
}

View File

@@ -718,7 +718,7 @@ trx_undo_rec_skip_row_ref(
log of an update or delete marking of a clustered index record.
@param[out] ext_buf buffer to hold the prefix data and BLOB pointer
@param[in] prefix_len prefix size to store in the undo log
@param[in] page_size page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] field an externally stored column
@param[in,out] len input: length of field; output: used length of
ext_buf
@@ -728,13 +728,13 @@ byte*
trx_undo_page_fetch_ext(
byte* ext_buf,
ulint prefix_len,
const page_size_t& page_size,
ulint zip_size,
const byte* field,
ulint* len)
{
/* Fetch the BLOB. */
ulint ext_len = btr_copy_externally_stored_field_prefix(
ext_buf, prefix_len, page_size, field, *len);
ext_buf, prefix_len, zip_size, field, *len);
/* BLOBs should always be nonempty. */
ut_a(ext_len);
/* Append the BLOB pointer to the prefix. */
@@ -752,7 +752,7 @@ available
size, or NULL when should not fetch a longer
prefix
@param[in] prefix_len prefix size to store in the undo log
@param[in] page_size page size
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in,out] field the locally stored part of the externally
stored column
@param[in,out] len length of field, in bytes
@@ -765,7 +765,7 @@ trx_undo_page_report_modify_ext(
byte* ptr,
byte* ext_buf,
ulint prefix_len,
const page_size_t& page_size,
ulint zip_size,
const byte** field,
ulint* len,
spatial_status_t spatial_status)
@@ -807,7 +807,7 @@ trx_undo_page_report_modify_ext(
ptr += mach_write_compressed(ptr, *len);
*field = trx_undo_page_fetch_ext(ext_buf, prefix_len,
page_size, *field, len);
zip_size, *field, len);
ptr += mach_write_compressed(ptr, *len + spatial_len);
} else {
@@ -820,7 +820,7 @@ trx_undo_page_report_modify_ext(
/** Get MBR from a Geometry column stored externally
@param[out] mbr MBR to fill
@param[in] pagesize table pagesize
@param[in] zip_size ROW_FORMAT=COMPRESSED page size, or 0
@param[in] field field contain the geometry data
@param[in,out] len length of field, in bytes
*/
@@ -828,17 +828,17 @@ static
void
trx_undo_get_mbr_from_ext(
/*======================*/
double* mbr,
const page_size_t& page_size,
const byte* field,
ulint* len)
double* mbr,
ulint zip_size,
const byte* field,
ulint* len)
{
uchar* dptr = NULL;
ulint dlen;
mem_heap_t* heap = mem_heap_create(100);
dptr = btr_copy_externally_stored_field(
&dlen, field, page_size, *len, heap);
&dlen, field, zip_size, *len, heap);
if (dlen <= GEO_DATA_HEADER_SIZE) {
for (uint i = 0; i < SPDIMS; ++i) {
@@ -1181,7 +1181,7 @@ write_field:
&& !ignore_prefix
&& flen < REC_ANTELOPE_MAX_INDEX_COL_LEN
? ext_buf : NULL, prefix_len,
dict_table_page_size(table),
table->space->zip_size(),
&field, &flen, SPATIAL_UNKNOWN);
*type_cmpl_ptr |= TRX_UNDO_UPD_EXTERN;
@@ -1335,8 +1335,8 @@ store_len:
table, col);
ut_a(prefix_len < sizeof ext_buf);
const page_size_t& page_size
= dict_table_page_size(table);
const ulint zip_size
= table->space->zip_size();
/* If there is a spatial index on it,
log its MBR */
@@ -1345,7 +1345,7 @@ store_len:
col->mtype));
trx_undo_get_mbr_from_ext(
mbr, page_size,
mbr, zip_size,
field, &flen);
}
@@ -1354,7 +1354,7 @@ store_len:
flen < REC_ANTELOPE_MAX_INDEX_COL_LEN
&& !ignore_prefix
? ext_buf : NULL, prefix_len,
page_size,
zip_size,
&field, &flen,
spatial_status);
} else {

View File

@@ -187,7 +187,7 @@ trx_undo_get_prev_rec_from_prev_page(
space = page_get_space_id(undo_page);
buf_block_t* block = buf_page_get(
page_id_t(space, prev_page_no), univ_page_size,
page_id_t(space, prev_page_no), 0,
shared ? RW_S_LATCH : RW_X_LATCH, mtr);
buf_block_dbg_add_level(block, SYNC_TRX_UNDO_PAGE);
@@ -1340,7 +1340,7 @@ trx_undo_reuse_cached(trx_t* trx, trx_rseg_t* rseg, trx_undo_t** pundo,
buf_block_t* block = buf_page_get(page_id_t(undo->rseg->space->id,
undo->hdr_page_no),
univ_page_size, RW_X_LATCH, mtr);
0, RW_X_LATCH, mtr);
if (!block) {
return NULL;
}
@@ -1399,7 +1399,7 @@ trx_undo_assign(trx_t* trx, dberr_t* err, mtr_t* mtr)
if (undo) {
return buf_page_get_gen(
page_id_t(undo->rseg->space->id, undo->last_page_no),
univ_page_size, RW_X_LATCH,
0, RW_X_LATCH,
buf_pool_is_obsolete(undo->withdraw_clock)
? NULL : undo->guess_block,
BUF_GET, __FILE__, __LINE__, mtr, err);
@@ -1455,7 +1455,7 @@ trx_undo_assign_low(trx_t* trx, trx_rseg_t* rseg, trx_undo_t** undo,
if (*undo) {
return buf_page_get_gen(
page_id_t(rseg->space->id, (*undo)->last_page_no),
univ_page_size, RW_X_LATCH,
0, RW_X_LATCH,
buf_pool_is_obsolete((*undo)->withdraw_clock)
? NULL : (*undo)->guess_block,
BUF_GET, __FILE__, __LINE__, mtr, err);