Commit 2e5aea4b authored by Marko Mäkelä's avatar Marko Mäkelä

Merge 10.1 into 10.2

parents ad3346dd 621041b6
......@@ -6584,8 +6584,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
......@@ -6603,10 +6601,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;
......@@ -6614,10 +6617,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))
......@@ -6653,7 +6667,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--;
}
......@@ -6668,9 +6682,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;
......@@ -6802,8 +6816,6 @@ int read_line(char *buf, int size)
}
}
}
die("The input buffer is too small for this query.\n"
"check your query or increase MAX_QUERY and recompile");
DBUG_RETURN(0);
}
......@@ -6948,12 +6960,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");
......@@ -6969,8 +6977,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);
......@@ -6979,6 +6986,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 == '#')
{
......@@ -9210,6 +9218,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));
......
......@@ -13,7 +13,7 @@ fi
MYSQL="/usr/bin/mysql --defaults-file=/etc/mysql/debian.cnf"
MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf"
MYUPGRADE="/usr/bin/mysql_upgrade --defaults-extra-file=/etc/mysql/debian.cnf"
MYUPGRADE="/usr/bin/mysql_upgrade --defaults-extra-file=/etc/mysql/debian.cnf --version-check"
MYCHECK="/usr/bin/mysqlcheck --defaults-file=/etc/mysql/debian.cnf"
MYCHECK_SUBJECT="WARNING: mysqlcheck has found corrupt tables"
MYCHECK_PARAMS="--all-databases --fast --silent"
......
......@@ -2,13 +2,16 @@
. /usr/share/debconf/confmodule
# assume the filename is /path/to/mariadb-server-##.#.postinst
VER=${0: -13:4}
if [ -n "$DEBIAN_SCRIPT_DEBUG" ]; then set -v -x; DEBIAN_SCRIPT_TRACE=1; fi
${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 }
export PATH=$PATH:/sbin:/usr/sbin:/bin:/usr/bin
# This command can be used as pipe to syslog. With "-s" it also logs to stderr.
ERR_LOGGER="logger -p daemon.err -t mysqld_safe -i"
ERR_LOGGER="logger -p daemon.err -t mariadb-server-$VER.postinst -i"
# This will make an error in a logged command immediately apparent by aborting
# the install, rather than failing silently and leaving a broken install.
set -o pipefail
......@@ -145,6 +148,9 @@ EOF
set -e
# To avoid downgrades.
touch $mysql_statedir/debian-$VER.flag
## On every reconfiguration the maintenance user is recreated.
#
# - It is easier to regenerate the password every time but as people
......
......@@ -1084,7 +1084,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;
}
......
......@@ -65,17 +65,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;
......
--skip-innodb-doublewrite
--innodb-file-per-table
--innodb-file-format=Barracuda
--innodb_checksum_algorithm=crc32
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -3744,10 +3744,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;
......@@ -4077,10 +4077,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
......@@ -4089,9 +4085,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;
}
This diff is collapsed.
......@@ -2622,7 +2622,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 (page_size.is_compressed()) {
valid = checksum1 == cchecksum1;
......@@ -2630,12 +2630,36 @@ 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, false
/* FIXME: also try the original crc32 that was
buggy on big-endian architectures? */)
|| buf_page_is_checksum_valid_innodb(
srv_checksum_algorithm_t algorithm =
static_cast<srv_checksum_algorithm_t>(
srv_checksum_algorithm);
switch (algorithm) {
case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32:
/* We never supported upgrade from the "legacy crc32"
on big endian systems from MariaDB 10.1 to later. */
valid = buf_page_is_checksum_valid_crc32(
page, checksum1, checksum2, false);
break;
case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB:
valid = buf_page_is_checksum_valid_innodb(
page, checksum1, checksum2);
break;
case SRV_CHECKSUM_ALGORITHM_STRICT_NONE:
case SRV_CHECKSUM_ALGORITHM_CRC32:
case SRV_CHECKSUM_ALGORITHM_INNODB:
case SRV_CHECKSUM_ALGORITHM_NONE:
/* We never supported upgrade from the "legacy crc32"
on big endian systems from MariaDB 10.1 to later.
We also never supported
innodb_checksum_algorithm=none or strict_none
for encrypted pages. */
valid = buf_page_is_checksum_valid_crc32(
page, checksum1, checksum2, false)
|| buf_page_is_checksum_valid_innodb(
page, checksum1, checksum2);
break;
}
}
if (encrypted && valid) {
......
/*****************************************************************************
Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 2017, 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
......@@ -1229,17 +1229,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] page_id page identifier */
void
page_warn_strict_checksum(
srv_checksum_algorithm_t curr_algo,
srv_checksum_algorithm_t page_checksum,
const page_id_t page_id);
#ifdef UNIV_MATERIALIZE
#undef UNIV_INLINE
#define UNIV_INLINE UNIV_INLINE_ORIGINAL
......
......@@ -2823,42 +2823,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] page_id page identifier */
void
page_warn_strict_checksum(
srv_checksum_algorithm_t curr_algo,
srv_checksum_algorithm_t page_checksum,
const page_id_t page_id)
{
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::warn() << "innodb_checksum_algorithm is set to \""
<< buf_checksum_algorithm_name(curr_algo) << "\""
<< " but the page " << page_id << " contains a valid checksum \""
<< buf_checksum_algorithm_name(page_checksum) << "\". "
<< " Accepting the page as valid. Change"
<< " innodb_checksum_algorithm to \""
<< buf_checksum_algorithm_name(curr_algo_nonstrict)
<< "\" to silently accept such pages or rewrite all pages"
<< " so that they contain \""
<< buf_checksum_algorithm_name(curr_algo_nonstrict)
<< "\" checksum.";
}
......@@ -4986,18 +4986,12 @@ page_zip_verify_checksum(
{
ib_uint32_t stored;
ib_uint32_t calc;
ib_uint32_t crc32 = 0;
ib_uint32_t innodb = 0;
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);
const page_id_t page_id(space_id, page_no);
#if FIL_PAGE_LSN % 8
#error "FIL_PAGE_LSN must be 64 bit aligned"
#endif
......@@ -5074,149 +5068,46 @@ page_zip_verify_checksum(
return(TRUE);
}
bool legacy_checksum_checked = false;
switch (curr_algo) {
case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32:
case SRV_CHECKSUM_ALGORITHM_CRC32: {
if (stored == BUF_NO_CHECKSUM_MAGIC) {
#ifndef UNIV_INNOCHECKSUM
if (curr_algo
== SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) {
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_NONE,
page_id);
}
#endif /* UNIV_INNOCHECKSUM */
return(TRUE);
}
/* We need to check whether the stored checksum matches legacy
big endian checksum or Innodb checksum. We optimize the order
based on earlier results. if earlier we have found pages
matching legacy big endian checksum, we try to match it first.
Otherwise we check innodb checksum first. */
if (legacy_big_endian_checksum) {
const uint32_t calculated =
page_zip_calc_checksum(data, size, curr_algo, true);
if (stored == calculated) {
return(TRUE);
}
legacy_checksum_checked = true;
}
uint32_t calculated =
page_zip_calc_checksum(data, size, SRV_CHECKSUM_ALGORITHM_INNODB);
if (stored == calculated) {
#ifndef UNIV_INNOCHECKSUM
if (curr_algo
== SRV_CHECKSUM_ALGORITHM_STRICT_CRC32) {
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_INNODB,
page_id);
}
#endif /* UNIV_INNOCHECKSUM */
return(TRUE);
}
calculated = page_zip_calc_checksum(
data, size, curr_algo, true);
/* If legacy checksum is not checked, do it now. */
if ((legacy_checksum_checked
&& stored == calculated)) {
calc = page_zip_calc_checksum(data, size, curr_algo, true);
if (calc == stored) {
legacy_big_endian_checksum = true;
return(TRUE);
return TRUE;
}
break;
}
return FALSE;
case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB:
case SRV_CHECKSUM_ALGORITHM_INNODB: {
case SRV_CHECKSUM_ALGORITHM_STRICT_NONE:
return FALSE;
case SRV_CHECKSUM_ALGORITHM_CRC32:
if (stored == BUF_NO_CHECKSUM_MAGIC) {
#ifndef UNIV_INNOCHECKSUM
if (curr_algo
== SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) {
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_NONE,
page_id);
}
#endif /* UNIV_INNOCHECKSUM */
return(TRUE);
}
const uint32_t calculated = page_zip_calc_checksum(
data, size, SRV_CHECKSUM_ALGORITHM_CRC32);
uint32_t calculated1;
if (stored == calculated
|| stored == (calculated1 =
page_zip_calc_checksum(data, size, SRV_CHECKSUM_ALGORITHM_CRC32, true))
) {
#ifndef UNIV_INNOCHECKSUM
if (curr_algo
== SRV_CHECKSUM_ALGORITHM_STRICT_INNODB) {
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_CRC32,
page_id);
}
#endif /* UNIV_INNOCHECKSUM */
return(TRUE);
}
break;
}
case SRV_CHECKSUM_ALGORITHM_STRICT_NONE: {
calc = page_zip_calc_checksum(data, size, curr_algo, true);
crc32 = calc;
uint32_t calculated = page_zip_calc_checksum(
data, size, SRV_CHECKSUM_ALGORITHM_CRC32);
const uint32_t calculated1 = page_zip_calc_checksum(
data, size, SRV_CHECKSUM_ALGORITHM_CRC32, true);
if (stored == calculated
|| stored == calculated1) {
#ifndef UNIV_INNOCHECKSUM
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_CRC32,
page_id);
#endif /* UNIV_INNOCHECKSUM */
return(TRUE);
if (crc32 == stored) {
legacy_big_endian_checksum = true;
return TRUE;
}
calculated = page_zip_calc_checksum(
data, size, SRV_CHECKSUM_ALGORITHM_INNODB);
if (stored == calculated) {
#ifndef UNIV_INNOCHECKSUM
page_warn_strict_checksum(
curr_algo,
SRV_CHECKSUM_ALGORITHM_INNODB,
page_id);
#endif /* UNIV_INNOCHECKSUM */
return(TRUE);
innodb = static_cast<ib_uint32_t>(page_zip_calc_checksum(
data, size, SRV_CHECKSUM_ALGORITHM_INNODB));
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);
}
......@@ -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.
......
......@@ -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) {
......
/*****************************************************************************
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
......
......@@ -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));
}
......@@ -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);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment