From 9d2d80aaceccfb4602c935d6521d59232ca3491c Mon Sep 17 00:00:00 2001 From: Chris Calender Date: Thu, 7 Feb 2019 03:29:12 -0500 Subject: [PATCH 01/12] Update sql_parse.cc Corrected one more "refering" typo. --- sql/sql_parse.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 0dffae47ac8..c496cfc69e2 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -5415,7 +5415,7 @@ static bool execute_rename_table(THD *thd, TABLE_LIST *first_table, 0, 0)) return 1; - /* check if these are refering to temporary tables */ + /* check if these are referring to temporary tables */ table->table= find_temporary_table_for_rename(thd, first_table, table); table->next_local->table= table->table; From 137812c88a418479c7d637f4075712d9f6c6c82f Mon Sep 17 00:00:00 2001 From: FaramosCZ Date: Wed, 28 Nov 2018 15:25:53 +0100 Subject: [PATCH 02/12] Fix USE_AFTER_FREE (CWE-416) swap two lines --- tests/mysql_client_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 4978faafb67..4c8ee07cdd0 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -19390,8 +19390,8 @@ static void test_big_packet() opt_password, current_db, opt_port, opt_unix_socket, 0))) { - mysql_close(mysql_local); fprintf(stderr, "\n connection failed(%s)", mysql_error(mysql_local)); + mysql_close(mysql_local); exit(1); } From 9ff713d33a34d9cdec810e80b5ff23bbf1e21b15 Mon Sep 17 00:00:00 2001 From: FaramosCZ Date: Thu, 29 Nov 2018 15:28:03 +0100 Subject: [PATCH 03/12] Fix resource leak --- extra/mariabackup/backup_copy.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/extra/mariabackup/backup_copy.cc b/extra/mariabackup/backup_copy.cc index a998ebecd41..a270325211e 100644 --- a/extra/mariabackup/backup_copy.cc +++ b/extra/mariabackup/backup_copy.cc @@ -1216,6 +1216,7 @@ copy_or_move_file(const char *src_file_path, if (!directory_exists(dst_dir, true)) { ret = false; + free(link_filepath); goto cleanup; } From 89e390b7ceaa72a73cf4744311b96ec3d93d3806 Mon Sep 17 00:00:00 2001 From: FaramosCZ Date: Thu, 29 Nov 2018 16:08:55 +0100 Subject: [PATCH 04/12] Fix resource leak --- extra/mariabackup/ds_compress.c | 1 + 1 file changed, 1 insertion(+) diff --git a/extra/mariabackup/ds_compress.c b/extra/mariabackup/ds_compress.c index 88f50857362..af848db2f24 100644 --- a/extra/mariabackup/ds_compress.c +++ b/extra/mariabackup/ds_compress.c @@ -384,6 +384,7 @@ create_worker_threads(uint n) return threads; err: + my_free(threads); return NULL; } From 9c9bf9642e5693841375350540530141e1916b36 Mon Sep 17 00:00:00 2001 From: FaramosCZ Date: Tue, 4 Dec 2018 14:45:27 +0100 Subject: [PATCH 05/12] Fix resource leak --- extra/mariabackup/xtrabackup.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index af3fddbc264..e5d2474ba94 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -5327,6 +5327,7 @@ next_file_item_1: fileinfo.name, data)) { os_file_closedir(dbdir); + os_file_closedir(dir); return(FALSE); } } From f704361cd6f43445dbd108d54d1124f6722b4025 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Fri, 22 Mar 2019 15:48:49 +0400 Subject: [PATCH 06/12] Backporting slow log simulation logic details from 10.2 to 10.1 Simulate slow statements only for COM_QUERY and COM_STMT_EXECUTE commands, to exclude mysqld_stmt_prepare() and mysqld_stmt_close() entries from the log, as they are not relevant for log_slow_debug.test. This simplifies the test. --- mysql-test/r/log_slow_debug.result | 13 ++----------- mysql-test/t/log_slow_debug.test | 13 ++----------- sql/sql_parse.cc | 7 +++++-- 3 files changed, 9 insertions(+), 24 deletions(-) diff --git a/mysql-test/r/log_slow_debug.result b/mysql-test/r/log_slow_debug.result index bf803ad0530..a823f4c2b98 100644 --- a/mysql-test/r/log_slow_debug.result +++ b/mysql-test/r/log_slow_debug.result @@ -14,14 +14,6 @@ FROM mysql.slow_log WHERE sql_text NOT LIKE '%debug_dbug%'; END $$ -CREATE PROCEDURE show_slow_log_exclude_ps() -BEGIN -SELECT CONCAT('[slow] ', sql_text) AS sql_text -FROM mysql.slow_log -WHERE sql_text NOT LIKE '%debug_dbug%' - AND sql_text NOT IN ('Prepare','Close stmt'); -END -$$ # # Expect all admin statements in the slow log (ON,DEFAULT) # @@ -41,7 +33,7 @@ PREPARE stmt FROM 'ALTER TABLE t4 MODIFY a INT DEFAULT 1'; EXECUTE stmt; DEALLOCATE PREPARE stmt; DROP TABLE t4; -CALL show_slow_log_exclude_ps(); +CALL show_slow_log(); sql_text [slow] TRUNCATE TABLE mysql.slow_log [slow] CREATE TABLE t1 (a INT) @@ -123,7 +115,7 @@ PREPARE stmt FROM 'ALTER TABLE t4 MODIFY a INT DEFAULT 1'; EXECUTE stmt; DEALLOCATE PREPARE stmt; DROP TABLE t4; -CALL show_slow_log_exclude_ps(); +CALL show_slow_log(); sql_text [slow] TRUNCATE TABLE mysql.slow_log [slow] CREATE TABLE t1 (a INT) @@ -143,4 +135,3 @@ SET @@global.slow_query_log= @org_slow_query_log; SET @@global.log_output= @org_log_output; SET @@global.log_slow_admin_statements= @org_log_slow_admin_statements; DROP PROCEDURE show_slow_log; -DROP PROCEDURE show_slow_log_exclude_ps; diff --git a/mysql-test/t/log_slow_debug.test b/mysql-test/t/log_slow_debug.test index 7945328fee3..35b5b93423d 100644 --- a/mysql-test/t/log_slow_debug.test +++ b/mysql-test/t/log_slow_debug.test @@ -19,14 +19,6 @@ BEGIN WHERE sql_text NOT LIKE '%debug_dbug%'; END $$ -CREATE PROCEDURE show_slow_log_exclude_ps() -BEGIN - SELECT CONCAT('[slow] ', sql_text) AS sql_text - FROM mysql.slow_log - WHERE sql_text NOT LIKE '%debug_dbug%' - AND sql_text NOT IN ('Prepare','Close stmt'); -END -$$ DELIMITER ;$$ @@ -50,7 +42,7 @@ PREPARE stmt FROM 'ALTER TABLE t4 MODIFY a INT DEFAULT 1'; EXECUTE stmt; DEALLOCATE PREPARE stmt; DROP TABLE t4; -CALL show_slow_log_exclude_ps(); +CALL show_slow_log(); --echo # @@ -119,7 +111,7 @@ PREPARE stmt FROM 'ALTER TABLE t4 MODIFY a INT DEFAULT 1'; EXECUTE stmt; DEALLOCATE PREPARE stmt; DROP TABLE t4; -CALL show_slow_log_exclude_ps(); +CALL show_slow_log(); --echo # @@ -132,4 +124,3 @@ SET @@global.slow_query_log= @org_slow_query_log; SET @@global.log_output= @org_log_output; SET @@global.log_slow_admin_statements= @org_log_slow_admin_statements; DROP PROCEDURE show_slow_log; -DROP PROCEDURE show_slow_log_exclude_ps; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 6b289a9fee9..0edb8a3f5a3 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2048,8 +2048,11 @@ void log_slow_statement(THD *thd) if (!thd->enable_slow_log) goto end; // E.g. SP statement - DBUG_EXECUTE_IF("simulate_slow_query", - thd->server_status|= SERVER_QUERY_WAS_SLOW;); + DBUG_EXECUTE_IF("simulate_slow_query", { + if (thd->get_command() == COM_QUERY || + thd->get_command() == COM_STMT_EXECUTE) + thd->server_status|= SERVER_QUERY_WAS_SLOW; + }); if (((thd->server_status & SERVER_QUERY_WAS_SLOW) || ((thd->server_status & From ed643f4bb31d8e5a9c0bc161583b8c9b2a08c26b Mon Sep 17 00:00:00 2001 From: FaramosCZ Date: Thu, 29 Nov 2018 15:59:26 +0100 Subject: [PATCH 07/12] Fix resource leak The 'bitmap_dir' has to be closed when no longer needed --- extra/mariabackup/changed_page_bitmap.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/extra/mariabackup/changed_page_bitmap.cc b/extra/mariabackup/changed_page_bitmap.cc index d5185b18971..d4d3b71f994 100644 --- a/extra/mariabackup/changed_page_bitmap.cc +++ b/extra/mariabackup/changed_page_bitmap.cc @@ -381,6 +381,7 @@ log_online_setup_bitmap_file_range( msg("InnoDB: Error: inconsistent bitmap file " "directory\n"); + os_file_closedir(bitmap_dir); free(bitmap_files->files); return FALSE; } From 07096ada9b51fd48117c17659080b99104cc47c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 25 Mar 2019 17:15:34 +0200 Subject: [PATCH 08/12] Fix the Windows build btr_cur_compress_recommendation(): Backport a change from 10.3. This is a follow-up to commit 1bd98154791d77a44d2afc4bf6eb78f692fb7b5b. --- storage/innobase/include/btr0cur.ic | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/storage/innobase/include/btr0cur.ic b/storage/innobase/include/btr0cur.ic index b1e59651a1d..68c73c48778 100644 --- a/storage/innobase/include/btr0cur.ic +++ b/storage/innobase/include/btr0cur.ic @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1994, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 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 @@ -134,7 +135,7 @@ btr_cur_compress_recommendation( page = btr_cur_get_page(cursor); - LIMIT_OPTIMISTIC_INSERT_DEBUG(page_get_n_recs(page) * 2, + LIMIT_OPTIMISTIC_INSERT_DEBUG(page_get_n_recs(page) * 2U, return(FALSE)); if ((page_get_data_size(page) From b30bbb7d9a1c3855c901b74735660e49ab64a2a8 Mon Sep 17 00:00:00 2001 From: Daniel Bartholomew Date: Mon, 25 Mar 2019 12:53:20 -0400 Subject: [PATCH 09/12] bump the VERSION --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 43f159b8281..65e6c5d921d 100644 --- a/VERSION +++ b/VERSION @@ -1,3 +1,3 @@ MYSQL_VERSION_MAJOR=10 MYSQL_VERSION_MINOR=2 -MYSQL_VERSION_PATCH=23 +MYSQL_VERSION_PATCH=24 From 6fbbb0853e7e58621f73f0afc600cd95995413ed Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Tue, 26 Mar 2019 11:37:18 +0400 Subject: [PATCH 10/12] MDEV-18968 Both (WHERE 0.1) and (WHERE NOT 0.1) return empty set --- mysql-test/r/func_group.result | 8 ++++---- mysql-test/r/type_decimal.result | 20 ++++++++++++++++++++ mysql-test/t/type_decimal.test | 21 +++++++++++++++++++++ sql/item.h | 7 +++++++ sql/item_cmpfunc.cc | 2 +- sql/item_func.cc | 12 ------------ sql/item_func.h | 1 - sql/sql_select.cc | 4 ++-- 8 files changed, 55 insertions(+), 20 deletions(-) diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index e0e870d1573..b9875faacb6 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -1979,8 +1979,8 @@ FROM t2); MIN(t2.pk) NULL Warnings: -Warning 1292 Truncated incorrect INTEGER value: 'j' -Warning 1292 Truncated incorrect INTEGER value: 'j' +Warning 1292 Truncated incorrect DOUBLE value: 'j' +Warning 1292 Truncated incorrect DOUBLE value: 'j' EXPLAIN SELECT MIN(t2.pk) @@ -1993,8 +1993,8 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 Warnings: -Warning 1292 Truncated incorrect INTEGER value: 'j' -Warning 1292 Truncated incorrect INTEGER value: 'j' +Warning 1292 Truncated incorrect DOUBLE value: 'j' +Warning 1292 Truncated incorrect DOUBLE value: 'j' # # 2) Test that subquery materialization is setup for query with diff --git a/mysql-test/r/type_decimal.result b/mysql-test/r/type_decimal.result index e515326e851..c9adf6a4f88 100644 --- a/mysql-test/r/type_decimal.result +++ b/mysql-test/r/type_decimal.result @@ -1019,3 +1019,23 @@ cast('-0.0' as decimal(5,1)) < 0 # # End of 5.5 tests # +# +# Start of 10.1 tests +# +# +# MDEV-18968 Both (WHERE 0.1) and (WHERE NOT 0.1) return empty set +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (10); +SELECT CASE WHEN 0.1 THEN 'TRUE' ELSE 'FALSE' END FROM t1; +CASE WHEN 0.1 THEN 'TRUE' ELSE 'FALSE' END +TRUE +SELECT * FROM t1 WHERE 0.1; +a +10 +SELECT * FROM t1 WHERE NOT 0.1; +a +DROP TABLE t1; +# +# End of 10.1 tests +# diff --git a/mysql-test/t/type_decimal.test b/mysql-test/t/type_decimal.test index 834fd0c5327..4a4b3d52884 100644 --- a/mysql-test/t/type_decimal.test +++ b/mysql-test/t/type_decimal.test @@ -612,3 +612,24 @@ select cast('-0.0' as decimal(5,1)) < 0; --echo # --echo # End of 5.5 tests --echo # + + +--echo # +--echo # Start of 10.1 tests +--echo # + +--echo # +--echo # MDEV-18968 Both (WHERE 0.1) and (WHERE NOT 0.1) return empty set +--echo # + +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (10); +SELECT CASE WHEN 0.1 THEN 'TRUE' ELSE 'FALSE' END FROM t1; +SELECT * FROM t1 WHERE 0.1; +SELECT * FROM t1 WHERE NOT 0.1; +DROP TABLE t1; + + +--echo # +--echo # End of 10.1 tests +--echo # diff --git a/sql/item.h b/sql/item.h index 79cde008946..75ebcdb624c 100644 --- a/sql/item.h +++ b/sql/item.h @@ -1000,6 +1000,13 @@ public: virtual bool val_bool(); virtual String *val_nodeset(String*) { return 0; } + bool eval_const_cond() + { + DBUG_ASSERT(const_item()); + DBUG_ASSERT(!is_expensive()); + return val_bool(); + } + /* save_val() is method of val_* family which stores value in the given field. diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 2c1320f82b3..28e94275c85 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -4667,7 +4667,7 @@ Item_cond::fix_fields(THD *thd, Item **ref) if (item->const_item() && !item->with_param && !item->is_expensive() && !cond_has_datetime_is_null(item)) { - if (item->val_int() == is_and_cond && top_level()) + if (item->eval_const_cond() == is_and_cond && top_level()) { /* a. This is "... AND true_cond AND ..." diff --git a/sql/item_func.cc b/sql/item_func.cc index 169eb76d802..e995903b940 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -68,18 +68,6 @@ bool check_reserved_words(LEX_STRING *name) } -/** - @return - TRUE if item is a constant -*/ - -bool -eval_const_cond(COND *cond) -{ - return ((Item_func*) cond)->val_int() ? TRUE : FALSE; -} - - /** Test if the sum of arguments overflows the ulonglong range. */ diff --git a/sql/item_func.h b/sql/item_func.h index e3eab02f213..c387c56f3b4 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -2279,7 +2279,6 @@ extern enum_field_types agg_field_type(Item **items, uint nitems, Item *find_date_time_item(Item **args, uint nargs, uint col); double my_double_round(double value, longlong dec, bool dec_unsigned, bool truncate); -bool eval_const_cond(COND *cond); extern bool volatile mqh_used; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 280de2b2ef1..62365f48404 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -15644,7 +15644,7 @@ Item::remove_eq_conds(THD *thd, Item::cond_result *cond_value, bool top_level_ar { if (const_item() && !is_expensive()) { - *cond_value= eval_const_cond(this) ? Item::COND_TRUE : Item::COND_FALSE; + *cond_value= eval_const_cond() ? Item::COND_TRUE : Item::COND_FALSE; return (COND*) 0; } *cond_value= Item::COND_OK; @@ -15658,7 +15658,7 @@ Item_bool_func2::remove_eq_conds(THD *thd, Item::cond_result *cond_value, { if (const_item() && !is_expensive()) { - *cond_value= eval_const_cond(this) ? Item::COND_TRUE : Item::COND_FALSE; + *cond_value= eval_const_cond() ? Item::COND_TRUE : Item::COND_FALSE; return (COND*) 0; } if ((*cond_value= eq_cmp_result()) != Item::COND_OK) From 065ba53ccbf3ab468408dc5a5dbcb3741750a02d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 26 Mar 2019 13:51:15 +0200 Subject: [PATCH 11/12] MDEV-12711 mariabackup --backup is refused for multi-file system tablespace Before MDEV-12113 (MariaDB Server 10.1.25), on shutdown InnoDB would write the current LSN to the first page of each file of the system tablespace. This is incompatible with MariaDB's InnoDB table encryption, because encryption repurposed the field for an encryption key ID and checksum. buf_page_is_corrupted(): For the InnoDB system tablespace, skip FIL_PAGE_FILE_FLUSH_LSN when checking if a page is all zero, because the first page of each file in the system tablespace can contain nonzero bytes in the field. --- .../mariabackup/absolute_ibdata_paths.opt | 2 +- .../mariabackup/absolute_ibdata_paths.test | 26 +++++++++++++-- storage/innobase/buf/buf0buf.cc | 33 +++++++++++++------ storage/xtradb/buf/buf0buf.cc | 31 +++++++++++------ 4 files changed, 68 insertions(+), 24 deletions(-) diff --git a/mysql-test/suite/mariabackup/absolute_ibdata_paths.opt b/mysql-test/suite/mariabackup/absolute_ibdata_paths.opt index 52b6b743ac8..28848b9b086 100644 --- a/mysql-test/suite/mariabackup/absolute_ibdata_paths.opt +++ b/mysql-test/suite/mariabackup/absolute_ibdata_paths.opt @@ -1 +1 @@ ---innodb --innodb-data-home-dir= --innodb-data-file-path=$MYSQLTEST_VARDIR/tmp/absolute_path_ibdata1:3M;ibdata_second:1M:autoextend \ No newline at end of file +--innodb --innodb-data-home-dir= --innodb-data-file-path=$MYSQLTEST_VARDIR/tmp/absolute_path_ibdata1:6M;ibdata_second:1M:autoextend diff --git a/mysql-test/suite/mariabackup/absolute_ibdata_paths.test b/mysql-test/suite/mariabackup/absolute_ibdata_paths.test index 6717f16d199..fa304f0bc55 100644 --- a/mysql-test/suite/mariabackup/absolute_ibdata_paths.test +++ b/mysql-test/suite/mariabackup/absolute_ibdata_paths.test @@ -2,12 +2,32 @@ # Innodb system tablespace is specified with absolute path in the .opt file CREATE TABLE t(i INT) ENGINE INNODB; INSERT INTO t VALUES(1); + +let INNODB_PAGE_SIZE=`select @@innodb_page_size`; +let MYSQLD_DATADIR= `SELECT @@datadir`; +--source include/shutdown_mysqld.inc +perl; +my $file= "$ENV{MYSQLD_DATADIR}/ibdata_second"; +open(FILE, "+<", $file) or die "Unable to open $file\n"; +binmode FILE; +my $ps= $ENV{INNODB_PAGE_SIZE}; +my $page; +my $pos = $ps * 0; +sysseek(FILE, $pos, 0) || die "Unable to seek $file\n"; +die "Unable to read $file" unless sysread(FILE, $page, $ps) == $ps; +substr($page,26,8) = pack("NN", 1, 1); +sysseek(FILE, $pos, 0) || die "Unable to rewind $file\n"; +syswrite(FILE, $page, $ps)==$ps || die "Unable to write $file\n"; +close(FILE) || die "Unable to close $file\n"; +EOF + +--source include/start_mysqld.inc + echo # xtrabackup backup; let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; let $_innodb_data_file_path=`select @@innodb_data_file_path`; let $_innodb_data_home_dir=`select @@innodb_data_home_dir`; -let $_datadir= `SELECT @@datadir`; --disable_result_log exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir; @@ -16,11 +36,11 @@ exec $XTRABACKUP --prepare --target-dir=$targetdir; --source include/shutdown_mysqld.inc echo # remove datadir; -rmdir $_datadir; +rmdir $MYSQLD_DATADIR; #remove out-of-datadir ibdata1 remove_file $MYSQLTEST_VARDIR/tmp/absolute_path_ibdata1; echo # xtrabackup copy back; -exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --copy-back --datadir=$_datadir --target-dir=$targetdir "--innodb_data_file_path=$_innodb_data_file_path" --innodb_data_home_dir=$_innodb_data_home_dir; +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --copy-back --datadir=$MYSQLD_DATADIR --target-dir=$targetdir "--innodb_data_file_path=$_innodb_data_file_path" --innodb_data_home_dir=$_innodb_data_home_dir; echo # restart server; --source include/start_mysqld.inc --enable_result_log diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 621433c1c5c..78200198e62 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -946,18 +946,31 @@ buf_page_is_corrupted( #error "FIL_PAGE_LSN must be 64 bit aligned" #endif - /* declare empty pages non-corrupted */ - if (checksum_field1 == 0 && checksum_field2 == 0 - && *reinterpret_cast(read_buf + - FIL_PAGE_LSN) == 0) { - /* make sure that the page is really empty */ - for (ulint i = 0; i < UNIV_PAGE_SIZE; i++) { - if (read_buf[i] != 0) { - return(true); + /* A page filled with NUL bytes is considered not corrupted. + The FIL_PAGE_FILE_FLUSH_LSN field may be written nonzero for + the first page of each file of the system tablespace. + Ignore it for the system tablespace. */ + if (!checksum_field1 && !checksum_field2) { + ulint i = 0; + do { + if (read_buf[i]) { + return true; } - } + } while (++i < FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION); - return(false); +#ifndef UNIV_INNOCHECKSUM + if (!space || !space->id) { + /* Skip FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION + in the system tablespace. */ + i += 8; + } +#endif + do { + if (read_buf[i]) { + return true; + } + } while (++i < srv_page_size); + return false; } switch (curr_algo) { diff --git a/storage/xtradb/buf/buf0buf.cc b/storage/xtradb/buf/buf0buf.cc index f4ef3ca7015..773b528b40d 100644 --- a/storage/xtradb/buf/buf0buf.cc +++ b/storage/xtradb/buf/buf0buf.cc @@ -945,18 +945,29 @@ buf_page_is_corrupted( #error "FIL_PAGE_LSN must be 64 bit aligned" #endif - /* declare empty pages non-corrupted */ - if (checksum_field1 == 0 && checksum_field2 == 0 - && *reinterpret_cast(read_buf + - FIL_PAGE_LSN) == 0) { - /* make sure that the page is really empty */ - for (ulint i = 0; i < UNIV_PAGE_SIZE; i++) { - if (read_buf[i] != 0) { - return(true); + /* A page filled with NUL bytes is considered not corrupted. + The FIL_PAGE_FILE_FLUSH_LSN field may be written nonzero for + the first page of each file of the system tablespace. + Ignore it for the system tablespace. */ + if (!checksum_field1 && !checksum_field2) { + ulint i = 0; + do { + if (read_buf[i]) { + return true; } - } + } while (++i < FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION); - return(false); + if (!space || !space->id) { + /* Skip FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION + in the system tablespace. */ + i += 8; + } + do { + if (read_buf[i]) { + return true; + } + } while (++i < srv_page_size); + return false; } switch (curr_algo) { From f2c1c9590c7d5bdff0d7c95985cb1a5154a96786 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 26 Mar 2019 14:57:33 +0200 Subject: [PATCH 12/12] Fix cmake -DENABLED_PROFILING=OFF --- sql/sql_parse.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index e3f183e3e42..1f060305d4f 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2017, Oracle and/or its affiliates. - Copyright (c) 2008, 2018, MariaDB + Copyright (c) 2008, 2019, MariaDB 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 @@ -3016,8 +3016,10 @@ mysql_execute_command(THD *thd) else { WSREP_SYNC_WAIT(thd, WSREP_SYNC_WAIT_BEFORE_SHOW); +#ifdef ENABLED_PROFILING if (lex->sql_command == SQLCOM_SHOW_PROFILE) thd->profiling.discard_current_query(); +#endif } thd->status_var.last_query_cost= 0.0;