Commit 0072d2e9 authored by Sergei Golubchik's avatar Sergei Golubchik

InnoDB cleanup: remove a bunch of #ifdef UNIV_INNOCHECKSUM

innochecksum uses global variables. great, let's use them all the
way down, instead of passing them as arguments to innodb internals,
conditionally modifying function prototypes with #ifdefs
parent 7a29ca27
...@@ -571,7 +571,6 @@ is_page_corrupted( ...@@ -571,7 +571,6 @@ is_page_corrupted(
if (mach_read_from_4(buf+FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION) != 0) { if (mach_read_from_4(buf+FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION) != 0) {
is_corrupted = fil_space_verify_crypt_checksum( is_corrupted = fil_space_verify_crypt_checksum(
const_cast<byte*>(buf), page_size, const_cast<byte*>(buf), page_size,
strict_verify, is_log_enabled ? log_file : NULL,
mach_read_from_4(buf mach_read_from_4(buf
+ FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID), + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID),
cur_page_num); cur_page_num);
...@@ -581,9 +580,7 @@ is_page_corrupted( ...@@ -581,9 +580,7 @@ is_page_corrupted(
if (is_corrupted) { if (is_corrupted) {
is_corrupted = buf_page_is_corrupted( is_corrupted = buf_page_is_corrupted(
true, buf, page_size, NULL, true, buf, page_size, NULL);
cur_page_num, strict_verify,
is_log_enabled, log_file);
} }
return(is_corrupted); return(is_corrupted);
......
This diff is collapsed.
...@@ -2492,10 +2492,6 @@ bool ...@@ -2492,10 +2492,6 @@ bool
fil_space_verify_crypt_checksum( fil_space_verify_crypt_checksum(
byte* page, byte* page,
const page_size_t& page_size, const page_size_t& page_size,
#ifdef UNIV_INNOCHECKSUM
bool strict_check, /*!< --strict-check */
FILE* log_file, /*!< --log */
#endif /* UNIV_INNOCHECKSUM */
ulint space, ulint space,
ulint offset) ulint offset)
{ {
...@@ -2541,14 +2537,7 @@ fil_space_verify_crypt_checksum( ...@@ -2541,14 +2537,7 @@ fil_space_verify_crypt_checksum(
mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM, checksum); mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM, checksum);
bool valid = page_zip_verify_checksum(page, bool valid = page_zip_verify_checksum(page,
page_size.physical() page_size.physical());
#ifdef UNIV_INNOCHECKSUM
, offset,
strict_check,
log_file != NULL,
log_file
#endif
);
mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM, old); mach_write_to_4(page + FIL_PAGE_SPACE_OR_CHKSUM, old);
...@@ -2594,19 +2583,11 @@ fil_space_verify_crypt_checksum( ...@@ -2594,19 +2583,11 @@ fil_space_verify_crypt_checksum(
ulint checksum2 = mach_read_from_4( ulint checksum2 = mach_read_from_4(
page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM); page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM);
#ifdef UNIV_INNOCHECKSUM
# define CKARGS page, checksum1, checksum2, \
offset, log_file != NULL, log_file, algorithm
#else
# define CKARGS page, checksum1, checksum2
#endif
bool valid = buf_page_is_checksum_valid_crc32( bool valid = buf_page_is_checksum_valid_crc32(
CKARGS, false page, checksum1, checksum2, false
/* FIXME: also try the original crc32 that was /* FIXME: also try the original crc32 that was
buggy on big-endian architectures? */) buggy on big-endian architectures? */)
|| buf_page_is_checksum_valid_innodb(CKARGS); || buf_page_is_checksum_valid_innodb(page, checksum1, checksum2);
#undef CKARGS
if (encrypted && valid) { if (encrypted && valid) {
/* If page is encrypted and traditional checksums match, /* If page is encrypted and traditional checksums match,
......
...@@ -769,10 +769,6 @@ buf_block_unfix( ...@@ -769,10 +769,6 @@ buf_block_unfix(
@param[in] read_buf database page @param[in] read_buf database page
@param[in] checksum_field1 new checksum field @param[in] checksum_field1 new checksum field
@param[in] checksum_field2 old checksum field @param[in] checksum_field2 old checksum field
@param[in] page_no page number of given read_buf
@param[in] is_log_enabled true if log option is enabled
@param[in] log_file file pointer to log_file
@param[in] curr_algo current checksum algorithm
@param[in] use_legacy_big_endian use legacy big endian algorithm @param[in] use_legacy_big_endian use legacy big endian algorithm
@return true if the page is in crc32 checksum format. */ @return true if the page is in crc32 checksum format. */
bool bool
...@@ -780,12 +776,6 @@ buf_page_is_checksum_valid_crc32( ...@@ -780,12 +776,6 @@ buf_page_is_checksum_valid_crc32(
const byte* read_buf, const byte* read_buf,
ulint checksum_field1, ulint checksum_field1,
ulint checksum_field2, ulint checksum_field2,
#ifdef UNIV_INNOCHECKSUM
uintmax_t page_no,
bool is_log_enabled,
FILE* log_file,
const srv_checksum_algorithm_t curr_algo,
#endif /* UNIV_INNOCHECKSUM */
bool use_legacy_big_endian) bool use_legacy_big_endian)
MY_ATTRIBUTE((nonnull(1), warn_unused_result)); MY_ATTRIBUTE((nonnull(1), warn_unused_result));
...@@ -793,46 +783,24 @@ buf_page_is_checksum_valid_crc32( ...@@ -793,46 +783,24 @@ buf_page_is_checksum_valid_crc32(
@param[in] read_buf database page @param[in] read_buf database page
@param[in] checksum_field1 new checksum field @param[in] checksum_field1 new checksum field
@param[in] checksum_field2 old checksum field @param[in] checksum_field2 old checksum field
@param[in] page_no page number of given read_buf
@param[in] is_log_enabled true if log option is enabled
@param[in] log_file file pointer to log_file
@param[in] curr_algo current checksum algorithm
@return true if the page is in innodb checksum format. */ @return true if the page is in innodb checksum format. */
bool bool
buf_page_is_checksum_valid_innodb( buf_page_is_checksum_valid_innodb(
const byte* read_buf, const byte* read_buf,
ulint checksum_field1, ulint checksum_field1,
ulint checksum_field2 ulint checksum_field2)
#ifdef UNIV_INNOCHECKSUM
,uintmax_t page_no,
bool is_log_enabled,
FILE* log_file,
const srv_checksum_algorithm_t curr_algo
#endif /* UNIV_INNOCHECKSUM */
)
MY_ATTRIBUTE((nonnull(1), warn_unused_result)); MY_ATTRIBUTE((nonnull(1), warn_unused_result));
/** Checks if the page is in none checksum format. /** Checks if the page is in none checksum format.
@param[in] read_buf database page @param[in] read_buf database page
@param[in] checksum_field1 new checksum field @param[in] checksum_field1 new checksum field
@param[in] checksum_field2 old checksum field @param[in] checksum_field2 old checksum field
@param[in] page_no page number of given read_buf
@param[in] is_log_enabled true if log option is enabled
@param[in] log_file file pointer to log_file
@param[in] curr_algo current checksum algorithm
@return true if the page is in none checksum format. */ @return true if the page is in none checksum format. */
bool bool
buf_page_is_checksum_valid_none( buf_page_is_checksum_valid_none(
const byte* read_buf, const byte* read_buf,
ulint checksum_field1, ulint checksum_field1,
ulint checksum_field2 ulint checksum_field2)
#ifdef UNIV_INNOCHECKSUM
,uintmax_t page_no,
bool is_log_enabled,
FILE* log_file,
const srv_checksum_algorithm_t curr_algo
#endif /* UNIV_INNOCHECKSUM */
)
MY_ATTRIBUTE((nonnull(1), warn_unused_result)); MY_ATTRIBUTE((nonnull(1), warn_unused_result));
/** Checks if a page contains only zeroes. /** Checks if a page contains only zeroes.
...@@ -850,10 +818,6 @@ the LSN ...@@ -850,10 +818,6 @@ the LSN
@param[in] read_buf database page @param[in] read_buf database page
@param[in] page_size page size @param[in] page_size page size
@param[in] space tablespace @param[in] space tablespace
@param[in] page_no page number of given read_buf
@param[in] strict_check true if strict-check option is enabled
@param[in] is_log_enabled true if log option is enabled
@param[in] log_file file pointer to log_file
@return whether the page is corrupted */ @return whether the page is corrupted */
bool bool
buf_page_is_corrupted( buf_page_is_corrupted(
...@@ -861,12 +825,6 @@ buf_page_is_corrupted( ...@@ -861,12 +825,6 @@ buf_page_is_corrupted(
const byte* read_buf, const byte* read_buf,
const page_size_t& page_size, const page_size_t& page_size,
const fil_space_t* space = NULL const fil_space_t* space = NULL
#ifdef UNIV_INNOCHECKSUM
,uintmax_t page_no = 0,
bool strict_check = false,
bool is_log_enabled = false,
FILE* log_file = NULL
#endif /* UNIV_INNOCHECKSUM */
) MY_ATTRIBUTE((warn_unused_result)); ) MY_ATTRIBUTE((warn_unused_result));
#ifndef UNIV_INNOCHECKSUM #ifndef UNIV_INNOCHECKSUM
/**********************************************************************//** /**********************************************************************//**
......
...@@ -492,10 +492,6 @@ bool ...@@ -492,10 +492,6 @@ bool
fil_space_verify_crypt_checksum( fil_space_verify_crypt_checksum(
byte* page, byte* page,
const page_size_t& page_size, const page_size_t& page_size,
#ifdef UNIV_INNOCHECKSUM
bool strict_check, /*!< --strict-check */
FILE* log_file, /*!< --log */
#endif /* UNIV_INNOCHECKSUM */
ulint space, ulint space,
ulint offset) ulint offset)
MY_ATTRIBUTE((warn_unused_result)); MY_ATTRIBUTE((warn_unused_result));
......
...@@ -512,19 +512,7 @@ ibool ...@@ -512,19 +512,7 @@ ibool
page_zip_verify_checksum( page_zip_verify_checksum(
/*=====================*/ /*=====================*/
const void* data, /*!< in: compressed page */ const void* data, /*!< in: compressed page */
ulint size /*!< in: size of compressed page */ ulint size); /*!< in: size of compressed page */
#ifdef UNIV_INNOCHECKSUM
/* these variables are used only for innochecksum tool. */
,uintmax_t page_no, /*!< in: page number of
given read_buf */
bool strict_check, /*!< in: true if strict-check
option is enable */
bool is_log_enabled, /*!< in: true if log option is
enable */
FILE* log_file /*!< in: file pointer to
log_file */
#endif /* UNIV_INNOCHECKSUM */
);
#ifndef UNIV_INNOCHECKSUM #ifndef UNIV_INNOCHECKSUM
/**********************************************************************//** /**********************************************************************//**
......
...@@ -108,6 +108,12 @@ support cross-platform development and expose comonly used SQL names. */ ...@@ -108,6 +108,12 @@ support cross-platform development and expose comonly used SQL names. */
#include <unistd.h> #include <unistd.h>
#endif #endif
#ifdef UNIV_INNOCHECKSUM
extern bool strict_verify;
extern FILE* log_file;
extern uintmax_t cur_page_num;
#endif /* UNIV_INNOCHECKSUM */
#include "my_pthread.h" #include "my_pthread.h"
/* Following defines are to enable performance schema /* Following defines are to enable performance schema
instrumentation in each of five InnoDB modules if instrumentation in each of five InnoDB modules if
......
...@@ -4973,19 +4973,7 @@ ibool ...@@ -4973,19 +4973,7 @@ ibool
page_zip_verify_checksum( page_zip_verify_checksum(
/*=====================*/ /*=====================*/
const void* data, /*!< in: compressed page */ const void* data, /*!< in: compressed page */
ulint size /*!< in: size of compressed page */ ulint size) /*!< in: size of compressed page */
#ifdef UNIV_INNOCHECKSUM
/* these variables are used only for innochecksum tool. */
,uintmax_t page_no, /*!< in: page number of
given read_buf */
bool strict_check, /*!< in: true if strict-check
option is enable */
bool is_log_enabled, /*!< in: true if log option is
enabled */
FILE* log_file /*!< in: file pointer to
log_file */
#endif /* UNIV_INNOCHECKSUM */
)
{ {
const unsigned char* p = static_cast<const unsigned char*>(data) const unsigned char* p = static_cast<const unsigned char*>(data)
+ FIL_PAGE_SPACE_OR_CHKSUM; + FIL_PAGE_SPACE_OR_CHKSUM;
...@@ -5023,9 +5011,9 @@ page_zip_verify_checksum( ...@@ -5023,9 +5011,9 @@ page_zip_verify_checksum(
break; break;
} }
if (i >= size) { if (i >= size) {
if (is_log_enabled) { if (log_file) {
fprintf(log_file, "Page::%lu is empty and" fprintf(log_file, "Page::%lu is empty and"
" uncorrupted\n", page_no); " uncorrupted\n", cur_page_num);
} }
return(TRUE); return(TRUE);
...@@ -5061,28 +5049,28 @@ page_zip_verify_checksum( ...@@ -5061,28 +5049,28 @@ page_zip_verify_checksum(
const uint32_t calc = page_zip_calc_checksum(data, size, curr_algo); const uint32_t calc = page_zip_calc_checksum(data, size, curr_algo);
#ifdef UNIV_INNOCHECKSUM #ifdef UNIV_INNOCHECKSUM
if (is_log_enabled) { if (log_file) {
fprintf(log_file, "page::%lu;" fprintf(log_file, "page::%lu;"
" %s checksum: calculated = %u;" " %s checksum: calculated = %u;"
" recorded = %u\n", page_no, " recorded = %u\n", cur_page_num,
buf_checksum_algorithm_name( buf_checksum_algorithm_name(
static_cast<srv_checksum_algorithm_t>( static_cast<srv_checksum_algorithm_t>(
srv_checksum_algorithm)), srv_checksum_algorithm)),
calc, stored); calc, stored);
} }
if (!strict_check) { if (!strict_verify) {
const uint32_t crc32 = page_zip_calc_checksum( const uint32_t crc32 = page_zip_calc_checksum(
data, size, SRV_CHECKSUM_ALGORITHM_CRC32); data, size, SRV_CHECKSUM_ALGORITHM_CRC32);
if (is_log_enabled) { if (log_file) {
fprintf(log_file, "page::%lu: crc32 checksum:" fprintf(log_file, "page::%lu: crc32 checksum:"
" calculated = %u; recorded = %u\n", " calculated = %u; recorded = %u\n",
page_no, crc32, stored); cur_page_num, crc32, stored);
fprintf(log_file, "page::%lu: none checksum:" fprintf(log_file, "page::%lu: none checksum:"
" calculated = %lu; recorded = %u\n", " calculated = %lu; recorded = %u\n",
page_no, BUF_NO_CHECKSUM_MAGIC, stored); cur_page_num, BUF_NO_CHECKSUM_MAGIC, stored);
} }
} }
#endif /* UNIV_INNOCHECKSUM */ #endif /* UNIV_INNOCHECKSUM */
......
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