diff options
70 files changed, 957 insertions, 726 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d759fb744a..ed45c8f01a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -221,7 +221,7 @@ ENDIF() OPTION(WITH_UBSAN "Enable undefined behavior sanitizer" OFF) IF (WITH_UBSAN) - MY_CHECK_AND_SET_COMPILER_FLAG("-fsanitize=undefined -fno-sanitize=alignment -U_FORTIFY_SOURCE" DEBUG RELWITHDEBINFO) + MY_CHECK_AND_SET_COMPILER_FLAG("-fsanitize=undefined -fno-sanitize=alignment -U_FORTIFY_SOURCE -DWITH_UBSAN" DEBUG RELWITHDEBINFO) ENDIF() OPTION(WITH_MSAN "Enable memory sanitizer" OFF) diff --git a/include/my_pthread.h b/include/my_pthread.h index 9802e43e97d..acac64790ce 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2014, Oracle and/or its affiliates. - Copyright (c) 2009, 2019, MariaDB Corporation. + Copyright (c) 2009, 2020, 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 @@ -693,7 +693,7 @@ extern void my_mutex_end(void); We need to have at least 256K stack to handle calls to myisamchk_init() with the current number of keys and key parts. */ -#ifdef __SANITIZE_ADDRESS__ +#if defined(__SANITIZE_ADDRESS__) || defined(WITH_UBSAN) #define DEFAULT_THREAD_STACK (383*1024L) /* 392192 */ #else #define DEFAULT_THREAD_STACK (292*1024L) /* 299008 */ diff --git a/include/span.h b/include/span.h new file mode 100644 index 00000000000..0ed0158088c --- /dev/null +++ b/include/span.h @@ -0,0 +1,141 @@ +/***************************************************************************** + +Copyright (c) 2019, 2020 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 +Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA + +*****************************************************************************/ + +#pragma once + +#include <cstddef> +#include <iterator> + +namespace st_ +{ + +template <class ElementType> class span +{ +public: + typedef ElementType element_type; + typedef ElementType value_type; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef element_type *pointer; + typedef const element_type *const_pointer; + typedef element_type &reference; + typedef const element_type &const_reference; + typedef pointer iterator; + typedef const_pointer const_iterator; + typedef std::reverse_iterator<iterator> reverse_iterator; + typedef std::reverse_iterator<const_iterator> const_reverse_iterator; + + span() : data_(NULL), size_(0) {} + + span(pointer ptr, size_type count) : data_(ptr), size_(count) {} + + span(pointer first, pointer last) : data_(first), size_(last - first) {} + + template <size_t N> span(element_type (&arr)[N]) : data_(arr), size_(N) {} + + template <class Container> + span(Container &cont) : data_(cont.data()), size_(cont.size()) + { + } + + template <class Container> + span(const Container &cont) : data_(cont.data()), size_(cont.size()) + { + } + + span(const span &other) : data_(other.data_), size_(other.size_) {} + + ~span(){}; + + span &operator=(const span &other) + { + data_= other.data_; + size_= other.size_; + return *this; + } + + template <size_t Count> span<element_type> first() const + { + assert(!empty()); + return span(data_, 1); + } + template <size_t Count> span<element_type> last() const + { + assert(!empty()); + return span(data_ + size() - 1, 1); + } + + span<element_type> first(size_type count) const + { + assert(!empty()); + return span(data_, 1); + } + span<element_type> last(size_type count) const + { + assert(!empty()); + return span(data_ + size() - 1, 1); + } + span<element_type> subspan(size_type offset, size_type count) const + { + assert(!empty()); + assert(size() >= offset + count); + return span(data_ + offset, count); + } + + size_type size() const { return size_; } + size_type size_bytes() const { return size_ * sizeof(ElementType); } + bool empty() const __attribute__((warn_unused_result)) { return size_ == 0; } + + reference operator[](size_type idx) const + { + assert(size() > idx); + return data_[idx]; + } + reference front() const + { + assert(!empty()); + return data_[0]; + } + reference back() const + { + assert(!empty()); + return data_[size() - 1]; + } + pointer data() const + { + assert(!empty()); + return data_; + } + + iterator begin() const { return data_; } + iterator end() const { return data_ + size_; } + reverse_iterator rbegin() const + { + return std::reverse_iterator<iterator>(std::advance(end(), -1)); + } + reverse_iterator rend() const + { + return std::reverse_iterator<iterator>(std::advance(begin(), -1)); + } + +private: + pointer data_; + size_type size_; +}; + +} // namespace st_ diff --git a/mysql-test/include/io_thd_fault_injection.inc b/mysql-test/include/io_thd_fault_injection.inc index 11479b3a66c..67b41371913 100644 --- a/mysql-test/include/io_thd_fault_injection.inc +++ b/mysql-test/include/io_thd_fault_injection.inc @@ -1,20 +1,19 @@ # # Takes the flag as an argument: -# -- let $io_thd_injection_fault_flag=+d,fault_injection_new_file_rotate_event +# -- let $io_thd_injection_fault_flag=d,fault_injection_new_file_rotate_event # -- source include/io_thd_fault_injection.inc # -SET @old_debug=@@global.debug; +SET @saved_debug=@@global.debug_dbug; -- disable_warnings -- source include/stop_slave.inc -- enable_warnings --- eval SET GLOBAL debug_dbug="+d,$io_thd_injection_fault_flag" +-- eval SET @@global.debug_dbug="d,$io_thd_injection_fault_flag" START SLAVE io_thread; -- source include/wait_for_slave_io_error.inc --- eval SET GLOBAL debug_dbug="-d,$io_thd_injection_fault_flag" -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@saved_debug; # restart because slave is in bad shape --let $rpl_server_number= 2 diff --git a/mysql-test/main/derived_cond_pushdown.result b/mysql-test/main/derived_cond_pushdown.result index 532a6cc77ff..bd632e39dfc 100644 --- a/mysql-test/main/derived_cond_pushdown.result +++ b/mysql-test/main/derived_cond_pushdown.result @@ -10598,6 +10598,18 @@ a b max_c a b dayname(v1.b) DROP VIEW v1; DROP TABLE t1, t2; SET optimizer_switch=DEFAULT; +# +# MDEV-17177: an attempt to push down IN predicate when one of +# the arguments is too complex to be cloned +# +CREATE TABLE t1 (a VARCHAR(8)); +INSERT INTO t1 VALUES ('abc'),('def'); +CREATE VIEW v1 AS SELECT * FROM t1 GROUP BY a; +SELECT * FROM v1 WHERE IF( a REGEXP 'def', 'foo', a ) IN ('abc', 'foobar'); +a +abc +DROP VIEW v1; +DROP TABLE t1; # End of 10.2 tests # # MDEV-14579: pushdown conditions into materialized views/derived tables diff --git a/mysql-test/main/derived_cond_pushdown.test b/mysql-test/main/derived_cond_pushdown.test index 592f23debb4..c98330da07d 100644 --- a/mysql-test/main/derived_cond_pushdown.test +++ b/mysql-test/main/derived_cond_pushdown.test @@ -2169,6 +2169,22 @@ DROP TABLE t1, t2; SET optimizer_switch=DEFAULT; + + +--echo # +--echo # MDEV-17177: an attempt to push down IN predicate when one of +--echo # the arguments is too complex to be cloned +--echo # + +CREATE TABLE t1 (a VARCHAR(8)); +INSERT INTO t1 VALUES ('abc'),('def'); +CREATE VIEW v1 AS SELECT * FROM t1 GROUP BY a; + +SELECT * FROM v1 WHERE IF( a REGEXP 'def', 'foo', a ) IN ('abc', 'foobar'); + +DROP VIEW v1; +DROP TABLE t1; + --echo # End of 10.2 tests --echo # diff --git a/mysql-test/main/group_by.result b/mysql-test/main/group_by.result index 99e843b732b..2e5f545a67b 100644 --- a/mysql-test/main/group_by.result +++ b/mysql-test/main/group_by.result @@ -2863,6 +2863,20 @@ GROUP BY REPEAT((BINARY pk), v1), AES_DECRYPT((@A := i1), 20852) WITH ROLLUP HAV 1 drop table t1; # +# MDEV-22019: Sig 11 in next_breadth_first_tab | max_sort_length setting + double +# GROUP BY leads to crash +# +CALL mtr.add_suppression("Out of sort memory"); +CALL mtr.add_suppression("Sort aborted"); +SET @save_max_sort_length= @@max_sort_length; +SET max_sort_length=2000000; +SELECT * FROM information_schema.tables t JOIN information_schema.columns c +ON t.table_schema=c.table_schema +WHERE c.table_schema=(SELECT COUNT(*) FROM INFORMATION_SCHEMA.columns GROUP BY column_type) +GROUP BY t.table_name; +ERROR HY001: Out of sort memory, consider increasing server sort buffer size +SET max_sort_length= @save_max_sort_length; +# # MDEV-16170 # Server crashes in Item_null_result::type_handler on SELECT with ROLLUP # @@ -2873,3 +2887,4 @@ f COUNT(*) 1 1 NULL 1 DROP TABLE t1; +# End of 10.3 tests diff --git a/mysql-test/main/group_by.test b/mysql-test/main/group_by.test index 7b79e6caac1..22feed8d6f2 100644 --- a/mysql-test/main/group_by.test +++ b/mysql-test/main/group_by.test @@ -1981,6 +1981,23 @@ GROUP BY REPEAT((BINARY pk), v1), AES_DECRYPT((@A := i1), 20852) WITH ROLLUP HAV drop table t1; --echo # +--echo # MDEV-22019: Sig 11 in next_breadth_first_tab | max_sort_length setting + double +--echo # GROUP BY leads to crash +--echo # + + +CALL mtr.add_suppression("Out of sort memory"); +CALL mtr.add_suppression("Sort aborted"); +SET @save_max_sort_length= @@max_sort_length; +SET max_sort_length=2000000; +--error ER_OUT_OF_SORTMEMORY +SELECT * FROM information_schema.tables t JOIN information_schema.columns c +ON t.table_schema=c.table_schema +WHERE c.table_schema=(SELECT COUNT(*) FROM INFORMATION_SCHEMA.columns GROUP BY column_type) +GROUP BY t.table_name; +SET max_sort_length= @save_max_sort_length; + +--echo # --echo # MDEV-16170 --echo # Server crashes in Item_null_result::type_handler on SELECT with ROLLUP --echo # @@ -1989,3 +2006,5 @@ CREATE TABLE t1 (d DATE); INSERT INTO t1 VALUES ('2032-10-08'); SELECT d != '2023-03-04' AS f, COUNT(*) FROM t1 GROUP BY d WITH ROLLUP; DROP TABLE t1; + +--echo # End of 10.3 tests diff --git a/mysql-test/suite/binlog_encryption/rpl_binlog_errors.result b/mysql-test/suite/binlog_encryption/rpl_binlog_errors.result index eb58dd06997..c8a10577517 100644 --- a/mysql-test/suite/binlog_encryption/rpl_binlog_errors.result +++ b/mysql-test/suite/binlog_encryption/rpl_binlog_errors.result @@ -22,7 +22,7 @@ master-bin.000001 # master-bin.000002 # ###################### TEST #2 RESET MASTER; -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; FLUSH LOGS; ERROR HY000: Can't generate a unique log-filename master-bin.(1-999) @@ -30,7 +30,7 @@ ERROR HY000: Can't generate a unique log-filename master-bin.(1-999) show binary logs; Log_name File_size master-bin.000001 # -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; RESET MASTER; ###################### TEST #3 CREATE TABLE t1 (a INT); @@ -44,11 +44,11 @@ show binary logs; Log_name File_size master-bin.000001 # master-bin.000002 # -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; DELETE FROM t2; RESET MASTER; ###################### TEST #4 -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug_46166.data' INTO TABLE t2; ERROR HY000: Can't generate a unique log-filename master-bin.(1-999) @@ -56,21 +56,21 @@ ERROR HY000: Can't generate a unique log-filename master-bin.(1-999) SELECT count(*) FROM t2; count(*) 1 -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; DELETE FROM t2; RESET MASTER; ###################### TEST #5 -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug_46166-2.data' INTO TABLE t2; # assert: must show one entry SELECT count(*) FROM t2; count(*) 1 -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; DELETE FROM t2; RESET MASTER; ###################### TEST #6 -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; SET AUTOCOMMIT=0; INSERT INTO t2 VALUES ('muse'); LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug_46166.data' INTO TABLE t2; @@ -83,11 +83,11 @@ SELECT count(*) FROM t2; count(*) 3 SET AUTOCOMMIT= 1; -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; DELETE FROM t2; RESET MASTER; ###################### TEST #7 -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; SET @@binlog_annotate_row_events= 0; SELECT count(*) FROM t4; count(*) @@ -100,14 +100,14 @@ SELECT count(*) FROM t4; count(*) 1 ### check that the incident event is written to the current log -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Incident # # #1 (LOST_EVENTS) DELETE FROM t4; RESET MASTER; ###################### TEST #8 -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; # must show 0 entries SELECT count(*) FROM t4; count(*) @@ -147,9 +147,9 @@ count(*) SELECT count(*) FROM t2; count(*) 0 -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; ###################### TEST #9 -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; SET SQL_LOG_BIN=0; INSERT INTO t2 VALUES ('aaa'), ('bbb'), ('ccc'), ('ddd'); INSERT INTO t4 VALUES ('eee'), ('fff'), ('ggg'), ('hhh'); @@ -170,17 +170,17 @@ SELECT count(*) FROM t4; count(*) 0 SET SQL_LOG_BIN=1; -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; ###################### TEST #10 call mtr.add_suppression("MYSQL_BIN_LOG::open failed to sync the index file."); call mtr.add_suppression("Could not use .*"); RESET MASTER; SHOW WARNINGS; Level Code Message -SET GLOBAL debug_dbug="+d,fault_injection_registering_index"; +SET @@global.debug_dbug="d,fault_injection_registering_index"; FLUSH LOGS; ERROR HY000: Can't open file: 'master-bin.000002' (errno: 1 "Operation not permitted") -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; SHOW BINARY LOGS; ERROR HY000: You are not using binary logging CREATE TABLE t5 (a INT); @@ -192,10 +192,10 @@ DROP TABLE t5; flush tables; ###################### TEST #11 include/rpl_restart_server.inc [server_number=1] -SET GLOBAL debug_dbug="+d,fault_injection_openning_index"; +SET @@global.debug_dbug="d,fault_injection_openning_index"; FLUSH LOGS; ERROR HY000: Can't open file: 'master-bin.index' (errno: 1 "Operation not permitted") -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; RESET MASTER; ERROR HY000: Binlog closed, cannot RESET MASTER CREATE TABLE t5 (a INT); @@ -207,10 +207,10 @@ DROP TABLE t5; flush tables; include/rpl_restart_server.inc [server_number=1] ###################### TEST #12 -SET GLOBAL debug_dbug="+d,fault_injection_new_file_rotate_event"; +SET @@global.debug_dbug="d,fault_injection_new_file_rotate_event"; FLUSH LOGS; ERROR HY000: Can't open file: 'master-bin' (errno: 2 "No such file or directory") -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; RESET MASTER; ERROR HY000: Binlog closed, cannot RESET MASTER CREATE TABLE t5 (a INT); @@ -237,44 +237,40 @@ call mtr.add_suppression("Could not use .*"); call mtr.add_suppression("MYSQL_BIN_LOG::open failed to sync the index file."); call mtr.add_suppression("Can't generate a unique log-filename .*"); ###################### TEST #13 -SET @old_debug=@@global.debug; +SET @saved_debug=@@global.debug_dbug; include/stop_slave.inc -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; START SLAVE io_thread; include/wait_for_slave_io_error.inc [errno=1595] Last_IO_Error = 'Relay log write failure: could not queue event from master' -SET GLOBAL debug_dbug="-d,error_unique_log_filename"; -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@saved_debug; include/rpl_restart_server.inc [server_number=2] ###################### TEST #14 -SET @old_debug=@@global.debug; +SET @saved_debug=@@global.debug_dbug; include/stop_slave.inc -SET GLOBAL debug_dbug="+d,fault_injection_new_file_rotate_event"; +SET @@global.debug_dbug="d,fault_injection_new_file_rotate_event"; START SLAVE io_thread; include/wait_for_slave_io_error.inc [errno=1595] Last_IO_Error = 'Relay log write failure: could not queue event from master' -SET GLOBAL debug_dbug="-d,fault_injection_new_file_rotate_event"; -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@saved_debug; include/rpl_restart_server.inc [server_number=2] ###################### TEST #15 -SET @old_debug=@@global.debug; +SET @saved_debug=@@global.debug_dbug; include/stop_slave.inc -SET GLOBAL debug_dbug="+d,fault_injection_registering_index"; +SET @@global.debug_dbug="d,fault_injection_registering_index"; START SLAVE io_thread; include/wait_for_slave_io_error.inc [errno=1595] Last_IO_Error = 'Relay log write failure: could not queue event from master' -SET GLOBAL debug_dbug="-d,fault_injection_registering_index"; -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@saved_debug; include/rpl_restart_server.inc [server_number=2] ###################### TEST #16 -SET @old_debug=@@global.debug; +SET @saved_debug=@@global.debug_dbug; include/stop_slave.inc -SET GLOBAL debug_dbug="+d,fault_injection_openning_index"; +SET @@global.debug_dbug="d,fault_injection_openning_index"; START SLAVE io_thread; include/wait_for_slave_io_error.inc [errno=1595] Last_IO_Error = 'Relay log write failure: could not queue event from master' -SET GLOBAL debug_dbug="-d,fault_injection_openning_index"; -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@saved_debug; include/rpl_restart_server.inc [server_number=2] include/stop_slave_sql.inc Warnings: diff --git a/mysql-test/suite/binlog_encryption/rpl_corruption.result b/mysql-test/suite/binlog_encryption/rpl_corruption.result index f32b7c58ad1..73bb373d6be 100644 --- a/mysql-test/suite/binlog_encryption/rpl_corruption.result +++ b/mysql-test/suite/binlog_encryption/rpl_corruption.result @@ -13,42 +13,40 @@ connection master; CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY, b VARCHAR(10), c VARCHAR(100)); include/stop_slave.inc # 2. Corruption in master binlog and SHOW BINLOG EVENTS -set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug="+d,corrupt_read_log_event_char"; +SET @saved_dbug = @@global.debug_dbug; +SET @@global.debug_dbug="d,corrupt_read_log_event_char"; SHOW BINLOG EVENTS; ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Wrong offset or I/O error -SET GLOBAL debug_dbug="-d,corrupt_read_log_event_char"; +SET @@global.debug_dbug=@saved_dbug; # 3. Master read a corrupted event from binlog and send the error to slave -SET GLOBAL debug_dbug="+d,corrupt_read_log_event2_set"; +SET @@global.debug_dbug="d,corrupt_read_log_event2_set"; connection slave; START SLAVE IO_THREAD; include/wait_for_slave_io_error.inc [errno=1236] connection master; -SET GLOBAL debug_dbug="-d,corrupt_read_log_event2_set"; +SET @@global.debug_dbug=@saved_dbug; # 4. Master read a corrupted event from binlog and send it to slave connection master; SET GLOBAL master_verify_checksum=0; -SET GLOBAL debug_dbug="+d,corrupt_read_log_event2_set"; +SET @@global.debug_dbug="d,corrupt_read_log_event2_set"; connection slave; START SLAVE IO_THREAD; include/wait_for_slave_io_error.inc [errno=1595,1743] connection master; -SET GLOBAL debug_dbug="-d,corrupt_read_log_event2_set"; -SET GLOBAL debug_dbug=@saved_dbug; +SET @@global.debug_dbug=@saved_dbug; SET GLOBAL master_verify_checksum=1; # 5. Slave. Corruption in network connection slave; SET @saved_dbug_slave = @@GLOBAL.debug_dbug; -SET GLOBAL debug_dbug="+d,corrupt_queue_event"; +SET @@global.debug_dbug="d,corrupt_queue_event"; START SLAVE IO_THREAD; include/wait_for_slave_io_error.inc [errno=1595,1743] -SET GLOBAL debug_dbug="-d,corrupt_queue_event"; +SET @@global.debug_dbug=@saved_dbug_slave; # 6. Slave. Corruption in relay log -SET GLOBAL debug_dbug="+d,corrupt_read_log_event_char"; +SET @@global.debug_dbug="d,corrupt_read_log_event_char"; START SLAVE SQL_THREAD; include/wait_for_slave_sql_error.inc [errno=1593] -SET GLOBAL debug_dbug="-d,corrupt_read_log_event_char"; -SET GLOBAL debug_dbug=@saved_dbug_slave; +SET @@global.debug_dbug=@saved_dbug_slave; # 7. Seek diff for tables on master and slave connection slave; include/start_slave.inc diff --git a/mysql-test/suite/gcol/r/innodb_virtual_debug_purge.result b/mysql-test/suite/gcol/r/innodb_virtual_debug_purge.result index ffc821b6ecc..e3e5ee6857c 100644 --- a/mysql-test/suite/gcol/r/innodb_virtual_debug_purge.result +++ b/mysql-test/suite/gcol/r/innodb_virtual_debug_purge.result @@ -12,7 +12,7 @@ CREATE TABLE `t` ( INSERT INTO t VALUES (REPEAT('g', 16000), REPEAT('x', 16000), DEFAULT, "kk", 1); INSERT INTO t VALUES (REPEAT('a', 16000), REPEAT('b', 16000), DEFAULT, "mm", 2); CREATE INDEX idx ON t(c(100)); -SET global debug_dbug="+d,ib_purge_virtual_index_callback"; +SET global debug_dbug="d,ib_purge_virtual_index_callback"; UPDATE t SET a = REPEAT('m', 16000) WHERE a like "aaa%"; InnoDB 0 transactions not purged SET global debug_dbug=@old_dbug; @@ -27,7 +27,7 @@ i INT INSERT INTO t VALUES (REPEAT('g', 100), REPEAT('x', 100), DEFAULT, "kk", 1); INSERT INTO t VALUES (REPEAT('a', 100), REPEAT('b', 100), DEFAULT, "mm", 2); CREATE INDEX idx ON t(c(100)); -SET global debug_dbug="+d,ib_purge_virtual_index_callback"; +SET global debug_dbug="d,ib_purge_virtual_index_callback"; UPDATE t SET a = REPEAT('m', 100) WHERE a like "aaa%"; InnoDB 0 transactions not purged SET global debug_dbug=@old_dbug; @@ -48,7 +48,7 @@ insert into t1 values(3, 4, default); insert into t1 values(3, 12, default); insert into t1 values(4, 18, default); CREATE INDEX idx ON t1(x); -SET global debug_dbug="+d,ib_purge_virtual_index_callback"; +SET global debug_dbug="d,ib_purge_virtual_index_callback"; UPDATE t1 SET id = 10 WHERE id = 1; InnoDB 0 transactions not purged SET global debug_dbug=@old_dbug; @@ -138,7 +138,7 @@ DROP TABLE t0, t1; create table t (a blob, b blob, c blob as (concat(a,b)), h varchar(10), index (c(100))); insert t(a,b,h) values (repeat('g', 16000), repeat('x', 16000), "kk"); insert t(a,b,h) values (repeat('a', 16000), repeat('b', 16000), "mm"); -set global debug_dbug="+d,ib_purge_virtual_index_callback"; +set global debug_dbug="d,ib_purge_virtual_index_callback"; connect prevent_purge, localhost, root; start transaction with consistent snapshot; connection default; @@ -181,7 +181,7 @@ CREATE TABLE t1 (y YEAR, vy YEAR AS (y) VIRTUAL UNIQUE, pk INT PRIMARY KEY) ENGINE=InnoDB; INSERT INTO t1 (pk,y) VALUES (1,2022); CREATE TABLE t2(f1 INT NOT NULL, PRIMARY KEY(f1))ENGINE=InnoDB; -SET GLOBAL debug_dbug = '+d,ib_purge_virtual_index_callback'; +SET GLOBAL debug_dbug = 'd,ib_purge_virtual_index_callback'; BEGIN; INSERT INTO t2(f1) VALUES(1); connection prevent_purge; @@ -209,8 +209,8 @@ DROP TABLE t1, t2; # on table with virtual columns and indexes # InnoDB 0 transactions not purged -set @saved_dbug= @@global.debug_dbug; -set global debug_dbug= "+d,ib_purge_virtual_mdev_16222_1,ib_purge_virtual_mdev_16222_2"; +SET @saved_dbug= @@GLOBAL.debug_dbug; +set global debug_dbug= "d,ib_purge_virtual_mdev_16222_1,ib_purge_virtual_mdev_16222_2"; create table t1 ( pk serial, vb tinyblob as (b) virtual, b tinyblob, primary key(pk), index (vb(64))) @@ -219,7 +219,7 @@ insert ignore into t1 (b) values ('foo'); select * into outfile 'load.data' from t1; load data infile 'load.data' replace into table t1; set debug_sync= "now WAIT_FOR latch_released"; -set global debug_dbug= "-d,ib_purge_virtual_mdev_16222_1"; +set global debug_dbug= @saved_dbug; drop table t1; set debug_sync= "now SIGNAL drop_started WAIT_FOR got_no_such_table"; create table t1 ( @@ -255,7 +255,7 @@ SET GLOBAL innodb_debug_sync = "ib_open_after_dict_open " "SIGNAL purge_open " "WAIT_FOR select_open"; SET @saved_dbug= @@GLOBAL.debug_dbug; -set global debug_dbug= "+d,ib_purge_virtual_index_callback"; +set global debug_dbug= "d,ib_purge_virtual_index_callback"; connect purge_waiter,localhost,root; SET debug_sync= "now WAIT_FOR before_row_allocated"; connection default; diff --git a/mysql-test/suite/gcol/t/innodb_virtual_debug_purge.test b/mysql-test/suite/gcol/t/innodb_virtual_debug_purge.test index a384e0667de..69b784d497a 100644 --- a/mysql-test/suite/gcol/t/innodb_virtual_debug_purge.test +++ b/mysql-test/suite/gcol/t/innodb_virtual_debug_purge.test @@ -22,7 +22,7 @@ INSERT INTO t VALUES (REPEAT('a', 16000), REPEAT('b', 16000), DEFAULT, "mm", 2); CREATE INDEX idx ON t(c(100)); -SET global debug_dbug="+d,ib_purge_virtual_index_callback"; +SET global debug_dbug="d,ib_purge_virtual_index_callback"; UPDATE t SET a = REPEAT('m', 16000) WHERE a like "aaa%"; --source ../../innodb/include/wait_all_purged.inc SET global debug_dbug=@old_dbug; @@ -41,7 +41,7 @@ INSERT INTO t VALUES (REPEAT('a', 100), REPEAT('b', 100), DEFAULT, "mm", 2); CREATE INDEX idx ON t(c(100)); -SET global debug_dbug="+d,ib_purge_virtual_index_callback"; +SET global debug_dbug="d,ib_purge_virtual_index_callback"; UPDATE t SET a = REPEAT('m', 100) WHERE a like "aaa%"; --source ../../innodb/include/wait_all_purged.inc SET global debug_dbug=@old_dbug; @@ -68,7 +68,7 @@ insert into t1 values(4, 18, default); CREATE INDEX idx ON t1(x); -SET global debug_dbug="+d,ib_purge_virtual_index_callback"; +SET global debug_dbug="d,ib_purge_virtual_index_callback"; UPDATE t1 SET id = 10 WHERE id = 1; --source ../../innodb/include/wait_all_purged.inc SET global debug_dbug=@old_dbug; @@ -179,7 +179,7 @@ DROP TABLE t0, t1; create table t (a blob, b blob, c blob as (concat(a,b)), h varchar(10), index (c(100))); insert t(a,b,h) values (repeat('g', 16000), repeat('x', 16000), "kk"); insert t(a,b,h) values (repeat('a', 16000), repeat('b', 16000), "mm"); -set global debug_dbug="+d,ib_purge_virtual_index_callback"; +set global debug_dbug="d,ib_purge_virtual_index_callback"; connect(prevent_purge, localhost, root); start transaction with consistent snapshot; connection default; @@ -228,7 +228,7 @@ ENGINE=InnoDB; INSERT INTO t1 (pk,y) VALUES (1,2022); CREATE TABLE t2(f1 INT NOT NULL, PRIMARY KEY(f1))ENGINE=InnoDB; -SET GLOBAL debug_dbug = '+d,ib_purge_virtual_index_callback'; +SET GLOBAL debug_dbug = 'd,ib_purge_virtual_index_callback'; BEGIN; INSERT INTO t2(f1) VALUES(1); @@ -266,8 +266,8 @@ DROP TABLE t1, t2; --source suite/innodb/include/wait_all_purged.inc --let $datadir= `select @@datadir` -set @saved_dbug= @@global.debug_dbug; -set global debug_dbug= "+d,ib_purge_virtual_mdev_16222_1,ib_purge_virtual_mdev_16222_2"; +SET @saved_dbug= @@GLOBAL.debug_dbug; +set global debug_dbug= "d,ib_purge_virtual_mdev_16222_1,ib_purge_virtual_mdev_16222_2"; create table t1 ( pk serial, vb tinyblob as (b) virtual, b tinyblob, @@ -280,7 +280,7 @@ select * into outfile 'load.data' from t1; load data infile 'load.data' replace into table t1; set debug_sync= "now WAIT_FOR latch_released"; -set global debug_dbug= "-d,ib_purge_virtual_mdev_16222_1"; +set global debug_dbug= @saved_dbug; drop table t1; --remove_file $datadir/test/load.data @@ -338,7 +338,7 @@ SET GLOBAL innodb_debug_sync = "ib_open_after_dict_open " # In 10.2 trx_undo_roll_ptr_is_insert(t_roll_ptr) condition never pass in purge, # so this condition is forced to pass in row_vers_old_has_index_entry SET @saved_dbug= @@GLOBAL.debug_dbug; -set global debug_dbug= "+d,ib_purge_virtual_index_callback"; +set global debug_dbug= "d,ib_purge_virtual_index_callback"; # The purge starts from REPLACE command. To avoid possible race, separate # connection is used. diff --git a/mysql-test/suite/innodb/r/corrupted_during_recovery.result b/mysql-test/suite/innodb/r/corrupted_during_recovery.result index ee4db08fc85..951233ced3c 100644 --- a/mysql-test/suite/innodb/r/corrupted_during_recovery.result +++ b/mysql-test/suite/innodb/r/corrupted_during_recovery.result @@ -17,3 +17,19 @@ CHECK TABLE t2; Table Op Msg_type Msg_text test.t2 check status OK DROP TABLE t1, t2; +CREATE TABLE t1(pk SERIAL) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1),(2),(3); +connect con1,localhost,root,,; +BEGIN; +DELETE FROM t1 WHERE pk=1; +connection default; +SET GLOBAL innodb_flush_log_at_trx_commit=1; +DELETE FROM t1 WHERE pk=3; +# Kill the server +disconnect con1; +# Corrupt the pages +SELECT * FROM t1; +pk +1 +2 +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/corrupted_during_recovery.test b/mysql-test/suite/innodb/t/corrupted_during_recovery.test index dad08645085..67f2f2dde40 100644 --- a/mysql-test/suite/innodb/t/corrupted_during_recovery.test +++ b/mysql-test/suite/innodb/t/corrupted_during_recovery.test @@ -62,3 +62,31 @@ SELECT * FROM t2; CHECK TABLE t2; DROP TABLE t1, t2; + +# MDEV-21572 buf_page_get_gen() should apply buffered page +# initialized redo log during recovery +--source ../include/no_checkpoint_start.inc +CREATE TABLE t1(pk SERIAL) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1),(2),(3); +connect (con1,localhost,root,,); +BEGIN; +DELETE FROM t1 WHERE pk=1; +connection default; +SET GLOBAL innodb_flush_log_at_trx_commit=1; +DELETE FROM t1 WHERE pk=3; +--let CLEANUP_IF_CHECKPOINT=DROP TABLE t1; +--source ../include/no_checkpoint_end.inc +disconnect con1; + +--echo # Corrupt the pages +perl; +my $file = "$ENV{MYSQLD_DATADIR}/test/t1.ibd"; +open(FILE, "+<$file") || die "Unable to open $file"; +binmode FILE; +seek (FILE, $ENV{INNODB_PAGE_SIZE} * 3, SEEK_SET) or die "seek"; +print FILE "junk"; +close FILE or die "close"; +EOF +--source include/start_mysqld.inc +SELECT * FROM t1; +DROP TABLE t1; diff --git a/mysql-test/suite/rpl/disabled.def b/mysql-test/suite/rpl/disabled.def index 4f3fb1cd0e3..9b123cda2aa 100644 --- a/mysql-test/suite/rpl/disabled.def +++ b/mysql-test/suite/rpl/disabled.def @@ -11,7 +11,7 @@ ############################################################################## rpl_spec_variables : BUG#11755836 2009-10-27 jasonh rpl_spec_variables fails on PB2 hpux -rpl_get_master_version_and_clock : Bug#11766137 Jan 05 2011 joro Valgrind warnings rpl_get_master_version_and_clock +#rpl_get_master_version_and_clock : Bug#11766137 Jan 05 2011 joro Valgrind warnings rpl_get_master_version_and_clock rpl_partition_archive : MDEV-5077 2013-09-27 svoj Cannot exchange partition with archive table rpl_row_binlog_max_cache_size : MDEV-11092 rpl_row_index_choice : MDEV-11666 diff --git a/mysql-test/suite/rpl/include/rpl_binlog_errors.inc b/mysql-test/suite/rpl/include/rpl_binlog_errors.inc index 72f8bc053e3..7dd09ad1a24 100644 --- a/mysql-test/suite/rpl/include/rpl_binlog_errors.inc +++ b/mysql-test/suite/rpl/include/rpl_binlog_errors.inc @@ -84,14 +84,14 @@ FLUSH LOGS; ### (should show just one binlog) RESET MASTER; -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; -- error ER_NO_UNIQUE_LOGFILE FLUSH LOGS; -- echo # assert: must show one binlog -- source include/show_binary_logs.inc ### ACTION: clean up and move to next test -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; RESET MASTER; -- echo ###################### TEST #3 @@ -116,7 +116,7 @@ RESET MASTER; -- source include/show_binary_logs.inc # clean up the table and the binlog to be used in next part of test -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; DELETE FROM t2; RESET MASTER; @@ -127,7 +127,7 @@ RESET MASTER; ### changes performed despite the fact that it reported an ### error. -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR -- error ER_NO_UNIQUE_LOGFILE -- eval LOAD DATA INFILE '$load_file' INTO TABLE t2 @@ -137,7 +137,7 @@ SET GLOBAL debug_dbug="+d,error_unique_log_filename"; SELECT count(*) FROM t2; # clean up the table and the binlog to be used in next part of test -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; DELETE FROM t2; RESET MASTER; @@ -146,7 +146,7 @@ RESET MASTER; ### ASSERTION: load the small file into a transactional table and ### check that it succeeds -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR -- eval LOAD DATA INFILE '$load_file2' INTO TABLE t2 @@ -155,7 +155,7 @@ SET GLOBAL debug_dbug="+d,error_unique_log_filename"; SELECT count(*) FROM t2; # clean up the table and the binlog to be used in next part of test -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; DELETE FROM t2; RESET MASTER; @@ -166,7 +166,7 @@ RESET MASTER; ### fails we get the error. Transaction is not rolledback ### because rotation happens after the commit. -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; SET AUTOCOMMIT=0; INSERT INTO t2 VALUES ('muse'); -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR @@ -181,7 +181,7 @@ SELECT count(*) FROM t2; ### ACTION: clean up and move to the next test SET AUTOCOMMIT= 1; -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; DELETE FROM t2; RESET MASTER; @@ -191,7 +191,7 @@ RESET MASTER; ### fails then an error is reported and an incident event ### is written to the current binary log. -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; # Disable logging Annotate_rows events to preserve events count. let $binlog_annotate_row_events_saved= `SELECT @@binlog_annotate_row_events`; @@ -206,7 +206,7 @@ SELECT count(*) FROM t4; SELECT count(*) FROM t4; -- echo ### check that the incident event is written to the current log -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; if (!$binlog_limit) { -- let $binlog_limit= 4,1 @@ -227,7 +227,7 @@ RESET MASTER; ### ASSERTION: check that statements end up in error but they succeed ### on changing the data. -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; -- echo # must show 0 entries SELECT count(*) FROM t4; SELECT count(*) FROM t2; @@ -258,13 +258,13 @@ SELECT count(*) FROM t4; SELECT count(*) FROM t2; # remove fault injection -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; -- echo ###################### TEST #9 ### ASSERTION: check that if we disable binlogging, then statements ### succeed. -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; SET SQL_LOG_BIN=0; INSERT INTO t2 VALUES ('aaa'), ('bbb'), ('ccc'), ('ddd'); INSERT INTO t4 VALUES ('eee'), ('fff'), ('ggg'), ('hhh'); @@ -277,7 +277,7 @@ DELETE FROM t4; SELECT count(*) FROM t2; SELECT count(*) FROM t4; SET SQL_LOG_BIN=1; -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; -- echo ###################### TEST #10 @@ -292,11 +292,11 @@ RESET MASTER; SHOW WARNINGS; # +d,fault_injection_registering_index => injects fault on MYSQL_BIN_LOG::open -SET GLOBAL debug_dbug="+d,fault_injection_registering_index"; +SET @@global.debug_dbug="d,fault_injection_registering_index"; -- replace_regex /\.[\\\/]master/master/ -- error ER_CANT_OPEN_FILE FLUSH LOGS; -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; -- error ER_NO_BINARY_LOGGING SHOW BINARY LOGS; @@ -321,11 +321,11 @@ flush tables; --source include/rpl_restart_server.inc # +d,fault_injection_openning_index => injects fault on MYSQL_BIN_LOG::open_index_file -SET GLOBAL debug_dbug="+d,fault_injection_openning_index"; +SET @@global.debug_dbug="d,fault_injection_openning_index"; -- replace_regex /\.[\\\/]master/master/ -- error ER_CANT_OPEN_FILE FLUSH LOGS; -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; -- error ER_FLUSH_MASTER_BINLOG_CLOSED RESET MASTER; @@ -350,10 +350,10 @@ flush tables; ### file. # +d,fault_injection_new_file_rotate_event => injects fault on MYSQL_BIN_LOG::MYSQL_BIN_LOG::new_file_impl -SET GLOBAL debug_dbug="+d,fault_injection_new_file_rotate_event"; +SET @@global.debug_dbug="d,fault_injection_new_file_rotate_event"; -- error ER_ERROR_ON_WRITE FLUSH LOGS; -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; -- error ER_FLUSH_MASTER_BINLOG_CLOSED RESET MASTER; diff --git a/mysql-test/suite/rpl/include/rpl_corruption.inc b/mysql-test/suite/rpl/include/rpl_corruption.inc index 4106bb45eef..c7a913af9d7 100644 --- a/mysql-test/suite/rpl/include/rpl_corruption.inc +++ b/mysql-test/suite/rpl/include/rpl_corruption.inc @@ -73,8 +73,8 @@ while ($i) { # Emulate corruption in binlog file when SHOW BINLOG EVENTS is executing --echo # 2. Corruption in master binlog and SHOW BINLOG EVENTS -set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug="+d,corrupt_read_log_event_char"; +SET @saved_dbug = @@global.debug_dbug; +SET @@global.debug_dbug="d,corrupt_read_log_event_char"; --echo SHOW BINLOG EVENTS; --disable_query_log send_eval SHOW BINLOG EVENTS FROM $pos; @@ -82,7 +82,7 @@ send_eval SHOW BINLOG EVENTS FROM $pos; --error ER_ERROR_WHEN_EXECUTING_COMMAND reap; -SET GLOBAL debug_dbug="-d,corrupt_read_log_event_char"; +SET @@global.debug_dbug=@saved_dbug; # Emulate corruption on master with crc checking on master --echo # 3. Master read a corrupted event from binlog and send the error to slave @@ -107,20 +107,20 @@ let $wait_condition= SELECT COUNT(*)=0 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE command = 'Binlog Dump'; --source include/wait_condition.inc -SET GLOBAL debug_dbug="+d,corrupt_read_log_event2_set"; +SET @@global.debug_dbug="d,corrupt_read_log_event2_set"; --connection slave START SLAVE IO_THREAD; let $slave_io_errno= 1236; --let $slave_timeout= 10 --source include/wait_for_slave_io_error.inc --connection master -SET GLOBAL debug_dbug="-d,corrupt_read_log_event2_set"; +SET @@global.debug_dbug=@saved_dbug; # Emulate corruption on master without crc checking on master --echo # 4. Master read a corrupted event from binlog and send it to slave --connection master SET GLOBAL master_verify_checksum=0; -SET GLOBAL debug_dbug="+d,corrupt_read_log_event2_set"; +SET @@global.debug_dbug="d,corrupt_read_log_event2_set"; --connection slave START SLAVE IO_THREAD; # When the checksum error is detected, the slave sets error code 1743 @@ -130,31 +130,29 @@ START SLAVE IO_THREAD; let $slave_io_errno= 1595,1743; # ER_SLAVE_RELAY_LOG_WRITE_FAILURE, ER_NETWORK_READ_EVENT_CHECKSUM_FAILURE --source include/wait_for_slave_io_error.inc --connection master -SET GLOBAL debug_dbug="-d,corrupt_read_log_event2_set"; -SET GLOBAL debug_dbug=@saved_dbug; +SET @@global.debug_dbug=@saved_dbug; SET GLOBAL master_verify_checksum=1; # Emulate corruption in network --echo # 5. Slave. Corruption in network --connection slave SET @saved_dbug_slave = @@GLOBAL.debug_dbug; -SET GLOBAL debug_dbug="+d,corrupt_queue_event"; +SET @@global.debug_dbug="d,corrupt_queue_event"; START SLAVE IO_THREAD; let $slave_io_errno= 1595,1743; # ER_SLAVE_RELAY_LOG_WRITE_FAILURE, ER_NETWORK_READ_EVENT_CHECKSUM_FAILURE --source include/wait_for_slave_io_error.inc -SET GLOBAL debug_dbug="-d,corrupt_queue_event"; +SET @@global.debug_dbug=@saved_dbug_slave; # Emulate corruption in relay log --echo # 6. Slave. Corruption in relay log -SET GLOBAL debug_dbug="+d,corrupt_read_log_event_char"; +SET @@global.debug_dbug="d,corrupt_read_log_event_char"; START SLAVE SQL_THREAD; let $slave_sql_errno= 1593; --source include/wait_for_slave_sql_error.inc -SET GLOBAL debug_dbug="-d,corrupt_read_log_event_char"; -SET GLOBAL debug_dbug=@saved_dbug_slave; +SET @@global.debug_dbug=@saved_dbug_slave; # Start normal replication and compare same table on master # and slave diff --git a/mysql-test/suite/rpl/include/rpl_get_master_version_and_clock.test b/mysql-test/suite/rpl/include/rpl_get_master_version_and_clock.test index eb0e5e21d62..181759283e2 100644 --- a/mysql-test/suite/rpl/include/rpl_get_master_version_and_clock.test +++ b/mysql-test/suite/rpl/include/rpl_get_master_version_and_clock.test @@ -41,8 +41,8 @@ if (!$debug_sync_action) # Restart slave --source include/stop_slave.inc - -eval SET @@global.debug_dbug= "+d,$dbug_sync_point"; +SET @old_dbug = @@global.debug_dbug; +eval SET @@global.debug_dbug= "d,$dbug_sync_point"; --source include/start_slave.inc --echo slave is going to hang in get_master_version_and_clock @@ -70,7 +70,7 @@ source include/wait_for_slave_io_error.inc; # now to avoid restarting IO-thread to re-enter it. # There will be a new IO thread forked out with its @@session.debug # unset. -eval set @@global.debug_dbug= "-d,$dbug_sync_point"; +set @@global.debug_dbug= @old_dbug; --let $rpl_server_number= 1 --source include/rpl_start_server.inc diff --git a/mysql-test/suite/rpl/include/rpl_stop_middle_group.test b/mysql-test/suite/rpl/include/rpl_stop_middle_group.test index 5c88c14d9b5..ac01fb04d16 100644 --- a/mysql-test/suite/rpl/include/rpl_stop_middle_group.test +++ b/mysql-test/suite/rpl/include/rpl_stop_middle_group.test @@ -14,7 +14,7 @@ create table ti (a int auto_increment primary key) engine=innodb; sync_slave_with_master; SET @saved_dbug = @@GLOBAL.debug_dbug; -set @@global.debug_dbug="+d,stop_slave_middle_group"; +set @@global.debug_dbug="d,stop_slave_middle_group"; connection master; @@ -44,7 +44,7 @@ eval SELECT "NO$error" AS Last_SQL_Error, @check as `true`; select count(*) as one from tm; select count(*) as one from ti; -set @@global.debug_dbug="-d"; +set @@global.debug_dbug=@saved_dbug; # # bug#45940 issues around rli->last_event_start_time @@ -68,8 +68,7 @@ truncate table ti; #connection slave; sync_slave_with_master; -set @@global.debug_dbug="+d,stop_slave_middle_group"; -set @@global.debug_dbug="+d,incomplete_group_in_relay_log"; +set @@global.debug_dbug="d,stop_slave_middle_group,incomplete_group_in_relay_log"; connection master; @@ -97,7 +96,7 @@ eval SELECT "$error" AS Last_SQL_Error, @check as `true`; select count(*) as one from tm; select count(*) as zero from ti; -set @@global.debug_dbug="-d"; +set @@global.debug_dbug=@saved_dbug; # # The mixed multi-table update @@ -110,8 +109,7 @@ connection master; #connection slave; sync_slave_with_master; -set @@global.debug_dbug="+d,stop_slave_middle_group"; -set @@global.debug_dbug="+d,incomplete_group_in_relay_log"; +set @@global.debug_dbug="d,stop_slave_middle_group,incomplete_group_in_relay_log"; connection master; update tm as t1, ti as t2 set t1.a=t1.a * 2, t2.a=t2.a * 2; diff --git a/mysql-test/suite/rpl/r/circular_serverid0.result b/mysql-test/suite/rpl/r/circular_serverid0.result index 928a0a48888..19c800cf01b 100644 --- a/mysql-test/suite/rpl/r/circular_serverid0.result +++ b/mysql-test/suite/rpl/r/circular_serverid0.result @@ -3,8 +3,8 @@ include/rpl_connect.inc [creating M4] include/rpl_connect.inc [creating M2] connection M2; STOP SLAVE; -SET @old_debug= @@global.debug; -SET GLOBAL debug_dbug= "+d,dbug.rows_events_to_delay_relay_logging"; +SET @old_debug= @@global.debug_dbug; +SET GLOBAL debug_dbug= "d,dbug.rows_events_to_delay_relay_logging"; START SLAVE IO_THREAD; include/wait_for_slave_io_to_start.inc connection M2; diff --git a/mysql-test/suite/rpl/r/rpl_binlog_errors.result b/mysql-test/suite/rpl/r/rpl_binlog_errors.result index eb58dd06997..c8a10577517 100644 --- a/mysql-test/suite/rpl/r/rpl_binlog_errors.result +++ b/mysql-test/suite/rpl/r/rpl_binlog_errors.result @@ -22,7 +22,7 @@ master-bin.000001 # master-bin.000002 # ###################### TEST #2 RESET MASTER; -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; FLUSH LOGS; ERROR HY000: Can't generate a unique log-filename master-bin.(1-999) @@ -30,7 +30,7 @@ ERROR HY000: Can't generate a unique log-filename master-bin.(1-999) show binary logs; Log_name File_size master-bin.000001 # -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; RESET MASTER; ###################### TEST #3 CREATE TABLE t1 (a INT); @@ -44,11 +44,11 @@ show binary logs; Log_name File_size master-bin.000001 # master-bin.000002 # -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; DELETE FROM t2; RESET MASTER; ###################### TEST #4 -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug_46166.data' INTO TABLE t2; ERROR HY000: Can't generate a unique log-filename master-bin.(1-999) @@ -56,21 +56,21 @@ ERROR HY000: Can't generate a unique log-filename master-bin.(1-999) SELECT count(*) FROM t2; count(*) 1 -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; DELETE FROM t2; RESET MASTER; ###################### TEST #5 -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug_46166-2.data' INTO TABLE t2; # assert: must show one entry SELECT count(*) FROM t2; count(*) 1 -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; DELETE FROM t2; RESET MASTER; ###################### TEST #6 -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; SET AUTOCOMMIT=0; INSERT INTO t2 VALUES ('muse'); LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug_46166.data' INTO TABLE t2; @@ -83,11 +83,11 @@ SELECT count(*) FROM t2; count(*) 3 SET AUTOCOMMIT= 1; -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; DELETE FROM t2; RESET MASTER; ###################### TEST #7 -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; SET @@binlog_annotate_row_events= 0; SELECT count(*) FROM t4; count(*) @@ -100,14 +100,14 @@ SELECT count(*) FROM t4; count(*) 1 ### check that the incident event is written to the current log -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Incident # # #1 (LOST_EVENTS) DELETE FROM t4; RESET MASTER; ###################### TEST #8 -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; # must show 0 entries SELECT count(*) FROM t4; count(*) @@ -147,9 +147,9 @@ count(*) SELECT count(*) FROM t2; count(*) 0 -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; ###################### TEST #9 -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; SET SQL_LOG_BIN=0; INSERT INTO t2 VALUES ('aaa'), ('bbb'), ('ccc'), ('ddd'); INSERT INTO t4 VALUES ('eee'), ('fff'), ('ggg'), ('hhh'); @@ -170,17 +170,17 @@ SELECT count(*) FROM t4; count(*) 0 SET SQL_LOG_BIN=1; -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; ###################### TEST #10 call mtr.add_suppression("MYSQL_BIN_LOG::open failed to sync the index file."); call mtr.add_suppression("Could not use .*"); RESET MASTER; SHOW WARNINGS; Level Code Message -SET GLOBAL debug_dbug="+d,fault_injection_registering_index"; +SET @@global.debug_dbug="d,fault_injection_registering_index"; FLUSH LOGS; ERROR HY000: Can't open file: 'master-bin.000002' (errno: 1 "Operation not permitted") -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; SHOW BINARY LOGS; ERROR HY000: You are not using binary logging CREATE TABLE t5 (a INT); @@ -192,10 +192,10 @@ DROP TABLE t5; flush tables; ###################### TEST #11 include/rpl_restart_server.inc [server_number=1] -SET GLOBAL debug_dbug="+d,fault_injection_openning_index"; +SET @@global.debug_dbug="d,fault_injection_openning_index"; FLUSH LOGS; ERROR HY000: Can't open file: 'master-bin.index' (errno: 1 "Operation not permitted") -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; RESET MASTER; ERROR HY000: Binlog closed, cannot RESET MASTER CREATE TABLE t5 (a INT); @@ -207,10 +207,10 @@ DROP TABLE t5; flush tables; include/rpl_restart_server.inc [server_number=1] ###################### TEST #12 -SET GLOBAL debug_dbug="+d,fault_injection_new_file_rotate_event"; +SET @@global.debug_dbug="d,fault_injection_new_file_rotate_event"; FLUSH LOGS; ERROR HY000: Can't open file: 'master-bin' (errno: 2 "No such file or directory") -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@old_debug; RESET MASTER; ERROR HY000: Binlog closed, cannot RESET MASTER CREATE TABLE t5 (a INT); @@ -237,44 +237,40 @@ call mtr.add_suppression("Could not use .*"); call mtr.add_suppression("MYSQL_BIN_LOG::open failed to sync the index file."); call mtr.add_suppression("Can't generate a unique log-filename .*"); ###################### TEST #13 -SET @old_debug=@@global.debug; +SET @saved_debug=@@global.debug_dbug; include/stop_slave.inc -SET GLOBAL debug_dbug="+d,error_unique_log_filename"; +SET @@global.debug_dbug="d,error_unique_log_filename"; START SLAVE io_thread; include/wait_for_slave_io_error.inc [errno=1595] Last_IO_Error = 'Relay log write failure: could not queue event from master' -SET GLOBAL debug_dbug="-d,error_unique_log_filename"; -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@saved_debug; include/rpl_restart_server.inc [server_number=2] ###################### TEST #14 -SET @old_debug=@@global.debug; +SET @saved_debug=@@global.debug_dbug; include/stop_slave.inc -SET GLOBAL debug_dbug="+d,fault_injection_new_file_rotate_event"; +SET @@global.debug_dbug="d,fault_injection_new_file_rotate_event"; START SLAVE io_thread; include/wait_for_slave_io_error.inc [errno=1595] Last_IO_Error = 'Relay log write failure: could not queue event from master' -SET GLOBAL debug_dbug="-d,fault_injection_new_file_rotate_event"; -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@saved_debug; include/rpl_restart_server.inc [server_number=2] ###################### TEST #15 -SET @old_debug=@@global.debug; +SET @saved_debug=@@global.debug_dbug; include/stop_slave.inc -SET GLOBAL debug_dbug="+d,fault_injection_registering_index"; +SET @@global.debug_dbug="d,fault_injection_registering_index"; START SLAVE io_thread; include/wait_for_slave_io_error.inc [errno=1595] Last_IO_Error = 'Relay log write failure: could not queue event from master' -SET GLOBAL debug_dbug="-d,fault_injection_registering_index"; -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@saved_debug; include/rpl_restart_server.inc [server_number=2] ###################### TEST #16 -SET @old_debug=@@global.debug; +SET @saved_debug=@@global.debug_dbug; include/stop_slave.inc -SET GLOBAL debug_dbug="+d,fault_injection_openning_index"; +SET @@global.debug_dbug="d,fault_injection_openning_index"; START SLAVE io_thread; include/wait_for_slave_io_error.inc [errno=1595] Last_IO_Error = 'Relay log write failure: could not queue event from master' -SET GLOBAL debug_dbug="-d,fault_injection_openning_index"; -SET GLOBAL debug_dbug=@old_debug; +SET @@global.debug_dbug=@saved_debug; include/rpl_restart_server.inc [server_number=2] include/stop_slave_sql.inc Warnings: diff --git a/mysql-test/suite/rpl/r/rpl_corruption.result b/mysql-test/suite/rpl/r/rpl_corruption.result index f32b7c58ad1..73bb373d6be 100644 --- a/mysql-test/suite/rpl/r/rpl_corruption.result +++ b/mysql-test/suite/rpl/r/rpl_corruption.result @@ -13,42 +13,40 @@ connection master; CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY, b VARCHAR(10), c VARCHAR(100)); include/stop_slave.inc # 2. Corruption in master binlog and SHOW BINLOG EVENTS -set @saved_dbug = @@global.debug_dbug; -SET GLOBAL debug_dbug="+d,corrupt_read_log_event_char"; +SET @saved_dbug = @@global.debug_dbug; +SET @@global.debug_dbug="d,corrupt_read_log_event_char"; SHOW BINLOG EVENTS; ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Wrong offset or I/O error -SET GLOBAL debug_dbug="-d,corrupt_read_log_event_char"; +SET @@global.debug_dbug=@saved_dbug; # 3. Master read a corrupted event from binlog and send the error to slave -SET GLOBAL debug_dbug="+d,corrupt_read_log_event2_set"; +SET @@global.debug_dbug="d,corrupt_read_log_event2_set"; connection slave; START SLAVE IO_THREAD; include/wait_for_slave_io_error.inc [errno=1236] connection master; -SET GLOBAL debug_dbug="-d,corrupt_read_log_event2_set"; +SET @@global.debug_dbug=@saved_dbug; # 4. Master read a corrupted event from binlog and send it to slave connection master; SET GLOBAL master_verify_checksum=0; -SET GLOBAL debug_dbug="+d,corrupt_read_log_event2_set"; +SET @@global.debug_dbug="d,corrupt_read_log_event2_set"; connection slave; START SLAVE IO_THREAD; include/wait_for_slave_io_error.inc [errno=1595,1743] connection master; -SET GLOBAL debug_dbug="-d,corrupt_read_log_event2_set"; -SET GLOBAL debug_dbug=@saved_dbug; +SET @@global.debug_dbug=@saved_dbug; SET GLOBAL master_verify_checksum=1; # 5. Slave. Corruption in network connection slave; SET @saved_dbug_slave = @@GLOBAL.debug_dbug; -SET GLOBAL debug_dbug="+d,corrupt_queue_event"; +SET @@global.debug_dbug="d,corrupt_queue_event"; START SLAVE IO_THREAD; include/wait_for_slave_io_error.inc [errno=1595,1743] -SET GLOBAL debug_dbug="-d,corrupt_queue_event"; +SET @@global.debug_dbug=@saved_dbug_slave; # 6. Slave. Corruption in relay log -SET GLOBAL debug_dbug="+d,corrupt_read_log_event_char"; +SET @@global.debug_dbug="d,corrupt_read_log_event_char"; START SLAVE SQL_THREAD; include/wait_for_slave_sql_error.inc [errno=1593] -SET GLOBAL debug_dbug="-d,corrupt_read_log_event_char"; -SET GLOBAL debug_dbug=@saved_dbug_slave; +SET @@global.debug_dbug=@saved_dbug_slave; # 7. Seek diff for tables on master and slave connection slave; include/start_slave.inc diff --git a/mysql-test/suite/rpl/r/rpl_domain_id_filter_io_crash.result b/mysql-test/suite/rpl/r/rpl_domain_id_filter_io_crash.result index b8415977154..feef82a57fc 100644 --- a/mysql-test/suite/rpl/r/rpl_domain_id_filter_io_crash.result +++ b/mysql-test/suite/rpl/r/rpl_domain_id_filter_io_crash.result @@ -27,7 +27,7 @@ include/start_slave.inc DO_DOMAIN_IDS (AFTER) : IGNORE_DOMAIN_IDS (AFTER) : SET @saved_dbug = @@GLOBAL.debug_dbug; -SET @@global.debug_dbug="+d,kill_slave_io_before_commit"; +SET @@global.debug_dbug="d,kill_slave_io_before_commit"; connection master; START TRANSACTION; INSERT INTO t1 VALUES(2); @@ -43,7 +43,7 @@ include/wait_for_slave_io_error.inc [errno=1595] SELECT * FROM t1; i 1 -SET @@global.debug_dbug="-d"; +SET @@global.debug_dbug=@saved_dbug; START SLAVE io_thread; include/wait_for_slave_io_to_start.inc SELECT * FROM t1; @@ -61,7 +61,7 @@ CHANGE MASTER TO IGNORE_DOMAIN_IDS=(1), MASTER_USE_GTID=slave_pos; include/start_slave.inc DO_DOMAIN_IDS (AFTER) : IGNORE_DOMAIN_IDS (AFTER) : 1 -SET @@global.debug_dbug="+d,kill_slave_io_before_commit"; +SET @@global.debug_dbug="d,kill_slave_io_before_commit"; connection master; START TRANSACTION; INSERT INTO t1 VALUES(4); @@ -81,7 +81,7 @@ i 1 2 3 -SET @@global.debug_dbug="-d"; +SET @@global.debug_dbug=@saved_dbug; START SLAVE io_thread; include/wait_for_slave_io_to_start.inc SELECT * FROM t1; @@ -99,7 +99,7 @@ CHANGE MASTER TO IGNORE_DOMAIN_IDS=(), MASTER_USE_GTID=slave_pos; include/start_slave.inc DO_DOMAIN_IDS (AFTER) : IGNORE_DOMAIN_IDS (AFTER) : -SET @@global.debug_dbug="+d,kill_slave_io_before_commit"; +SET @@global.debug_dbug="d,kill_slave_io_before_commit"; connection master; START TRANSACTION; INSERT INTO t1 VALUES(6); @@ -134,7 +134,7 @@ i 1 2 3 -SET @@global.debug_dbug="-d"; +SET @@global.debug_dbug=@saved_dbug; include/stop_slave.inc DO_DOMAIN_IDS (BEFORE) : IGNORE_DOMAIN_IDS (BEFORE) : @@ -159,7 +159,7 @@ CHANGE MASTER TO IGNORE_DOMAIN_IDS=(1), MASTER_USE_GTID=slave_pos; include/start_slave.inc DO_DOMAIN_IDS (AFTER) : IGNORE_DOMAIN_IDS (AFTER) : 1 -SET @@global.debug_dbug="+d,kill_slave_io_before_commit"; +SET @@global.debug_dbug="d,kill_slave_io_before_commit"; connection master; SET @@session.gtid_domain_id= 1; START TRANSACTION; @@ -203,7 +203,7 @@ i 3 10 11 -SET @@global.debug_dbug="-d"; +SET @@global.debug_dbug=@saved_dbug; include/stop_slave.inc DO_DOMAIN_IDS (BEFORE) : IGNORE_DOMAIN_IDS (BEFORE) : 1 @@ -232,7 +232,7 @@ CHANGE MASTER TO IGNORE_DOMAIN_IDS=(1), MASTER_USE_GTID=slave_pos; include/start_slave.inc DO_DOMAIN_IDS (AFTER) : IGNORE_DOMAIN_IDS (AFTER) : 1 -SET @@global.debug_dbug="+d,kill_slave_io_after_2_events"; +SET @@global.debug_dbug="d,kill_slave_io_after_2_events"; connection master; SET @@session.gtid_domain_id= 1; START TRANSACTION; @@ -286,7 +286,7 @@ i 15 16 17 -SET @@global.debug_dbug="-d"; +SET @@global.debug_dbug=@saved_dbug; include/stop_slave.inc DO_DOMAIN_IDS (BEFORE) : IGNORE_DOMAIN_IDS (BEFORE) : 1 @@ -319,7 +319,7 @@ CHANGE MASTER TO IGNORE_DOMAIN_IDS=(), MASTER_USE_GTID=slave_pos; include/start_slave.inc DO_DOMAIN_IDS (AFTER) : IGNORE_DOMAIN_IDS (AFTER) : -SET @@global.debug_dbug="+d,kill_slave_io_after_2_events"; +SET @@global.debug_dbug="d,kill_slave_io_after_2_events"; connection master; SET @@session.gtid_domain_id= 1; START TRANSACTION; @@ -383,7 +383,7 @@ i 21 22 23 -SET @@global.debug_dbug="-d"; +SET @@global.debug_dbug=@saved_dbug; include/stop_slave.inc DO_DOMAIN_IDS (BEFORE) : IGNORE_DOMAIN_IDS (BEFORE) : diff --git a/mysql-test/suite/rpl/r/rpl_get_master_version_and_clock.result b/mysql-test/suite/rpl/r/rpl_get_master_version_and_clock.result index e7f4e566566..deea7caa12a 100644 --- a/mysql-test/suite/rpl/r/rpl_get_master_version_and_clock.result +++ b/mysql-test/suite/rpl/r/rpl_get_master_version_and_clock.result @@ -1,33 +1,42 @@ include/master-slave.inc [connection master] +connection slave; call mtr.add_suppression("Slave I/O: Master command COM_REGISTER_SLAVE failed: .*"); call mtr.add_suppression("Slave I/O: .* failed with error: Lost connection to MySQL server at 'reading initial communication packet'"); call mtr.add_suppression("Fatal error: The slave I/O thread stops because master and slave have equal MySQL server ids; .*"); call mtr.add_suppression("Slave I/O thread .* register on master"); +SET @saved_dbug = @@GLOBAL.debug_dbug; +connection slave; include/stop_slave.inc -SET @@global.debug= "+d,'debug_lock.before_get_UNIX_TIMESTAMP'"; +SET @old_dbug = @@global.debug_dbug; +SET @@global.debug_dbug= "d,'debug_lock.before_get_UNIX_TIMESTAMP'"; include/start_slave.inc slave is going to hang in get_master_version_and_clock include/rpl_stop_server.inc [server_number=1] slave is unblocked SET DEBUG_SYNC='now SIGNAL signal.get_unix_timestamp'; +connection slave; Check network error happened here include/wait_for_slave_io_error.inc [errno=1053, 2002, 2003, 2006, 2013] -set @@global.debug = "-d,'debug_lock.before_get_UNIX_TIMESTAMP'"; +set @@global.debug_dbug= @old_dbug; include/rpl_start_server.inc [server_number=1] include/wait_for_slave_param.inc [Slave_IO_Running] +connection slave; +connection slave; include/stop_slave.inc -SET @@global.debug= "+d,'debug_lock.before_get_SERVER_ID'"; +SET @old_dbug = @@global.debug_dbug; +SET @@global.debug_dbug= "d,'debug_lock.before_get_SERVER_ID'"; include/start_slave.inc slave is going to hang in get_master_version_and_clock include/rpl_stop_server.inc [server_number=1] slave is unblocked SET DEBUG_SYNC='now SIGNAL signal.get_server_id'; +connection slave; Check network error happened here include/wait_for_slave_io_error.inc [errno=1053, 2002, 2003, 2006, 2013] -set @@global.debug = "-d,'debug_lock.before_get_SERVER_ID'"; +set @@global.debug_dbug= @old_dbug; include/rpl_start_server.inc [server_number=1] include/wait_for_slave_param.inc [Slave_IO_Running] -set global debug= ''; +SET @@GLOBAL.debug_dbug = @saved_dbug; SET DEBUG_SYNC= 'RESET'; include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_gtid_strict.result b/mysql-test/suite/rpl/r/rpl_gtid_strict.result index 528c4c5b5c1..27e7d105125 100644 --- a/mysql-test/suite/rpl/r/rpl_gtid_strict.result +++ b/mysql-test/suite/rpl/r/rpl_gtid_strict.result @@ -27,16 +27,17 @@ master-bin.000001 # Xid # # COMMIT /* XID */ SET server_id= 3; SET gtid_seq_no= 3; ERROR HY000: An attempt was made to binlog GTID 0-3-3 which would create an out-of-order sequence number with existing GTID 0-1-3, and gtid strict mode is enabled -SET SESSION debug_dbug="+d,ignore_set_gtid_seq_no_check"; +SET @old_dbug = @@session.debug_dbug; +SET SESSION debug_dbug="d,ignore_set_gtid_seq_no_check"; SET gtid_seq_no= 3; -SET SESSION debug_dbug="-d,ignore_set_gtid_seq_no_check"; +SET SESSION debug_dbug=@old_dbug; INSERT INTO t1 VALUES (2); ERROR HY000: An attempt was made to binlog GTID 0-3-3 which would create an out-of-order sequence number with existing GTID 0-1-3, and gtid strict mode is enabled SET gtid_seq_no= 2; ERROR HY000: An attempt was made to binlog GTID 0-3-2 which would create an out-of-order sequence number with existing GTID 0-1-3, and gtid strict mode is enabled -SET SESSION debug_dbug="+d,ignore_set_gtid_seq_no_check"; +SET SESSION debug_dbug="d,ignore_set_gtid_seq_no_check"; SET gtid_seq_no= 2; -SET SESSION debug_dbug="-d,ignore_set_gtid_seq_no_check"; +SET SESSION debug_dbug=@old_dbug; INSERT INTO t1 VALUES (3); ERROR HY000: An attempt was made to binlog GTID 0-3-2 which would create an out-of-order sequence number with existing GTID 0-1-3, and gtid strict mode is enabled SET server_id= 1; @@ -62,9 +63,9 @@ master-bin.000001 # Xid # # COMMIT /* XID */ SET server_id= 3; SET gtid_seq_no= 1; ERROR HY000: An attempt was made to binlog GTID 0-3-1 which would create an out-of-order sequence number with existing GTID 0-1-4, and gtid strict mode is enabled -SET SESSION debug_dbug="+d,ignore_set_gtid_seq_no_check"; +SET SESSION debug_dbug="d,ignore_set_gtid_seq_no_check"; SET gtid_seq_no= 1; -SET SESSION debug_dbug="-d,ignore_set_gtid_seq_no_check"; +SET SESSION debug_dbug=@old_dbug; CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=MyISAM; ERROR HY000: An attempt was made to binlog GTID 0-3-1 which would create an out-of-order sequence number with existing GTID 0-1-4, and gtid strict mode is enabled SET sql_log_bin= 0; @@ -73,9 +74,9 @@ SET sql_log_bin= 1; CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=MyISAM; SET gtid_seq_no= 1; ERROR HY000: An attempt was made to binlog GTID 0-3-1 which would create an out-of-order sequence number with existing GTID 0-3-5, and gtid strict mode is enabled -SET SESSION debug_dbug="+d,ignore_set_gtid_seq_no_check"; +SET SESSION debug_dbug="d,ignore_set_gtid_seq_no_check"; SET gtid_seq_no= 1; -SET SESSION debug_dbug="-d,ignore_set_gtid_seq_no_check"; +SET SESSION debug_dbug=@old_dbug; INSERT INTO t2 VALUES (1); ERROR HY000: An attempt was made to binlog GTID 0-3-1 which would create an out-of-order sequence number with existing GTID 0-3-5, and gtid strict mode is enabled SET server_id= 1; diff --git a/mysql-test/suite/rpl/r/rpl_row_corruption.result b/mysql-test/suite/rpl/r/rpl_row_corruption.result index b5bdc32200a..24535460418 100644 --- a/mysql-test/suite/rpl/r/rpl_row_corruption.result +++ b/mysql-test/suite/rpl/r/rpl_row_corruption.result @@ -7,15 +7,15 @@ INSERT INTO t2_11753004 VALUES (2); connection slave; call mtr.add_suppression(".*Found table map event mapping table id 0 which was already mapped but with different settings.*"); include/stop_slave.inc -SET @save_debug= @@global.debug; -SET GLOBAL debug_dbug="+d,inject_tblmap_same_id_maps_diff_table"; +SET @saved_debug= @@global.debug_dbug; +SET @@global.debug_dbug="d,inject_tblmap_same_id_maps_diff_table"; include/start_slave.inc connection master; UPDATE t1_11753004, t2_11753004 SET t1_11753004.c1=3, t2_11753004.c1=4 WHERE t1_11753004.c1=1 OR t2_11753004.c1=2; connection slave; include/wait_for_slave_sql_error.inc [errno=1593 ] include/stop_slave.inc -SET GLOBAL debug_dbug="-d,inject_tblmap_same_id_maps_diff_table"; +SET @@global.debug_dbug=@saved_debug; include/start_slave.inc connection master; include/rpl_reset.inc @@ -23,7 +23,7 @@ DROP TABLE t1_11753004, t2_11753004; connection slave; connection slave; include/stop_slave.inc -SET GLOBAL debug_dbug="+d,inject_tblmap_same_id_maps_diff_table"; +SET @@global.debug_dbug="d,inject_tblmap_same_id_maps_diff_table"; include/start_slave.inc include/rpl_reset.inc connection master; @@ -41,7 +41,7 @@ BINLOG ' SOgWTg8BAAAAbgAAAHIAAAAAAAQANS42LjMtbTUtZGVidWctbG9nAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAABI6BZOEzgNAAgAEgAEBAQEEgAAVgAEGggAAAAICAgCAAAAAAVAYI8= '/*!*/; -SET GLOBAL debug_dbug="+d,inject_tblmap_same_id_maps_diff_table"; +SET @@global.debug_dbug="d,inject_tblmap_same_id_maps_diff_table"; BINLOG ' SOgWThMBAAAAKQAAAAYDAAAAAEIAAAAAAAEABHRlc3QAAnQxAAEDAAE= SOgWThMBAAAAKQAAAC8DAAAAAEMAAAAAAAEABHRlc3QAAnQyAAEDAAE= @@ -51,10 +51,10 @@ SOgWThgBAAAAKAAAAH8DAAAAAEMAAAAAAAEAAf///gEAAAD+BAAAAA== ERROR HY000: Fatal error: Found table map event mapping table id 0 which was already mapped but with different settings. DROP TABLE t1,t2; connection slave; -SET GLOBAL debug_dbug="-d,inject_tblmap_same_id_maps_diff_table"; +SET @@global.debug_dbug=@saved_debug; connection master; DROP TABLE t1_11753004; DROP TABLE t2_11753004_ign; connection slave; -SET GLOBAL debug_dbug= @save_debug; +SET @@global.debug_dbug= @save_debug; include/rpl_end.inc diff --git a/mysql-test/suite/rpl/r/rpl_stm_stop_middle_group.result b/mysql-test/suite/rpl/r/rpl_stm_stop_middle_group.result index b670a16bfcd..0afe1992fb9 100644 --- a/mysql-test/suite/rpl/r/rpl_stm_stop_middle_group.result +++ b/mysql-test/suite/rpl/r/rpl_stm_stop_middle_group.result @@ -7,7 +7,7 @@ create table tm (a int auto_increment primary key) engine=myisam; create table ti (a int auto_increment primary key) engine=innodb; connection slave; SET @saved_dbug = @@GLOBAL.debug_dbug; -set @@global.debug_dbug="+d,stop_slave_middle_group"; +set @@global.debug_dbug="d,stop_slave_middle_group"; connection master; begin; insert into ti set a=null; @@ -28,14 +28,13 @@ one select count(*) as one from ti; one 1 -set @@global.debug_dbug="-d"; +set @@global.debug_dbug=@saved_dbug; include/start_slave.inc connection master; truncate table tm; truncate table ti; connection slave; -set @@global.debug_dbug="+d,stop_slave_middle_group"; -set @@global.debug_dbug="+d,incomplete_group_in_relay_log"; +set @@global.debug_dbug="d,stop_slave_middle_group,incomplete_group_in_relay_log"; connection master; begin; insert into ti set a=null; @@ -54,14 +53,13 @@ one select count(*) as zero from ti; zero 0 -set @@global.debug_dbug="-d"; +set @@global.debug_dbug=@saved_dbug; stop slave; truncate table tm; include/start_slave.inc connection master; connection slave; -set @@global.debug_dbug="+d,stop_slave_middle_group"; -set @@global.debug_dbug="+d,incomplete_group_in_relay_log"; +set @@global.debug_dbug="d,stop_slave_middle_group,incomplete_group_in_relay_log"; connection master; update tm as t1, ti as t2 set t1.a=t1.a * 2, t2.a=t2.a * 2; connection slave; diff --git a/mysql-test/suite/rpl/t/circular_serverid0.test b/mysql-test/suite/rpl/t/circular_serverid0.test index 097a2932404..64cf231c2c2 100644 --- a/mysql-test/suite/rpl/t/circular_serverid0.test +++ b/mysql-test/suite/rpl/t/circular_serverid0.test @@ -24,8 +24,8 @@ --connection M2 STOP SLAVE; -SET @old_debug= @@global.debug; -SET GLOBAL debug_dbug= "+d,dbug.rows_events_to_delay_relay_logging"; +SET @old_debug= @@global.debug_dbug; +SET GLOBAL debug_dbug= "d,dbug.rows_events_to_delay_relay_logging"; START SLAVE IO_THREAD; --source include/wait_for_slave_io_to_start.inc diff --git a/mysql-test/suite/rpl/t/rpl_bug41902-slave.opt b/mysql-test/suite/rpl/t/rpl_bug41902-slave.opt deleted file mode 100644 index 37fc56036fb..00000000000 --- a/mysql-test/suite/rpl/t/rpl_bug41902-slave.opt +++ /dev/null @@ -1 +0,0 @@ ---loose-debug=-d,simulate_find_log_pos_error diff --git a/mysql-test/suite/rpl/t/rpl_domain_id_filter_io_crash.test b/mysql-test/suite/rpl/t/rpl_domain_id_filter_io_crash.test index f3ba39fb330..a949da0cc25 100644 --- a/mysql-test/suite/rpl/t/rpl_domain_id_filter_io_crash.test +++ b/mysql-test/suite/rpl/t/rpl_domain_id_filter_io_crash.test @@ -36,7 +36,7 @@ let $ignore_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Ignor --echo IGNORE_DOMAIN_IDS (AFTER) : $ignore_domain_ids_after SET @saved_dbug = @@GLOBAL.debug_dbug; -SET @@global.debug_dbug="+d,kill_slave_io_before_commit"; +SET @@global.debug_dbug="d,kill_slave_io_before_commit"; connection master; @@ -51,7 +51,7 @@ connection slave; --let $slave_io_errno= 1595 --source include/wait_for_slave_io_error.inc SELECT * FROM t1; -SET @@global.debug_dbug="-d"; +SET @@global.debug_dbug=@saved_dbug; START SLAVE io_thread; --source include/wait_for_slave_io_to_start.inc @@ -77,7 +77,7 @@ let $ignore_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Ignor --echo DO_DOMAIN_IDS (AFTER) : $do_domain_ids_after --echo IGNORE_DOMAIN_IDS (AFTER) : $ignore_domain_ids_after -SET @@global.debug_dbug="+d,kill_slave_io_before_commit"; +SET @@global.debug_dbug="d,kill_slave_io_before_commit"; connection master; @@ -93,7 +93,7 @@ connection slave; --let $slave_io_errno= 1595 --source include/wait_for_slave_io_error.inc SELECT * FROM t1; -SET @@global.debug_dbug="-d"; +SET @@global.debug_dbug=@saved_dbug; START SLAVE io_thread; --source include/wait_for_slave_io_to_start.inc @@ -119,7 +119,7 @@ let $ignore_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Ignor --echo DO_DOMAIN_IDS (AFTER) : $do_domain_ids_after --echo IGNORE_DOMAIN_IDS (AFTER) : $ignore_domain_ids_after -SET @@global.debug_dbug="+d,kill_slave_io_before_commit"; +SET @@global.debug_dbug="d,kill_slave_io_before_commit"; connection master; @@ -148,7 +148,7 @@ connection slave; --source include/wait_for_slave_io_error.inc SELECT * FROM t1; -SET @@global.debug_dbug="-d"; +SET @@global.debug_dbug=@saved_dbug; --source include/stop_slave.inc let $do_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1); @@ -186,7 +186,7 @@ let $ignore_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Ignor --echo DO_DOMAIN_IDS (AFTER) : $do_domain_ids_after --echo IGNORE_DOMAIN_IDS (AFTER) : $ignore_domain_ids_after -SET @@global.debug_dbug="+d,kill_slave_io_before_commit"; +SET @@global.debug_dbug="d,kill_slave_io_before_commit"; connection master; @@ -216,7 +216,7 @@ connection slave; --source include/wait_for_slave_io_error.inc SELECT * FROM t1; -SET @@global.debug_dbug="-d"; +SET @@global.debug_dbug=@saved_dbug; --source include/stop_slave.inc let $do_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1); @@ -254,7 +254,7 @@ let $ignore_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Ignor --echo DO_DOMAIN_IDS (AFTER) : $do_domain_ids_after --echo IGNORE_DOMAIN_IDS (AFTER) : $ignore_domain_ids_after -SET @@global.debug_dbug="+d,kill_slave_io_after_2_events"; +SET @@global.debug_dbug="d,kill_slave_io_after_2_events"; connection master; @@ -284,7 +284,7 @@ connection slave; --source include/wait_for_slave_io_error.inc SELECT * FROM t1; -SET @@global.debug_dbug="-d"; +SET @@global.debug_dbug=@saved_dbug; --source include/stop_slave.inc let $do_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1); @@ -322,7 +322,7 @@ let $ignore_domain_ids_after= query_get_value(SHOW SLAVE STATUS, Replicate_Ignor --echo DO_DOMAIN_IDS (AFTER) : $do_domain_ids_after --echo IGNORE_DOMAIN_IDS (AFTER) : $ignore_domain_ids_after -SET @@global.debug_dbug="+d,kill_slave_io_after_2_events"; +SET @@global.debug_dbug="d,kill_slave_io_after_2_events"; connection master; @@ -352,7 +352,7 @@ connection slave; --source include/wait_for_slave_io_error.inc SELECT * FROM t1; -SET @@global.debug_dbug="-d"; +SET @@global.debug_dbug=@saved_dbug; --source include/stop_slave.inc let $do_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1); diff --git a/mysql-test/suite/rpl/t/rpl_gtid_strict.test b/mysql-test/suite/rpl/t/rpl_gtid_strict.test index afcb179da78..56ebba824c4 100644 --- a/mysql-test/suite/rpl/t/rpl_gtid_strict.test +++ b/mysql-test/suite/rpl/t/rpl_gtid_strict.test @@ -29,17 +29,18 @@ INSERT INTO t1 VALUES (1); SET server_id= 3; --error ER_GTID_STRICT_OUT_OF_ORDER SET gtid_seq_no= 3; -SET SESSION debug_dbug="+d,ignore_set_gtid_seq_no_check"; +SET @old_dbug = @@session.debug_dbug; +SET SESSION debug_dbug="d,ignore_set_gtid_seq_no_check"; SET gtid_seq_no= 3; -SET SESSION debug_dbug="-d,ignore_set_gtid_seq_no_check"; +SET SESSION debug_dbug=@old_dbug; --error ER_GTID_STRICT_OUT_OF_ORDER INSERT INTO t1 VALUES (2); --error ER_GTID_STRICT_OUT_OF_ORDER SET gtid_seq_no= 2; -SET SESSION debug_dbug="+d,ignore_set_gtid_seq_no_check"; +SET SESSION debug_dbug="d,ignore_set_gtid_seq_no_check"; SET gtid_seq_no= 2; -SET SESSION debug_dbug="-d,ignore_set_gtid_seq_no_check"; +SET SESSION debug_dbug=@old_dbug; --error ER_GTID_STRICT_OUT_OF_ORDER INSERT INTO t1 VALUES (3); SET server_id= 1; @@ -52,9 +53,9 @@ SELECT * FROM t1 ORDER BY 1; SET server_id= 3; --error ER_GTID_STRICT_OUT_OF_ORDER SET gtid_seq_no= 1; -SET SESSION debug_dbug="+d,ignore_set_gtid_seq_no_check"; +SET SESSION debug_dbug="d,ignore_set_gtid_seq_no_check"; SET gtid_seq_no= 1; -SET SESSION debug_dbug="-d,ignore_set_gtid_seq_no_check"; +SET SESSION debug_dbug=@old_dbug; --error ER_GTID_STRICT_OUT_OF_ORDER CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=MyISAM; # The table is still created, DDL cannot be rolled back. @@ -66,9 +67,9 @@ CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=MyISAM; --error ER_GTID_STRICT_OUT_OF_ORDER SET gtid_seq_no= 1; -SET SESSION debug_dbug="+d,ignore_set_gtid_seq_no_check"; +SET SESSION debug_dbug="d,ignore_set_gtid_seq_no_check"; SET gtid_seq_no= 1; -SET SESSION debug_dbug="-d,ignore_set_gtid_seq_no_check"; +SET SESSION debug_dbug=@old_dbug; --error ER_GTID_STRICT_OUT_OF_ORDER INSERT INTO t2 VALUES (1); # The value is still inserted, cannot be rolled back. diff --git a/mysql-test/suite/rpl/t/rpl_row_corruption.test b/mysql-test/suite/rpl/t/rpl_row_corruption.test index acf3964f0c5..d78df905ccb 100644 --- a/mysql-test/suite/rpl/t/rpl_row_corruption.test +++ b/mysql-test/suite/rpl/t/rpl_row_corruption.test @@ -27,8 +27,8 @@ call mtr.add_suppression(".*Found table map event mapping table id 0 which was a # stop the slave and inject corruption --source include/stop_slave.inc -SET @save_debug= @@global.debug; -SET GLOBAL debug_dbug="+d,inject_tblmap_same_id_maps_diff_table"; +SET @saved_debug= @@global.debug_dbug; +SET @@global.debug_dbug="d,inject_tblmap_same_id_maps_diff_table"; --source include/start_slave.inc --connection master # both tables get mapped to 0 (in a way, simulating scenario @@ -42,7 +42,7 @@ SET GLOBAL debug_dbug="+d,inject_tblmap_same_id_maps_diff_table"; --source include/stop_slave.inc # clean up -SET GLOBAL debug_dbug="-d,inject_tblmap_same_id_maps_diff_table"; +SET @@global.debug_dbug=@saved_debug; --source include/start_slave.inc --connection master --source include/rpl_reset.inc @@ -55,7 +55,7 @@ SET GLOBAL debug_dbug="-d,inject_tblmap_same_id_maps_diff_table"; --connection slave --source include/stop_slave.inc -SET GLOBAL debug_dbug="+d,inject_tblmap_same_id_maps_diff_table"; +SET @@global.debug_dbug="d,inject_tblmap_same_id_maps_diff_table"; --source include/start_slave.inc --source include/rpl_reset.inc --connection master @@ -92,7 +92,7 @@ AAAAAAAAAAAAAAAAAABI6BZOEzgNAAgAEgAEBAQEEgAAVgAEGggAAAAICAgCAAAAAAVAYI8= #110708 12:21:44 server id 1 end_log_pos 855 Update_rows: table id 66 # at 855 #110708 12:21:44 server id 1 end_log_pos 895 Update_rows: table id 67 flags: STMT_END_F -SET GLOBAL debug_dbug="+d,inject_tblmap_same_id_maps_diff_table"; +SET @@global.debug_dbug="d,inject_tblmap_same_id_maps_diff_table"; --error ER_SLAVE_FATAL_ERROR BINLOG ' SOgWThMBAAAAKQAAAAYDAAAAAEIAAAAAAAEABHRlc3QAAnQxAAEDAAE= @@ -105,11 +105,11 @@ SOgWThgBAAAAKAAAAH8DAAAAAEMAAAAAAAEAAf///gEAAAD+BAAAAA== # clean up DROP TABLE t1,t2; --connection slave -SET GLOBAL debug_dbug="-d,inject_tblmap_same_id_maps_diff_table"; +SET @@global.debug_dbug=@saved_debug; --connection master --eval DROP TABLE $t1 --eval DROP TABLE $t2_ign --sync_slave_with_master -SET GLOBAL debug_dbug= @save_debug; +SET @@global.debug_dbug= @save_debug; --source include/rpl_end.inc diff --git a/sql/item.cc b/sql/item.cc index 0a42912dd91..30e83d26a0c 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2018, Oracle and/or its affiliates. - Copyright (c) 2010, 2018, MariaDB Corporation + Copyright (c) 2010, 2020, 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 @@ -2786,42 +2786,46 @@ bool Type_std_attributes::agg_item_set_converter(const DTCollation &coll, /** @brief Building clone for Item_func_or_sum - + @param thd thread handle - @param mem_root part of the memory for the clone + @param mem_root part of the memory for the clone @details - This method gets copy of the current item and also - build clones for its referencies. For the referencies - build_copy is called again. - - @retval - clone of the item - 0 if an error occurred -*/ + This method first builds clones of the arguments. If it is successful with + buiding the clones then it constructs a copy of this Item_func_or_sum object + and attaches to it the built clones of the arguments. + + @return clone of the item + @retval 0 on a failure +*/ Item* Item_func_or_sum::build_clone(THD *thd) { - Item_func_or_sum *copy= (Item_func_or_sum *) get_copy(thd); - if (unlikely(!copy)) - return 0; + Item *copy_tmp_args[2]= {0,0}; + Item **copy_args= copy_tmp_args; if (arg_count > 2) { - copy->args= - (Item**) alloc_root(thd->mem_root, sizeof(Item*) * arg_count); - if (unlikely(!copy->args)) + copy_args= static_cast<Item**> + (alloc_root(thd->mem_root, sizeof(Item*) * arg_count)); + if (unlikely(!copy_args)) return 0; } - else if (arg_count > 0) - copy->args= copy->tmp_arg; - - for (uint i= 0; i < arg_count; i++) { Item *arg_clone= args[i]->build_clone(thd); - if (!arg_clone) + if (unlikely(!arg_clone)) return 0; - copy->args[i]= arg_clone; + copy_args[i]= arg_clone; + } + Item_func_or_sum *copy= static_cast<Item_func_or_sum *>(get_copy(thd)); + if (unlikely(!copy)) + return 0; + if (arg_count > 2) + copy->args= copy_args; + else if (arg_count > 0) + { + copy->args= copy->tmp_arg; + memcpy(copy->args, copy_args, sizeof(Item *) * arg_count); } return copy; } diff --git a/sql/item_row.cc b/sql/item_row.cc index 70a9fe50c16..04868842f11 100644 --- a/sql/item_row.cc +++ b/sql/item_row.cc @@ -1,5 +1,6 @@ /* Copyright (c) 2002, 2011, Oracle and/or its affiliates. + Copyright (c) 2011, 2020, 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 @@ -165,16 +166,20 @@ void Item_row::bring_value() Item* Item_row::build_clone(THD *thd) { - Item_row *copy= (Item_row *) get_copy(thd); - if (!copy) + Item **copy_args= static_cast<Item**> + (alloc_root(thd->mem_root, sizeof(Item*) * arg_count)); + if (unlikely(!copy_args)) return 0; - copy->args= (Item**) alloc_root(thd->mem_root, sizeof(Item*) * arg_count); for (uint i= 0; i < arg_count; i++) { Item *arg_clone= args[i]->build_clone(thd); if (!arg_clone) return 0; - copy->args[i]= arg_clone; + copy_args[i]= arg_clone; } + Item_row *copy= (Item_row *) get_copy(thd); + if (unlikely(!copy)) + return 0; + copy->args= copy_args; return copy; } diff --git a/sql/slave.cc b/sql/slave.cc index 709834df06c..aea386855f5 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -5412,6 +5412,7 @@ pthread_handler_t handle_slave_sql(void *arg) #ifdef WITH_WSREP thd->wsrep_exec_mode= LOCAL_STATE; + wsrep_thd_set_query_state(thd, QUERY_EXEC); /* synchronize with wsrep replication */ if (WSREP_ON) wsrep_ready_wait(); diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 2b5d2258655..5636283768a 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2015, Oracle and/or its affiliates. - Copyright (c) 2008, 2018, MariaDB Corporation. + Copyright (c) 2008, 2020, 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 @@ -605,6 +605,7 @@ THD::THD(my_thread_id id, bool is_wsrep_applier) m_current_stage_key(0), in_sub_stmt(0), log_all_errors(0), binlog_unsafe_warning_flags(0), + current_stmt_binlog_format(BINLOG_FORMAT_MIXED), binlog_table_maps(0), bulk_param(0), table_map_for_update(0), @@ -1225,7 +1226,7 @@ void THD::init() #ifdef WITH_WSREP wsrep_exec_mode= wsrep_applier ? REPL_RECV : LOCAL_STATE; wsrep_conflict_state= NO_CONFLICT; - wsrep_query_state= QUERY_IDLE; + wsrep_thd_set_query_state(this, QUERY_IDLE); wsrep_last_query_id= 0; wsrep_trx_meta.gtid= WSREP_GTID_UNDEFINED; wsrep_trx_meta.depends_on= WSREP_SEQNO_UNDEFINED; diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index 826951f7c9d..37d2b0e902f 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -1409,7 +1409,7 @@ void do_handle_one_connection(CONNECT *connect) if (WSREP(thd)) { mysql_mutex_lock(&thd->LOCK_thd_data); - thd->wsrep_query_state= QUERY_EXITING; + wsrep_thd_set_query_state(thd, QUERY_EXITING); mysql_mutex_unlock(&thd->LOCK_thd_data); } #endif diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 59b4e148005..db5a03b3daf 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1226,7 +1226,7 @@ bool do_command(THD *thd) if (WSREP(thd)) { mysql_mutex_lock(&thd->LOCK_thd_data); - thd->wsrep_query_state= QUERY_IDLE; + wsrep_thd_set_query_state(thd, QUERY_IDLE); if (thd->wsrep_conflict_state==MUST_ABORT) { wsrep_client_rollback(thd); @@ -1294,7 +1294,7 @@ bool do_command(THD *thd) thd->store_globals(); } - thd->wsrep_query_state= QUERY_EXEC; + wsrep_thd_set_query_state(thd, QUERY_EXEC); mysql_mutex_unlock(&thd->LOCK_thd_data); } #endif /* WITH_WSREP */ @@ -1594,7 +1594,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, } mysql_mutex_lock(&thd->LOCK_thd_data); - thd->wsrep_query_state= QUERY_EXEC; + wsrep_thd_set_query_state(thd, QUERY_EXEC); if (thd->wsrep_conflict_state== RETRY_AUTOCOMMIT) { thd->wsrep_conflict_state= NO_CONFLICT; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 9b132644ee7..d6c4a49526c 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2626,8 +2626,12 @@ int JOIN::optimize_stage2() having_is_correlated= MY_TEST(having->used_tables() & OUTER_REF_TABLE_BIT); tmp_having= having; - if ((select_lex->options & OPTION_SCHEMA_TABLE)) - optimize_schema_tables_reads(this); + if ((select_lex->options & OPTION_SCHEMA_TABLE) && + optimize_schema_tables_reads(this)) + DBUG_RETURN(TRUE); + + if (unlikely(thd->is_error())) + DBUG_RETURN(TRUE); /* The loose index scan access method guarantees that all grouping or diff --git a/sql/sql_select.h b/sql/sql_select.h index abcf9764009..2f23a8b0d0d 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -2,7 +2,7 @@ #define SQL_SELECT_INCLUDED /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. - Copyright (c) 2008, 2017, MariaDB Corporation. + Copyright (c) 2008, 2020, 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 @@ -1633,6 +1633,9 @@ public: void copy_ref_ptr_array(Ref_ptr_array dst_arr, Ref_ptr_array src_arr) { DBUG_ASSERT(dst_arr.size() >= src_arr.size()); + if (src_arr.size() == 0) + return; + void *dest= dst_arr.array(); const void *src= src_arr.array(); memcpy(dest, src, src_arr.size() * src_arr.element_size()); diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 7240cb3264c..a920b236d4f 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -8724,7 +8724,6 @@ end: bool optimize_schema_tables_reads(JOIN *join) { THD *thd= join->thd; - bool result= 0; DBUG_ENTER("optimize_schema_tables_reads"); JOIN_TAB *tab; @@ -8759,11 +8758,11 @@ bool optimize_schema_tables_reads(JOIN *join) */ cond= tab->cache_select->cond; } - - optimize_for_get_all_tables(thd, table_list, cond); + if (optimize_for_get_all_tables(thd, table_list, cond)) + DBUG_RETURN(TRUE); // Handle OOM } } - DBUG_RETURN(result); + DBUG_RETURN(FALSE); } diff --git a/sql/sql_string.h b/sql/sql_string.h index f4764211522..614b54065fd 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -3,7 +3,7 @@ /* Copyright (c) 2000, 2013, Oracle and/or its affiliates. - Copyright (c) 2008, 2018, MariaDB Corporation. + Copyright (c) 2008, 2020, 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 @@ -79,6 +79,10 @@ public: Well_formed_prefix(CHARSET_INFO *cs, const char *str, size_t length) :Well_formed_prefix_status(cs, str, str + length, length), m_str(str) { } + Well_formed_prefix(CHARSET_INFO *cs, LEX_STRING str, size_t nchars) + :Well_formed_prefix_status(cs, str.str, str.str + str.length, nchars), + m_str(str.str) + { } size_t length() const { return m_source_end_pos - m_str; } }; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 8642bd47da5..690ff1efcca 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2019, Oracle and/or its affiliates. - Copyright (c) 2010, 2019, MariaDB + Copyright (c) 2010, 2020, 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 @@ -4327,8 +4327,14 @@ bool validate_comment_length(THD *thd, LEX_CSTRING *comment, size_t max_len, uint err_code, const char *name) { DBUG_ENTER("validate_comment_length"); - size_t tmp_len= my_charpos(system_charset_info, comment->str, - comment->str + comment->length, max_len); + if (comment->length == 0) + DBUG_RETURN(false); + + if (max_len > comment->length) + max_len= comment->length; + + size_t tmp_len= + Well_formed_prefix(system_charset_info, comment->str, max_len).length(); if (tmp_len < comment->length) { if (thd->is_strict_mode()) diff --git a/sql/wsrep_applier.cc b/sql/wsrep_applier.cc index 0322c5f6a40..4e19e15680e 100644 --- a/sql/wsrep_applier.cc +++ b/sql/wsrep_applier.cc @@ -99,7 +99,7 @@ static wsrep_cb_status_t wsrep_apply_events(THD* thd, } mysql_mutex_lock(&thd->LOCK_thd_data); - thd->wsrep_query_state= QUERY_EXEC; + wsrep_thd_set_query_state(thd, QUERY_EXEC); if (thd->wsrep_conflict_state!= REPLAYING) thd->wsrep_conflict_state= NO_CONFLICT; mysql_mutex_unlock(&thd->LOCK_thd_data); @@ -199,7 +199,7 @@ static wsrep_cb_status_t wsrep_apply_events(THD* thd, error: mysql_mutex_lock(&thd->LOCK_thd_data); - thd->wsrep_query_state= QUERY_IDLE; + wsrep_thd_set_query_state(thd, QUERY_IDLE); mysql_mutex_unlock(&thd->LOCK_thd_data); assert(thd->wsrep_exec_mode== REPL_RECV); diff --git a/sql/wsrep_hton.cc b/sql/wsrep_hton.cc index 1feb46ecdaf..acd648de892 100644 --- a/sql/wsrep_hton.cc +++ b/sql/wsrep_hton.cc @@ -445,7 +445,7 @@ wsrep_run_wsrep_commit(THD *thd, bool all) DBUG_RETURN(WSREP_TRX_CERT_FAIL); } - thd->wsrep_query_state = QUERY_COMMITTING; + wsrep_thd_set_query_state(thd, QUERY_COMMITTING); mysql_mutex_unlock(&thd->LOCK_thd_data); cache = get_trans_log(thd); @@ -482,7 +482,7 @@ wsrep_run_wsrep_commit(THD *thd, bool all) { WSREP_DEBUG("empty rbr buffer, query: %s", thd->query()); } - thd->wsrep_query_state= QUERY_EXEC; + wsrep_thd_set_query_state(thd, QUERY_EXEC); DBUG_RETURN(WSREP_TRX_OK); } @@ -594,7 +594,7 @@ wsrep_run_wsrep_commit(THD *thd, bool all) WSREP_DEBUG("commit failed for reason: %d", rcode); DBUG_PRINT("wsrep", ("replicating commit fail")); - thd->wsrep_query_state= QUERY_EXEC; + wsrep_thd_set_query_state(thd, QUERY_EXEC); if (thd->wsrep_conflict_state == MUST_ABORT) { thd->wsrep_conflict_state= ABORTED; @@ -626,7 +626,7 @@ wsrep_run_wsrep_commit(THD *thd, bool all) DBUG_RETURN(WSREP_TRX_ERROR); } - thd->wsrep_query_state= QUERY_EXEC; + wsrep_thd_set_query_state(thd, QUERY_EXEC); mysql_mutex_unlock(&thd->LOCK_thd_data); DBUG_RETURN(WSREP_TRX_OK); diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index fe949298a76..6d7099375b5 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -2575,6 +2575,17 @@ extern "C" void wsrep_thd_set_exec_mode(THD *thd, enum wsrep_exec_mode mode) extern "C" void wsrep_thd_set_query_state( THD *thd, enum wsrep_query_state state) { + /* async slave thread should never flag IDLE state, as it may + give rollbacker thread chance to interfere and rollback async slave + transaction. + in fact, async slave thread is never idle as it reads complete + transactions from relay log and applies them, as a whole. + BF abort happens voluntarily by async slave thread. + */ + if (thd->slave_thread && state == QUERY_IDLE) { + WSREP_DEBUG("Skipping IDLE state change for slave SQL"); + return; + } thd->wsrep_query_state= state; } diff --git a/storage/connect/jdbconn.cpp b/storage/connect/jdbconn.cpp index 2cb75e0adc1..2dab385a36f 100644 --- a/storage/connect/jdbconn.cpp +++ b/storage/connect/jdbconn.cpp @@ -766,7 +766,6 @@ void JDBConn::AddJars(PSTRG jpop, char sep) /***********************************************************************/ bool JDBConn::Connect(PJPARM sop) { - int irc = RC_FX; bool err = false; jint rc; jboolean jt = (trace(1)); diff --git a/storage/connect/tabrest.cpp b/storage/connect/tabrest.cpp index 9c6b724973f..3ef2a460b9d 100644 --- a/storage/connect/tabrest.cpp +++ b/storage/connect/tabrest.cpp @@ -167,8 +167,7 @@ PQRYRES __stdcall ColREST(PGLOBAL g, PTOS tp, char *tab, char *db, bool info) #endif // !MARIADB // We used the file name relative to recorded datapath - strcat(strcat(strcat(strcpy(filename, "."), slash), db), slash); - strncat(filename, fn, _MAX_PATH - strlen(filename)); + snprintf(filename, sizeof filename, IF_WIN(".\\%s\\%s","./%s/%s"), db, fn); // Retrieve the file from the web and copy it locally if (http && grf(g->Message, trace(515), http, uri, filename)) { diff --git a/storage/connect/tabrest.h b/storage/connect/tabrest.h index 9cf2d10a6b8..f08ac7984c9 100644 --- a/storage/connect/tabrest.h +++ b/storage/connect/tabrest.h @@ -5,10 +5,7 @@ /***********************************************************************/ #pragma once -#if defined(__WIN__) -static PCSZ slash = "\\"; -#else // !__WIN__ -static PCSZ slash = "/"; +#ifndef __WIN__ #define stricmp strcasecmp #endif // !__WIN__ diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 54b527007c6..cff6dcb50a6 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -83,6 +83,8 @@ Created 11/5/1995 Heikki Tuuri #include "lzo/lzo1x.h" #endif +using st_::span; + #ifdef HAVE_LIBNUMA #include <numa.h> #include <numaif.h> @@ -461,7 +463,7 @@ buf_pool_register_chunk( @return true if temporary tablespace decrypted, false if not */ static bool buf_tmp_page_decrypt(byte* tmp_frame, byte* src_frame) { - if (buf_page_is_zeroes(src_frame, srv_page_size)) { + if (buf_is_zeroes(span<const byte>(src_frame, srv_page_size))) { return true; } @@ -948,20 +950,14 @@ static uint32_t buf_page_check_crc32(const byte* page, uint32_t checksum) # define buf_page_check_crc32(page, checksum) buf_calc_page_crc32(page) #endif /* INNODB_BUG_ENDIAN_CRC32 */ -/** Check if a page is all zeroes. -@param[in] read_buf database page -@param[in] page_size page frame size -@return whether the page is all zeroes */ -bool buf_page_is_zeroes(const void* read_buf, size_t page_size) + +/** Check if a buffer is all zeroes. +@param[in] buf data to check +@return whether the buffer is all zeroes */ +bool buf_is_zeroes(span<const byte> buf) { - const ulint* b = reinterpret_cast<const ulint*>(read_buf); - const ulint* const e = b + page_size / sizeof *b; - do { - if (*b++) { - return false; - } - } while (b != e); - return true; + ut_ad(buf.size() <= sizeof field_ref_zero); + return memcmp(buf.data(), field_ref_zero, buf.size()) == 0; } /** Check if a page is corrupt. @@ -1077,7 +1073,7 @@ buf_page_is_corrupted( /* 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. + the first page of the system tablespace. Ignore it for the system tablespace. */ if (!checksum_field1 && !checksum_field2) { /* Checksum fields can have valid value as zero. @@ -4240,7 +4236,45 @@ buf_wait_for_read( } } -/** This is the general function used to get access to a database page. +/** Lock the page with the given latch type. +@param[in,out] block block to be locked +@param[in] rw_latch RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH +@param[in] mtr mini-transaction +@param[in] file file name +@param[in] line line where called +@return pointer to locked block */ +static buf_block_t* buf_page_mtr_lock(buf_block_t *block, + ulint rw_latch, + mtr_t* mtr, + const char *file, + unsigned line) +{ + mtr_memo_type_t fix_type; + switch (rw_latch) + { + case RW_NO_LATCH: + fix_type= MTR_MEMO_BUF_FIX; + break; + case RW_S_LATCH: + rw_lock_s_lock_inline(&block->lock, 0, file, line); + fix_type= MTR_MEMO_PAGE_S_FIX; + break; + case RW_SX_LATCH: + rw_lock_sx_lock_inline(&block->lock, 0, file, line); + fix_type= MTR_MEMO_PAGE_SX_FIX; + break; + default: + ut_ad(rw_latch == RW_X_LATCH); + rw_lock_x_lock_inline(&block->lock, 0, file, line); + fix_type= MTR_MEMO_PAGE_X_FIX; + break; + } + + mtr_memo_push(mtr, block, fix_type); + return block; +} + +/** This is the low level function used to get access to a database page. @param[in] page_id page id @param[in] rw_latch RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH @param[in] guess guessed block or NULL @@ -4251,7 +4285,7 @@ BUF_PEEK_IF_IN_POOL, BUF_GET_NO_LATCH, or BUF_GET_IF_IN_POOL_OR_WATCH @param[in] mtr mini-transaction @return pointer to the block or NULL */ buf_block_t* -buf_page_get_gen( +buf_page_get_low( const page_id_t page_id, const page_size_t& page_size, ulint rw_latch, @@ -4897,35 +4931,7 @@ evict_from_pool: return NULL; } - mtr_memo_type_t fix_type; - - switch (rw_latch) { - case RW_NO_LATCH: - - fix_type = MTR_MEMO_BUF_FIX; - break; - - case RW_S_LATCH: - rw_lock_s_lock_inline(&fix_block->lock, 0, file, line); - - fix_type = MTR_MEMO_PAGE_S_FIX; - break; - - case RW_SX_LATCH: - rw_lock_sx_lock_inline(&fix_block->lock, 0, file, line); - - fix_type = MTR_MEMO_PAGE_SX_FIX; - break; - - default: - ut_ad(rw_latch == RW_X_LATCH); - rw_lock_x_lock_inline(&fix_block->lock, 0, file, line); - - fix_type = MTR_MEMO_PAGE_X_FIX; - break; - } - - mtr_memo_push(mtr, fix_block, fix_type); + fix_block = buf_page_mtr_lock(fix_block, rw_latch, mtr, file, line); if (mode != BUF_PEEK_IF_IN_POOL && !access_time) { /* In the case of a first access, try to apply linear @@ -4940,6 +4946,42 @@ evict_from_pool: return(fix_block); } +/** This is the general function used to get access to a database page. +It does page initialization and applies the buffered redo logs. +@param[in] page_id page id +@param[in] rw_latch RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH +@param[in] guess guessed block or NULL +@param[in] mode BUF_GET, BUF_GET_IF_IN_POOL, +BUF_PEEK_IF_IN_POOL, BUF_GET_NO_LATCH, or BUF_GET_IF_IN_POOL_OR_WATCH +@param[in] file file name +@param[in] line line where called +@param[in] mtr mini-transaction +@param[out] err DB_SUCCESS or error code +@return pointer to the block or NULL */ +buf_block_t* +buf_page_get_gen( + const page_id_t page_id, + const page_size_t& page_size, + ulint rw_latch, + buf_block_t* guess, + ulint mode, + const char* file, + unsigned line, + mtr_t* mtr, + dberr_t* err) +{ + if (buf_block_t *block = recv_recovery_create_page(page_id)) + { + buf_block_fix(block); + ut_ad(rw_lock_s_lock_nowait(&block->debug_latch, file, line)); + block= buf_page_mtr_lock(block, rw_latch, mtr, file, line); + return block; + } + + return buf_page_get_low(page_id, page_size, rw_latch, + guess, mode, file, line, mtr, err); +} + /********************************************************************//** This is the general function used to get optimistic access to a database page. diff --git a/storage/innobase/buf/buf0dblwr.cc b/storage/innobase/buf/buf0dblwr.cc index 55ce17513c2..c32deffd80c 100644 --- a/storage/innobase/buf/buf0dblwr.cc +++ b/storage/innobase/buf/buf0dblwr.cc @@ -34,6 +34,8 @@ Created 2011/12/19 #include "fil0crypt.h" #include "fil0pagecompress.h" +using st_::span; + /** The doublewrite buffer */ buf_dblwr_t* buf_dblwr = NULL; @@ -578,7 +580,8 @@ buf_dblwr_process() } const page_size_t page_size(space->flags); - ut_ad(!buf_page_is_zeroes(page, page_size.physical())); + ut_ad(!buf_is_zeroes(span<const byte>(page, + page_size.physical()))); /* We want to ensure that for partial reads the unread portion of the page is NUL. */ @@ -601,8 +604,8 @@ buf_dblwr_process() << "error: " << ut_strerr(err); } - const bool is_all_zero = buf_page_is_zeroes( - read_buf, page_size.physical()); + const bool is_all_zero = buf_is_zeroes( + span<const byte>(read_buf, page_size.physical())); const bool expect_encrypted = space->crypt_data && space->crypt_data->type != CRYPT_SCHEME_UNENCRYPTED; diff --git a/storage/innobase/ibuf/ibuf0ibuf.cc b/storage/innobase/ibuf/ibuf0ibuf.cc index 38814da0c8d..26ba7f6a388 100644 --- a/storage/innobase/ibuf/ibuf0ibuf.cc +++ b/storage/innobase/ibuf/ibuf0ibuf.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1997, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2016, 2019, MariaDB Corporation. +Copyright (c) 2016, 2020 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 @@ -28,6 +28,8 @@ Created 7/19/1997 Heikki Tuuri #include "sync0sync.h" #include "btr0sea.h" +using st_::span; + #if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG my_bool srv_ibuf_disable_background_merge; #endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */ @@ -4948,7 +4950,8 @@ dberr_t ibuf_check_bitmap_on_import(const trx_t* trx, fil_space_t* space) bitmap_page = ibuf_bitmap_get_map_page( page_id_t(space->id, page_no), page_size, &mtr); - if (buf_page_is_zeroes(bitmap_page, page_size.physical())) { + if (buf_is_zeroes(span<const byte>(bitmap_page, + page_size.physical()))) { /* This means we got all-zero page instead of ibuf bitmap page. The subsequent page should be all-zero pages. */ @@ -4960,8 +4963,8 @@ dberr_t ibuf_check_bitmap_on_import(const trx_t* trx, fil_space_t* space) page_id_t(space->id, curr_page), page_size, RW_S_LATCH, &mtr); page_t* page = buf_block_get_frame(block); - ut_ad(buf_page_is_zeroes( - page, page_size.physical())); + ut_ad(buf_is_zeroes(span<const byte>( + page, page_size.physical()))); } #endif /* UNIV_DEBUG */ ibuf_exit(&mtr); diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h index b44715478a8..6bf2dc2f1c4 100644 --- a/storage/innobase/include/buf0buf.h +++ b/storage/innobase/include/buf0buf.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2019, MariaDB Corporation. +Copyright (c) 2013, 2020 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 @@ -33,6 +33,7 @@ Created 11/5/1995 Heikki Tuuri #include "fil0fil.h" #include "mtr0types.h" #include "buf0types.h" +#include "span.h" #ifndef UNIV_INNOCHECKSUM #include "hash0hash.h" #include "ut0byte.h" @@ -435,6 +436,7 @@ buf_page_get_zip( const page_size_t& page_size); /** This is the general function used to get access to a database page. +It does page initialization and applies the buffered redo logs. @param[in] page_id page id @param[in] rw_latch RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH @param[in] guess guessed block or NULL @@ -457,6 +459,29 @@ buf_page_get_gen( mtr_t* mtr, dberr_t* err); +/** This is the low level function used to get access to a database page. +@param[in] page_id page id +@param[in] rw_latch RW_S_LATCH, RW_X_LATCH, RW_NO_LATCH +@param[in] guess guessed block or NULL +@param[in] mode BUF_GET, BUF_GET_IF_IN_POOL, +BUF_PEEK_IF_IN_POOL, BUF_GET_NO_LATCH, or BUF_GET_IF_IN_POOL_OR_WATCH +@param[in] file file name +@param[in] line line where called +@param[in] mtr mini-transaction +@param[out] err DB_SUCCESS or error code +@return pointer to the block or NULL */ +buf_block_t* +buf_page_get_low( + const page_id_t page_id, + const page_size_t& page_size, + ulint rw_latch, + buf_block_t* guess, + ulint mode, + const char* file, + unsigned line, + mtr_t* mtr, + dberr_t* err); + /** Initializes a page to the buffer buf_pool. The page is usually not read from a file even if it cannot be found in the buffer buf_pool. This is one of the functions which perform to a block a state transition NOT_USED => @@ -646,11 +671,10 @@ buf_block_unfix(buf_block_t* block); # endif /* UNIV_DEBUG */ #endif /* !UNIV_INNOCHECKSUM */ -/** Check if a page is all zeroes. -@param[in] read_buf database page -@param[in] page_size page frame size -@return whether the page is all zeroes */ -bool buf_page_is_zeroes(const void* read_buf, size_t page_size); +/** Check if a buffer is all zeroes. +@param[in] buf data to check +@return whether the buffer is all zeroes */ +bool buf_is_zeroes(st_::span<const byte> buf); /** Checks if the page is in crc32 checksum format. @param[in] read_buf database page diff --git a/storage/innobase/include/data0data.h b/storage/innobase/include/data0data.h index 706d65a4469..11a7f2e516f 100644 --- a/storage/innobase/include/data0data.h +++ b/storage/innobase/include/data0data.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2019, MariaDB Corporation. +Copyright (c) 2017, 2019, 2020 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 @@ -32,6 +32,7 @@ Created 5/30/1994 Heikki Tuuri #include "mem0mem.h" #include "dict0types.h" #include "btr0types.h" +#include <vector> #include <ostream> @@ -526,9 +527,6 @@ struct dtuple_t { dfield_t* fields; /*!< fields */ ulint n_v_fields; /*!< number of virtual fields */ dfield_t* v_fields; /*!< fields on virtual column */ - UT_LIST_NODE_T(dtuple_t) tuple_list; - /*!< data tuples can be linked into a - list using this field */ #ifdef UNIV_DEBUG ulint magic_n; /*!< magic number, used in debug assertions */ diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index ee4c12b4134..a754b978cbe 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -653,7 +653,7 @@ public: /** Return the next fil_space_t from key rotation list. Once started, the caller must keep calling this until it returns NULL. - fil_space_acquire() and fil_space_release() are invoked here which + fil_space_acquire() and fil_space_t::release() are invoked here, which blocks a concurrent operation from dropping the tablespace. @param[in] prev_space Previous tablespace or NULL to start from beginning of fil_system->rotation diff --git a/storage/innobase/include/log0recv.h b/storage/innobase/include/log0recv.h index 6c5bb2551cf..866102e6f3d 100644 --- a/storage/innobase/include/log0recv.h +++ b/storage/innobase/include/log0recv.h @@ -329,4 +329,22 @@ times! */ roll-forward */ #define RECV_SCAN_SIZE (4U << srv_page_size_shift) +/** This is a low level function for the recovery system +to create a page which has buffered intialized redo log records. +@param[in] page_id page to be created using redo logs +@return whether the page creation successfully */ +buf_block_t* recv_recovery_create_page_low(const page_id_t page_id); + +/** Recovery system creates a page which has buffered intialized +redo log records. +@param[in] page_id page to be created using redo logs +@return block which contains page was initialized */ +inline buf_block_t* recv_recovery_create_page(const page_id_t page_id) +{ + if (UNIV_LIKELY(!recv_recovery_on)) + return NULL; + + return recv_recovery_create_page_low(page_id); +} + #endif diff --git a/storage/innobase/include/page0size.h b/storage/innobase/include/page0size.h index 128975f55bc..ca1e704eda1 100644 --- a/storage/innobase/include/page0size.h +++ b/storage/innobase/include/page0size.h @@ -34,7 +34,7 @@ Created Nov 14, 2013 Vasil Dimov /** A BLOB field reference full of zero, for use in assertions and tests.Initially, BLOB field references are set to zero, in dtuple_convert_big_rec(). */ -extern const byte field_ref_zero[FIELD_REF_SIZE]; +extern const byte field_ref_zero[UNIV_PAGE_SIZE_MAX]; #define PAGE_SIZE_T_SIZE_BITS 17 diff --git a/storage/innobase/include/page0zip.h b/storage/innobase/include/page0zip.h index c2be1783cbf..da682df2e14 100644 --- a/storage/innobase/include/page0zip.h +++ b/storage/innobase/include/page0zip.h @@ -528,7 +528,7 @@ page_zip_calc_checksum( @param data ROW_FORMAT=COMPRESSED page @param size size of the page, in bytes @return whether the stored checksum matches innodb_checksum_algorithm */ -bool page_zip_verify_checksum(const void *data, size_t size); +bool page_zip_verify_checksum(const byte *data, size_t size); #ifndef UNIV_INNOCHECKSUM /**********************************************************************//** diff --git a/storage/innobase/include/row0ins.h b/storage/innobase/include/row0ins.h index 9b6aac9c548..95f4388902d 100644 --- a/storage/innobase/include/row0ins.h +++ b/storage/innobase/include/row0ins.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2019, MariaDB Corporation. +Copyright (c) 2017, 2020, 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 @@ -31,6 +31,7 @@ Created 4/20/1996 Heikki Tuuri #include "que0types.h" #include "trx0types.h" #include "row0types.h" +#include <vector> /***************************************************************//** Checks if foreign key constraint fails for an index entry. Sets shared locks @@ -52,15 +53,7 @@ row_ins_check_foreign_constraint( dtuple_t* entry, /*!< in: index entry for index */ que_thr_t* thr) /*!< in: query thread */ MY_ATTRIBUTE((nonnull, warn_unused_result)); -/*********************************************************************//** -Creates an insert node struct. -@return own: insert node struct */ -ins_node_t* -ins_node_create( -/*============*/ - ulint ins_type, /*!< in: INS_VALUES, ... */ - dict_table_t* table, /*!< in: table where to insert */ - mem_heap_t* heap); /*!< in: mem heap where created */ + /*********************************************************************//** Sets a new row to insert for an INS_DIRECT node. This function is only used if we have constructed the row separately, which is a rare case; this @@ -158,10 +151,31 @@ row_ins_step( /*=========*/ que_thr_t* thr); /*!< in: query thread */ -/* Insert node structure */ +/* Insert node types */ +#define INS_SEARCHED 0 /* INSERT INTO ... SELECT ... */ +#define INS_VALUES 1 /* INSERT INTO ... VALUES ... */ +#define INS_DIRECT 2 /* this is for internal use in dict0crea: + insert the row directly */ + +/* Node execution states */ +#define INS_NODE_SET_IX_LOCK 1 /* we should set an IX lock on table */ +#define INS_NODE_ALLOC_ROW_ID 2 /* row id should be allocated */ +#define INS_NODE_INSERT_ENTRIES 3 /* index entries should be built and + inserted */ -struct ins_node_t{ - que_common_t common; /*!< node type: QUE_NODE_INSERT */ +/** Insert node structure */ +struct ins_node_t +{ + explicit ins_node_t(ulint ins_type, dict_table_t *table) : + common(QUE_NODE_INSERT, NULL), + ins_type(ins_type), + row(NULL), table(table), select(NULL), values_list(NULL), + state(INS_NODE_SET_IX_LOCK), index(NULL), + entry_list(), entry(entry_list.end()), + trx_id(0), entry_sys_heap(mem_heap_create(128)) + { + } + que_common_t common; /*!< node type: QUE_NODE_INSERT */ ulint ins_type;/* INS_VALUES, INS_SEARCHED, or INS_DIRECT */ dtuple_t* row; /*!< row to insert */ dict_table_t* table; /*!< table where to insert */ @@ -171,11 +185,12 @@ struct ins_node_t{ ulint state; /*!< node execution state */ dict_index_t* index; /*!< NULL, or the next index where the index entry should be inserted */ - dtuple_t* entry; /*!< NULL, or entry to insert in the index; + std::vector<dtuple_t*> + entry_list;/* list of entries, one for each index */ + std::vector<dtuple_t*>::iterator + entry; /*!< NULL, or entry to insert in the index; after a successful insert of the entry, this should be reset to NULL */ - UT_LIST_BASE_NODE_T(dtuple_t) - entry_list;/* list of entries, one for each index */ /** buffer for the system columns */ byte sys_buf[DATA_ROW_ID_LEN + DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN]; @@ -188,20 +203,18 @@ struct ins_node_t{ entry_list and sys fields are stored here; if this is NULL, entry list should be created and buffers for sys fields in row allocated */ - ulint magic_n; }; -#define INS_NODE_MAGIC_N 15849075 +/** Create an insert object. +@param ins_type INS_VALUES, ... +@param table table where to insert +@param heap memory heap +@return the created object */ +inline ins_node_t *ins_node_create(ulint ins_type, dict_table_t *table, + mem_heap_t *heap) +{ + return new (mem_heap_alloc(heap, sizeof(ins_node_t))) + ins_node_t(ins_type, table); +} -/* Insert node types */ -#define INS_SEARCHED 0 /* INSERT INTO ... SELECT ... */ -#define INS_VALUES 1 /* INSERT INTO ... VALUES ... */ -#define INS_DIRECT 2 /* this is for internal use in dict0crea: - insert the row directly */ - -/* Node execution states */ -#define INS_NODE_SET_IX_LOCK 1 /* we should set an IX lock on table */ -#define INS_NODE_ALLOC_ROW_ID 2 /* row id should be allocated */ -#define INS_NODE_INSERT_ENTRIES 3 /* index entries should be built and - inserted */ #endif diff --git a/storage/innobase/include/span.h b/storage/innobase/include/span.h deleted file mode 100644 index faeb41029b8..00000000000 --- a/storage/innobase/include/span.h +++ /dev/null @@ -1,145 +0,0 @@ -/***************************************************************************** - -Copyright (c) 2019, 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 -Foundation; version 2 of the License. - -This program is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA - -*****************************************************************************/ - -#pragma once - -#include <cstddef> -#include <iterator> - -namespace st_ { - -template <class ElementType> class span { -public: - typedef ElementType element_type; - typedef ElementType value_type; - typedef size_t index_type; - typedef ptrdiff_t difference_type; - typedef element_type* pointer; - typedef const element_type* const_pointer; - typedef element_type& reference; - typedef const element_type& const_reference; - typedef pointer iterator; - typedef const pointer const_iterator; - typedef std::reverse_iterator<iterator> reverse_iterator; - typedef std::reverse_iterator<const_iterator> const_reverse_iterator; - - span() : data_(NULL), size_(0) {} - - span(pointer ptr, index_type count) : data_(ptr), size_(count) {} - - span(pointer first, pointer last) : data_(first), size_(last - first) {} - - template <size_t N> span(element_type (&arr)[N]) : data_(arr), size_(N) - { - } - - template <class Container> - span(Container& cont) : data_(cont.begin()), size_(cont.size()) - { - } - - template <class Container> - span(const Container& cont) : data_(cont.begin()), size_(cont.size()) - { - } - - span(const span& other) : data_(other.data_), size_(other.size_) {} - - ~span(){}; - - span& operator=(const span& other) - { - data_ = other.data_; - size_ = other.size_; - return *this; - } - - template <size_t Count> span<element_type> first() const - { - assert(!empty()); - return span(data_, 1); - } - template <size_t Count> span<element_type> last() const - { - assert(!empty()); - return span(data_ + size() - 1, 1); - } - - span<element_type> first(index_type count) const - { - assert(!empty()); - return span(data_, 1); - } - span<element_type> last(index_type count) const - { - assert(!empty()); - return span(data_ + size() - 1, 1); - } - span<element_type> subspan(index_type offset, index_type count) const - { - assert(!empty()); - assert(size() >= offset + count); - return span(data_ + offset, count); - } - - index_type size() const { return size_; } - index_type size_bytes() const { return size_ * sizeof(ElementType); } - bool empty() const __attribute__((warn_unused_result)) - { - return size_ == 0; - } - - reference operator[](index_type idx) const - { - assert(size() > idx); - return data_[idx]; - } - reference front() const - { - assert(!empty()); - return data_[0]; - } - reference back() const - { - assert(!empty()); - return data_[size() - 1]; - } - pointer data() const - { - assert(!empty()); - return data_; - } - - iterator begin() const { return data_; } - iterator end() const { return data_ + size_; } - reverse_iterator rbegin() const - { - return std::reverse_iterator<iterator>(std::advance(end(), -1)); - } - reverse_iterator rend() const - { - return std::reverse_iterator<iterator>( - std::advance(begin(), -1)); - } - -private: - pointer data_; - index_type size_; -}; - -} // namespace st_ diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc index d2e0e6118c7..ad2fc4e22d3 100644 --- a/storage/innobase/log/log0recv.cc +++ b/storage/innobase/log/log0recv.cc @@ -313,7 +313,7 @@ public: if (!i->second.created) { continue; } - if (buf_block_t* block = buf_page_get_gen( + if (buf_block_t* block = buf_page_get_low( i->first, univ_page_size, RW_X_LATCH, NULL, BUF_GET_IF_IN_POOL, __FILE__, __LINE__, &mtr, NULL)) { @@ -2254,6 +2254,99 @@ static void recv_read_in_area(const page_id_t page_id) mutex_enter(&recv_sys->mutex); } +/** This is another low level function for the recovery system +to create a page which has buffered page intialization redo log records. +@param[in] page_id page to be created using redo logs +@param[in,out] recv_addr Hashed redo logs for the given page id +@return whether the page creation successfully */ +static buf_block_t* recv_recovery_create_page_low(const page_id_t page_id, + recv_addr_t* recv_addr) +{ + mtr_t mtr; + mlog_init_t::init &i= mlog_init.last(page_id); + const lsn_t end_lsn= UT_LIST_GET_LAST(recv_addr->rec_list)->end_lsn; + + if (end_lsn < i.lsn) + { + DBUG_LOG("ib_log", "skip log for page " + << page_id + << " LSN " << end_lsn + << " < " << i.lsn); + recv_addr->state= RECV_PROCESSED; +ignore: + ut_a(recv_sys->n_addrs); + recv_sys->n_addrs--; + return NULL; + } + + fil_space_t *space= fil_space_acquire(recv_addr->space); + if (!space) + { + recv_addr->state= RECV_PROCESSED; + goto ignore; + } + + if (space->enable_lsn) + { +init_fail: + space->release(); + recv_addr->state= RECV_NOT_PROCESSED; + return NULL; + } + + /* Determine if a tablespace could be for an internal table + for FULLTEXT INDEX. For those tables, no MLOG_INDEX_LOAD record + used to be written when redo logging was disabled. Hence, we + cannot optimize away page reads, because all the redo + log records for initializing and modifying the page in the + past could be older than the page in the data file. + + The check is too broad, causing all + tables whose names start with FTS_ to skip the optimization. */ + + if (strstr(space->name, "/FTS_")) + goto init_fail; + + mtr.start(); + mtr.set_log_mode(MTR_LOG_NONE); + buf_block_t *block= buf_page_create(page_id, page_size_t(space->flags), + &mtr); + if (recv_addr->state == RECV_PROCESSED) + /* The page happened to exist in the buffer pool, or it was + just being read in. Before buf_page_get_with_no_latch() returned, + all changes must have been applied to the page already. */ + mtr.commit(); + else + { + i.created= true; + buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK); + mtr.x_latch_at_savepoint(0, block); + recv_recover_page(block, mtr, recv_addr, i.lsn); + ut_ad(mtr.has_committed()); + } + + space->release(); + return block; +} + +/** This is a low level function for the recovery system +to create a page which has buffered intialized redo log records. +@param[in] page_id page to be created using redo logs +@return whether the page creation successfully */ +buf_block_t* recv_recovery_create_page_low(const page_id_t page_id) +{ + buf_block_t* block= NULL; + mutex_enter(&recv_sys->mutex); + recv_addr_t* recv_addr= recv_get_fil_addr_struct(page_id.space(), + page_id.page_no()); + if (recv_addr && recv_addr->state == RECV_WILL_NOT_READ) + { + block= recv_recovery_create_page_low(page_id, recv_addr); + } + mutex_exit(&recv_sys->mutex); + return block; +} + /** Apply the hash table of stored log records to persistent data pages. @param[in] last_batch whether the change buffer merge will be performed as part of the operation */ @@ -2345,7 +2438,7 @@ ignore: apply: mtr.start(); mtr.set_log_mode(MTR_LOG_NONE); - if (buf_block_t* block = buf_page_get_gen( + if (buf_block_t* block = buf_page_get_low( page_id, univ_page_size, RW_X_LATCH, NULL, BUF_GET_IF_IN_POOL, @@ -2359,77 +2452,9 @@ apply: mtr.commit(); recv_read_in_area(page_id); } - } else { - mlog_init_t::init& i = mlog_init.last(page_id); - const lsn_t end_lsn = UT_LIST_GET_LAST( - recv_addr->rec_list)->end_lsn; - - if (end_lsn < i.lsn) { - DBUG_LOG("ib_log", "skip log for page " - << page_id - << " LSN " << end_lsn - << " < " << i.lsn); -skip: - recv_addr->state = RECV_PROCESSED; - goto ignore; - } - - fil_space_t* space = fil_space_acquire( - recv_addr->space); - if (!space) { - goto skip; - } - - if (space->enable_lsn) { -do_read: - space->release(); - recv_addr->state = RECV_NOT_PROCESSED; - goto apply; - } - - /* Determine if a tablespace could be - for an internal table for FULLTEXT INDEX. - For those tables, no MLOG_INDEX_LOAD record - used to be written when redo logging was - disabled. Hence, we cannot optimize - away page reads, because all the redo - log records for initializing and - modifying the page in the past could - be older than the page in the data - file. - - The check is too broad, causing all - tables whose names start with FTS_ to - skip the optimization. */ - - if (strstr(space->name, "/FTS_")) { - goto do_read; - } - - mtr.start(); - mtr.set_log_mode(MTR_LOG_NONE); - buf_block_t* block = buf_page_create( - page_id, page_size_t(space->flags), - &mtr); - if (recv_addr->state == RECV_PROCESSED) { - /* The page happened to exist - in the buffer pool, or it was - just being read in. Before - buf_page_get_with_no_latch() - returned, all changes must have - been applied to the page already. */ - mtr.commit(); - } else { - i.created = true; - buf_block_dbg_add_level( - block, SYNC_NO_ORDER_CHECK); - mtr.x_latch_at_savepoint(0, block); - recv_recover_page(block, mtr, - recv_addr, i.lsn); - ut_ad(mtr.has_committed()); - } - - space->release(); + } else if (!recv_recovery_create_page_low( + page_id, recv_addr)) { + goto apply; } } } diff --git a/storage/innobase/page/page0zip.cc b/storage/innobase/page/page0zip.cc index 5f64b8c4b3a..05b4d907ff0 100644 --- a/storage/innobase/page/page0zip.cc +++ b/storage/innobase/page/page0zip.cc @@ -27,16 +27,14 @@ Created June 2005 by Marko Makela #include "page0size.h" #include "page0zip.h" +#include "span.h" + +using st_::span; /** A BLOB field reference full of zero, for use in assertions and tests. Initially, BLOB field references are set to zero, in dtuple_convert_big_rec(). */ -const byte field_ref_zero[FIELD_REF_SIZE] = { - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, -}; +const byte field_ref_zero[UNIV_PAGE_SIZE_MAX] = { 0, }; #ifndef UNIV_INNOCHECKSUM #include "page0page.h" @@ -110,7 +108,7 @@ Compare at most sizeof(field_ref_zero) bytes. /** Assert that a BLOB pointer is filled with zero bytes. @param b in: BLOB pointer */ #define ASSERT_ZERO_BLOB(b) \ - ut_ad(!memcmp(b, field_ref_zero, sizeof field_ref_zero)) + ut_ad(!memcmp(b, field_ref_zero, FIELD_REF_SIZE)) /* Enable some extra debugging output. This code can be enabled independently of any UNIV_ debugging conditions. */ @@ -5064,7 +5062,7 @@ page_zip_calc_checksum( @param data ROW_FORMAT=COMPRESSED page @param size size of the page, in bytes @return whether the stored checksum matches innodb_checksum_algorithm */ -bool page_zip_verify_checksum(const void *data, size_t size) +bool page_zip_verify_checksum(const byte *data, size_t size) { const srv_checksum_algorithm_t curr_algo = static_cast<srv_checksum_algorithm_t>(srv_checksum_algorithm); @@ -5073,17 +5071,12 @@ bool page_zip_verify_checksum(const void *data, size_t size) return true; } - for (size_t i = 0; i < size; i++) { - if (static_cast<const byte*>(data)[i] != 0) { - goto not_all_zeroes; - } + if (buf_is_zeroes(span<const byte>(data, size))) { + return true; } - return true; - -not_all_zeroes: const uint32_t stored = mach_read_from_4( - static_cast<const byte*>(data) + FIL_PAGE_SPACE_OR_CHKSUM); + data + FIL_PAGE_SPACE_OR_CHKSUM); uint32_t calc = page_zip_calc_checksum(data, size, curr_algo); diff --git a/storage/innobase/que/que0que.cc b/storage/innobase/que/que0que.cc index 878427e536e..abd4672517e 100644 --- a/storage/innobase/que/que0que.cc +++ b/storage/innobase/que/que0que.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2018, MariaDB Corporation. +Copyright (c) 2017, 2018, 2020 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 @@ -460,6 +460,8 @@ que_graph_free_recursive( que_graph_free_recursive(ins->select); ins->select = NULL; + ins->~ins_node_t(); + if (ins->entry_sys_heap != NULL) { mem_heap_free(ins->entry_sys_heap); ins->entry_sys_heap = NULL; diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc index c494ae519ca..f0e14790d8d 100644 --- a/storage/innobase/row/row0ins.cc +++ b/storage/innobase/row/row0ins.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2016, 2019, MariaDB Corporation. +Copyright (c) 2016, 2020, 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 @@ -61,39 +61,6 @@ check. If you make a change in this module make sure that no codepath is introduced where a call to log_free_check() is bypassed. */ -/*********************************************************************//** -Creates an insert node struct. -@return own: insert node struct */ -ins_node_t* -ins_node_create( -/*============*/ - ulint ins_type, /*!< in: INS_VALUES, ... */ - dict_table_t* table, /*!< in: table where to insert */ - mem_heap_t* heap) /*!< in: mem heap where created */ -{ - ins_node_t* node; - - node = static_cast<ins_node_t*>( - mem_heap_zalloc(heap, sizeof(ins_node_t))); - - if (!node) { - return(NULL); - } - - node->common.type = QUE_NODE_INSERT; - - node->ins_type = ins_type; - - node->state = INS_NODE_SET_IX_LOCK; - node->table = table; - - node->entry_sys_heap = mem_heap_create(128); - - node->magic_n = INS_NODE_MAGIC_N; - - return(node); -} - /***********************************************************//** Creates an entry template for each index of a table. */ static @@ -107,12 +74,12 @@ ins_node_create_entry_list( ut_ad(node->entry_sys_heap); - UT_LIST_INIT(node->entry_list, &dtuple_t::tuple_list); - /* We will include all indexes (include those corrupted - secondary indexes) in the entry list. Filteration of + secondary indexes) in the entry list. Filtration of these corrupted index will be done in row_ins() */ + node->entry_list.reserve(UT_LIST_GET_LEN(node->table->indexes)); + for (index = dict_table_get_first_index(node->table); index != 0; index = dict_table_get_next_index(index)) { @@ -121,7 +88,7 @@ ins_node_create_entry_list( node->row, NULL, index, node->entry_sys_heap, ROW_BUILD_FOR_INSERT); - UT_LIST_ADD_LAST(node->entry_list, entry); + node->entry_list.push_back(entry); } } @@ -189,7 +156,8 @@ ins_node_set_new_row( { node->state = INS_NODE_SET_IX_LOCK; node->index = NULL; - node->entry = NULL; + node->entry_list.clear(); + node->entry = node->entry_list.end(); node->row = row; @@ -3499,15 +3467,16 @@ row_ins_index_entry_step( ut_ad(dtuple_check_typed(node->row)); - err = row_ins_index_entry_set_vals(node->index, node->entry, node->row); + err = row_ins_index_entry_set_vals(node->index, *node->entry, + node->row); if (err != DB_SUCCESS) { DBUG_RETURN(err); } - ut_ad(dtuple_check_typed(node->entry)); + ut_ad(dtuple_check_typed(*node->entry)); - err = row_ins_index_entry(node->index, node->entry, thr); + err = row_ins_index_entry(node->index, *node->entry, thr); DEBUG_SYNC_C_IF_THD(thr_get_trx(thr)->mysql_thd, "after_row_ins_index_entry_step"); @@ -3625,7 +3594,8 @@ row_ins( row_ins_alloc_row_id_step(node); node->index = dict_table_get_first_index(node->table); - node->entry = UT_LIST_GET_FIRST(node->entry_list); + ut_ad(node->entry_list.empty() == false); + node->entry = node->entry_list.begin(); if (node->ins_type == INS_SEARCHED) { @@ -3651,20 +3621,16 @@ row_ins( } node->index = dict_table_get_next_index(node->index); - node->entry = UT_LIST_GET_NEXT(tuple_list, node->entry); - - DBUG_EXECUTE_IF( - "row_ins_skip_sec", - node->index = NULL; node->entry = NULL; break;); + ++node->entry; /* Skip corrupted secondary index and its entry */ while (node->index && node->index->is_corrupted()) { node->index = dict_table_get_next_index(node->index); - node->entry = UT_LIST_GET_NEXT(tuple_list, node->entry); + ++node->entry; } } - ut_ad(node->entry == NULL); + ut_ad(node->entry == node->entry_list.end()); node->state = INS_NODE_ALLOC_ROW_ID; @@ -3720,14 +3686,14 @@ row_ins_step( DBUG_ASSERT(node->table->get_ref_count() > 0); DBUG_ASSERT(node->ins_type == INS_DIRECT); /* No-rollback tables can consist only of a single index. */ - DBUG_ASSERT(UT_LIST_GET_LEN(node->entry_list) == 1); + DBUG_ASSERT(node->entry_list.size() == 1); DBUG_ASSERT(UT_LIST_GET_LEN(node->table->indexes) == 1); /* There should be no possibility for interruption and restarting here. In theory, we could allow resumption from the INS_NODE_INSERT_ENTRIES state here. */ DBUG_ASSERT(node->state == INS_NODE_SET_IX_LOCK); node->index = dict_table_get_first_index(node->table); - node->entry = UT_LIST_GET_FIRST(node->entry_list); + node->entry = node->entry_list.begin(); node->state = INS_NODE_INSERT_ENTRIES; goto do_insert; } diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index c14be0e8260..51845e2ea47 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -1097,7 +1097,7 @@ row_get_prebuilt_insert_row( may need to rebuild the row insert template. */ if (prebuilt->trx_id == table->def_trx_id - && UT_LIST_GET_LEN(prebuilt->ins_node->entry_list) + && prebuilt->ins_node->entry_list.size() == UT_LIST_GET_LEN(table->indexes)) { return(prebuilt->ins_node->row); diff --git a/storage/innobase/trx/trx0rec.cc b/storage/innobase/trx/trx0rec.cc index ab17dd03a43..242ac46c720 100644 --- a/storage/innobase/trx/trx0rec.cc +++ b/storage/innobase/trx/trx0rec.cc @@ -42,8 +42,7 @@ Created 3/26/1996 Heikki Tuuri /** The search tuple corresponding to TRX_UNDO_INSERT_METADATA */ const dtuple_t trx_undo_metadata = { REC_INFO_METADATA, 0, 0, - NULL, 0, NULL, - UT_LIST_NODE_T(dtuple_t)() + NULL, 0, NULL #ifdef UNIV_DEBUG , DATA_TUPLE_MAGIC_N #endif /* UNIV_DEBUG */ diff --git a/storage/rocksdb/build_rocksdb.cmake b/storage/rocksdb/build_rocksdb.cmake index 2fbc938ae00..4b12baee9f8 100644 --- a/storage/rocksdb/build_rocksdb.cmake +++ b/storage/rocksdb/build_rocksdb.cmake @@ -60,10 +60,10 @@ if(BZIP2_FOUND AND (NOT WITH_ROCKSDB_BZIP2 STREQUAL "OFF")) list(APPEND THIRDPARTY_LIBS ${BZIP2_LIBRARIES}) endif() -if(SNAPPY_FOUND AND (NOT WITH_ROCKSDB_SNAPPY STREQUAL "OFF")) +if(snappy_FOUND AND (NOT WITH_ROCKSDB_SNAPPY STREQUAL "OFF")) add_definitions(-DSNAPPY) - include_directories(${SNAPPY_INCLUDE_DIR}) - list(APPEND THIRDPARTY_LIBS ${SNAPPY_LIBRARIES}) + include_directories(${snappy_INCLUDE_DIR}) + list(APPEND THIRDPARTY_LIBS ${snappy_LIBRARIES}) endif() include(CheckFunctionExists) @@ -189,31 +189,32 @@ set(ROCKSDB_SOURCES cache/clock_cache.cc cache/lru_cache.cc cache/sharded_cache.cc + db/arena_wrapped_db_iter.cc db/builder.cc db/c.cc db/column_family.cc db/compacted_db_impl.cc db/compaction/compaction.cc db/compaction/compaction_iterator.cc - db/compaction/compaction_job.cc db/compaction/compaction_picker.cc + db/compaction/compaction_job.cc db/compaction/compaction_picker_fifo.cc db/compaction/compaction_picker_level.cc db/compaction/compaction_picker_universal.cc db/convenience.cc db/db_filesnapshot.cc - db/dbformat.cc db/db_impl/db_impl.cc + db/db_impl/db_impl_write.cc db/db_impl/db_impl_compaction_flush.cc - db/db_impl/db_impl_debug.cc - db/db_impl/db_impl_experimental.cc db/db_impl/db_impl_files.cc db/db_impl/db_impl_open.cc + db/db_impl/db_impl_debug.cc + db/db_impl/db_impl_experimental.cc db/db_impl/db_impl_readonly.cc db/db_impl/db_impl_secondary.cc - db/db_impl/db_impl_write.cc db/db_info_dumper.cc db/db_iter.cc + db/dbformat.cc db/error_handler.cc db/event_helpers.cc db/experimental.cc @@ -222,9 +223,10 @@ set(ROCKSDB_SOURCES db/flush_job.cc db/flush_scheduler.cc db/forward_iterator.cc + db/import_column_family_job.cc db/internal_stats.cc - db/log_reader.cc db/logs_with_prep_tracker.cc + db/log_reader.cc db/log_writer.cc db/malloc_stats.cc db/memtable.cc @@ -238,22 +240,31 @@ set(ROCKSDB_SOURCES db/table_cache.cc db/table_properties_collector.cc db/transaction_log_impl.cc + db/trim_history_scheduler.cc db/version_builder.cc db/version_edit.cc db/version_set.cc db/wal_manager.cc - db/write_batch_base.cc db/write_batch.cc + db/write_batch_base.cc db/write_controller.cc db/write_thread.cc env/env.cc env/env_chroot.cc + env/env_encryption.cc env/env_hdfs.cc + env/file_system.cc env/mock_env.cc file/delete_scheduler.cc - file/filename.cc + file/file_prefetch_buffer.cc file/file_util.cc + file/filename.cc + file/random_access_file_reader.cc + file/read_write_util.cc + file/readahead_raf.cc + file/sequence_file_reader.cc file/sst_file_manager_impl.cc + file/writable_file_writer.cc logging/auto_roll_logger.cc logging/event_logger.cc logging/log_buffer.cc @@ -268,8 +279,8 @@ set(ROCKSDB_SOURCES memtable/write_buffer_manager.cc monitoring/histogram.cc monitoring/histogram_windowing.cc - monitoring/instrumented_mutex.cc monitoring/in_memory_stats_history.cc + monitoring/instrumented_mutex.cc monitoring/iostats_context.cc monitoring/perf_context.cc monitoring/perf_level.cc @@ -277,7 +288,6 @@ set(ROCKSDB_SOURCES monitoring/statistics.cc monitoring/thread_status_impl.cc monitoring/thread_status_updater.cc - monitoring/thread_status_updater_debug.cc monitoring/thread_status_util.cc monitoring/thread_status_util_debug.cc options/cf_options.cc @@ -288,21 +298,24 @@ set(ROCKSDB_SOURCES options/options_sanity_check.cc port/stack_trace.cc table/adaptive/adaptive_table_factory.cc + table/block_based/block.cc table/block_based/block_based_filter_block.cc table/block_based/block_based_table_builder.cc table/block_based/block_based_table_factory.cc table/block_based/block_based_table_reader.cc table/block_based/block_builder.cc - table/block_based/block.cc table/block_based/block_prefix_index.cc - table/block_based/data_block_footer.cc table/block_based/data_block_hash_index.cc + table/block_based/data_block_footer.cc + table/block_based/filter_block_reader_common.cc + table/block_based/filter_policy.cc table/block_based/flush_block_policy.cc table/block_based/full_filter_block.cc table/block_based/index_builder.cc + table/block_based/parsed_full_filter_block.cc table/block_based/partitioned_filter_block.cc + table/block_based/uncompression_dict_reader.cc table/block_fetcher.cc - table/bloom_block.cc table/cuckoo/cuckoo_table_builder.cc table/cuckoo/cuckoo_table_factory.cc table/cuckoo/cuckoo_table_reader.cc @@ -312,6 +325,7 @@ set(ROCKSDB_SOURCES table/merging_iterator.cc table/meta_blocks.cc table/persistent_cache_helper.cc + table/plain/plain_table_bloom.cc table/plain/plain_table_builder.cc table/plain/plain_table_factory.cc table/plain/plain_table_index.cc @@ -323,23 +337,34 @@ set(ROCKSDB_SOURCES table/two_level_iterator.cc test_util/sync_point.cc test_util/sync_point_impl.cc + test_util/testutil.cc + test_util/transaction_test_util.cc + tools/block_cache_analyzer/block_cache_trace_analyzer.cc + tools/dump/db_dump_tool.cc tools/ldb_cmd.cc tools/ldb_tool.cc tools/sst_dump_tool.cc - trace_replay/block_cache_tracer.cc + tools/trace_analyzer_tool.cc trace_replay/trace_replay.cc - util/bloom.cc + trace_replay/block_cache_tracer.cc util/coding.cc util/compaction_job_stats_impl.cc util/comparator.cc util/compression_context_cache.cc util/concurrent_task_limiter_impl.cc - util/crc32c_arm64.cc util/crc32c.cc util/dynamic_bloom.cc - util/file_reader_writer.cc - util/filter_policy.cc util/hash.cc + util/murmurhash.cc + util/random.cc + util/rate_limiter.cc + util/slice.cc + util/file_checksum_helper.cc + util/status.cc + util/string_util.cc + util/thread_local.cc + util/threadpool_imp.cc + util/xxhash.cc utilities/backupable/backupable_db.cc utilities/blob_db/blob_compaction_filter.cc utilities/blob_db/blob_db.cc @@ -347,12 +372,11 @@ set(ROCKSDB_SOURCES utilities/blob_db/blob_db_impl_filesnapshot.cc utilities/blob_db/blob_dump_tool.cc utilities/blob_db/blob_file.cc - utilities/blob_db/blob_log_format.cc utilities/blob_db/blob_log_reader.cc utilities/blob_db/blob_log_writer.cc + utilities/blob_db/blob_log_format.cc utilities/checkpoint/checkpoint_impl.cc utilities/compaction_filters/remove_emptyvalue_compactionfilter.cc - utilities/convenience/info_log_finder.cc utilities/debug.cc utilities/env_mirror.cc utilities/env_timed.cc @@ -361,9 +385,11 @@ set(ROCKSDB_SOURCES utilities/merge_operators/bytesxor.cc utilities/merge_operators/max.cc utilities/merge_operators/put.cc - utilities/merge_operators/string_append/stringappend2.cc + utilities/merge_operators/sortlist.cc utilities/merge_operators/string_append/stringappend.cc + utilities/merge_operators/string_append/stringappend2.cc utilities/merge_operators/uint64add.cc + utilities/object_registry.cc utilities/option_change_migration/option_change_migration.cc utilities/options/options_util.cc utilities/persistent_cache/block_cache_tier.cc @@ -371,11 +397,12 @@ set(ROCKSDB_SOURCES utilities/persistent_cache/block_cache_tier_metadata.cc utilities/persistent_cache/persistent_cache_tier.cc utilities/persistent_cache/volatile_tier_impl.cc + utilities/simulator_cache/cache_simulator.cc utilities/simulator_cache/sim_cache.cc utilities/table_properties_collectors/compact_on_deletion_collector.cc utilities/trace/file_trace_reader_writer.cc - utilities/transactions/optimistic_transaction.cc utilities/transactions/optimistic_transaction_db_impl.cc + utilities/transactions/optimistic_transaction.cc utilities/transactions/pessimistic_transaction.cc utilities/transactions/pessimistic_transaction_db.cc utilities/transactions/snapshot_checker.cc @@ -390,15 +417,6 @@ set(ROCKSDB_SOURCES utilities/ttl/db_ttl_impl.cc utilities/write_batch_with_index/write_batch_with_index.cc utilities/write_batch_with_index/write_batch_with_index_internal.cc - util/murmurhash.cc - util/random.cc - util/rate_limiter.cc - util/slice.cc - util/status.cc - util/string_util.cc - util/thread_local.cc - util/threadpool_imp.cc - util/xxhash.cc ) @@ -415,7 +433,8 @@ else() list(APPEND ROCKSDB_SOURCES port/port_posix.cc env/env_posix.cc - env/io_posix.cc) + env/io_posix.cc + env/fs_posix.cc) # ppc64 or ppc64le if(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64") enable_language(ASM) diff --git a/storage/rocksdb/rdb_sst_info.cc b/storage/rocksdb/rdb_sst_info.cc index 9f470ea2fef..45ae89c1bd4 100644 --- a/storage/rocksdb/rdb_sst_info.cc +++ b/storage/rocksdb/rdb_sst_info.cc @@ -510,7 +510,7 @@ void Rdb_sst_info::set_error_msg(const std::string &sst_file_name, void Rdb_sst_info::report_error_msg(const rocksdb::Status &s, const char *sst_file_name) { if (s.IsInvalidArgument() && - strcmp(s.getState(), "Keys must be added in order") == 0) { + strcmp(s.getState(), "Keys must be added in strict ascending order.") == 0) { my_printf_error(ER_KEYS_OUT_OF_ORDER, "Rows must be inserted in primary key order " "during bulk load operation", diff --git a/storage/rocksdb/rocksdb b/storage/rocksdb/rocksdb -Subproject e731f4402258554812c46334dc0d9483e6cc769 +Subproject bba5e7bc21093d7cfa765e1280a7c4fdcd28428 diff --git a/storage/rocksdb/ut0counter.h b/storage/rocksdb/ut0counter.h index cfa474e7a99..3a7ee85d01c 100644 --- a/storage/rocksdb/ut0counter.h +++ b/storage/rocksdb/ut0counter.h @@ -23,7 +23,7 @@ Created 2012/04/12 by Sunny Bains #include <string.h> /** CPU cache line size */ -#define CACHE_LINE_SIZE 64 +#define UT_CACHE_LINE_SIZE 64 /** Default number of slots to use in ib_counter_t */ #define IB_N_SLOTS 64 @@ -43,7 +43,7 @@ struct generic_indexer_t { /** @return offset within m_counter */ size_t offset(size_t index) const { - return(((index % N) + 1) * (CACHE_LINE_SIZE / sizeof(Type))); + return(((index % N) + 1) * (UT_CACHE_LINE_SIZE / sizeof(Type))); } }; @@ -90,7 +90,7 @@ struct single_indexer_t { /** @return offset within m_counter */ size_t offset(size_t index) const { DBUG_ASSERT(N == 1); - return((CACHE_LINE_SIZE / sizeof(Type))); + return((UT_CACHE_LINE_SIZE / sizeof(Type))); } /* @return 1 */ @@ -103,7 +103,7 @@ struct single_indexer_t { /** Class for using fuzzy counters. The counter is not protected by any mutex and the results are not guaranteed to be 100% accurate but close enough. Creates an array of counters and separates each element by the -CACHE_LINE_SIZE bytes */ +UT_CACHE_LINE_SIZE bytes */ template < typename Type, int N = IB_N_SLOTS, @@ -119,7 +119,7 @@ public: bool validate() { #ifdef UNIV_DEBUG - size_t n = (CACHE_LINE_SIZE / sizeof(Type)); + size_t n = (UT_CACHE_LINE_SIZE / sizeof(Type)); /* Check that we aren't writing outside our defined bounds. */ for (size_t i = 0; i < UT_ARRAY_SIZE(m_counter); i += n) { @@ -197,7 +197,7 @@ private: Indexer<Type, N>m_policy; /** Slot 0 is unused. */ - Type m_counter[(N + 1) * (CACHE_LINE_SIZE / sizeof(Type))]; + Type m_counter[(N + 1) * (UT_CACHE_LINE_SIZE / sizeof(Type))]; }; #endif /* UT0COUNTER_H */ |