summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2018-12-13 13:37:21 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2018-12-13 13:37:21 +0200
commit621041b67698b040080b33928883336967687e1e (patch)
tree75b5591e343f313dab07998b06ddeb4aa76233e3
parent541500295abdba7fa619065069291ac9c1dd6e83 (diff)
parent8e613458e1ad797b5e2c7870ffe1c3d5100dbbee (diff)
downloadmariadb-git-621041b67698b040080b33928883336967687e1e.tar.gz
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.
-rw-r--r--client/mysqltest.cc42
-rw-r--r--include/my_global.h2
-rw-r--r--mysql-test/suite/encryption/r/innodb-checksum-algorithm.result225
-rw-r--r--mysql-test/suite/encryption/t/innodb-checksum-algorithm.test9
-rw-r--r--mysql-test/suite/innodb/t/innodb_zip_innochecksum.opt2
-rw-r--r--mysql-test/suite/innodb/t/innodb_zip_innochecksum.test4
-rw-r--r--scripts/mytop.sh19
-rw-r--r--sql/sql_statistics.cc20
-rw-r--r--storage/innobase/buf/buf0buf.cc259
-rw-r--r--storage/innobase/fil/fil0crypt.cc27
-rw-r--r--storage/innobase/include/page0page.h15
-rw-r--r--storage/innobase/include/page0zip.h15
-rw-r--r--storage/innobase/page/page0page.cc42
-rw-r--r--storage/innobase/page/page0zip.cc127
-rw-r--r--storage/xtradb/buf/buf0buf.cc191
-rw-r--r--storage/xtradb/fil/fil0crypt.cc27
-rw-r--r--storage/xtradb/include/page0page.h18
-rw-r--r--storage/xtradb/page/page0page.cc46
-rw-r--r--storage/xtradb/page/page0zip.cc92
19 files changed, 313 insertions, 869 deletions
diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index 32532c34835..250f73fe3fc 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -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));
diff --git a/include/my_global.h b/include/my_global.h
index dcfd607b455..36e4b5368fa 100644
--- a/include/my_global.h
+++ b/include/my_global.h
@@ -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;
}
diff --git a/mysql-test/suite/encryption/r/innodb-checksum-algorithm.result b/mysql-test/suite/encryption/r/innodb-checksum-algorithm.result
index a853f3869a9..7fdea4b67b5 100644
--- a/mysql-test/suite/encryption/r/innodb-checksum-algorithm.result
+++ b/mysql-test/suite/encryption/r/innodb-checksum-algorithm.result
@@ -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;
diff --git a/mysql-test/suite/encryption/t/innodb-checksum-algorithm.test b/mysql-test/suite/encryption/t/innodb-checksum-algorithm.test
index d0caed05006..b31678b7e9b 100644
--- a/mysql-test/suite/encryption/t/innodb-checksum-algorithm.test
+++ b/mysql-test/suite/encryption/t/innodb-checksum-algorithm.test
@@ -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;
diff --git a/mysql-test/suite/innodb/t/innodb_zip_innochecksum.opt b/mysql-test/suite/innodb/t/innodb_zip_innochecksum.opt
index f8c8c9d247d..f47343e5e7c 100644
--- a/mysql-test/suite/innodb/t/innodb_zip_innochecksum.opt
+++ b/mysql-test/suite/innodb/t/innodb_zip_innochecksum.opt
@@ -1,4 +1,4 @@
--skip-innodb-doublewrite
--innodb-file-per-table
--innodb-file-format=Barracuda
-
+--innodb_checksum_algorithm=crc32
diff --git a/mysql-test/suite/innodb/t/innodb_zip_innochecksum.test b/mysql-test/suite/innodb/t/innodb_zip_innochecksum.test
index 63a4b418677..fec8acf52c4 100644
--- a/mysql-test/suite/innodb/t/innodb_zip_innochecksum.test
+++ b/mysql-test/suite/innodb/t/innodb_zip_innochecksum.test
@@ -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
diff --git a/scripts/mytop.sh b/scripts/mytop.sh
index 17a87e9efd2..3ef0a59f27f 100644
--- a/scripts/mytop.sh
+++ b/scripts/mytop.sh
@@ -437,7 +437,7 @@ while (1)
if ($key eq 'C')
{
- if ( $HAS_COLOR )
+ if ( $HAS_COLOR )
{
$HAS_COLOR = 0;
}
@@ -817,11 +817,11 @@ sub GetData()
if ($config{header})
{
my @recs = "";
- if ( $db_release > 4 )
+ if ( $db_release > 4 )
{
@recs = Hashes("show global status");
- }
- else
+ }
+ else
{
@recs = Hashes("show status");
}
@@ -978,7 +978,7 @@ sub GetData()
# print("q_diff: $STATUS{Questions} - $OLD_STATUS{Questions} / $t_delta = $q_diff\n");
printf(" Sorts: %5.0f qps now: %4.0f Slow qps: %3.1f Threads: %4.0f (%4.0f/%4.0f) %02.0f/%02.0f/%02.0f/%02.0f\n",
- ( $STATUS{Sort_rows} - $OLD_STATUS{Sort_rows} ) / $t_delta,
+ ( $STATUS{Sort_rows} - $OLD_STATUS{Sort_rows} ) / $t_delta,
( $STATUS{Questions} - $OLD_STATUS{Questions} ) / $t_delta,
( # slow now (qps)
($STATUS{Slow_queries} ) ?
@@ -989,7 +989,7 @@ sub GetData()
$STATUS{Threads_running},
$STATUS{Threads_cached},
- (100 * ($STATUS{Com_select} - $OLD_STATUS{Com_select} +
+ (100 * ($STATUS{Com_select} - $OLD_STATUS{Com_select} +
($STATUS{Qcache_hits}||0) - ($OLD_STATUS{Qcache_hits}||0)
) ) / ($q_diff ),
(100 * ($STATUS{Com_insert} - $OLD_STATUS{Com_insert} +
@@ -1075,7 +1075,7 @@ sub GetData()
$t_delta,
($STATUS{Rows_tmp_read} - $OLD_STATUS{Rows_tmp_read}) /
$t_delta,
- ($STATUS{Handler_tmp_write}
+ ($STATUS{Handler_tmp_write}
-$OLD_STATUS{Handler_tmp_write})/$t_delta,
($STATUS{Handler_tmp_update} -
$OLD_STATUS{Handler_tmp_update})/$t_delta);
@@ -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);
@@ -1225,9 +1226,9 @@ sub GetData()
$thread->{State} ||= "";
$thread->{Progress} ||= 0;
- ## alter double hyphen comments so they don't break
+ ## alter double hyphen comments so they don't break
## the query when newlines are removed - http://freshmeat.net/users/jerjones
- $thread->{Info} =~ s~\s--(.*)$~ /* $1 */ ~mg;
+ $thread->{Info} =~ s~\s--(.*)$~ /* $1 */ ~mg;
## Normalize spaces -- mostly disabled for now. This can
## break EXPLAIN if you try to explain a mangled query. It
diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc
index 7d73a894bdc..f4dcafdb7c3 100644
--- a/sql/sql_statistics.cc
+++ b/sql/sql_statistics.cc
@@ -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;
}
diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc
index c628147fce5..f0f3181e26a 100644
--- a/storage/innobase/buf/buf0buf.cc
+++ b/storage/innobase/buf/buf0buf.cc
@@ -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);
- }
+ case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB:
+ 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)) {
- 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 */
- }
+ /* Since innodb_checksum_algorithm is not strict_* allow
+ any of the algos to match for the old field */
-#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 */
+ if (checksum_field2
+ != mach_read_from_4(read_buf + FIL_PAGE_LSN)
+ && checksum_field2 != BUF_NO_CHECKSUM_MAGIC) {
- return(false);
- }
+ /* 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 (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
- }
+ if (srv_checksum_algorithm
+ == SRV_CHECKSUM_ALGORITHM_CRC32) {
- return(false);
- }
+ crc32 = buf_calc_page_crc32(read_buf);
+ crc32_inited = true;
-#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);
+ 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);
- case SRV_CHECKSUM_ALGORITHM_INNODB:
- case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB:
+ if (checksum_field2
+ != buf_calc_page_old_checksum(read_buf)) {
- if (buf_page_is_checksum_valid_innodb(read_buf,
- checksum_field1, checksum_field2)) {
- return(false);
- }
+ crc32 = buf_calc_page_crc32(read_buf);
+ crc32_inited = true;
- 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);
+ if (checksum_field2 != crc32) {
+ return true;
+ }
+ }
}
-#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
- }
+ /* old field is fine, check the new field */
- return(false);
- }
+ /* InnoDB versions < 4.0.14 and < 4.1.1 stored the space id
+ (always equal to 0), to FIL_PAGE_SPACE_OR_CHKSUM */
-#ifdef UNIV_INNOCHECKSUM
- if (log_file) {
- fprintf(log_file, "Fail; page::%llu;"
- " invalid (fails innodb checksum)\n",
- cur_page_num);
- }
-#endif /* UNIV_INNOCHECKSUM */
+ if (checksum_field1 != 0
+ && checksum_field1 != BUF_NO_CHECKSUM_MAGIC) {
- return(true);
+ /* 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. */
- case SRV_CHECKSUM_ALGORITHM_STRICT_NONE:
+ if (srv_checksum_algorithm
+ == SRV_CHECKSUM_ALGORITHM_CRC32) {
- if (buf_page_is_checksum_valid_none(read_buf,
- checksum_field1, checksum_field2)) {
- return(false);
- }
+ if (!crc32_inited) {
+ crc32 = buf_calc_page_crc32(read_buf);
+ crc32_inited = 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);
- }
+ 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 (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 (checksum_field1
+ != buf_calc_page_new_checksum(read_buf)) {
-#ifdef UNIV_INNOCHECKSUM
- if (log_file) {
- fprintf(log_file, "Fail; page::%llu;"
- " invalid (fails none checksum)\n",
- cur_page_num);
+ if (!crc32_inited) {
+ crc32 = buf_calc_page_crc32(
+ read_buf);
+ crc32_inited = true;
+ }
+
+ if (checksum_field1 != crc32) {
+ return true;
+ }
+ }
+ }
}
-#endif /* UNIV_INNOCHECKSUM */
- return(true);
+ /* 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;
+ }
+ 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
diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc
index 7859fe67d40..b0333cd294f 100644
--- a/storage/innobase/fil/fil0crypt.cc
+++ b/storage/innobase/fil/fil0crypt.cc
@@ -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) {
diff --git a/storage/innobase/include/page0page.h b/storage/innobase/include/page0page.h
index e8b4265bc68..9c6d430eb2a 100644
--- a/storage/innobase/include/page0page.h
+++ b/storage/innobase/include/page0page.h
@@ -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
diff --git a/storage/innobase/include/page0zip.h b/storage/innobase/include/page0zip.h
index 4e362cec641..0bf77e2fcf3 100644
--- a/storage/innobase/include/page0zip.h
+++ b/storage/innobase/include/page0zip.h
@@ -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"
diff --git a/storage/innobase/page/page0page.cc b/storage/innobase/page/page0page.cc
index 2cc967129a9..9d267f3f0f4 100644
--- a/storage/innobase/page/page0page.cc
+++ b/storage/innobase/page/page0page.cc
@@ -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));
-}
diff --git a/storage/innobase/page/page0zip.cc b/storage/innobase/page/page0zip.cc
index b580ba6d098..5090aa40575 100644
--- a/storage/innobase/page/page0zip.cc
+++ b/storage/innobase/page/page0zip.cc
@@ -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_STRICT_INNODB:
+ case SRV_CHECKSUM_ALGORITHM_STRICT_NONE:
+ return stored == calc;
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);
}
+ crc32 = calc;
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);
+ 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(TRUE);
- }
-
- 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);
- }
-
+ 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);
}
diff --git a/storage/xtradb/buf/buf0buf.cc b/storage/xtradb/buf/buf0buf.cc
index a5c8da7c5a9..5227d1ff970 100644
--- a/storage/xtradb/buf/buf0buf.cc
+++ b/storage/xtradb/buf/buf0buf.cc
@@ -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);
- }
+ case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB:
+ 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)) {
- if (curr_algo
- == SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) {
- page_warn_strict_checksum(
- curr_algo,
- SRV_CHECKSUM_ALGORITHM_NONE,
- space_id, page_no);
- }
+ /* Since innodb_checksum_algorithm is not strict_* allow
+ any of the algos to match for the old field */
- return(false);
- }
+ if (checksum_field2
+ != mach_read_from_4(read_buf + FIL_PAGE_LSN)
+ && checksum_field2 != BUF_NO_CHECKSUM_MAGIC) {
- 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);
- }
+ /* 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. */
- return(false);
- }
+ if (srv_checksum_algorithm
+ == SRV_CHECKSUM_ALGORITHM_CRC32) {
- return(true);
+ crc32 = buf_calc_page_crc32(read_buf);
+ crc32_inited = true;
- case SRV_CHECKSUM_ALGORITHM_INNODB:
- case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB:
+ 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 (buf_page_is_checksum_valid_innodb(read_buf,
- checksum_field1, checksum_field2)) {
- return(false);
- }
+ if (checksum_field2
+ != buf_calc_page_old_checksum(read_buf)) {
- 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);
- }
+ crc32 = buf_calc_page_crc32(read_buf);
+ crc32_inited = true;
- return(false);
+ if (checksum_field2 != crc32) {
+ return true;
+ }
+ }
+ }
}
- 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);
- }
+ /* old field is fine, check the new field */
- return(false);
- }
+ /* InnoDB versions < 4.0.14 and < 4.1.1 stored the space id
+ (always equal to 0), to FIL_PAGE_SPACE_OR_CHKSUM */
- return(true);
+ if (checksum_field1 != 0
+ && checksum_field1 != BUF_NO_CHECKSUM_MAGIC) {
- case SRV_CHECKSUM_ALGORITHM_STRICT_NONE:
+ /* 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 (buf_page_is_checksum_valid_none(read_buf,
- checksum_field1, checksum_field2)) {
- return(false);
- }
+ if (srv_checksum_algorithm
+ == SRV_CHECKSUM_ALGORITHM_CRC32) {
- 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);
- }
+ if (!crc32_inited) {
+ crc32 = buf_calc_page_crc32(read_buf);
+ crc32_inited = 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 (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;
+ }
+ }
+ }
}
- return(true);
+ /* 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;
+ }
+ 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.
diff --git a/storage/xtradb/fil/fil0crypt.cc b/storage/xtradb/fil/fil0crypt.cc
index 7859fe67d40..b0333cd294f 100644
--- a/storage/xtradb/fil/fil0crypt.cc
+++ b/storage/xtradb/fil/fil0crypt.cc
@@ -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) {
diff --git a/storage/xtradb/include/page0page.h b/storage/xtradb/include/page0page.h
index eefa0fa4c5b..26e71ff8081 100644
--- a/storage/xtradb/include/page0page.h
+++ b/storage/xtradb/include/page0page.h
@@ -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
diff --git a/storage/xtradb/page/page0page.cc b/storage/xtradb/page/page0page.cc
index e21880c2d4b..7b62fe756af 100644
--- a/storage/xtradb/page/page0page.cc
+++ b/storage/xtradb/page/page0page.cc
@@ -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));
-}
diff --git a/storage/xtradb/page/page0zip.cc b/storage/xtradb/page/page0zip.cc
index bf7b4928e61..90a1d0794a3 100644
--- a/storage/xtradb/page/page0zip.cc
+++ b/storage/xtradb/page/page0zip.cc
@@ -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_STRICT_INNODB:
+ case SRV_CHECKSUM_ALGORITHM_STRICT_NONE:
+ return stored == calc;
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);
}
+ crc32 = calc;
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);
+ 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(TRUE);
- }
-
- 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);
- }
-
+ 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);
}