From c362ea3ffdf2b6def0735492dbec3a72342f7859 Mon Sep 17 00:00:00 2001 From: fran Date: Wed, 25 Jun 2014 12:32:22 +0200 Subject: Added Master_Host to the Replication information Closes #3 --- scripts/mytop.sh | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/scripts/mytop.sh b/scripts/mytop.sh index 480805e90b1..b3dbf5508c6 100644 --- a/scripts/mytop.sh +++ b/scripts/mytop.sh @@ -438,7 +438,7 @@ while (1) if ($key eq 'C') { - if ( $HAS_COLOR ) + if ( $HAS_COLOR ) { $HAS_COLOR = 0; } @@ -818,11 +818,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"); } @@ -979,7 +979,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} ) ? @@ -990,7 +990,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} + @@ -1076,7 +1076,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); @@ -1120,6 +1120,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); @@ -1226,9 +1227,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 -- cgit v1.2.1 From 32b7d456d5da193c8797e20467f6eac0a6b0c39a Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 28 Nov 2018 19:19:16 +0100 Subject: mysqltest: use a dynamically growing command buffer --- client/mysqltest.cc | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index e41118d742d..088afed41b2 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -6501,8 +6501,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 @@ -6520,10 +6518,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; @@ -6531,10 +6534,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)) @@ -6570,7 +6584,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--; } @@ -6585,9 +6599,9 @@ int read_line(char *buf, int size) } else if ((c == '{' && (!my_strnncoll_simple(charset_info, (const uchar*) "while", 5, - (uchar*) buf, min(5, p - buf), 0) || + (uchar*) read_command_buf, min(5, p - read_command_buf), 0) || !my_strnncoll_simple(charset_info, (const uchar*) "if", 2, - (uchar*) buf, min(2, p - buf), 0)))) + (uchar*) read_command_buf, min(2, p - read_command_buf), 0)))) { /* Only if and while commands can be terminated by { */ *p++= c; @@ -6721,8 +6735,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); } @@ -6867,12 +6879,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"); @@ -6888,8 +6896,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); @@ -6898,6 +6905,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 == '#') { @@ -9025,6 +9033,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); -- cgit v1.2.1 From 9eadef013e77e1622c7c527a1cdfa6dcc2e906dd Mon Sep 17 00:00:00 2001 From: Jiaye Wu Date: Wed, 12 Dec 2018 15:05:14 +0800 Subject: Fix UNICODE issue of dlerror Current implementation is conflicting. If UNICODE is defined, FormatMessage() will be FormatMessageW(), and variable win_errormsg with type char can not be passed to it, which should be changed to TCHAR instead. Since we don't use UNICODE here, we can use FormatMessageA() directly to avoid conversion error. ``` my_global.h(1092): error C2664: 'DWORD FormatMessageW(D WORD,LPCVOID,DWORD,DWORD,LPWSTR,DWORD,va_list *)' : cannot convert argument 5 from 'char [2048]' to 'LPWSTR' ``` --- include/my_global.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/my_global.h b/include/my_global.h index 816c9dd87c6..fd31de115c8 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -1077,7 +1077,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; } -- cgit v1.2.1 From ce1669af121f705f85c64daf8e40bf0eac9f7887 Mon Sep 17 00:00:00 2001 From: Varun Gupta Date: Thu, 13 Dec 2018 00:26:54 +0530 Subject: Fix compile error when building without the partition engine --- sql/sql_statistics.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc index 0c359a29431..2a90269e532 100644 --- a/sql/sql_statistics.cc +++ b/sql/sql_statistics.cc @@ -3931,9 +3931,8 @@ 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; + partition_info *part_info= field->table->part_info; #endif /* (1): checks if we have EITS statistics for a particular column @@ -3944,8 +3943,11 @@ bool is_eits_usable(Field *field) */ 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) + field->type() != MYSQL_TYPE_GEOMETRY //(2) + #ifdef WITH_PARTITION_STORAGE_ENGINE + && (!part_info || !part_info->field_in_partition_expr(field)) //(3) + #endif + ) return TRUE; return FALSE; } -- cgit v1.2.1 From 5f5e73f1fe4f34b806b94cf9443348ed6cf14c1e Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Tue, 11 Dec 2018 16:16:11 +0530 Subject: MDEV-17957 Make Innodb_checksum_algorithm stricter for strict_* values Problem: Innodb_checksum_algorithm checks for all checksum algorithm to validate the page checksum even though the algorithm is specified as strict_crc32, strict_innodb, strict_none. Fix: Remove the checks for all checksum algorithm to validate the page checksum if the algo is specified as strict_* values. --- storage/innobase/buf/buf0buf.cc | 172 +++++++++++++++++----------------- storage/innobase/include/page0page.h | 15 +-- storage/innobase/include/page0zip.h | 15 --- storage/innobase/page/page0page.cc | 42 --------- storage/innobase/page/page0zip.cc | 95 ++----------------- storage/xtradb/buf/buf0buf.cc | 174 ++++++++++++++++++----------------- storage/xtradb/include/page0page.h | 18 +--- storage/xtradb/page/page0page.cc | 46 --------- storage/xtradb/page/page0zip.cc | 87 ++---------------- 9 files changed, 199 insertions(+), 465 deletions(-) diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 11dceacf592..eb29d46daff 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -581,6 +581,8 @@ buf_page_is_corrupted( ulint checksum_field1; ulint checksum_field2; + ib_uint32_t crc32 = ULINT32_UNDEFINED; + bool crc32_inited = false; if (!zip_size && memcmp(read_buf + FIL_PAGE_LSN + 4, @@ -660,120 +662,124 @@ buf_page_is_corrupted( return(FALSE); } - ulint page_no = mach_read_from_4(read_buf + FIL_PAGE_OFFSET); - ulint space_id = mach_read_from_4(read_buf + FIL_PAGE_SPACE_ID); const srv_checksum_algorithm_t curr_algo = static_cast(srv_checksum_algorithm); switch (curr_algo) { - case SRV_CHECKSUM_ALGORITHM_CRC32: case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32: - - if (buf_page_is_checksum_valid_crc32(read_buf, - checksum_field1, checksum_field2)) { - return(FALSE); + 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 TRUE; + case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB: + if (buf_page_is_checksum_valid_innodb(read_buf, checksum_field1, + checksum_field2)) { + return FALSE; + } - return(FALSE); + return TRUE; + case SRV_CHECKSUM_ALGORITHM_STRICT_NONE: + if (buf_page_is_checksum_valid_none(read_buf, checksum_field1, + checksum_field2)) { + 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 TRUE; + case SRV_CHECKSUM_ALGORITHM_CRC32: + case SRV_CHECKSUM_ALGORITHM_INNODB: + /* Verify old versions of InnoDB only stored 8 byte lsn to the + start and end of the page. */ - return(FALSE); - } + /* Since innodb_checksum_algorithm is not strict_* allow + any of the algos to match for the old field. */ - return(TRUE); + if (checksum_field2 + != mach_read_from_4(read_buf + FIL_PAGE_LSN) + && checksum_field2 != BUF_NO_CHECKSUM_MAGIC) { - case SRV_CHECKSUM_ALGORITHM_INNODB: - case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB: + if (srv_checksum_algorithm + == SRV_CHECKSUM_ALGORITHM_CRC32) { - 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) { - page_warn_strict_checksum( - curr_algo, - SRV_CHECKSUM_ALGORITHM_NONE, - space_id, page_no); - } + 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); - return(FALSE); - } + if (checksum_field2 + != buf_calc_page_old_checksum(read_buf)) { - 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); - } + crc32 = buf_calc_page_crc32(read_buf); + crc32_inited = TRUE; - return(FALSE); + if (checksum_field2 != crc32) { + return TRUE; + } + } + } } - return(TRUE); + /* Old field is fine, check the new field */ - case SRV_CHECKSUM_ALGORITHM_STRICT_NONE: + if (checksum_field1 != 0 + && checksum_field1 != BUF_NO_CHECKSUM_MAGIC) { - 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 (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_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; - /* no default so the compiler will emit a warning if new enum - is added and not handled here */ + ut_error; } - ut_error; - return(FALSE); + return FALSE; } /** Dump a page to stderr. diff --git a/storage/innobase/include/page0page.h b/storage/innobase/include/page0page.h index 5cbbe30401f..5a572b1f314 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 @@ -1123,19 +1123,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 fcd722f3492..dd1136eb23a 100644 --- a/storage/innobase/page/page0page.cc +++ b/storage/innobase/page/page0page.cc @@ -2807,45 +2807,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 878a0b8728f..f9a4e38064c 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) 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(mach_read_from_4( static_cast(data) + FIL_PAGE_SPACE_OR_CHKSUM)); - ulint page_no MY_ATTRIBUTE((unused)) = - mach_read_from_4(static_cast - (data) + FIL_PAGE_OFFSET); - ulint space_id MY_ATTRIBUTE((unused)) = - mach_read_from_4(static_cast - (data) + FIL_PAGE_SPACE_ID); - #if FIL_PAGE_LSN % 8 #error "FIL_PAGE_LSN must be 64 bit aligned" #endif @@ -4974,97 +4965,31 @@ page_zip_verify_checksum( switch (curr_algo) { case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32: - case SRV_CHECKSUM_ALGORITHM_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(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); + return TRUE; } crc32 = static_cast(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(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(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 2d9c47e7ad8..aaaf486dddb 100644 --- a/storage/xtradb/buf/buf0buf.cc +++ b/storage/xtradb/buf/buf0buf.cc @@ -653,6 +653,8 @@ buf_page_is_corrupted( ulint checksum_field1; ulint checksum_field2; + ib_uint32_t crc32 = ULINT32_UNDEFINED; + bool crc32_inited = false; if (!zip_size && memcmp(read_buf + FIL_PAGE_LSN + 4, @@ -732,120 +734,124 @@ buf_page_is_corrupted( return(FALSE); } - ulint page_no = mach_read_from_4(read_buf + FIL_PAGE_OFFSET); - ulint space_id = mach_read_from_4(read_buf + FIL_PAGE_SPACE_ID); const srv_checksum_algorithm_t curr_algo = static_cast(srv_checksum_algorithm); switch (curr_algo) { - case SRV_CHECKSUM_ALGORITHM_CRC32: case SRV_CHECKSUM_ALGORITHM_STRICT_CRC32: - - if (buf_page_is_checksum_valid_crc32(read_buf, - checksum_field1, checksum_field2)) { - return(FALSE); + 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 TRUE; - return(FALSE); + 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_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_STRICT_NONE: + if (buf_page_is_checksum_valid_none(read_buf, checksum_field1, + checksum_field2)) { + return FALSE; } - return(TRUE); - + return TRUE; + case SRV_CHECKSUM_ALGORITHM_CRC32: case SRV_CHECKSUM_ALGORITHM_INNODB: - case SRV_CHECKSUM_ALGORITHM_STRICT_INNODB: + /* Verify old versions of InnoDB only stored 8 byte lsn to the + start and end of the page. */ - if (buf_page_is_checksum_valid_innodb(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 (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); - } + if (checksum_field2 + != mach_read_from_4(read_buf + FIL_PAGE_LSN) + && checksum_field2 != BUF_NO_CHECKSUM_MAGIC) { - return(FALSE); - } + if (srv_checksum_algorithm + == SRV_CHECKSUM_ALGORITHM_CRC32) { - 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); - } + crc32 = buf_calc_page_crc32(read_buf); + crc32_inited = true; - return(FALSE); - } + 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); - return(TRUE); + if (checksum_field2 + != buf_calc_page_old_checksum(read_buf)) { - case SRV_CHECKSUM_ALGORITHM_STRICT_NONE: + crc32 = buf_calc_page_crc32(read_buf); + crc32_inited = TRUE; - if (buf_page_is_checksum_valid_none(read_buf, - checksum_field1, checksum_field2)) { - return(FALSE); + 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 */ - 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 != 0 + && checksum_field1 != BUF_NO_CHECKSUM_MAGIC) { + + 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; + } + } + } } - return(TRUE); + if (crc32_inited + && ((checksum_field1 == crc32 + && checksum_field2 != crc32) + || (checksum_field1 != crc32 + && checksum_field2 == crc32))) { + return TRUE; + } - case SRV_CHECKSUM_ALGORITHM_NONE: - /* should have returned FALSE earlier */ break; - /* no default so the compiler will emit a warning if new enum - is added and not handled here */ + case SRV_CHECKSUM_ALGORITHM_NONE: + ut_error; } - ut_error; - return(FALSE); + return FALSE; } /** Dump a page to stderr. 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 518400a9bf0..76c41941b08 100644 --- a/storage/xtradb/page/page0page.cc +++ b/storage/xtradb/page/page0page.cc @@ -2814,49 +2814,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 0d2bb7fb986..b9b05db24cc 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, SkySQL Ab. All Rights Reserved. +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 @@ -4934,10 +4934,6 @@ page_zip_verify_checksum( stored = static_cast(mach_read_from_4( static_cast(data) + FIL_PAGE_SPACE_OR_CHKSUM)); - ulint page_no = mach_read_from_4(static_cast (data) + FIL_PAGE_OFFSET); - ulint space_id = mach_read_from_4(static_cast - (data) + FIL_PAGE_SPACE_ID); - #if FIL_PAGE_LSN % 8 #error "FIL_PAGE_LSN must be 64 bit aligned" #endif @@ -4974,97 +4970,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(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(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(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(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); } -- cgit v1.2.1 From 5ab91f5914cd632a0615c071e38a1bfff4371303 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 13 Dec 2018 12:15:18 +0200 Subject: Remove space before #ifdef --- sql/sql_statistics.cc | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc index 2a90269e532..a2e6621055d 100644 --- a/sql/sql_statistics.cc +++ b/sql/sql_statistics.cc @@ -3601,10 +3601,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; @@ -3931,9 +3931,6 @@ bool is_stat_table(const char *db, const char *table) bool is_eits_usable(Field *field) { - #ifdef WITH_PARTITION_STORAGE_ENGINE - partition_info *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 @@ -3942,12 +3939,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) - #ifdef WITH_PARTITION_STORAGE_ENGINE - && (!part_info || !part_info->field_in_partition_expr(field)) //(3) - #endif - ) - 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; } -- cgit v1.2.1 From 8e613458e1ad797b5e2c7870ffe1c3d5100dbbee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 13 Dec 2018 12:36:57 +0200 Subject: Fix cmake -DWITH_PARTITION_STORAGE_ENGINE:BOOL=OFF This is a backport of a part of commit 18455ec3f1a9c22977f0ed87233852813b53eb49 from 10.1. --- sql/partition_info.cc | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/sql/partition_info.cc b/sql/partition_info.cc index 9d7d0d92686..e6a30c8a7f0 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -2748,23 +2748,6 @@ end: } -bool partition_info::error_if_requires_values() const -{ - switch (part_type) { - case NOT_A_PARTITION: - case HASH_PARTITION: - break; - case RANGE_PARTITION: - my_error(ER_PARTITION_REQUIRES_VALUES_ERROR, MYF(0), "RANGE", "LESS THAN"); - return true; - case LIST_PARTITION: - my_error(ER_PARTITION_REQUIRES_VALUES_ERROR, MYF(0), "LIST", "IN"); - return true; - } - return false; -} - - /** Fix partition data from parser. @@ -3232,3 +3215,19 @@ bool check_partition_dirs(partition_info *part_info) } #endif /* WITH_PARTITION_STORAGE_ENGINE */ + +bool partition_info::error_if_requires_values() const +{ + switch (part_type) { + case NOT_A_PARTITION: + case HASH_PARTITION: + break; + case RANGE_PARTITION: + my_error(ER_PARTITION_REQUIRES_VALUES_ERROR, MYF(0), "RANGE", "LESS THAN"); + return true; + case LIST_PARTITION: + my_error(ER_PARTITION_REQUIRES_VALUES_ERROR, MYF(0), "LIST", "IN"); + return true; + } + return false; +} -- cgit v1.2.1