1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Merge 10.0 into 10.1

Also, apply the MDEV-17957 changes to encrypted page checksums,
and remove error message output from the checksum function,
because these messages would be useless noise when mariabackup
is retrying reads of corrupted-looking pages, and not that
useful during normal server operation either.

The error messages in fil_space_verify_crypt_checksum()
should be refactored separately.
This commit is contained in:
Marko Mäkelä
2018-12-13 13:37:21 +02:00
19 changed files with 348 additions and 904 deletions

View File

@ -6547,8 +6547,6 @@ static inline bool is_escape_char(char c, char in_string)
SYNOPSIS
read_line
buf buffer for the read line
size size of the buffer i.e max size to read
DESCRIPTION
This function actually reads several lines and adds them to the
@ -6566,10 +6564,15 @@ static inline bool is_escape_char(char c, char in_string)
*/
int read_line(char *buf, int size)
static char *read_command_buf= NULL;
static size_t read_command_buflen= 0;
static const size_t max_multibyte_length= 6;
int read_line()
{
char c, last_quote=0, last_char= 0;
char *p= buf, *buf_end= buf + size - 1;
char *p= read_command_buf;
char *buf_end= read_command_buf + read_command_buflen - max_multibyte_length;
int skip_char= 0;
my_bool have_slash= FALSE;
@ -6577,10 +6580,21 @@ int read_line(char *buf, int size)
R_COMMENT, R_LINE_START} state= R_LINE_START;
DBUG_ENTER("read_line");
*p= 0;
start_lineno= cur_file->lineno;
DBUG_PRINT("info", ("Starting to read at lineno: %d", start_lineno));
for (; p < buf_end ;)
while (1)
{
if (p >= buf_end)
{
my_ptrdiff_t off= p - read_command_buf;
read_command_buf= (char*)my_realloc(read_command_buf,
read_command_buflen*2, MYF(MY_FAE));
p= read_command_buf + off;
read_command_buflen*= 2;
buf_end= read_command_buf + read_command_buflen - max_multibyte_length;
}
skip_char= 0;
c= my_getc(cur_file->file);
if (feof(cur_file->file))
@ -6616,7 +6630,7 @@ int read_line(char *buf, int size)
cur_file->lineno++;
/* Convert cr/lf to lf */
if (p != buf && *(p-1) == '\r')
if (p != read_command_buf && *(p-1) == '\r')
p--;
}
@ -6631,9 +6645,9 @@ int read_line(char *buf, int size)
}
else if ((c == '{' &&
(!my_strnncoll_simple(charset_info, (const uchar*) "while", 5,
(uchar*) buf, MY_MIN(5, p - buf), 0) ||
(uchar*) read_command_buf, MY_MIN(5, p - read_command_buf), 0) ||
!my_strnncoll_simple(charset_info, (const uchar*) "if", 2,
(uchar*) buf, MY_MIN(2, p - buf), 0))))
(uchar*) read_command_buf, MY_MIN(2, p - read_command_buf), 0))))
{
/* Only if and while commands can be terminated by { */
*p++= c;
@ -6767,8 +6781,6 @@ int read_line(char *buf, int size)
*p++= c;
}
}
die("The input buffer is too small for this query.x\n" \
"check your query or increase MAX_QUERY and recompile");
DBUG_RETURN(0);
}
@ -6913,12 +6925,8 @@ bool is_delimiter(const char* p)
terminated by new line '\n' regardless how many "delimiter" it contain.
*/
#define MAX_QUERY (256*1024*2) /* 256K -- a test in sp-big is >128K */
static char read_command_buf[MAX_QUERY];
int read_command(struct st_command** command_ptr)
{
char *p= read_command_buf;
struct st_command* command;
DBUG_ENTER("read_command");
@ -6934,8 +6942,7 @@ int read_command(struct st_command** command_ptr)
die("Out of memory");
command->type= Q_UNKNOWN;
read_command_buf[0]= 0;
if (read_line(read_command_buf, sizeof(read_command_buf)))
if (read_line())
{
check_eol_junk(read_command_buf);
DBUG_RETURN(1);
@ -6944,6 +6951,7 @@ int read_command(struct st_command** command_ptr)
if (opt_result_format_version == 1)
convert_to_format_v1(read_command_buf);
char *p= read_command_buf;
DBUG_PRINT("info", ("query: '%s'", read_command_buf));
if (*p == '#')
{
@ -9095,6 +9103,8 @@ int main(int argc, char **argv)
init_win_path_patterns();
#endif
read_command_buf= (char*)my_malloc(read_command_buflen= 65536, MYF(MY_FAE));
init_dynamic_string(&ds_res, "", 2048, 2048);
init_alloc_root(&require_file_root, 1024, 1024, MYF(0));

View File

@ -1082,7 +1082,7 @@ typedef ulong myf; /* Type of MyFlags in my_funcs */
static inline char *dlerror(void)
{
static char win_errormsg[2048];
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM,
0, GetLastError(), 0, win_errormsg, 2048, NULL);
return win_errormsg;
}

View File

@ -59,31 +59,6 @@ tpe_crc32.cfg
tpe_crc32.frm
tpe_crc32.ibd
UNLOCK TABLES;
SET GLOBAL innodb_checksum_algorithm=strict_crc32;
ALTER TABLE tce_crc32 DISCARD TABLESPACE;
ALTER TABLE tc_crc32 DISCARD TABLESPACE;
ALTER TABLE te_crc32 DISCARD TABLESPACE;
ALTER TABLE t_crc32 DISCARD TABLESPACE;
ALTER TABLE tpe_crc32 DISCARD TABLESPACE;
ALTER TABLE tp_crc32 DISCARD TABLESPACE;
restore: tce_crc32 .ibd and .cfg files
restore: tc_crc32 .ibd and .cfg files
restore: te_crc32 .ibd and .cfg files
restore: t_crc32 .ibd and .cfg files
restore: tpe_crc32 .ibd and .cfg files
restore: tp_crc32 .ibd and .cfg files
ALTER TABLE tce_crc32 IMPORT TABLESPACE;
update tce_crc32 set b=substr(b,1);
ALTER TABLE tc_crc32 IMPORT TABLESPACE;
update tc_crc32 set b=substr(b,1);
ALTER TABLE te_crc32 IMPORT TABLESPACE;
update te_crc32 set b=substr(b,1);
ALTER TABLE t_crc32 IMPORT TABLESPACE;
update t_crc32 set b=substr(b,1);
ALTER TABLE tpe_crc32 IMPORT TABLESPACE;
update tpe_crc32 set b=substr(b,1);
ALTER TABLE tp_crc32 IMPORT TABLESPACE;
update tp_crc32 set b=substr(b,1);
SET GLOBAL innodb_checksum_algorithm=crc32;
ALTER TABLE tce_crc32 DISCARD TABLESPACE;
ALTER TABLE tc_crc32 DISCARD TABLESPACE;
@ -109,31 +84,6 @@ ALTER TABLE tpe_crc32 IMPORT TABLESPACE;
update tpe_crc32 set b=substr(b,1);
ALTER TABLE tp_crc32 IMPORT TABLESPACE;
update tp_crc32 set b=substr(b,1);
SET GLOBAL innodb_checksum_algorithm=strict_innodb;
ALTER TABLE tce_crc32 DISCARD TABLESPACE;
ALTER TABLE tc_crc32 DISCARD TABLESPACE;
ALTER TABLE te_crc32 DISCARD TABLESPACE;
ALTER TABLE t_crc32 DISCARD TABLESPACE;
ALTER TABLE tpe_crc32 DISCARD TABLESPACE;
ALTER TABLE tp_crc32 DISCARD TABLESPACE;
restore: tce_crc32 .ibd and .cfg files
restore: tc_crc32 .ibd and .cfg files
restore: te_crc32 .ibd and .cfg files
restore: t_crc32 .ibd and .cfg files
restore: tpe_crc32 .ibd and .cfg files
restore: tp_crc32 .ibd and .cfg files
ALTER TABLE tce_crc32 IMPORT TABLESPACE;
update tce_crc32 set b=substr(b,1);
ALTER TABLE tc_crc32 IMPORT TABLESPACE;
update tc_crc32 set b=substr(b,1);
ALTER TABLE te_crc32 IMPORT TABLESPACE;
update te_crc32 set b=substr(b,1);
ALTER TABLE t_crc32 IMPORT TABLESPACE;
update t_crc32 set b=substr(b,1);
ALTER TABLE tpe_crc32 IMPORT TABLESPACE;
update tpe_crc32 set b=substr(b,1);
ALTER TABLE tp_crc32 IMPORT TABLESPACE;
update tp_crc32 set b=substr(b,1);
SET GLOBAL innodb_checksum_algorithm=innodb;
ALTER TABLE tce_crc32 DISCARD TABLESPACE;
ALTER TABLE tc_crc32 DISCARD TABLESPACE;
@ -159,31 +109,6 @@ ALTER TABLE tpe_crc32 IMPORT TABLESPACE;
update tpe_crc32 set b=substr(b,1);
ALTER TABLE tp_crc32 IMPORT TABLESPACE;
update tp_crc32 set b=substr(b,1);
SET GLOBAL innodb_checksum_algorithm=strict_none;
ALTER TABLE tce_crc32 DISCARD TABLESPACE;
ALTER TABLE tc_crc32 DISCARD TABLESPACE;
ALTER TABLE te_crc32 DISCARD TABLESPACE;
ALTER TABLE t_crc32 DISCARD TABLESPACE;
ALTER TABLE tpe_crc32 DISCARD TABLESPACE;
ALTER TABLE tp_crc32 DISCARD TABLESPACE;
restore: tce_crc32 .ibd and .cfg files
restore: tc_crc32 .ibd and .cfg files
restore: te_crc32 .ibd and .cfg files
restore: t_crc32 .ibd and .cfg files
restore: tpe_crc32 .ibd and .cfg files
restore: tp_crc32 .ibd and .cfg files
ALTER TABLE tce_crc32 IMPORT TABLESPACE;
update tce_crc32 set b=substr(b,1);
ALTER TABLE tc_crc32 IMPORT TABLESPACE;
update tc_crc32 set b=substr(b,1);
ALTER TABLE te_crc32 IMPORT TABLESPACE;
update te_crc32 set b=substr(b,1);
ALTER TABLE t_crc32 IMPORT TABLESPACE;
update t_crc32 set b=substr(b,1);
ALTER TABLE tpe_crc32 IMPORT TABLESPACE;
update tpe_crc32 set b=substr(b,1);
ALTER TABLE tp_crc32 IMPORT TABLESPACE;
update tp_crc32 set b=substr(b,1);
SET GLOBAL innodb_checksum_algorithm=none;
ALTER TABLE tce_crc32 DISCARD TABLESPACE;
ALTER TABLE tc_crc32 DISCARD TABLESPACE;
@ -268,31 +193,6 @@ tpe_innodb.cfg
tpe_innodb.frm
tpe_innodb.ibd
UNLOCK TABLES;
SET GLOBAL innodb_checksum_algorithm=strict_crc32;
ALTER TABLE tce_innodb DISCARD TABLESPACE;
ALTER TABLE tc_innodb DISCARD TABLESPACE;
ALTER TABLE te_innodb DISCARD TABLESPACE;
ALTER TABLE t_innodb DISCARD TABLESPACE;
ALTER TABLE tpe_innodb DISCARD TABLESPACE;
ALTER TABLE tp_innodb DISCARD TABLESPACE;
restore: tce_innodb .ibd and .cfg files
restore: tc_innodb .ibd and .cfg files
restore: te_innodb .ibd and .cfg files
restore: t_innodb .ibd and .cfg files
restore: tpe_innodb .ibd and .cfg files
restore: tp_innodb .ibd and .cfg files
ALTER TABLE tce_innodb IMPORT TABLESPACE;
update tce_innodb set b=substr(b,1);
ALTER TABLE tc_innodb IMPORT TABLESPACE;
update tc_innodb set b=substr(b,1);
ALTER TABLE te_innodb IMPORT TABLESPACE;
update te_innodb set b=substr(b,1);
ALTER TABLE t_innodb IMPORT TABLESPACE;
update t_innodb set b=substr(b,1);
ALTER TABLE tpe_innodb IMPORT TABLESPACE;
update tpe_innodb set b=substr(b,1);
ALTER TABLE tp_innodb IMPORT TABLESPACE;
update tp_innodb set b=substr(b,1);
SET GLOBAL innodb_checksum_algorithm=crc32;
ALTER TABLE tce_innodb DISCARD TABLESPACE;
ALTER TABLE tc_innodb DISCARD TABLESPACE;
@ -318,31 +218,6 @@ ALTER TABLE tpe_innodb IMPORT TABLESPACE;
update tpe_innodb set b=substr(b,1);
ALTER TABLE tp_innodb IMPORT TABLESPACE;
update tp_innodb set b=substr(b,1);
SET GLOBAL innodb_checksum_algorithm=strict_innodb;
ALTER TABLE tce_innodb DISCARD TABLESPACE;
ALTER TABLE tc_innodb DISCARD TABLESPACE;
ALTER TABLE te_innodb DISCARD TABLESPACE;
ALTER TABLE t_innodb DISCARD TABLESPACE;
ALTER TABLE tpe_innodb DISCARD TABLESPACE;
ALTER TABLE tp_innodb DISCARD TABLESPACE;
restore: tce_innodb .ibd and .cfg files
restore: tc_innodb .ibd and .cfg files
restore: te_innodb .ibd and .cfg files
restore: t_innodb .ibd and .cfg files
restore: tpe_innodb .ibd and .cfg files
restore: tp_innodb .ibd and .cfg files
ALTER TABLE tce_innodb IMPORT TABLESPACE;
update tce_innodb set b=substr(b,1);
ALTER TABLE tc_innodb IMPORT TABLESPACE;
update tc_innodb set b=substr(b,1);
ALTER TABLE te_innodb IMPORT TABLESPACE;
update te_innodb set b=substr(b,1);
ALTER TABLE t_innodb IMPORT TABLESPACE;
update t_innodb set b=substr(b,1);
ALTER TABLE tpe_innodb IMPORT TABLESPACE;
update tpe_innodb set b=substr(b,1);
ALTER TABLE tp_innodb IMPORT TABLESPACE;
update tp_innodb set b=substr(b,1);
SET GLOBAL innodb_checksum_algorithm=innodb;
ALTER TABLE tce_innodb DISCARD TABLESPACE;
ALTER TABLE tc_innodb DISCARD TABLESPACE;
@ -368,31 +243,6 @@ ALTER TABLE tpe_innodb IMPORT TABLESPACE;
update tpe_innodb set b=substr(b,1);
ALTER TABLE tp_innodb IMPORT TABLESPACE;
update tp_innodb set b=substr(b,1);
SET GLOBAL innodb_checksum_algorithm=strict_none;
ALTER TABLE tce_innodb DISCARD TABLESPACE;
ALTER TABLE tc_innodb DISCARD TABLESPACE;
ALTER TABLE te_innodb DISCARD TABLESPACE;
ALTER TABLE t_innodb DISCARD TABLESPACE;
ALTER TABLE tpe_innodb DISCARD TABLESPACE;
ALTER TABLE tp_innodb DISCARD TABLESPACE;
restore: tce_innodb .ibd and .cfg files
restore: tc_innodb .ibd and .cfg files
restore: te_innodb .ibd and .cfg files
restore: t_innodb .ibd and .cfg files
restore: tpe_innodb .ibd and .cfg files
restore: tp_innodb .ibd and .cfg files
ALTER TABLE tce_innodb IMPORT TABLESPACE;
update tce_innodb set b=substr(b,1);
ALTER TABLE tc_innodb IMPORT TABLESPACE;
update tc_innodb set b=substr(b,1);
ALTER TABLE te_innodb IMPORT TABLESPACE;
update te_innodb set b=substr(b,1);
ALTER TABLE t_innodb IMPORT TABLESPACE;
update t_innodb set b=substr(b,1);
ALTER TABLE tpe_innodb IMPORT TABLESPACE;
update tpe_innodb set b=substr(b,1);
ALTER TABLE tp_innodb IMPORT TABLESPACE;
update tp_innodb set b=substr(b,1);
SET GLOBAL innodb_checksum_algorithm=none;
ALTER TABLE tce_innodb DISCARD TABLESPACE;
ALTER TABLE tc_innodb DISCARD TABLESPACE;
@ -477,31 +327,6 @@ tpe_none.cfg
tpe_none.frm
tpe_none.ibd
UNLOCK TABLES;
SET GLOBAL innodb_checksum_algorithm=strict_crc32;
ALTER TABLE tce_none DISCARD TABLESPACE;
ALTER TABLE tc_none DISCARD TABLESPACE;
ALTER TABLE te_none DISCARD TABLESPACE;
ALTER TABLE t_none DISCARD TABLESPACE;
ALTER TABLE tpe_none DISCARD TABLESPACE;
ALTER TABLE tp_none DISCARD TABLESPACE;
restore: tce_none .ibd and .cfg files
restore: tc_none .ibd and .cfg files
restore: te_none .ibd and .cfg files
restore: t_none .ibd and .cfg files
restore: tpe_none .ibd and .cfg files
restore: tp_none .ibd and .cfg files
ALTER TABLE tce_none IMPORT TABLESPACE;
update tce_none set b=substr(b,1);
ALTER TABLE tc_none IMPORT TABLESPACE;
update tc_none set b=substr(b,1);
ALTER TABLE te_none IMPORT TABLESPACE;
update te_none set b=substr(b,1);
ALTER TABLE t_none IMPORT TABLESPACE;
update t_none set b=substr(b,1);
ALTER TABLE tpe_none IMPORT TABLESPACE;
update tpe_none set b=substr(b,1);
ALTER TABLE tp_none IMPORT TABLESPACE;
update tp_none set b=substr(b,1);
SET GLOBAL innodb_checksum_algorithm=crc32;
ALTER TABLE tce_none DISCARD TABLESPACE;
ALTER TABLE tc_none DISCARD TABLESPACE;
@ -527,31 +352,6 @@ ALTER TABLE tpe_none IMPORT TABLESPACE;
update tpe_none set b=substr(b,1);
ALTER TABLE tp_none IMPORT TABLESPACE;
update tp_none set b=substr(b,1);
SET GLOBAL innodb_checksum_algorithm=strict_innodb;
ALTER TABLE tce_none DISCARD TABLESPACE;
ALTER TABLE tc_none DISCARD TABLESPACE;
ALTER TABLE te_none DISCARD TABLESPACE;
ALTER TABLE t_none DISCARD TABLESPACE;
ALTER TABLE tpe_none DISCARD TABLESPACE;
ALTER TABLE tp_none DISCARD TABLESPACE;
restore: tce_none .ibd and .cfg files
restore: tc_none .ibd and .cfg files
restore: te_none .ibd and .cfg files
restore: t_none .ibd and .cfg files
restore: tpe_none .ibd and .cfg files
restore: tp_none .ibd and .cfg files
ALTER TABLE tce_none IMPORT TABLESPACE;
update tce_none set b=substr(b,1);
ALTER TABLE tc_none IMPORT TABLESPACE;
update tc_none set b=substr(b,1);
ALTER TABLE te_none IMPORT TABLESPACE;
update te_none set b=substr(b,1);
ALTER TABLE t_none IMPORT TABLESPACE;
update t_none set b=substr(b,1);
ALTER TABLE tpe_none IMPORT TABLESPACE;
update tpe_none set b=substr(b,1);
ALTER TABLE tp_none IMPORT TABLESPACE;
update tp_none set b=substr(b,1);
SET GLOBAL innodb_checksum_algorithm=innodb;
ALTER TABLE tce_none DISCARD TABLESPACE;
ALTER TABLE tc_none DISCARD TABLESPACE;
@ -577,31 +377,6 @@ ALTER TABLE tpe_none IMPORT TABLESPACE;
update tpe_none set b=substr(b,1);
ALTER TABLE tp_none IMPORT TABLESPACE;
update tp_none set b=substr(b,1);
SET GLOBAL innodb_checksum_algorithm=strict_none;
ALTER TABLE tce_none DISCARD TABLESPACE;
ALTER TABLE tc_none DISCARD TABLESPACE;
ALTER TABLE te_none DISCARD TABLESPACE;
ALTER TABLE t_none DISCARD TABLESPACE;
ALTER TABLE tpe_none DISCARD TABLESPACE;
ALTER TABLE tp_none DISCARD TABLESPACE;
restore: tce_none .ibd and .cfg files
restore: tc_none .ibd and .cfg files
restore: te_none .ibd and .cfg files
restore: t_none .ibd and .cfg files
restore: tpe_none .ibd and .cfg files
restore: tp_none .ibd and .cfg files
ALTER TABLE tce_none IMPORT TABLESPACE;
update tce_none set b=substr(b,1);
ALTER TABLE tc_none IMPORT TABLESPACE;
update tc_none set b=substr(b,1);
ALTER TABLE te_none IMPORT TABLESPACE;
update te_none set b=substr(b,1);
ALTER TABLE t_none IMPORT TABLESPACE;
update t_none set b=substr(b,1);
ALTER TABLE tpe_none IMPORT TABLESPACE;
update tpe_none set b=substr(b,1);
ALTER TABLE tp_none IMPORT TABLESPACE;
update tp_none set b=substr(b,1);
SET GLOBAL innodb_checksum_algorithm=none;
ALTER TABLE tce_none DISCARD TABLESPACE;
ALTER TABLE tc_none DISCARD TABLESPACE;

View File

@ -67,17 +67,14 @@ EOF
--list_files $MYSQLD_DATADIR/test
UNLOCK TABLES;
let $to = 6;
let $to = 3;
while ($to)
{
dec $to;
let $tocksum = `select case $to
when 0 then 'none'
when 1 then 'strict_none'
when 2 then 'innodb'
when 3 then 'strict_innodb'
when 4 then 'crc32'
when 5 then 'strict_crc32'
when 1 then 'innodb'
when 2 then 'crc32'
end`;
eval SET GLOBAL innodb_checksum_algorithm=$tocksum;

View File

@ -1,4 +1,4 @@
--skip-innodb-doublewrite
--innodb-file-per-table
--innodb-file-format=Barracuda
--innodb_checksum_algorithm=crc32

View File

@ -79,18 +79,22 @@ let SEARCH_PATTERN= Error: --strict-check option cannot be used together with --
--echo [9]: check the innochecksum with full form --strict-check=innodb
# Server Default checksum = crc32
--error 1
--exec $INNOCHECKSUM --strict-check=innodb $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE
--echo [10]: check the innochecksum with full form --strict-check=none
--echo # when server Default checksum=crc32
--error 1
--exec $INNOCHECKSUM --strict-check=none $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE
--echo [11]: check the innochecksum with short form -C innodb
--echo # when server Default checksum=crc32
--error 1
--exec $INNOCHECKSUM -C innodb $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE
--echo [12]: check the innochecksum with short form -C none
--echo # when server Default checksum=crc32
--error 1
--exec $INNOCHECKSUM -C none $MYSQLD_DATADIR/test/tab1.ibd 2> $SEARCH_FILE
--echo [13]: check strict-check with invalid values

View File

@ -1119,6 +1119,7 @@ sub GetData()
}
}
print " Replication ";
print "Master:$data->{Master_Host} ";
print "IO:$data->{Slave_IO_Running} ";
print "SQL:$data->{Slave_SQL_Running} ";
print RESET() if ($HAS_COLOR);

View File

@ -3734,10 +3734,10 @@ void set_statistics_for_table(THD *thd, TABLE *table)
Ideally, EITS should provide per-partition statistics but this is not
implemented currently.
*/
#ifdef WITH_PARTITION_STORAGE_ENGINE
#ifdef WITH_PARTITION_STORAGE_ENGINE
if (table->part_info)
table->used_stat_records= table->file->stats.records;
#endif
#endif
KEY *key_info, *key_info_end;
for (key_info= table->key_info, key_info_end= key_info+table->s->keys;
@ -4064,10 +4064,6 @@ bool is_stat_table(const char *db, const char *table)
bool is_eits_usable(Field *field)
{
partition_info *part_info= NULL;
#ifdef WITH_PARTITION_STORAGE_ENGINE
part_info= field->table->part_info;
#endif
/*
(1): checks if we have EITS statistics for a particular column
(2): Don't use EITS for GEOMETRY columns
@ -4076,9 +4072,11 @@ bool is_eits_usable(Field *field)
such columns would be handled during partition pruning.
*/
Column_statistics* col_stats= field->read_stats;
if (col_stats && !col_stats->no_stat_values_provided() && //(1)
field->type() != MYSQL_TYPE_GEOMETRY && //(2)
(!part_info || !part_info->field_in_partition_expr(field))) //(3)
return TRUE;
return FALSE;
return col_stats && !col_stats->no_stat_values_provided() && //(1)
field->type() != MYSQL_TYPE_GEOMETRY && //(2)
#ifdef WITH_PARTITION_STORAGE_ENGINE
(!field->table->part_info ||
!field->table->part_info->field_in_partition_expr(field)) && //(3)
#endif
true;
}

View File

@ -865,16 +865,16 @@ buf_page_is_corrupted(
DBUG_EXECUTE_IF("buf_page_import_corrupt_failure", return(TRUE); );
ulint checksum_field1 = 0;
ulint checksum_field2 = 0;
#ifndef UNIV_INNOCHECKSUM
ulint space_id = mach_read_from_4(read_buf + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
#endif
bool crc32_inited = false;
ib_uint32_t crc32 = ULINT32_UNDEFINED;
ulint page_type = mach_read_from_2(read_buf + FIL_PAGE_TYPE);
/* We can trust page type if page compression is set on tablespace
flags because page compression flag means file must have been
created with 10.1 (later than 5.5 code base). In 10.1 page
compressed tables do not contain post compression checksum and
FIL_PAGE_END_LSN_OLD_CHKSUM field stored. Note that space can
FIL_PAGE_END_LSN_OLD_CHKSUM field stored. Note that space can
be null if we are in fil_check_first_page() and first page
is not compressed or encrypted. Page checksum is verified
after decompression (i.e. normally pages are already
@ -895,12 +895,6 @@ buf_page_is_corrupted(
/* Stored log sequence numbers at the start and the end
of page do not match */
#ifndef UNIV_INNOCHECKSUM
ib_logf(IB_LOG_LEVEL_INFO,
"Log sequence number at the start " ULINTPF " and the end " ULINTPF " do not match.",
mach_read_from_4(read_buf + FIL_PAGE_LSN + 4),
mach_read_from_4(read_buf + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM + 4));
#endif /* UNIV_INNOCHECKSUM */
return(true);
}
@ -945,7 +939,7 @@ buf_page_is_corrupted(
}
if (zip_size) {
return(!page_zip_verify_checksum((const void *)read_buf, zip_size));
return(!page_zip_verify_checksum(read_buf, zip_size));
}
checksum_field1 = mach_read_from_4(
@ -965,10 +959,6 @@ buf_page_is_corrupted(
/* make sure that the page is really empty */
for (ulint i = 0; i < UNIV_PAGE_SIZE; i++) {
if (read_buf[i] != 0) {
#ifndef UNIV_INNOCHECKSUM
ib_logf(IB_LOG_LEVEL_INFO,
"Checksum fields zero but page is not empty.");
#endif
return(true);
}
}
@ -976,191 +966,130 @@ buf_page_is_corrupted(
return(false);
}
#ifndef UNIV_INNOCHECKSUM
ulint page_no = mach_read_from_4(read_buf + FIL_PAGE_OFFSET);
#endif
const srv_checksum_algorithm_t curr_algo =
static_cast<srv_checksum_algorithm_t>(srv_checksum_algorithm);
switch (curr_algo) {
case SRV_CHECKSUM_ALGORITHM_CRC32:
case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32:
return !buf_page_is_checksum_valid_crc32(
read_buf, checksum_field1, checksum_field2);
if (buf_page_is_checksum_valid_crc32(read_buf,
checksum_field1, checksum_field2)) {
return(false);
}
if (buf_page_is_checksum_valid_none(read_buf,
checksum_field1, checksum_field2)) {
if (curr_algo
== SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) {
#ifndef UNIV_INNOCHECKSUM
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_NONE,
space_id, page_no);
#endif /* !UNIV_INNOCHECKSUM */
}
#ifdef UNIV_INNOCHECKSUM
if (log_file) {
fprintf(log_file, "page::%llu;"
" old style: calculated = " ULINTPF ";"
" recorded = " ULINTPF "\n",
cur_page_num,
buf_calc_page_old_checksum(read_buf),
checksum_field2);
fprintf(log_file, "page::%llu;"
" new style: calculated = " ULINTPF ";"
" crc32 = %u; recorded = " ULINTPF "\n",
cur_page_num,
buf_calc_page_new_checksum(read_buf),
buf_calc_page_crc32(read_buf),
checksum_field1);
}
#endif /* UNIV_INNOCHECKSUM */
return(false);
}
if (buf_page_is_checksum_valid_innodb(read_buf,
checksum_field1, checksum_field2)) {
if (curr_algo
== SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) {
#ifndef UNIV_INNOCHECKSUM
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_INNODB,
space_id, page_no);
#endif
}
return(false);
}
#ifdef UNIV_INNOCHECKSUM
if (log_file) {
fprintf(log_file, "Fail; page::%llu;"
" invalid (fails crc32 checksum)\n",
cur_page_num);
}
#endif /* UNIV_INNOCHECKSUM */
return(true);
case SRV_CHECKSUM_ALGORITHM_INNODB:
case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB:
if (buf_page_is_checksum_valid_innodb(read_buf,
checksum_field1, checksum_field2)) {
return(false);
}
if (buf_page_is_checksum_valid_none(read_buf,
checksum_field1, checksum_field2)) {
if (curr_algo
== SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) {
#ifndef UNIV_INNOCHECKSUM
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_NONE,
space_id, page_no);
#endif
}
#ifdef UNIV_INNOCHECKSUM
if (log_file) {
fprintf(log_file, "page::%llu;"
" old style: calculated = " ULINTPF ";"
" recorded = " ULINTPF "\n", cur_page_num,
buf_calc_page_old_checksum(read_buf),
checksum_field2);
fprintf(log_file, "page::%llu;"
" new style: calculated = " ULINTPF ";"
" crc32 = %u; recorded = " ULINTPF "\n",
cur_page_num,
buf_calc_page_new_checksum(read_buf),
buf_calc_page_crc32(read_buf),
checksum_field1);
}
#endif /* UNIV_INNOCHECKSUM */
return(false);
}
if (buf_page_is_checksum_valid_crc32(read_buf,
checksum_field1, checksum_field2)) {
if (curr_algo
== SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) {
#ifndef UNIV_INNOCHECKSUM
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_CRC32,
space_id, page_no);
#endif
}
return(false);
}
#ifdef UNIV_INNOCHECKSUM
if (log_file) {
fprintf(log_file, "Fail; page::%llu;"
" invalid (fails innodb checksum)\n",
cur_page_num);
}
#endif /* UNIV_INNOCHECKSUM */
return(true);
return !buf_page_is_checksum_valid_innodb(
read_buf, checksum_field1, checksum_field2);
case SRV_CHECKSUM_ALGORITHM_STRICT_NONE:
return !buf_page_is_checksum_valid_none(
read_buf, checksum_field1, checksum_field2);
case SRV_CHECKSUM_ALGORITHM_CRC32:
case SRV_CHECKSUM_ALGORITHM_INNODB:
/* Very old versions of InnoDB only stored 8 byte lsn to the
start and the end of the page. */
if (buf_page_is_checksum_valid_none(read_buf,
checksum_field1, checksum_field2)) {
return(false);
/* Since innodb_checksum_algorithm is not strict_* allow
any of the algos to match for the old field */
if (checksum_field2
!= mach_read_from_4(read_buf + FIL_PAGE_LSN)
&& checksum_field2 != BUF_NO_CHECKSUM_MAGIC) {
/* The checksum does not match any of the
fast to check. First check the selected algorithm
for writing checksums because we assume that the
chance of it matching is higher. */
if (srv_checksum_algorithm
== SRV_CHECKSUM_ALGORITHM_CRC32) {
crc32 = buf_calc_page_crc32(read_buf);
crc32_inited = true;
if (checksum_field2 != crc32
&& checksum_field2
!= buf_calc_page_old_checksum(read_buf)) {
return true;
}
} else {
ut_ad(srv_checksum_algorithm
== SRV_CHECKSUM_ALGORITHM_INNODB);
if (checksum_field2
!= buf_calc_page_old_checksum(read_buf)) {
crc32 = buf_calc_page_crc32(read_buf);
crc32_inited = true;
if (checksum_field2 != crc32) {
return true;
}
}
}
}
if (buf_page_is_checksum_valid_crc32(read_buf,
checksum_field1, checksum_field2)) {
#ifndef UNIV_INNOCHECKSUM
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_CRC32,
space_id, page_no);
#endif
return(false);
/* old field is fine, check the new field */
/* InnoDB versions < 4.0.14 and < 4.1.1 stored the space id
(always equal to 0), to FIL_PAGE_SPACE_OR_CHKSUM */
if (checksum_field1 != 0
&& checksum_field1 != BUF_NO_CHECKSUM_MAGIC) {
/* The checksum does not match any of the
fast to check. First check the selected algorithm
for writing checksums because we assume that the
chance of it matching is higher. */
if (srv_checksum_algorithm
== SRV_CHECKSUM_ALGORITHM_CRC32) {
if (!crc32_inited) {
crc32 = buf_calc_page_crc32(read_buf);
crc32_inited = true;
}
if (checksum_field1 != crc32
&& checksum_field1
!= buf_calc_page_new_checksum(read_buf)) {
return true;
}
} else {
ut_ad(srv_checksum_algorithm
== SRV_CHECKSUM_ALGORITHM_INNODB);
if (checksum_field1
!= buf_calc_page_new_checksum(read_buf)) {
if (!crc32_inited) {
crc32 = buf_calc_page_crc32(
read_buf);
crc32_inited = true;
}
if (checksum_field1 != crc32) {
return true;
}
}
}
}
if (buf_page_is_checksum_valid_innodb(read_buf,
checksum_field1, checksum_field2)) {
#ifndef UNIV_INNOCHECKSUM
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_INNODB,
space_id, page_no);
#endif
return(false);
/* If CRC32 is stored in at least one of the fields then the
other field must also be CRC32 */
if (crc32_inited
&& ((checksum_field1 == crc32
&& checksum_field2 != crc32)
|| (checksum_field1 != crc32
&& checksum_field2 == crc32))) {
return true;
}
#ifdef UNIV_INNOCHECKSUM
if (log_file) {
fprintf(log_file, "Fail; page::%llu;"
" invalid (fails none checksum)\n",
cur_page_num);
}
#endif /* UNIV_INNOCHECKSUM */
return(true);
break;
case SRV_CHECKSUM_ALGORITHM_NONE:
/* should have returned FALSE earlier */
break;
ut_error;
/* no default so the compiler will emit a warning if new enum
is added and not handled here */
}
ut_error;
return(false);
return false;
}
#ifndef UNIV_INNOCHECKSUM

View File

@ -2669,7 +2669,7 @@ fil_space_verify_crypt_checksum(
uint32_t checksum1 = mach_read_from_4(page + FIL_PAGE_SPACE_OR_CHKSUM);
uint32_t checksum2;
bool valid;
bool valid = false;
if (zip_size) {
valid = (checksum1 == cchecksum1);
@ -2677,8 +2677,29 @@ fil_space_verify_crypt_checksum(
} else {
checksum2 = mach_read_from_4(
page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM);
valid = (buf_page_is_checksum_valid_crc32(page,checksum1,checksum2)
|| buf_page_is_checksum_valid_innodb(page,checksum1, checksum2));
switch (algorithm) {
case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32:
valid = buf_page_is_checksum_valid_crc32(page, checksum1,
checksum2);
break;
case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB:
valid = buf_page_is_checksum_valid_innodb(page, checksum1,
checksum2);
break;
case SRV_CHECKSUM_ALGORITHM_STRICT_NONE:
valid = buf_page_is_checksum_valid_none(page, checksum1,
checksum2);
break;
case SRV_CHECKSUM_ALGORITHM_CRC32:
case SRV_CHECKSUM_ALGORITHM_INNODB:
valid = buf_page_is_checksum_valid_crc32(
page, checksum1, checksum2)
|| buf_page_is_checksum_valid_innodb(
page, checksum1, checksum2);
break;
case SRV_CHECKSUM_ALGORITHM_NONE:
ut_error;
}
}
if (encrypted && valid) {

View File

@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 2016, MariaDB Corporation
Copyright (c) 2013, 2018, 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
@ -1125,19 +1125,6 @@ const rec_t*
page_find_rec_max_not_deleted(
const page_t* page);
/** Issue a warning when the checksum that is stored in the page is valid,
but different than the global setting innodb_checksum_algorithm.
@param[in] current_algo current checksum algorithm
@param[in] page_checksum page valid checksum
@param[in] space_id tablespace id
@param[in] page_no page number */
void
page_warn_strict_checksum(
srv_checksum_algorithm_t curr_algo,
srv_checksum_algorithm_t page_checksum,
ulint space_id,
ulint page_no);
#ifdef UNIV_MATERIALIZE
#undef UNIV_INLINE
#define UNIV_INLINE UNIV_INLINE_ORIGINAL

View File

@ -546,21 +546,6 @@ from outside the buffer pool.
# define UNIV_INLINE UNIV_INLINE_ORIGINAL
#endif
#ifdef UNIV_INNOCHECKSUM
/** Issue a warning when the checksum that is stored in the page is valid,
but different than the global setting innodb_checksum_algorithm.
@param[in] current_algo current checksum algorithm
@param[in] page_checksum page valid checksum
@param[in] space_id tablespace id
@param[in] page_no page number */
void
page_warn_strict_checksum(
srv_checksum_algorithm_t curr_algo,
srv_checksum_algorithm_t page_checksum,
ulint space_id,
ulint page_no);
#endif /* UNIV_INNOCHECKSUM */
#ifndef UNIV_INNOCHECKSUM
#ifndef UNIV_NONINL
# include "page0zip.ic"

View File

@ -2815,45 +2815,3 @@ page_find_rec_max_not_deleted(
}
return(prev_rec);
}
/** Issue a warning when the checksum that is stored in the page is valid,
but different than the global setting innodb_checksum_algorithm.
@param[in] current_algo current checksum algorithm
@param[in] page_checksum page valid checksum
@param[in] space_id tablespace id
@param[in] page_no page number */
void
page_warn_strict_checksum(
srv_checksum_algorithm_t curr_algo,
srv_checksum_algorithm_t page_checksum,
ulint space_id,
ulint page_no)
{
srv_checksum_algorithm_t curr_algo_nonstrict;
switch (curr_algo) {
case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32:
curr_algo_nonstrict = SRV_CHECKSUM_ALGORITHM_CRC32;
break;
case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB:
curr_algo_nonstrict = SRV_CHECKSUM_ALGORITHM_INNODB;
break;
case SRV_CHECKSUM_ALGORITHM_STRICT_NONE:
curr_algo_nonstrict = SRV_CHECKSUM_ALGORITHM_NONE;
break;
default:
ut_error;
}
ib_logf(IB_LOG_LEVEL_WARN,
"innodb_checksum_algorithm is set to \"%s\""
" but the page [page id: space=" ULINTPF ","
" page number=" ULINTPF "] contains a valid checksum \"%s\"."
" Accepting the page as valid. Change innodb_checksum_algorithm"
" to \"%s\" to silently accept such pages or rewrite all pages"
" so that they contain \"%s\" checksum.",
buf_checksum_algorithm_name(curr_algo),
space_id, page_no,
buf_checksum_algorithm_name(page_checksum),
buf_checksum_algorithm_name(curr_algo_nonstrict),
buf_checksum_algorithm_name(curr_algo_nonstrict));
}

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) 2014, 2017, MariaDB Corporation.
Copyright (c) 2014, 2018, 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
@ -48,8 +48,6 @@ using namespace std;
#include "btr0cur.h"
#include "page0types.h"
#include "log0recv.h"
#else
#define page_warn_strict_checksum(A,B,C,D)
#endif /* !UNIV_INNOCHECKSUM */
#include "zlib.h"
#ifndef UNIV_HOTBACKUP
@ -4926,13 +4924,6 @@ page_zip_verify_checksum(
stored = static_cast<ib_uint32_t>(mach_read_from_4(
static_cast<const unsigned char*>(data) + FIL_PAGE_SPACE_OR_CHKSUM));
ulint page_no MY_ATTRIBUTE((unused)) =
mach_read_from_4(static_cast<const unsigned char*>
(data) + FIL_PAGE_OFFSET);
ulint space_id MY_ATTRIBUTE((unused)) =
mach_read_from_4(static_cast<const unsigned char*>
(data) + FIL_PAGE_SPACE_ID);
#if FIL_PAGE_LSN % 8
#error "FIL_PAGE_LSN must be 64 bit aligned"
#endif
@ -4948,12 +4939,6 @@ page_zip_verify_checksum(
return(FALSE);
}
}
#ifdef UNIV_INNOCHECKSUM
if (log_file) {
fprintf(log_file, "Page::%llu is empty and"
" uncorrupted\n", cur_page_num);
}
#endif /* UNIV_INNOCHECKSUM */
/* Empty page */
return(TRUE);
}
@ -4968,130 +4953,36 @@ page_zip_verify_checksum(
calc = static_cast<ib_uint32_t>(page_zip_calc_checksum(
data, size, curr_algo));
#ifdef UNIV_INNOCHECKSUM
if (log_file) {
fprintf(log_file, "page::%llu;"
" %s checksum: calculated = %u;"
" recorded = %u\n", cur_page_num,
buf_checksum_algorithm_name(
static_cast<srv_checksum_algorithm_t>(
srv_checksum_algorithm)),
calc, stored);
}
if (!strict_verify) {
const uint32_t crc32 = page_zip_calc_checksum(
data, size, SRV_CHECKSUM_ALGORITHM_CRC32);
if (log_file) {
fprintf(log_file, "page::%llu: crc32 checksum:"
" calculated = %u; recorded = %u\n",
cur_page_num, crc32, stored);
fprintf(log_file, "page::%llu: none checksum:"
" calculated = %lu; recorded = %u\n",
cur_page_num, BUF_NO_CHECKSUM_MAGIC, stored);
}
}
#endif /* UNIV_INNOCHECKSUM */
if (stored == calc) {
return(TRUE);
}
switch (curr_algo) {
case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32:
case SRV_CHECKSUM_ALGORITHM_CRC32:
if (stored == BUF_NO_CHECKSUM_MAGIC) {
if (curr_algo
== SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) {
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_NONE,
space_id, page_no);
}
return(TRUE);
}
innodb = static_cast<ib_uint32_t>(page_zip_calc_checksum(
data, size, SRV_CHECKSUM_ALGORITHM_INNODB));
if (stored == innodb) {
if (curr_algo
== SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) {
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_INNODB,
space_id, page_no);
}
return(TRUE);
}
break;
case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB:
case SRV_CHECKSUM_ALGORITHM_INNODB:
if (stored == BUF_NO_CHECKSUM_MAGIC) {
if (curr_algo
== SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) {
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_NONE,
space_id, page_no);
}
return(TRUE);
}
crc32 = static_cast<ib_uint32_t>(page_zip_calc_checksum(
data, size, SRV_CHECKSUM_ALGORITHM_CRC32));
if (stored == crc32) {
if (curr_algo
== SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) {
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_CRC32,
space_id, page_no);
}
return(TRUE);
}
break;
case SRV_CHECKSUM_ALGORITHM_STRICT_NONE:
crc32 = static_cast<ib_uint32_t>(page_zip_calc_checksum(
data, size, SRV_CHECKSUM_ALGORITHM_CRC32));
if (stored == crc32) {
page_warn_strict_checksum(
curr_algo, SRV_CHECKSUM_ALGORITHM_CRC32,
space_id, page_no);
return stored == calc;
case SRV_CHECKSUM_ALGORITHM_CRC32:
if (stored == BUF_NO_CHECKSUM_MAGIC) {
return(TRUE);
}
crc32 = calc;
innodb = static_cast<ib_uint32_t>(page_zip_calc_checksum(
data, size, SRV_CHECKSUM_ALGORITHM_INNODB));
if (stored == innodb) {
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_INNODB,
space_id, page_no);
return(TRUE);
break;
case SRV_CHECKSUM_ALGORITHM_INNODB:
if (stored == BUF_NO_CHECKSUM_MAGIC) {
return TRUE;
}
crc32 = static_cast<ib_uint32_t>(page_zip_calc_checksum(
data, size, SRV_CHECKSUM_ALGORITHM_CRC32));
innodb = calc;
break;
case SRV_CHECKSUM_ALGORITHM_NONE:
ut_error;
/* no default so the compiler will emit a warning if new enum
is added and not handled here */
return TRUE;
}
return(FALSE);
return (stored == crc32 || stored == innodb);
}

View File

@ -868,10 +868,9 @@ buf_page_is_corrupted(
ulint checksum_field1;
ulint checksum_field2;
ulint space_id = mach_read_from_4(
read_buf + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
ulint page_type = mach_read_from_2(
read_buf + FIL_PAGE_TYPE);
bool crc32_inited = false;
ib_uint32_t crc32 = ULINT32_UNDEFINED;
ulint page_type = mach_read_from_2(read_buf + FIL_PAGE_TYPE);
/* We can trust page type if page compression is set on tablespace
flags because page compression flag means file must have been
@ -896,12 +895,7 @@ buf_page_is_corrupted(
/* Stored log sequence numbers at the start and the end
of page do not match */
ib_logf(IB_LOG_LEVEL_INFO,
"Log sequence number at the start %lu and the end %lu do not match.",
mach_read_from_4(read_buf + FIL_PAGE_LSN + 4),
mach_read_from_4(read_buf + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM + 4));
return(TRUE);
return(true);
}
#ifndef UNIV_HOTBACKUP
@ -964,9 +958,6 @@ buf_page_is_corrupted(
/* make sure that the page is really empty */
for (ulint i = 0; i < UNIV_PAGE_SIZE; i++) {
if (read_buf[i] != 0) {
ib_logf(IB_LOG_LEVEL_INFO,
"Checksum fields zero but page is not empty.");
return(true);
}
}
@ -974,120 +965,130 @@ buf_page_is_corrupted(
return(false);
}
ulint page_no = mach_read_from_4(read_buf + FIL_PAGE_OFFSET);
const srv_checksum_algorithm_t curr_algo =
static_cast<srv_checksum_algorithm_t>(srv_checksum_algorithm);
switch (curr_algo) {
case SRV_CHECKSUM_ALGORITHM_CRC32:
case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32:
return !buf_page_is_checksum_valid_crc32(
read_buf, checksum_field1, checksum_field2);
if (buf_page_is_checksum_valid_crc32(read_buf,
checksum_field1, checksum_field2)) {
return(false);
}
if (buf_page_is_checksum_valid_none(read_buf,
checksum_field1, checksum_field2)) {
if (curr_algo
== SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) {
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_NONE,
space_id, page_no);
}
return(false);
}
if (buf_page_is_checksum_valid_innodb(read_buf,
checksum_field1, checksum_field2)) {
if (curr_algo
== SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) {
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_INNODB,
space_id, page_no);
}
return(false);
}
return(true);
case SRV_CHECKSUM_ALGORITHM_INNODB:
case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB:
if (buf_page_is_checksum_valid_innodb(read_buf,
checksum_field1, checksum_field2)) {
return(false);
}
if (buf_page_is_checksum_valid_none(read_buf,
checksum_field1, checksum_field2)) {
if (curr_algo
== SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) {
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_NONE,
space_id, page_no);
}
return(false);
}
if (buf_page_is_checksum_valid_crc32(read_buf,
checksum_field1, checksum_field2)) {
if (curr_algo
== SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) {
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_CRC32,
space_id, page_no);
}
return(false);
}
return(true);
return !buf_page_is_checksum_valid_innodb(
read_buf, checksum_field1, checksum_field2);
case SRV_CHECKSUM_ALGORITHM_STRICT_NONE:
return !buf_page_is_checksum_valid_none(
read_buf, checksum_field1, checksum_field2);
case SRV_CHECKSUM_ALGORITHM_CRC32:
case SRV_CHECKSUM_ALGORITHM_INNODB:
/* Very old versions of InnoDB only stored 8 byte lsn to the
start and the end of the page. */
if (buf_page_is_checksum_valid_none(read_buf,
checksum_field1, checksum_field2)) {
return(false);
/* Since innodb_checksum_algorithm is not strict_* allow
any of the algos to match for the old field */
if (checksum_field2
!= mach_read_from_4(read_buf + FIL_PAGE_LSN)
&& checksum_field2 != BUF_NO_CHECKSUM_MAGIC) {
/* The checksum does not match any of the
fast to check. First check the selected algorithm
for writing checksums because we assume that the
chance of it matching is higher. */
if (srv_checksum_algorithm
== SRV_CHECKSUM_ALGORITHM_CRC32) {
crc32 = buf_calc_page_crc32(read_buf);
crc32_inited = true;
if (checksum_field2 != crc32
&& checksum_field2
!= buf_calc_page_old_checksum(read_buf)) {
return true;
}
} else {
ut_ad(srv_checksum_algorithm
== SRV_CHECKSUM_ALGORITHM_INNODB);
if (checksum_field2
!= buf_calc_page_old_checksum(read_buf)) {
crc32 = buf_calc_page_crc32(read_buf);
crc32_inited = true;
if (checksum_field2 != crc32) {
return true;
}
}
}
}
if (buf_page_is_checksum_valid_crc32(read_buf,
checksum_field1, checksum_field2)) {
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_CRC32,
space_id, page_no);
return(false);
/* old field is fine, check the new field */
/* InnoDB versions < 4.0.14 and < 4.1.1 stored the space id
(always equal to 0), to FIL_PAGE_SPACE_OR_CHKSUM */
if (checksum_field1 != 0
&& checksum_field1 != BUF_NO_CHECKSUM_MAGIC) {
/* The checksum does not match any of the
fast to check. First check the selected algorithm
for writing checksums because we assume that the
chance of it matching is higher. */
if (srv_checksum_algorithm
== SRV_CHECKSUM_ALGORITHM_CRC32) {
if (!crc32_inited) {
crc32 = buf_calc_page_crc32(read_buf);
crc32_inited = true;
}
if (checksum_field1 != crc32
&& checksum_field1
!= buf_calc_page_new_checksum(read_buf)) {
return true;
}
} else {
ut_ad(srv_checksum_algorithm
== SRV_CHECKSUM_ALGORITHM_INNODB);
if (checksum_field1
!= buf_calc_page_new_checksum(read_buf)) {
if (!crc32_inited) {
crc32 = buf_calc_page_crc32(
read_buf);
crc32_inited = true;
}
if (checksum_field1 != crc32) {
return true;
}
}
}
}
if (buf_page_is_checksum_valid_innodb(read_buf,
checksum_field1, checksum_field2)) {
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_INNODB,
space_id, page_no);
return(false);
/* If CRC32 is stored in at least one of the fields then the
other field must also be CRC32 */
if (crc32_inited
&& ((checksum_field1 == crc32
&& checksum_field2 != crc32)
|| (checksum_field1 != crc32
&& checksum_field2 == crc32))) {
return true;
}
return(true);
break;
case SRV_CHECKSUM_ALGORITHM_NONE:
/* should have returned FALSE earlier */
break;
ut_error;
/* no default so the compiler will emit a warning if new enum
is added and not handled here */
}
ut_error;
return(false);
return false;
}
/** Dump a page to stderr.

View File

@ -2669,7 +2669,7 @@ fil_space_verify_crypt_checksum(
uint32_t checksum1 = mach_read_from_4(page + FIL_PAGE_SPACE_OR_CHKSUM);
uint32_t checksum2;
bool valid;
bool valid = false;
if (zip_size) {
valid = (checksum1 == cchecksum1);
@ -2677,8 +2677,29 @@ fil_space_verify_crypt_checksum(
} else {
checksum2 = mach_read_from_4(
page + UNIV_PAGE_SIZE - FIL_PAGE_END_LSN_OLD_CHKSUM);
valid = (buf_page_is_checksum_valid_crc32(page,checksum1,checksum2)
|| buf_page_is_checksum_valid_innodb(page,checksum1, checksum2));
switch (algorithm) {
case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32:
valid = buf_page_is_checksum_valid_crc32(page, checksum1,
checksum2);
break;
case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB:
valid = buf_page_is_checksum_valid_innodb(page, checksum1,
checksum2);
break;
case SRV_CHECKSUM_ALGORITHM_STRICT_NONE:
valid = buf_page_is_checksum_valid_none(page, checksum1,
checksum2);
break;
case SRV_CHECKSUM_ALGORITHM_CRC32:
case SRV_CHECKSUM_ALGORITHM_INNODB:
valid = buf_page_is_checksum_valid_crc32(
page, checksum1, checksum2)
|| buf_page_is_checksum_valid_innodb(
page, checksum1, checksum2);
break;
case SRV_CHECKSUM_ALGORITHM_NONE:
ut_error;
}
}
if (encrypted && valid) {

View File

@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 2018, 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
@ -1109,23 +1110,6 @@ const rec_t*
page_find_rec_max_not_deleted(
const page_t* page);
#endif /* #ifndef UNIV_INNOCHECKSUM */
/** Issue a warning when the checksum that is stored in the page is valid,
but different than the global setting innodb_checksum_algorithm.
@param[in] current_algo current checksum algorithm
@param[in] page_checksum page valid checksum
@param[in] space_id tablespace id
@param[in] page_no page number */
void
page_warn_strict_checksum(
srv_checksum_algorithm_t curr_algo,
srv_checksum_algorithm_t page_checksum,
ulint space_id,
ulint page_no);
#ifndef UNIV_INNOCHECKSUM
#ifdef UNIV_MATERIALIZE
#undef UNIV_INLINE
#define UNIV_INLINE UNIV_INLINE_ORIGINAL

View File

@ -2822,49 +2822,3 @@ page_find_rec_max_not_deleted(
}
#endif /* #ifndef UNIV_INNOCHECKSUM */
/** Issue a warning when the checksum that is stored in the page is valid,
but different than the global setting innodb_checksum_algorithm.
@param[in] current_algo current checksum algorithm
@param[in] page_checksum page valid checksum
@param[in] space_id tablespace id
@param[in] page_no page number */
void
page_warn_strict_checksum(
srv_checksum_algorithm_t curr_algo,
srv_checksum_algorithm_t page_checksum,
ulint space_id,
ulint page_no)
{
srv_checksum_algorithm_t curr_algo_nonstrict = srv_checksum_algorithm_t();
switch (curr_algo) {
case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32:
curr_algo_nonstrict = SRV_CHECKSUM_ALGORITHM_CRC32;
break;
case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB:
curr_algo_nonstrict = SRV_CHECKSUM_ALGORITHM_INNODB;
break;
case SRV_CHECKSUM_ALGORITHM_STRICT_NONE:
curr_algo_nonstrict = SRV_CHECKSUM_ALGORITHM_NONE;
break;
default:
ut_error;
}
#ifdef UNIV_INNOCHECKSUM
fprintf(stderr,
#else
ib_logf(IB_LOG_LEVEL_WARN,
#endif
"innodb_checksum_algorithm is set to \"%s\""
" but the page [page id: space=" ULINTPF ","
" page number=" ULINTPF "] contains a valid checksum \"%s\"."
" Accepting the page as valid. Change innodb_checksum_algorithm"
" to \"%s\" to silently accept such pages or rewrite all pages"
" so that they contain \"%s\" checksum.",
buf_checksum_algorithm_name(curr_algo),
space_id, page_no,
buf_checksum_algorithm_name(page_checksum),
buf_checksum_algorithm_name(curr_algo_nonstrict),
buf_checksum_algorithm_name(curr_algo_nonstrict));
}

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) 2014, 2017, MariaDB Corporation.
Copyright (c) 2014, 2018, 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
@ -4930,10 +4930,6 @@ page_zip_verify_checksum(
stored = static_cast<ib_uint32_t>(mach_read_from_4(
static_cast<const unsigned char*>(data) + FIL_PAGE_SPACE_OR_CHKSUM));
ulint page_no = mach_read_from_4(static_cast<const unsigned char*> (data) + FIL_PAGE_OFFSET);
ulint space_id = mach_read_from_4(static_cast<const unsigned char*>
(data) + FIL_PAGE_SPACE_ID);
#if FIL_PAGE_LSN % 8
#error "FIL_PAGE_LSN must be 64 bit aligned"
#endif
@ -4944,8 +4940,7 @@ page_zip_verify_checksum(
data)
+ FIL_PAGE_LSN) == 0) {
/* make sure that the page is really empty */
ulint i;
for (i = 0; i < size; i++) {
for (ulint i = 0; i < size; i++) {
if (*((const char*) data + i) != 0) {
return(FALSE);
}
@ -4970,97 +4965,30 @@ page_zip_verify_checksum(
switch (curr_algo) {
case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32:
case SRV_CHECKSUM_ALGORITHM_CRC32:
if (stored == BUF_NO_CHECKSUM_MAGIC) {
if (curr_algo
== SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) {
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_NONE,
space_id, page_no);
}
return(TRUE);
}
innodb = static_cast<ib_uint32_t>(page_zip_calc_checksum(
data, size, SRV_CHECKSUM_ALGORITHM_INNODB));
if (stored == innodb) {
if (curr_algo
== SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) {
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_INNODB,
space_id, page_no);
}
return(TRUE);
}
break;
case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB:
case SRV_CHECKSUM_ALGORITHM_INNODB:
if (stored == BUF_NO_CHECKSUM_MAGIC) {
if (curr_algo
== SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) {
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_NONE,
space_id, page_no);
}
return(TRUE);
}
crc32 = static_cast<ib_uint32_t>(page_zip_calc_checksum(
data, size, SRV_CHECKSUM_ALGORITHM_CRC32));
if (stored == crc32) {
if (curr_algo
== SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) {
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_CRC32,
space_id, page_no);
}
return(TRUE);
}
break;
case SRV_CHECKSUM_ALGORITHM_STRICT_NONE:
crc32 = static_cast<ib_uint32_t>(page_zip_calc_checksum(
data, size, SRV_CHECKSUM_ALGORITHM_CRC32));
if (stored == crc32) {
page_warn_strict_checksum(
curr_algo, SRV_CHECKSUM_ALGORITHM_CRC32,
space_id, page_no);
return stored == calc;
case SRV_CHECKSUM_ALGORITHM_CRC32:
if (stored == BUF_NO_CHECKSUM_MAGIC) {
return(TRUE);
}
crc32 = calc;
innodb = static_cast<ib_uint32_t>(page_zip_calc_checksum(
data, size, SRV_CHECKSUM_ALGORITHM_INNODB));
if (stored == innodb) {
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_INNODB,
space_id, page_no);
return(TRUE);
break;
case SRV_CHECKSUM_ALGORITHM_INNODB:
if (stored == BUF_NO_CHECKSUM_MAGIC) {
return TRUE;
}
crc32 = static_cast<ib_uint32_t>(page_zip_calc_checksum(
data, size, SRV_CHECKSUM_ALGORITHM_CRC32));
innodb = calc;
break;
case SRV_CHECKSUM_ALGORITHM_NONE:
ut_error;
/* no default so the compiler will emit a warning if new enum
is added and not handled here */
return TRUE;
}
return(FALSE);
return (stored == crc32 || stored == innodb);
}