Commit febe8819 authored by Marko Mäkelä's avatar Marko Mäkelä

Make some variables const in fil_iterate()

This is a non-functional change to make it slightly easier
to read the code. We seem to have some bugs in this
IMPORT TABLESPACE code; see MDEV-12396.
parent 408ef65f
...@@ -6583,15 +6583,15 @@ fil_iterate( ...@@ -6583,15 +6583,15 @@ fil_iterate(
/* TODO: For compressed tables we do a lot of useless /* TODO: For compressed tables we do a lot of useless
copying for non-index pages. Unfortunately, it is copying for non-index pages. Unfortunately, it is
required by buf_zip_decompress() */ required by buf_zip_decompress() */
const bool row_compressed = callback.get_zip_size() > 0;
for (offset = iter.start; offset < iter.end; offset += n_bytes) { for (offset = iter.start; offset < iter.end; offset += n_bytes) {
byte* io_buffer = iter.io_buffer; byte* io_buffer = iter.io_buffer;
bool row_compressed = false;
block->frame = io_buffer; block->frame = io_buffer;
if (callback.get_zip_size() > 0) { if (row_compressed) {
page_zip_des_init(&block->page.zip); page_zip_des_init(&block->page.zip);
page_zip_set_size(&block->page.zip, iter.page_size); page_zip_set_size(&block->page.zip, iter.page_size);
block->page.zip.data = block->frame + UNIV_PAGE_SIZE; block->page.zip.data = block->frame + UNIV_PAGE_SIZE;
...@@ -6600,9 +6600,6 @@ fil_iterate( ...@@ -6600,9 +6600,6 @@ fil_iterate(
/* Zip IO is done in the compressed page buffer. */ /* Zip IO is done in the compressed page buffer. */
io_buffer = block->page.zip.data; io_buffer = block->page.zip.data;
row_compressed = true;
} else {
io_buffer = iter.io_buffer;
} }
/* We have to read the exact number of bytes. Otherwise the /* We have to read the exact number of bytes. Otherwise the
...@@ -6615,16 +6612,12 @@ fil_iterate( ...@@ -6615,16 +6612,12 @@ fil_iterate(
ut_ad(n_bytes > 0); ut_ad(n_bytes > 0);
ut_ad(!(n_bytes % iter.page_size)); ut_ad(!(n_bytes % iter.page_size));
byte* readptr = io_buffer; const bool encrypted = iter.crypt_data != NULL
byte* writeptr = io_buffer; && iter.crypt_data->should_encrypt();
bool encrypted = false;
/* Use additional crypt io buffer if tablespace is encrypted */ /* Use additional crypt io buffer if tablespace is encrypted */
if (iter.crypt_data != NULL && iter.crypt_data->should_encrypt()) { byte* const readptr = encrypted
encrypted = true; ? iter.crypt_io_buffer : io_buffer;
readptr = iter.crypt_io_buffer; byte* const writeptr = readptr;
writeptr = iter.crypt_io_buffer;
}
if (!os_file_read(iter.file, readptr, offset, (ulint) n_bytes)) { if (!os_file_read(iter.file, readptr, offset, (ulint) n_bytes)) {
...@@ -6647,8 +6640,9 @@ fil_iterate( ...@@ -6647,8 +6640,9 @@ fil_iterate(
ulint page_type = mach_read_from_2(src+FIL_PAGE_TYPE); ulint page_type = mach_read_from_2(src+FIL_PAGE_TYPE);
bool page_compressed = (page_type == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED || const bool page_compressed
page_type == FIL_PAGE_PAGE_COMPRESSED); = page_type == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED
|| page_type == FIL_PAGE_PAGE_COMPRESSED;
/* If tablespace is encrypted, we need to decrypt /* If tablespace is encrypted, we need to decrypt
the page. Note that tablespaces are not in the page. Note that tablespaces are not in
......
...@@ -6929,15 +6929,15 @@ fil_iterate( ...@@ -6929,15 +6929,15 @@ fil_iterate(
/* TODO: For compressed tables we do a lot of useless /* TODO: For compressed tables we do a lot of useless
copying for non-index pages. Unfortunately, it is copying for non-index pages. Unfortunately, it is
required by buf_zip_decompress() */ required by buf_zip_decompress() */
const bool row_compressed = callback.get_zip_size() > 0;
for (offset = iter.start; offset < iter.end; offset += n_bytes) { for (offset = iter.start; offset < iter.end; offset += n_bytes) {
byte* io_buffer = iter.io_buffer; byte* io_buffer = iter.io_buffer;
bool row_compressed = false;
block->frame = io_buffer; block->frame = io_buffer;
if (callback.get_zip_size() > 0) { if (row_compressed) {
page_zip_des_init(&block->page.zip); page_zip_des_init(&block->page.zip);
page_zip_set_size(&block->page.zip, iter.page_size); page_zip_set_size(&block->page.zip, iter.page_size);
block->page.zip.data = block->frame + UNIV_PAGE_SIZE; block->page.zip.data = block->frame + UNIV_PAGE_SIZE;
...@@ -6946,9 +6946,6 @@ fil_iterate( ...@@ -6946,9 +6946,6 @@ fil_iterate(
/* Zip IO is done in the compressed page buffer. */ /* Zip IO is done in the compressed page buffer. */
io_buffer = block->page.zip.data; io_buffer = block->page.zip.data;
row_compressed = true;
} else {
io_buffer = iter.io_buffer;
} }
/* We have to read the exact number of bytes. Otherwise the /* We have to read the exact number of bytes. Otherwise the
...@@ -6961,16 +6958,12 @@ fil_iterate( ...@@ -6961,16 +6958,12 @@ fil_iterate(
ut_ad(n_bytes > 0); ut_ad(n_bytes > 0);
ut_ad(!(n_bytes % iter.page_size)); ut_ad(!(n_bytes % iter.page_size));
byte* readptr = io_buffer; const bool encrypted = iter.crypt_data != NULL
byte* writeptr = io_buffer; && iter.crypt_data->should_encrypt();
bool encrypted = false;
/* Use additional crypt io buffer if tablespace is encrypted */ /* Use additional crypt io buffer if tablespace is encrypted */
if (iter.crypt_data != NULL && iter.crypt_data->should_encrypt()) { byte* const readptr = encrypted
encrypted = true; ? iter.crypt_io_buffer : io_buffer;
readptr = iter.crypt_io_buffer; byte* const writeptr = readptr;
writeptr = iter.crypt_io_buffer;
}
if (!os_file_read(iter.file, readptr, offset, (ulint) n_bytes)) { if (!os_file_read(iter.file, readptr, offset, (ulint) n_bytes)) {
...@@ -6993,8 +6986,9 @@ fil_iterate( ...@@ -6993,8 +6986,9 @@ fil_iterate(
ulint page_type = mach_read_from_2(src+FIL_PAGE_TYPE); ulint page_type = mach_read_from_2(src+FIL_PAGE_TYPE);
bool page_compressed = (page_type == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED || const bool page_compressed
page_type == FIL_PAGE_PAGE_COMPRESSED); = page_type == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED
|| page_type == FIL_PAGE_PAGE_COMPRESSED;
/* If tablespace is encrypted, we need to decrypt /* If tablespace is encrypted, we need to decrypt
the page. Note that tablespaces are not in the page. Note that tablespaces are not in
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment