From 354e97cd722c6b8721f05e75084a6843e32b6b74 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Fri, 26 Jan 2024 15:07:41 +0100 Subject: [PATCH 001/568] Fix mtr for builds without perfschema. --- mysql-test/mysql-test-run.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index f75f0fe64df..df00402181d 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -3076,7 +3076,7 @@ sub mysql_install_db { mtr_add_arg($args, "--core-file"); mtr_add_arg($args, "--console"); mtr_add_arg($args, "--character-set-server=latin1"); - mtr_add_arg($args, "--disable-performance-schema"); + mtr_add_arg($args, "--loose-disable-performance-schema"); if ( $opt_debug ) { From 3228c08fa80963a9b18a59c2ac48d86eaaad30cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Thu, 7 Dec 2023 08:23:29 +0200 Subject: [PATCH 002/568] MDEV-22063 : Assertion `0' failed in wsrep::transaction::before_rollback Problem was that REPLACE was using consistency check that started TOI and we tried to rollback it. Do not use wsrep_before_rollback and wsrep_after_rollback if we are runing consistency check because no writeset keys are in that case added. Do not allow consistency check usage if table storage for target table is not InnoDB, instead give warning. REPLACE|SELECT INTO ... SELECT will use now TOI if table storage for target table is not InnoDB to maintain consistency between galera nodes. Signed-off-by: Julius Goryavsky --- .../galera/r/galera_myisam_autocommit.result | 40 ++- mysql-test/suite/galera/r/mdev-22063.result | 242 ++++++++++++++++++ .../galera/t/galera_myisam_autocommit.test | 24 +- mysql-test/suite/galera/t/mdev-22063.test | 186 ++++++++++++++ sql/handler.cc | 11 +- sql/sql_parse.cc | 28 +- 6 files changed, 516 insertions(+), 15 deletions(-) create mode 100644 mysql-test/suite/galera/r/mdev-22063.result create mode 100644 mysql-test/suite/galera/t/mdev-22063.test diff --git a/mysql-test/suite/galera/r/galera_myisam_autocommit.result b/mysql-test/suite/galera/r/galera_myisam_autocommit.result index 6213e8f6380..5878ea48bfe 100644 --- a/mysql-test/suite/galera/r/galera_myisam_autocommit.result +++ b/mysql-test/suite/galera/r/galera_myisam_autocommit.result @@ -1,5 +1,6 @@ connection node_2; connection node_1; +SET GLOBAL wsrep_replicate_myisam=ON; CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM; INSERT INTO t1 VALUES (1); INSERT INTO t1 VALUES (2), (3); @@ -14,14 +15,37 @@ UPDATE t1 SET f1 = 9; UPDATE t2 SET f1 = 9 WHERE f1 = 1; DELETE FROM t1 WHERE f1 = 9; DELETE FROM t2 WHERE f1 = 9; -TRUNCATE TABLE t1; -TRUNCATE TABLE t1; +SELECT * FROM t1 ORDER BY f1; +f1 +SELECT * FROM t2 ORDER BY f1; +f1 +2 +3 +4 +5 +6 connection node_2; -SELECT COUNT(*) = 0 FROM t1; -COUNT(*) = 0 -1 -SELECT COUNT(*) = 0 FROM t2; -COUNT(*) = 0 -1 +SELECT * FROM t1 ORDER BY f1; +f1 +SELECT * FROM t2 ORDER BY f1; +f1 +2 +3 +4 +5 +6 +TRUNCATE TABLE t1; +TRUNCATE TABLE t2; +SELECT * FROM t1 ORDER BY f1; +f1 +SELECT * FROM t2 ORDER BY f1; +f1 +connection node_2; +SELECT * FROM t1 ORDER BY f1; +f1 +SELECT * FROM t2 ORDER BY f1; +f1 +connection node_1; +SET GLOBAL wsrep_replicate_myisam=OFF; DROP TABLE t1; DROP TABLE t2; diff --git a/mysql-test/suite/galera/r/mdev-22063.result b/mysql-test/suite/galera/r/mdev-22063.result new file mode 100644 index 00000000000..5773e70cc9d --- /dev/null +++ b/mysql-test/suite/galera/r/mdev-22063.result @@ -0,0 +1,242 @@ +connection node_2; +connection node_1; +# Case 1 CREATE SEQUENCE with no NOCACHE +CREATE SEQUENCE s ENGINE=InnoDB; +ERROR 42000: This version of MariaDB doesn't yet support 'CACHE without INCREMENT BY 0 in Galera cluster' +CREATE SEQUENCE s NOCACHE ENGINE=InnoDB; +CREATE TABLE t1 (a INT) ENGINE=InnoDB; +START TRANSACTION; +REPLACE INTO s VALUES (1,1,9223372036854775806,1,1,1000,0,0); +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize note Table does not support optimize, doing recreate + analyze instead +test.t1 optimize status OK +SELECT * FROM t1; +a +SELECT * FROM s; +next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count +1 1 9223372036854775806 1 1 1000 0 0 +connection node_2; +SELECT * FROM t1; +a +SELECT * FROM s; +next_not_cached_value minimum_value maximum_value start_value increment cache_size cycle_option cycle_count +1 1 9223372036854775806 1 1 1000 0 0 +connection node_1; +DROP TABLE t1; +DROP SEQUENCE s; +# Case 2 REPLACE INTO ... SELECT with error +CREATE TABLE t (id INT KEY,a YEAR,INDEX (id,a)) engine=innodb; +REPLACE INTO t (id,a)SELECT /*!99997 */ 1; +ERROR 21S01: Column count doesn't match value count at row 1 +REPLACE INTO t (id,a)SELECT /*!99997 */ 1,2; +SELECT * FROM t; +id a +1 2002 +CREATE TABLE t2 (id INT KEY,a YEAR,INDEX (id,a)) engine=myisam; +REPLACE INTO t2 (id,a)SELECT /*!99997 */ 1; +ERROR 21S01: Column count doesn't match value count at row 1 +REPLACE INTO t2 (id,a)SELECT /*!99997 */ 1,2; +Warnings: +Warning 138 Galera cluster does support consistency check only for InnoDB tables. +SELECT * FROM t2; +id a +1 2002 +CREATE TABLE t3 (id INT KEY,a YEAR,INDEX (id,a)) engine=aria; +REPLACE INTO t3 (id,a)SELECT /*!99997 */ 1; +ERROR 21S01: Column count doesn't match value count at row 1 +REPLACE INTO t3 (id,a)SELECT /*!99997 */ 1,2; +Warnings: +Warning 138 Galera cluster does support consistency check only for InnoDB tables. +SELECT * FROM t3; +id a +1 2002 +connection node_2; +SELECT * FROM t; +id a +1 2002 +SELECT * FROM t2; +id a +1 2002 +SELECT * FROM t3; +id a +1 2002 +connection node_1; +DROP TABLE t,t2,t3; +# Bigger REPLACE ... AS SELECT test +SET GLOBAL wsrep_replicate_myisam=ON; +CREATE TABLE t1(id int not null primary key ,b int) ENGINE=InnoDB; +CREATE TABLE t2(id int not null primary key ,b int) ENGINE=MyISAM; +CREATE TABLE t3(id int not null primary key ,b int) ENGINE=Aria; +CREATE TABLE t4(id int not null primary key ,b int) ENGINE=InnoDB; +CREATE TABLE t5(id int not null primary key ,b int) ENGINE=InnoDB; +CREATE TABLE t6(id int not null primary key ,b int) ENGINE=InnoDB; +CREATE TABLE t7(id int not null primary key ,b int) ENGINE=MyISAM; +CREATE TABLE t8(id int not null primary key ,b int) ENGINE=Aria; +INSERT INTO t1(id) SELECT seq FROM seq_1_to_1000; +INSERT INTO t2(id) SELECT seq FROM seq_1_to_1000; +INSERT INTO t3(id) SELECT seq FROM seq_1_to_1000; +REPLACE INTO t4 SELECT * FROM t1; +REPLACE INTO t5 SELECT * FROM t2; +REPLACE INTO t6 SELECT * FROM t3; +REPLACE INTO t7 SELECT * FROM t2; +REPLACE INTO t8 SELECT * FROM t3; +SELECT COUNT(*) AS EXPECT_1000 FROM t1; +EXPECT_1000 +1000 +SELECT COUNT(*) AS EXPECT_1000 FROM t2; +EXPECT_1000 +1000 +SELECT COUNT(*) AS EXPECT_1000 FROM t3; +EXPECT_1000 +1000 +SELECT COUNT(*) AS EXPECT_1000 FROM t4; +EXPECT_1000 +1000 +SELECT COUNT(*) AS EXPECT_1000 FROM t5; +EXPECT_1000 +1000 +SELECT COUNT(*) AS EXPECT_1000 FROM t6; +EXPECT_1000 +1000 +SELECT COUNT(*) AS EXPECT_1000 FROM t7; +EXPECT_1000 +1000 +SELECT COUNT(*) AS EXPECT_1000 FROM t8; +EXPECT_1000 +1000 +connection node_2; +SELECT COUNT(*) AS EXPECT_1000 FROM t1; +EXPECT_1000 +1000 +SELECT COUNT(*) AS EXPECT_1000 FROM t2; +EXPECT_1000 +1000 +SELECT COUNT(*) AS EXPECT_1000 FROM t3; +EXPECT_1000 +1000 +SELECT COUNT(*) AS EXPECT_1000 FROM t4; +EXPECT_1000 +1000 +SELECT COUNT(*) AS EXPECT_1000 FROM t5; +EXPECT_1000 +1000 +SELECT COUNT(*) AS EXPECT_1000 FROM t6; +EXPECT_1000 +1000 +SELECT COUNT(*) AS EXPECT_1000 FROM t7; +EXPECT_1000 +1000 +SELECT COUNT(*) AS EXPECT_1000 FROM t8; +EXPECT_1000 +1000 +connection node_1; +DROP TABLE t1,t2,t3,t4,t5,t6,t7,t8; +# Bigger INSERT INTO ... SELECT test +CREATE TABLE t1(id int not null primary key ,b int) ENGINE=InnoDB; +CREATE TABLE t2(id int not null primary key ,b int) ENGINE=MyISAM; +CREATE TABLE t3(id int not null primary key ,b int) ENGINE=Aria; +CREATE TABLE t4(id int not null primary key ,b int) ENGINE=InnoDB; +CREATE TABLE t5(id int not null primary key ,b int) ENGINE=InnoDB; +CREATE TABLE t6(id int not null primary key ,b int) ENGINE=InnoDB; +CREATE TABLE t7(id int not null primary key ,b int) ENGINE=MyISAM; +CREATE TABLE t8(id int not null primary key ,b int) ENGINE=Aria; +INSERT INTO t1(id) SELECT seq FROM seq_1_to_1000; +INSERT INTO t2(id) SELECT seq FROM seq_1_to_1000; +INSERT INTO t3(id) SELECT seq FROM seq_1_to_1000; +INSERT INTO t4 SELECT * FROM t1; +INSERT INTO t5 SELECT * FROM t2; +INSERT INTO t6 SELECT * FROM t3; +INSERT INTO t7 SELECT * FROM t2; +INSERT INTO t8 SELECT * FROM t3; +SELECT COUNT(*) AS EXPECT_1000 FROM t1; +EXPECT_1000 +1000 +SELECT COUNT(*) AS EXPECT_1000 FROM t2; +EXPECT_1000 +1000 +SELECT COUNT(*) AS EXPECT_1000 FROM t3; +EXPECT_1000 +1000 +SELECT COUNT(*) AS EXPECT_1000 FROM t4; +EXPECT_1000 +1000 +SELECT COUNT(*) AS EXPECT_1000 FROM t5; +EXPECT_1000 +1000 +SELECT COUNT(*) AS EXPECT_1000 FROM t6; +EXPECT_1000 +1000 +SELECT COUNT(*) AS EXPECT_1000 FROM t7; +EXPECT_1000 +1000 +SELECT COUNT(*) AS EXPECT_1000 FROM t8; +EXPECT_1000 +1000 +connection node_2; +SELECT COUNT(*) AS EXPECT_1000 FROM t1; +EXPECT_1000 +1000 +SELECT COUNT(*) AS EXPECT_1000 FROM t2; +EXPECT_1000 +1000 +SELECT COUNT(*) AS EXPECT_1000 FROM t3; +EXPECT_1000 +1000 +SELECT COUNT(*) AS EXPECT_1000 FROM t4; +EXPECT_1000 +1000 +SELECT COUNT(*) AS EXPECT_1000 FROM t5; +EXPECT_1000 +1000 +SELECT COUNT(*) AS EXPECT_1000 FROM t6; +EXPECT_1000 +1000 +SELECT COUNT(*) AS EXPECT_1000 FROM t7; +EXPECT_1000 +1000 +SELECT COUNT(*) AS EXPECT_1000 FROM t8; +EXPECT_1000 +1000 +connection node_1; +DROP TABLE t1,t2,t3,t4,t5,t6,t7,t8; +CREATE TABLE t1(pk int not null primary key) engine=innodb; +INSERT INTO t1 values (1),(2),(3),(4); +CREATE VIEW view_t1 AS SELECT * FROM t1; +INSERT INTO view_t1 VALUES (5); +SELECT * FROM t1; +pk +1 +2 +3 +4 +5 +DROP TABLE t1; +DROP VIEW view_t1; +CREATE TABLE t1(pk int not null primary key) engine=myisam; +INSERT INTO t1 values (1),(2),(3),(4); +CREATE VIEW view_t1 AS SELECT * FROM t1; +INSERT INTO view_t1 VALUES (5); +SELECT * FROM t1; +pk +1 +2 +3 +4 +5 +DROP TABLE t1; +DROP VIEW view_t1; +CREATE TABLE t1(pk int not null primary key) engine=aria; +INSERT INTO t1 values (1),(2),(3),(4); +CREATE VIEW view_t1 AS SELECT * FROM t1; +INSERT INTO view_t1 VALUES (5); +SELECT * FROM t1; +pk +1 +2 +3 +4 +5 +DROP TABLE t1; +DROP VIEW view_t1; +SET GLOBAL wsrep_replicate_myisam=OFF; diff --git a/mysql-test/suite/galera/t/galera_myisam_autocommit.test b/mysql-test/suite/galera/t/galera_myisam_autocommit.test index b01b5dc07f7..65f957e8422 100644 --- a/mysql-test/suite/galera/t/galera_myisam_autocommit.test +++ b/mysql-test/suite/galera/t/galera_myisam_autocommit.test @@ -2,20 +2,24 @@ --source include/have_innodb.inc # -# This tests simple autocommit replication of MyISAM tables. No updates arrive on the slave. +# This tests simple autocommit replication of MyISAM tables. # +SET GLOBAL wsrep_replicate_myisam=ON; + # Without a PK CREATE TABLE t1 (f1 INTEGER) ENGINE=MyISAM; INSERT INTO t1 VALUES (1); INSERT INTO t1 VALUES (2), (3); +# This is TOI INSERT INTO t1 SELECT 4 FROM DUAL UNION ALL SELECT 5 FROM DUAL; CREATE TABLE t2 (f1 INTEGER PRIMARY KEY) ENGINE=MyISAM; INSERT INTO t2 VALUES (1); INSERT INTO t2 VALUES (2), (3); +# This is TOI INSERT INTO t2 SELECT 4 FROM DUAL UNION ALL SELECT 5 FROM DUAL; # Error @@ -32,14 +36,26 @@ UPDATE t2 SET f1 = 9 WHERE f1 = 1; DELETE FROM t1 WHERE f1 = 9; DELETE FROM t2 WHERE f1 = 9; +SELECT * FROM t1 ORDER BY f1; +SELECT * FROM t2 ORDER BY f1; + +--connection node_2 +SELECT * FROM t1 ORDER BY f1; +SELECT * FROM t2 ORDER BY f1; + # TRUNCATE TRUNCATE TABLE t1; -TRUNCATE TABLE t1; +TRUNCATE TABLE t2; + +SELECT * FROM t1 ORDER BY f1; +SELECT * FROM t2 ORDER BY f1; --connection node_2 -SELECT COUNT(*) = 0 FROM t1; -SELECT COUNT(*) = 0 FROM t2; +SELECT * FROM t1 ORDER BY f1; +SELECT * FROM t2 ORDER BY f1; +--connection node_1 +SET GLOBAL wsrep_replicate_myisam=OFF; DROP TABLE t1; DROP TABLE t2; diff --git a/mysql-test/suite/galera/t/mdev-22063.test b/mysql-test/suite/galera/t/mdev-22063.test new file mode 100644 index 00000000000..fa0e4d350d9 --- /dev/null +++ b/mysql-test/suite/galera/t/mdev-22063.test @@ -0,0 +1,186 @@ +--source include/galera_cluster.inc +--source include/have_innodb.inc +--source include/have_log_bin.inc +--source include/have_sequence.inc +--source include/have_aria.inc + +--echo # Case 1 CREATE SEQUENCE with no NOCACHE +--error ER_NOT_SUPPORTED_YET +CREATE SEQUENCE s ENGINE=InnoDB; +CREATE SEQUENCE s NOCACHE ENGINE=InnoDB; +CREATE TABLE t1 (a INT) ENGINE=InnoDB; +START TRANSACTION; +REPLACE INTO s VALUES (1,1,9223372036854775806,1,1,1000,0,0); +OPTIMIZE TABLE t1; +SELECT * FROM t1; +SELECT * FROM s; + +--connection node_2 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1' +--source include/wait_condition.inc +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 's' +--source include/wait_condition.inc +--let $wait_condition = SELECT COUNT(*) = 1 FROM test.s; +--source include/wait_condition.inc + +SELECT * FROM t1; +SELECT * FROM s; + +--connection node_1 +DROP TABLE t1; +DROP SEQUENCE s; + +--echo # Case 2 REPLACE INTO ... SELECT with error +CREATE TABLE t (id INT KEY,a YEAR,INDEX (id,a)) engine=innodb; +--error ER_WRONG_VALUE_COUNT_ON_ROW +REPLACE INTO t (id,a)SELECT /*!99997 */ 1; +REPLACE INTO t (id,a)SELECT /*!99997 */ 1,2; +SELECT * FROM t; + +CREATE TABLE t2 (id INT KEY,a YEAR,INDEX (id,a)) engine=myisam; +--error ER_WRONG_VALUE_COUNT_ON_ROW +REPLACE INTO t2 (id,a)SELECT /*!99997 */ 1; +REPLACE INTO t2 (id,a)SELECT /*!99997 */ 1,2; +SELECT * FROM t2; + +CREATE TABLE t3 (id INT KEY,a YEAR,INDEX (id,a)) engine=aria; +--error ER_WRONG_VALUE_COUNT_ON_ROW +REPLACE INTO t3 (id,a)SELECT /*!99997 */ 1; +REPLACE INTO t3 (id,a)SELECT /*!99997 */ 1,2; +SELECT * FROM t3; + +--connection node_2 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't3' +--source include/wait_condition.inc +--let $wait_condition = SELECT COUNT(*) = 1 FROM test.t3; +--source include/wait_condition.inc + +SELECT * FROM t; +SELECT * FROM t2; +SELECT * FROM t3; + +--connection node_1 +DROP TABLE t,t2,t3; + +--echo # Bigger REPLACE ... AS SELECT test + +SET GLOBAL wsrep_replicate_myisam=ON; + +CREATE TABLE t1(id int not null primary key ,b int) ENGINE=InnoDB; +CREATE TABLE t2(id int not null primary key ,b int) ENGINE=MyISAM; +CREATE TABLE t3(id int not null primary key ,b int) ENGINE=Aria; +CREATE TABLE t4(id int not null primary key ,b int) ENGINE=InnoDB; +CREATE TABLE t5(id int not null primary key ,b int) ENGINE=InnoDB; +CREATE TABLE t6(id int not null primary key ,b int) ENGINE=InnoDB; +CREATE TABLE t7(id int not null primary key ,b int) ENGINE=MyISAM; +CREATE TABLE t8(id int not null primary key ,b int) ENGINE=Aria; + +INSERT INTO t1(id) SELECT seq FROM seq_1_to_1000; +INSERT INTO t2(id) SELECT seq FROM seq_1_to_1000; +INSERT INTO t3(id) SELECT seq FROM seq_1_to_1000; + +REPLACE INTO t4 SELECT * FROM t1; +REPLACE INTO t5 SELECT * FROM t2; +REPLACE INTO t6 SELECT * FROM t3; +REPLACE INTO t7 SELECT * FROM t2; +REPLACE INTO t8 SELECT * FROM t3; + +SELECT COUNT(*) AS EXPECT_1000 FROM t1; +SELECT COUNT(*) AS EXPECT_1000 FROM t2; +SELECT COUNT(*) AS EXPECT_1000 FROM t3; +SELECT COUNT(*) AS EXPECT_1000 FROM t4; +SELECT COUNT(*) AS EXPECT_1000 FROM t5; +SELECT COUNT(*) AS EXPECT_1000 FROM t6; +SELECT COUNT(*) AS EXPECT_1000 FROM t7; +SELECT COUNT(*) AS EXPECT_1000 FROM t8; + +--connection node_2 +--let $wait_condition = SELECT COUNT(*) = 8 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME LIKE 't_' +--source include/wait_condition.inc +--let $wait_condition = SELECT COUNT(*) = 1000 FROM test.t6; +--source include/wait_condition.inc + +SELECT COUNT(*) AS EXPECT_1000 FROM t1; +SELECT COUNT(*) AS EXPECT_1000 FROM t2; +SELECT COUNT(*) AS EXPECT_1000 FROM t3; +SELECT COUNT(*) AS EXPECT_1000 FROM t4; +SELECT COUNT(*) AS EXPECT_1000 FROM t5; +SELECT COUNT(*) AS EXPECT_1000 FROM t6; +SELECT COUNT(*) AS EXPECT_1000 FROM t7; +SELECT COUNT(*) AS EXPECT_1000 FROM t8; + +--connection node_1 +DROP TABLE t1,t2,t3,t4,t5,t6,t7,t8; + +--echo # Bigger INSERT INTO ... SELECT test + +CREATE TABLE t1(id int not null primary key ,b int) ENGINE=InnoDB; +CREATE TABLE t2(id int not null primary key ,b int) ENGINE=MyISAM; +CREATE TABLE t3(id int not null primary key ,b int) ENGINE=Aria; +CREATE TABLE t4(id int not null primary key ,b int) ENGINE=InnoDB; +CREATE TABLE t5(id int not null primary key ,b int) ENGINE=InnoDB; +CREATE TABLE t6(id int not null primary key ,b int) ENGINE=InnoDB; +CREATE TABLE t7(id int not null primary key ,b int) ENGINE=MyISAM; +CREATE TABLE t8(id int not null primary key ,b int) ENGINE=Aria; + +INSERT INTO t1(id) SELECT seq FROM seq_1_to_1000; +INSERT INTO t2(id) SELECT seq FROM seq_1_to_1000; +INSERT INTO t3(id) SELECT seq FROM seq_1_to_1000; + +INSERT INTO t4 SELECT * FROM t1; +INSERT INTO t5 SELECT * FROM t2; +INSERT INTO t6 SELECT * FROM t3; +INSERT INTO t7 SELECT * FROM t2; +INSERT INTO t8 SELECT * FROM t3; + +SELECT COUNT(*) AS EXPECT_1000 FROM t1; +SELECT COUNT(*) AS EXPECT_1000 FROM t2; +SELECT COUNT(*) AS EXPECT_1000 FROM t3; +SELECT COUNT(*) AS EXPECT_1000 FROM t4; +SELECT COUNT(*) AS EXPECT_1000 FROM t5; +SELECT COUNT(*) AS EXPECT_1000 FROM t6; +SELECT COUNT(*) AS EXPECT_1000 FROM t7; +SELECT COUNT(*) AS EXPECT_1000 FROM t8; + +--connection node_2 +--let $wait_condition = SELECT COUNT(*) = 8 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME LIKE 't_' +--source include/wait_condition.inc +--let $wait_condition = SELECT COUNT(*) = 1000 FROM test.t6; +--source include/wait_condition.inc + +SELECT COUNT(*) AS EXPECT_1000 FROM t1; +SELECT COUNT(*) AS EXPECT_1000 FROM t2; +SELECT COUNT(*) AS EXPECT_1000 FROM t3; +SELECT COUNT(*) AS EXPECT_1000 FROM t4; +SELECT COUNT(*) AS EXPECT_1000 FROM t5; +SELECT COUNT(*) AS EXPECT_1000 FROM t6; +SELECT COUNT(*) AS EXPECT_1000 FROM t7; +SELECT COUNT(*) AS EXPECT_1000 FROM t8; + +--connection node_1 +DROP TABLE t1,t2,t3,t4,t5,t6,t7,t8; +# +# View +# +CREATE TABLE t1(pk int not null primary key) engine=innodb; +INSERT INTO t1 values (1),(2),(3),(4); +CREATE VIEW view_t1 AS SELECT * FROM t1; +INSERT INTO view_t1 VALUES (5); +SELECT * FROM t1; +DROP TABLE t1; +DROP VIEW view_t1; +CREATE TABLE t1(pk int not null primary key) engine=myisam; +INSERT INTO t1 values (1),(2),(3),(4); +CREATE VIEW view_t1 AS SELECT * FROM t1; +INSERT INTO view_t1 VALUES (5); +SELECT * FROM t1; +DROP TABLE t1; +DROP VIEW view_t1; +CREATE TABLE t1(pk int not null primary key) engine=aria; +INSERT INTO t1 values (1),(2),(3),(4); +CREATE VIEW view_t1 AS SELECT * FROM t1; +INSERT INTO view_t1 VALUES (5); +SELECT * FROM t1; +DROP TABLE t1; +DROP VIEW view_t1; +SET GLOBAL wsrep_replicate_myisam=OFF; diff --git a/sql/handler.cc b/sql/handler.cc index 45721d6cfbb..486beb56788 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1940,8 +1940,11 @@ int ha_rollback_trans(THD *thd, bool all) } #ifdef WITH_WSREP - (void) wsrep_before_rollback(thd, all); + // REPLACE|INSERT INTO ... SELECT uses TOI in consistency check + if (thd->wsrep_consistency_check != CONSISTENCY_CHECK_RUNNING) + (void) wsrep_before_rollback(thd, all); #endif /* WITH_WSREP */ + if (ha_info) { /* Close all cursors that can not survive ROLLBACK */ @@ -1977,8 +1980,12 @@ int ha_rollback_trans(THD *thd, bool all) thd->thread_id, all?"TRUE":"FALSE", wsrep_thd_query(thd), thd->get_stmt_da()->message(), is_real_trans); } - (void) wsrep_after_rollback(thd, all); + + // REPLACE|INSERT INTO ... SELECT uses TOI in consistency check + if (thd->wsrep_consistency_check != CONSISTENCY_CHECK_RUNNING) + (void) wsrep_after_rollback(thd, all); #endif /* WITH_WSREP */ + /* Always cleanup. Even if nht==0. There may be savepoints. */ if (is_real_trans) { diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index d6ad9dc270b..7ca63b06c6b 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4658,10 +4658,15 @@ mysql_execute_command(THD *thd) if ((res= insert_precheck(thd, all_tables))) break; + #ifdef WITH_WSREP - if (WSREP(thd) && thd->wsrep_consistency_check == CONSISTENCY_CHECK_DECLARED) + bool wsrep_toi= false; + const bool wsrep= WSREP(thd); + + if (wsrep && thd->wsrep_consistency_check == CONSISTENCY_CHECK_DECLARED) { thd->wsrep_consistency_check = CONSISTENCY_CHECK_RUNNING; + wsrep_toi= true; WSREP_TO_ISOLATION_BEGIN(first_table->db.str, first_table->table_name.str, NULL); } #endif /* WITH_WSREP */ @@ -4696,6 +4701,27 @@ mysql_execute_command(THD *thd) if (!(res=open_and_lock_tables(thd, all_tables, TRUE, 0))) { MYSQL_INSERT_SELECT_START(thd->query()); + +#ifdef WITH_WSREP + if (wsrep && !first_table->view) + { + bool is_innodb= (first_table->table->file->ht->db_type == DB_TYPE_INNODB); + + // For consistency check inserted table needs to be InnoDB + if (!is_innodb && thd->wsrep_consistency_check != NO_CONSISTENCY_CHECK) + { + push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, + HA_ERR_UNSUPPORTED, + "Galera cluster does support consistency check only" + " for InnoDB tables."); + thd->wsrep_consistency_check= NO_CONSISTENCY_CHECK; + } + + // For !InnoDB we start TOI if it is not yet started and hope for the best + if (!is_innodb && !wsrep_toi) + WSREP_TO_ISOLATION_BEGIN(first_table->db.str, first_table->table_name.str, NULL); + } +#endif /* WITH_WSREP */ /* Only the INSERT table should be merged. Other will be handled by select. From daaa16a47f67a89e57c4679e54e6b7376b1bfa1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Wed, 1 Nov 2023 11:07:16 +0200 Subject: [PATCH 003/568] MDEV-25089 : Assertion `error.len > 0' failed in galera::ReplicatorSMM::handle_apply_error() Problem is that Galera starts TOI (total order isolation) i.e. it sends query to all nodes. Later it is discovered that used engine or other feature is not supported by Galera. Because TOI is executed parallelly in all nodes appliers could execute given TOI and ignore the error and start inconsistency voting causing node to leave from cluster or we might have a crash as reported. For example SEQUENCE engine does not support GEOMETRY data type causing either inconsistency between nodes (because some errors are ignored on applier) or crash. Fixed my adding new function wsrep_check_support to check can Galera support provided CREATE TABLE/SEQUENCE before TOI is started and if not clear error message is provided to the user. Currently, not supported cases: * CREATE TABLE ... AS SELECT when streaming replication is used * CREATE TABLE ... WITH SYSTEM VERSIONING AS SELECT * CREATE TABLE ... ENGINE=SEQUENCE * CREATE SEQUENCE ... ENGINE!=InnoDB * ALTER TABLE t ... ENGINE!=InnoDB where table t is SEQUENCE Signed-off-by: Julius Goryavsky --- mysql-test/suite/galera/r/MDEV-24143.result | 2 +- .../galera/r/galera_sequence_engine.result | 12 ++ mysql-test/suite/galera/r/mdev-31285.result | 21 +--- mysql-test/suite/galera/t/MDEV-24143.test | 6 +- .../galera/t/galera_sequence_engine.test | 16 +++ mysql-test/suite/galera/t/mdev-31285.test | 35 ++---- sql/sql_sequence.cc | 6 +- sql/sql_table.cc | 104 ++++++++++++------ sql/sql_table.h | 4 - 9 files changed, 122 insertions(+), 84 deletions(-) create mode 100644 mysql-test/suite/galera/r/galera_sequence_engine.result create mode 100644 mysql-test/suite/galera/t/galera_sequence_engine.test diff --git a/mysql-test/suite/galera/r/MDEV-24143.result b/mysql-test/suite/galera/r/MDEV-24143.result index 860d8a35834..879e7d9c32c 100644 --- a/mysql-test/suite/galera/r/MDEV-24143.result +++ b/mysql-test/suite/galera/r/MDEV-24143.result @@ -14,7 +14,7 @@ c1 INSERT INTO t1 VALUES (4),(3),(1),(2); ERROR 40001: Deadlock found when trying to get lock; try restarting transaction CREATE TABLE t1 (pk INT PRIMARY KEY, b INT) ENGINE=SEQUENCE; -ERROR 42S01: Table 't1' already exists +ERROR 42000: This version of MariaDB doesn't yet support 'non-InnoDB sequences in Galera cluster' ALTER TABLE t1 DROP COLUMN c2; ERROR 42000: Can't DROP COLUMN `c2`; check that it exists SELECT get_lock ('test', 1.5); diff --git a/mysql-test/suite/galera/r/galera_sequence_engine.result b/mysql-test/suite/galera/r/galera_sequence_engine.result new file mode 100644 index 00000000000..93e6c46bd7a --- /dev/null +++ b/mysql-test/suite/galera/r/galera_sequence_engine.result @@ -0,0 +1,12 @@ +connection node_2; +connection node_1; +SET GLOBAL wsrep_ignore_apply_errors=0; +SET SESSION AUTOCOMMIT=0; +SET SESSION max_error_count=0; +CREATE TABLE t0 (id GEOMETRY,parent_id GEOMETRY)ENGINE=SEQUENCE; +ERROR 42000: This version of MariaDB doesn't yet support 'non-InnoDB sequences in Galera cluster' +connection node_2; +SHOW CREATE TABLE t0; +ERROR 42S02: Table 'test.t0' doesn't exist +connection node_1; +SET GLOBAL wsrep_ignore_apply_errors=DEFAULT; diff --git a/mysql-test/suite/galera/r/mdev-31285.result b/mysql-test/suite/galera/r/mdev-31285.result index 228f62fa305..58fcb385b1a 100644 --- a/mysql-test/suite/galera/r/mdev-31285.result +++ b/mysql-test/suite/galera/r/mdev-31285.result @@ -1,23 +1,8 @@ connection node_2; connection node_1; connection node_1; -connection node_2; -connection node_1; CREATE TABLE t ENGINE=InnoDB WITH SYSTEM VERSIONING AS SELECT 1 AS i; +ERROR 42000: This version of MariaDB doesn't yet support 'SYSTEM VERSIONING AS SELECT in Galera cluster' +connection node_2; SHOW CREATE TABLE t; -Table Create Table -t CREATE TABLE `t` ( - `i` int(1) NOT NULL -) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING -SELECT * from t; -i -1 -DROP TABLE IF EXISTS t; -COMMIT; -connection node_2; -SET SESSION wsrep_sync_wait=0; -Killing server ... -Starting server ... -connection node_2; -call mtr.add_suppression("WSREP: Event .*Write_rows_v1 apply failed:.*"); -call mtr.add_suppression("SREP: Failed to apply write set: gtid:.*"); +ERROR 42S02: Table 'test.t' doesn't exist diff --git a/mysql-test/suite/galera/t/MDEV-24143.test b/mysql-test/suite/galera/t/MDEV-24143.test index e58f147cb7c..3aecac8cb07 100644 --- a/mysql-test/suite/galera/t/MDEV-24143.test +++ b/mysql-test/suite/galera/t/MDEV-24143.test @@ -11,7 +11,11 @@ SET SESSION autocommit=0; SELECT * FROM t1 WHERE c1 <=0 ORDER BY c1 DESC; --error ER_LOCK_DEADLOCK INSERT INTO t1 VALUES (4),(3),(1),(2); ---error ER_TABLE_EXISTS_ERROR +# +# This is because support for CREATE TABLE ENGINE=SEQUENCE +# is done before we check does table exists already. +# +--error ER_NOT_SUPPORTED_YET CREATE TABLE t1 (pk INT PRIMARY KEY, b INT) ENGINE=SEQUENCE; --error ER_CANT_DROP_FIELD_OR_KEY ALTER TABLE t1 DROP COLUMN c2; diff --git a/mysql-test/suite/galera/t/galera_sequence_engine.test b/mysql-test/suite/galera/t/galera_sequence_engine.test new file mode 100644 index 00000000000..47107dcce84 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_sequence_engine.test @@ -0,0 +1,16 @@ +--source include/galera_cluster.inc +--source include/have_sequence.inc + +SET GLOBAL wsrep_ignore_apply_errors=0; +SET SESSION AUTOCOMMIT=0; +SET SESSION max_error_count=0; +--error ER_NOT_SUPPORTED_YET +CREATE TABLE t0 (id GEOMETRY,parent_id GEOMETRY)ENGINE=SEQUENCE; + +--connection node_2 +--error ER_NO_SUCH_TABLE +SHOW CREATE TABLE t0; + +--connection node_1 +SET GLOBAL wsrep_ignore_apply_errors=DEFAULT; + diff --git a/mysql-test/suite/galera/t/mdev-31285.test b/mysql-test/suite/galera/t/mdev-31285.test index d2749165ef7..5abef37cccd 100644 --- a/mysql-test/suite/galera/t/mdev-31285.test +++ b/mysql-test/suite/galera/t/mdev-31285.test @@ -1,34 +1,15 @@ --source include/galera_cluster.inc ---let $node_1 = node_1 ---let $node_2 = node_2 ---source include/auto_increment_offset_save.inc - --connection node_1 +# +# Below should not cause nodes to be inconsistent (they could if we +# allow TOI as some error are ignored on applier +# +--error ER_NOT_SUPPORTED_YET CREATE TABLE t ENGINE=InnoDB WITH SYSTEM VERSIONING AS SELECT 1 AS i; + +--connection node_2 +--error ER_NO_SUCH_TABLE SHOW CREATE TABLE t; -SELECT * from t; -DROP TABLE IF EXISTS t; -COMMIT; -# -# Restart node_2, force SST because database is inconsistent compared to node_1 -# ---connection node_2 -SET SESSION wsrep_sync_wait=0; ---source include/kill_galera.inc ---remove_file $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat ---echo Starting server ... -let $restart_noprint=2; ---source include/start_mysqld.inc ---let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; ---source include/wait_condition.inc ---let $wait_condition = SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready'; ---source include/wait_condition.inc - ---connection node_2 -call mtr.add_suppression("WSREP: Event .*Write_rows_v1 apply failed:.*"); -call mtr.add_suppression("SREP: Failed to apply write set: gtid:.*"); - ---source include/auto_increment_offset_restore.inc diff --git a/sql/sql_sequence.cc b/sql/sql_sequence.cc index 405b2d5b003..364d8e3fd51 100644 --- a/sql/sql_sequence.cc +++ b/sql/sql_sequence.cc @@ -27,6 +27,9 @@ #include "sql_acl.h" #ifdef WITH_WSREP #include "wsrep_mysqld.h" +bool wsrep_check_sequence(THD* thd, + const sequence_definition *seq, + const bool used_engine); #endif struct Field_definition @@ -945,7 +948,8 @@ bool Sql_cmd_alter_sequence::execute(THD *thd) #ifdef WITH_WSREP if (WSREP(thd) && wsrep_thd_is_local(thd)) { - if (wsrep_check_sequence(thd, new_seq)) + const bool used_engine= lex->create_info.used_fields & HA_CREATE_USED_ENGINE; + if (wsrep_check_sequence(thd, new_seq, used_engine)) DBUG_RETURN(TRUE); if (wsrep_to_isolation_begin(thd, first_table->db.str, diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 897027cc73d..4a4d6f9cca2 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -5343,18 +5343,21 @@ int mysql_create_table_no_lock(THD *thd, const LEX_CSTRING *db, #ifdef WITH_WSREP /** Additional sequence checks for Galera cluster. -@param thd thread handle -@param seq sequence definition +@param thd thread handle +@param seq sequence definition +@param used_engine create used ENGINE= @retval false success @retval true failure */ -bool wsrep_check_sequence(THD* thd, const sequence_definition *seq) +bool wsrep_check_sequence(THD* thd, + const sequence_definition *seq, + const bool used_engine) { enum legacy_db_type db_type; DBUG_ASSERT(WSREP(thd)); - if (thd->lex->create_info.used_fields & HA_CREATE_USED_ENGINE) + if (used_engine) { db_type= thd->lex->create_info.db_type->db_type; } @@ -5385,6 +5388,57 @@ bool wsrep_check_sequence(THD* thd, const sequence_definition *seq) return (false); } + +/** Additional CREATE TABLE/SEQUENCE checks for Galera cluster. + +@param thd thread handle +@param wsrep_ctas CREATE TABLE AS SELECT ? +@param used_engine CREATE TABLE ... ENGINE = ? +@param create_info Create information + +@retval false Galera cluster does support used clause +@retval true Galera cluster does not support used clause +*/ +static +bool wsrep_check_support(THD* thd, + const bool wsrep_ctas, + const bool used_engine, + const HA_CREATE_INFO* create_info) +{ + /* CREATE TABLE ... AS SELECT */ + if (wsrep_ctas && + thd->variables.wsrep_trx_fragment_size > 0) + { + my_message(ER_NOT_ALLOWED_COMMAND, + "CREATE TABLE AS SELECT is not supported with streaming replication", + MYF(0)); + return true; + } + /* CREATE TABLE .. WITH SYSTEM VERSIONING AS SELECT + is not supported in Galera cluster. + */ + if (wsrep_ctas && + create_info->versioned()) + { + my_error(ER_NOT_SUPPORTED_YET, MYF(0), + "SYSTEM VERSIONING AS SELECT in Galera cluster"); + return true; + } + /* + CREATE TABLE ... ENGINE=SEQUENCE is not supported in + Galera cluster. + CREATE SEQUENCE ... ENGINE=xxx Galera cluster supports + only InnoDB-sequences. + */ + if (((used_engine && create_info->db_type && + (create_info->db_type->db_type == DB_TYPE_SEQUENCE || + create_info->db_type->db_type >= DB_TYPE_FIRST_DYNAMIC)) || + thd->lex->sql_command == SQLCOM_CREATE_SEQUENCE) && + wsrep_check_sequence(thd, create_info->seq_create_info, used_engine)) + return true; + + return false; +} #endif /* WITH_WSREP */ /** @@ -5442,15 +5496,6 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table, if (!opt_explicit_defaults_for_timestamp) promote_first_timestamp_column(&alter_info->create_list); -#ifdef WITH_WSREP - if (thd->lex->sql_command == SQLCOM_CREATE_SEQUENCE && - WSREP(thd) && wsrep_thd_is_local_toi(thd)) - { - if (wsrep_check_sequence(thd, create_info->seq_create_info)) - DBUG_RETURN(true); - } -#endif /* WITH_WSREP */ - /* We can abort create table for any table type */ thd->abort_on_warning= thd->is_strict_mode(); @@ -9764,6 +9809,7 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db, TODO: this design is obsolete and will be removed. */ int table_kind= check_if_log_table(table_list, FALSE, NullS); + const bool used_engine= create_info->used_fields & HA_CREATE_USED_ENGINE; if (table_kind) { @@ -9775,7 +9821,7 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db, } /* Disable alter of log tables to unsupported engine */ - if ((create_info->used_fields & HA_CREATE_USED_ENGINE) && + if ((used_engine) && (!create_info->db_type || /* unknown engine */ !(create_info->db_type->flags & HTON_SUPPORT_LOG_TABLES))) { @@ -9826,7 +9872,7 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db, if we can support implementing storage engine. */ if (WSREP(thd) && table && table->s->sequence && - wsrep_check_sequence(thd, thd->lex->create_info.seq_create_info)) + wsrep_check_sequence(thd, thd->lex->create_info.seq_create_info, used_engine)) DBUG_RETURN(TRUE); #endif /* WITH_WSREP */ @@ -10285,12 +10331,10 @@ do_continue:; #endif #ifdef WITH_WSREP + // ALTER TABLE for sequence object, check can we support it if (table->s->sequence && WSREP(thd) && - wsrep_thd_is_local_toi(thd)) - { - if (wsrep_check_sequence(thd, create_info->seq_create_info)) + wsrep_check_sequence(thd, create_info->seq_create_info, used_engine)) DBUG_RETURN(TRUE); - } #endif /* WITH_WSREP */ /* @@ -11744,17 +11788,11 @@ bool Sql_cmd_create_table_like::execute(THD *thd) #endif #ifdef WITH_WSREP - if (wsrep_ctas) + if (WSREP(thd) && + wsrep_check_support(thd, wsrep_ctas, used_engine, &create_info)) { - if (thd->variables.wsrep_trx_fragment_size > 0) - { - my_message( - ER_NOT_ALLOWED_COMMAND, - "CREATE TABLE AS SELECT is not supported with streaming replication", - MYF(0)); - res= 1; - goto end_with_restore_list; - } + res= 1; + goto end_with_restore_list; } #endif /* WITH_WSREP */ @@ -11906,6 +11944,7 @@ bool Sql_cmd_create_table_like::execute(THD *thd) create_table->table_name, create_table->db)) goto end_with_restore_list; +#ifdef WITH_WSREP /* In STATEMENT format, we probably have to replicate also temporary tables, like mysql replication does. Also check if the requested @@ -11914,15 +11953,15 @@ bool Sql_cmd_create_table_like::execute(THD *thd) if (WSREP(thd)) { handlerton *orig_ht= create_info.db_type; + if (!check_engine(thd, create_table->db.str, create_table->table_name.str, &create_info) && (!thd->is_current_stmt_binlog_format_row() || !create_info.tmp_table())) { -#ifdef WITH_WSREP if (thd->lex->sql_command == SQLCOM_CREATE_SEQUENCE && - wsrep_check_sequence(thd, lex->create_info.seq_create_info)) + wsrep_check_sequence(thd, lex->create_info.seq_create_info, used_engine)) DBUG_RETURN(true); WSREP_TO_ISOLATION_BEGIN_ALTER(create_table->db.str, create_table->table_name.str, @@ -11932,13 +11971,14 @@ bool Sql_cmd_create_table_like::execute(THD *thd) res= true; goto end_with_restore_list; } -#endif /* WITH_WSREP */ } // check_engine will set db_type to NULL if e.g. TEMPORARY is // not supported by the storage engine, this case is checked // again in mysql_create_table create_info.db_type= orig_ht; } +#endif /* WITH_WSREP */ + /* Regular CREATE TABLE */ res= mysql_create_table(thd, create_table, &create_info, &alter_info); } diff --git a/sql/sql_table.h b/sql/sql_table.h index cf61ad6a4fa..e51b5ec0f0f 100644 --- a/sql/sql_table.h +++ b/sql/sql_table.h @@ -285,8 +285,4 @@ extern mysql_mutex_t LOCK_gdl; bool check_engine(THD *, const char *, const char *, HA_CREATE_INFO *); -#ifdef WITH_WSREP -bool wsrep_check_sequence(THD* thd, const class sequence_definition *seq); -#endif - #endif /* SQL_TABLE_INCLUDED */ From c768ac6208114d58c7365273fcbc627fff568c38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Mon, 4 Sep 2023 12:22:51 +0300 Subject: [PATCH 004/568] MDEV-25731 : Assertion `mode_ == m_local' failed in wsrep::client_state::streaming_params() Problem was that if wsrep_load_data_splitting was used streaming replication (SR) parameters were set for MyISAM table. Galera does not currently support SR for MyISAM. Fix is to ignore wsrep_load_data_splitting setting (with warning) if table is not InnoDB table. This is 10.4-10.5 case of fix. Signed-off-by: Julius Goryavsky --- mysql-test/std_data/mdev-25731.dat | 6 +++ mysql-test/suite/galera/r/MDEV-25731.result | 34 +++++++++++++++++ mysql-test/suite/galera/t/MDEV-25731.test | 27 ++++++++++++++ sql/sql_load.cc | 41 ++++++++++++++++----- 4 files changed, 98 insertions(+), 10 deletions(-) create mode 100644 mysql-test/std_data/mdev-25731.dat create mode 100644 mysql-test/suite/galera/r/MDEV-25731.result create mode 100644 mysql-test/suite/galera/t/MDEV-25731.test diff --git a/mysql-test/std_data/mdev-25731.dat b/mysql-test/std_data/mdev-25731.dat new file mode 100644 index 00000000000..e6c779a8292 --- /dev/null +++ b/mysql-test/std_data/mdev-25731.dat @@ -0,0 +1,6 @@ +1 +2 +3 +1 +5 +6 diff --git a/mysql-test/suite/galera/r/MDEV-25731.result b/mysql-test/suite/galera/r/MDEV-25731.result new file mode 100644 index 00000000000..93afc74afde --- /dev/null +++ b/mysql-test/suite/galera/r/MDEV-25731.result @@ -0,0 +1,34 @@ +connection node_2; +connection node_1; +connection node_1; +SET GLOBAL wsrep_load_data_splitting=ON; +Warnings: +Warning 1287 '@@wsrep_load_data_splitting' is deprecated and will be removed in a future release +SET GLOBAL wsrep_replicate_myisam=ON; +CREATE TABLE t1 (c1 int) ENGINE=MYISAM; +LOAD DATA INFILE '../../std_data/mdev-25731.dat' IGNORE INTO TABLE t1 LINES TERMINATED BY '\n'; +Warnings: +Warning 1235 wsrep_load_data_splitting for other than InnoDB tables +SELECT COUNT(*) AS EXPECT_6 FROM t1; +EXPECT_6 +6 +connection node_2; +SELECT COUNT(*) AS EXPECT_6 FROM t1; +EXPECT_6 +6 +connection node_1; +ALTER TABLE t1 ENGINE=InnoDB; +LOAD DATA INFILE '../../std_data/mdev-25731.dat' IGNORE INTO TABLE t1 LINES TERMINATED BY '\n'; +SELECT COUNT(*) AS EXPECT_12 FROM t1; +EXPECT_12 +12 +connection node_2; +SELECT COUNT(*) AS EXPECT_12 FROM t1; +EXPECT_12 +12 +connection node_1; +DROP TABLE t1; +SET GLOBAL wsrep_load_data_splitting=OFF; +Warnings: +Warning 1287 '@@wsrep_load_data_splitting' is deprecated and will be removed in a future release +SET GLOBAL wsrep_replicate_myisam=OFF; diff --git a/mysql-test/suite/galera/t/MDEV-25731.test b/mysql-test/suite/galera/t/MDEV-25731.test new file mode 100644 index 00000000000..c26fad2fa6a --- /dev/null +++ b/mysql-test/suite/galera/t/MDEV-25731.test @@ -0,0 +1,27 @@ +--source include/galera_cluster.inc +--source include/have_aria.inc + +--connection node_1 +SET GLOBAL wsrep_load_data_splitting=ON; +SET GLOBAL wsrep_replicate_myisam=ON; +CREATE TABLE t1 (c1 int) ENGINE=MYISAM; +LOAD DATA INFILE '../../std_data/mdev-25731.dat' IGNORE INTO TABLE t1 LINES TERMINATED BY '\n'; +SELECT COUNT(*) AS EXPECT_6 FROM t1; + +--connection node_2 +SELECT COUNT(*) AS EXPECT_6 FROM t1; + +--connection node_1 +ALTER TABLE t1 ENGINE=InnoDB; +LOAD DATA INFILE '../../std_data/mdev-25731.dat' IGNORE INTO TABLE t1 LINES TERMINATED BY '\n'; +SELECT COUNT(*) AS EXPECT_12 FROM t1; + +--connection node_2 +SELECT COUNT(*) AS EXPECT_12 FROM t1; + +--connection node_1 +DROP TABLE t1; +SET GLOBAL wsrep_load_data_splitting=OFF; +SET GLOBAL wsrep_replicate_myisam=OFF; + + diff --git a/sql/sql_load.cc b/sql/sql_load.cc index cc4361b0472..aef649309fc 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -105,23 +105,41 @@ public: class Wsrep_load_data_split { public: - Wsrep_load_data_split(THD *thd) + Wsrep_load_data_split(THD *thd, TABLE *table) : m_thd(thd) - , m_load_data_splitting(wsrep_load_data_splitting) + , m_load_data_splitting(false) , m_fragment_unit(thd->wsrep_trx().streaming_context().fragment_unit()) , m_fragment_size(thd->wsrep_trx().streaming_context().fragment_size()) { - if (WSREP(m_thd) && m_load_data_splitting) + /* + We support load data splitting for InnoDB only as it will use + streaming replication (SR). + */ + if (WSREP(thd) && wsrep_load_data_splitting) { - /* Override streaming settings with backward compatible values for - load data splitting */ - m_thd->wsrep_cs().streaming_params(wsrep::streaming_context::row, 10000); + handlerton *ht= table->s->db_type(); + // For partitioned tables find underlying hton + if (table->file->partition_ht()) + ht= table->file->partition_ht(); + if (ht->db_type != DB_TYPE_INNODB) + { + push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, + ER_NOT_SUPPORTED_YET, + "wsrep_load_data_splitting for other than InnoDB tables"); + } + else + { + /* Override streaming settings with backward compatible values for + load data splitting */ + m_thd->wsrep_cs().streaming_params(wsrep::streaming_context::row, 10000); + m_load_data_splitting= true; + } } } ~Wsrep_load_data_split() { - if (WSREP(m_thd) && m_load_data_splitting) + if (m_load_data_splitting) { /* Restore original settings */ m_thd->wsrep_cs().streaming_params(m_fragment_unit, m_fragment_size); @@ -346,6 +364,7 @@ int mysql_load(THD *thd, const sql_exchange *ex, TABLE_LIST *table_list, bool is_concurrent; #endif const char *db= table_list->db.str; // This is never null + /* If path for file is not defined, we will use the current database. If this is not set, we will use the directory where the table to be @@ -356,9 +375,6 @@ int mysql_load(THD *thd, const sql_exchange *ex, TABLE_LIST *table_list, bool transactional_table __attribute__((unused)); DBUG_ENTER("mysql_load"); -#ifdef WITH_WSREP - Wsrep_load_data_split wsrep_load_data_split(thd); -#endif /* WITH_WSREP */ /* Bug #34283 mysqlbinlog leaves tmpfile after termination if binlog contains @@ -422,6 +438,11 @@ int mysql_load(THD *thd, const sql_exchange *ex, TABLE_LIST *table_list, { DBUG_RETURN(TRUE); } + +#ifdef WITH_WSREP + Wsrep_load_data_split wsrep_load_data_split(thd, table_list->table); +#endif /* WITH_WSREP */ + thd_proc_info(thd, "Executing"); /* Let us emit an error if we are loading data to table which is used From 12d05c8266567ea9a62ccabc3180a90129bf81e0 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Mon, 29 Jan 2024 09:59:36 +1100 Subject: [PATCH 005/568] MDEV-28640: Debian typo in init script Noted by Eric X. --- debian/mariadb-server-10.6.mariadb.init | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/mariadb-server-10.6.mariadb.init b/debian/mariadb-server-10.6.mariadb.init index 4a41ed9758c..ff94ec5c22a 100644 --- a/debian/mariadb-server-10.6.mariadb.init +++ b/debian/mariadb-server-10.6.mariadb.init @@ -88,7 +88,7 @@ sanity_checks() { # If datadir location is not changed int configuration # then it's not printed with /usr/sbin/mariadbd --print-defaults # then we use 'sane' default. - if [ -z "$datadir"] + if [ -z "$datadir" ] then datadir="/var/lib/mysql" fi From e4f221a5f2a103320015cd20bac8412040d0fc2e Mon Sep 17 00:00:00 2001 From: Brandon Nesterenko Date: Mon, 29 Jan 2024 15:17:57 -0700 Subject: [PATCH 006/568] MDEV-33327: rpl_seconds_behind_master_spike Sensitive to IO Thread Stop Position rpl.rpl_seconds_behind_master_spike uses the DEBUG_SYNC mechanism to count how many format descriptor events (FDEs) have been executed, to attempt to pause on a specific relay log FDE after executing transactions. However, depending on when the IO thread is stopped, it can send an extra FDE before sending the transactions, forcing the test to pause before executing any transactions, resulting in a table not existing, that is attempted to be read for COUNT. This patch fixes this by no longer counting FDEs, but rather by programmatically waiting until the SQL thread has executed the transaction and then automatically activating the DEBUG_SYNC point to trigger at the next relay log FDE. --- .../rpl/r/rpl_seconds_behind_master_spike.result | 8 ++------ .../rpl/t/rpl_seconds_behind_master_spike.test | 9 ++------- sql/slave.cc | 15 +++++++++++++-- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/mysql-test/suite/rpl/r/rpl_seconds_behind_master_spike.result b/mysql-test/suite/rpl/r/rpl_seconds_behind_master_spike.result index bb71f6c92b0..3234a512d86 100644 --- a/mysql-test/suite/rpl/r/rpl_seconds_behind_master_spike.result +++ b/mysql-test/suite/rpl/r/rpl_seconds_behind_master_spike.result @@ -3,7 +3,8 @@ include/master-slave.inc connection slave; include/stop_slave.inc SET @save_dbug= @@GLOBAL.debug_dbug; -SET @@global.debug_dbug="+d,pause_sql_thread_on_fde,negate_clock_diff_with_master"; +SET @@global.debug_dbug="+d,pause_sql_thread_on_relay_fde_after_trans"; +SET @@global.debug_dbug="+d,negate_clock_diff_with_master"; include/start_slave.inc # Future events must be logged at least 2 seconds after # the slave starts @@ -15,11 +16,6 @@ insert into t1 values (1); # event in its relay log flush logs; connection slave; -# Ignore FDEs that happen before the CREATE/INSERT commands -SET DEBUG_SYNC='now WAIT_FOR paused_on_fde'; -SET DEBUG_SYNC='now SIGNAL sql_thread_continue'; -SET DEBUG_SYNC='now WAIT_FOR paused_on_fde'; -SET DEBUG_SYNC='now SIGNAL sql_thread_continue'; # On the next FDE, the slave should have the master CREATE/INSERT events SET DEBUG_SYNC='now WAIT_FOR paused_on_fde'; select count(*)=1 from t1; diff --git a/mysql-test/suite/rpl/t/rpl_seconds_behind_master_spike.test b/mysql-test/suite/rpl/t/rpl_seconds_behind_master_spike.test index 9e73e6678a2..cd6311c5e19 100644 --- a/mysql-test/suite/rpl/t/rpl_seconds_behind_master_spike.test +++ b/mysql-test/suite/rpl/t/rpl_seconds_behind_master_spike.test @@ -27,7 +27,8 @@ --connection slave --source include/stop_slave.inc SET @save_dbug= @@GLOBAL.debug_dbug; -SET @@global.debug_dbug="+d,pause_sql_thread_on_fde,negate_clock_diff_with_master"; +SET @@global.debug_dbug="+d,pause_sql_thread_on_relay_fde_after_trans"; +SET @@global.debug_dbug="+d,negate_clock_diff_with_master"; --source include/start_slave.inc --let $sleep_time=2 @@ -46,12 +47,6 @@ insert into t1 values (1); flush logs; --connection slave ---echo # Ignore FDEs that happen before the CREATE/INSERT commands -SET DEBUG_SYNC='now WAIT_FOR paused_on_fde'; -SET DEBUG_SYNC='now SIGNAL sql_thread_continue'; -SET DEBUG_SYNC='now WAIT_FOR paused_on_fde'; -SET DEBUG_SYNC='now SIGNAL sql_thread_continue'; - --echo # On the next FDE, the slave should have the master CREATE/INSERT events SET DEBUG_SYNC='now WAIT_FOR paused_on_fde'; select count(*)=1 from t1; diff --git a/sql/slave.cc b/sql/slave.cc index f4d76e447cd..d37b00f2888 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -4301,6 +4301,15 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli, { Gtid_log_event *gev= static_cast(ev); +#ifdef ENABLED_DEBUG_SYNC + DBUG_EXECUTE_IF( + "pause_sql_thread_on_relay_fde_after_trans", + { + DBUG_SET("-d,pause_sql_thread_on_relay_fde_after_trans"); + DBUG_SET("+d,pause_sql_thread_on_next_relay_fde"); + }); +#endif + /* For GTID, allocate a new sub_id for the given domain_id. The sub_id must be allocated in increasing order of binlog order. @@ -4451,12 +4460,14 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli, #endif /* WITH_WSREP */ #ifdef ENABLED_DEBUG_SYNC DBUG_EXECUTE_IF( - "pause_sql_thread_on_fde", - if (ev && typ == FORMAT_DESCRIPTION_EVENT) { + "pause_sql_thread_on_next_relay_fde", + if (ev && typ == FORMAT_DESCRIPTION_EVENT && + ((Format_description_log_event *) ev)->is_relay_log_event()) { DBUG_ASSERT(!debug_sync_set_action( thd, STRING_WITH_LEN( "now SIGNAL paused_on_fde WAIT_FOR sql_thread_continue"))); + DBUG_SET("-d,pause_sql_thread_on_next_relay_fde"); }); #endif From 736e429320c28d963bc66f80e2c8a35b7db72ec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Fri, 5 Jan 2024 13:35:41 +0200 Subject: [PATCH 007/568] MDEV-32635: galera_shutdown_nonprim: mysql_shutdown failed Add wait_condition after cluster membership change Signed-off-by: Julius Goryavsky --- mysql-test/suite/galera/disabled.def | 1 - .../galera/r/galera_shutdown_nonprim.result | 7 ++++- .../galera/t/galera_shutdown_nonprim.test | 26 ++++++++++++------- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index a05ee3f8880..1f41e521bd3 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -13,7 +13,6 @@ galera_as_slave_ctas : MDEV-28378 timeout galera_pc_recovery : MDEV-25199 cluster fails to start up galera_sequences : MDEV-32561 WSREP FSM failure: no such a transition REPLICATING -> COMMITTED -galera_shutdown_nonprim : MDEV-32635 galera_shutdown_nonprim: mysql_shutdown failed versioning_trx_id : MDEV-18590 : galera.versioning_trx_id: Test failure: mysqltest: Result content mismatch galera_concurrent_ctas : MDEV-32779 galera_concurrent_ctas: assertion in the galera::ReplicatorSMM::finish_cert() galera_as_slave_replay : MDEV-32780 galera_as_slave_replay: assertion in the wsrep::transaction::before_rollback() diff --git a/mysql-test/suite/galera/r/galera_shutdown_nonprim.result b/mysql-test/suite/galera/r/galera_shutdown_nonprim.result index 8b7697432a3..d577eab9f1a 100644 --- a/mysql-test/suite/galera/r/galera_shutdown_nonprim.result +++ b/mysql-test/suite/galera/r/galera_shutdown_nonprim.result @@ -5,7 +5,12 @@ connection node_2; connection node_1; SET GLOBAL wsrep_provider_options = 'pc.weight=2'; connection node_2; -SET GLOBAL wsrep_provider_options = 'gmcast.isolate = 1'; SET SESSION wsrep_sync_wait = 0; +SET GLOBAL wsrep_provider_options = 'gmcast.isolate = 1'; +connection node_1; +connection node_2; +SHOW STATUS LIKE 'wsrep_cluster_status'; +Variable_name Value +wsrep_cluster_status non-Primary connection node_1; SET GLOBAL wsrep_provider_options = 'pc.weight = 1'; diff --git a/mysql-test/suite/galera/t/galera_shutdown_nonprim.test b/mysql-test/suite/galera/t/galera_shutdown_nonprim.test index cf7018cd751..d1a1c91456b 100644 --- a/mysql-test/suite/galera/t/galera_shutdown_nonprim.test +++ b/mysql-test/suite/galera/t/galera_shutdown_nonprim.test @@ -16,21 +16,27 @@ SET GLOBAL wsrep_provider_options = 'pc.weight=2'; --connection node_2 # Isolate node_2 from the group and wait until wsrep_ready becomes OFF. -SET GLOBAL wsrep_provider_options = 'gmcast.isolate = 1'; SET SESSION wsrep_sync_wait = 0; ---let $wait_condition = SELECT VARIABLE_VALUE = 'OFF' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready' ---source include/wait_condition.inc - -# Verify that graceful shutdown succeeds. ---source include/shutdown_mysqld.inc ---source include/start_mysqld.inc - ---let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; ---source include/wait_condition.inc +SET GLOBAL wsrep_provider_options = 'gmcast.isolate = 1'; --connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + +--connection node_2 +--let $wait_condition = SELECT VARIABLE_VALUE = 'OFF' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready' +--source include/wait_condition.inc +SHOW STATUS LIKE 'wsrep_cluster_status'; +# Verify that graceful shutdown succeeds. +--source include/shutdown_mysqld.inc + +--source include/start_mysqld.inc + +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; --source include/wait_condition.inc # Restore original settings. SET GLOBAL wsrep_provider_options = 'pc.weight = 1'; + --source include/auto_increment_offset_restore.inc From 49fa5f6b5f573b25d7712859ca404d086f4f5223 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Fri, 5 Jan 2024 11:33:53 +0200 Subject: [PATCH 008/568] MDEV-33138 : Galera test case MW-336 unstable Add more inserts before wsrep_slave_threads is set to 1 and add wait_condition to wait all of them are replicated before wait_condition about number of wsrep_slave_threads. Signed-off-by: Julius Goryavsky --- mysql-test/suite/galera/r/MW-336.result | 46 ++++-------------- mysql-test/suite/galera/t/MW-336.cnf | 2 + mysql-test/suite/galera/t/MW-336.test | 62 +++++++++++-------------- 3 files changed, 39 insertions(+), 71 deletions(-) diff --git a/mysql-test/suite/galera/r/MW-336.result b/mysql-test/suite/galera/r/MW-336.result index 8996b85c77c..e0cb1ee0464 100644 --- a/mysql-test/suite/galera/r/MW-336.result +++ b/mysql-test/suite/galera/r/MW-336.result @@ -1,7 +1,8 @@ connection node_2; connection node_1; connection node_1; -CREATE TABLE t1 (f1 INTEGER) Engine=InnoDB; +SET @wsrep_slave_threads_orig = @@wsrep_slave_threads; +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT) Engine=InnoDB; SET GLOBAL wsrep_slave_threads = 10; # Set slave threads to 10 step 1 SELECT VARIABLE_VALUE AS EXPECT_10 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_applier_thread_count'; @@ -9,7 +10,7 @@ EXPECT_10 10 SET GLOBAL wsrep_slave_threads = 1; connection node_2; -INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (NULL); connection node_1; # Wait until one of the appliers has exited SELECT VARIABLE_VALUE AS EXPECT_9 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_applier_thread_count'; @@ -27,33 +28,14 @@ EXPECT_20 20 SET GLOBAL wsrep_slave_threads = 1; connection node_2; -INSERT INTO t1 VALUES (1); -INSERT INTO t1 VALUES (2); -INSERT INTO t1 VALUES (3); -INSERT INTO t1 VALUES (4); -INSERT INTO t1 VALUES (5); -INSERT INTO t1 VALUES (6); -INSERT INTO t1 VALUES (7); -INSERT INTO t1 VALUES (8); -INSERT INTO t1 VALUES (9); -INSERT INTO t1 VALUES (10); -INSERT INTO t1 VALUES (11); -INSERT INTO t1 VALUES (12); -INSERT INTO t1 VALUES (13); -INSERT INTO t1 VALUES (14); -INSERT INTO t1 VALUES (16); -INSERT INTO t1 VALUES (17); -INSERT INTO t1 VALUES (18); -INSERT INTO t1 VALUES (19); -INSERT INTO t1 VALUES (20); connection node_1; # Wait until 19 of the appliers has exited SELECT VARIABLE_VALUE AS EXPECT_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_applier_thread_count'; EXPECT_1 1 -SELECT COUNT(*) FROM t1; -COUNT(*) -20 +SELECT COUNT(*) AS EXPECT_51 FROM t1; +EXPECT_51 +51 SET GLOBAL wsrep_slave_threads = 10; # Set slave threads to 10 step 3 SELECT VARIABLE_VALUE AS EXPECT_10 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_applier_thread_count'; @@ -62,22 +44,12 @@ EXPECT_10 connection node_1; SET GLOBAL wsrep_slave_threads = 1; connection node_2; -INSERT INTO t1 VALUES (21); -INSERT INTO t1 VALUES (22); -INSERT INTO t1 VALUES (23); -INSERT INTO t1 VALUES (24); -INSERT INTO t1 VALUES (25); -INSERT INTO t1 VALUES (26); -INSERT INTO t1 VALUES (27); -INSERT INTO t1 VALUES (28); -INSERT INTO t1 VALUES (29); -INSERT INTO t1 VALUES (30); connection node_1; # Wait until slave threads back to 1 SELECT VARIABLE_VALUE AS EXPECT_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_applier_thread_count'; EXPECT_1 1 -SELECT COUNT(*) FROM t1; -COUNT(*) -30 +SELECT COUNT(*) AS EXPECT_101 FROM t1; +EXPECT_101 +101 DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/MW-336.cnf b/mysql-test/suite/galera/t/MW-336.cnf index e68f891792c..da97be5f86d 100644 --- a/mysql-test/suite/galera/t/MW-336.cnf +++ b/mysql-test/suite/galera/t/MW-336.cnf @@ -2,6 +2,8 @@ [mysqld.1] wsrep-debug=SERVER +loose-wsrep-mw-336=1 [mysqld.2] wsrep-debug=SERVER +loose-wsrep-mw-336=2 diff --git a/mysql-test/suite/galera/t/MW-336.test b/mysql-test/suite/galera/t/MW-336.test index 83943c7d8ea..29a70978e5e 100644 --- a/mysql-test/suite/galera/t/MW-336.test +++ b/mysql-test/suite/galera/t/MW-336.test @@ -3,11 +3,12 @@ # --source include/galera_cluster.inc ---source include/have_innodb.inc --source include/force_restart.inc +--source include/have_sequence.inc --connection node_1 -CREATE TABLE t1 (f1 INTEGER) Engine=InnoDB; +SET @wsrep_slave_threads_orig = @@wsrep_slave_threads; +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT) Engine=InnoDB; SET GLOBAL wsrep_slave_threads = 10; @@ -22,7 +23,7 @@ SELECT VARIABLE_VALUE AS EXPECT_10 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE V SET GLOBAL wsrep_slave_threads = 1; --connection node_2 -INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (NULL); --connection node_1 --echo # Wait until one of the appliers has exited @@ -54,27 +55,19 @@ SELECT VARIABLE_VALUE AS EXPECT_20 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE V SET GLOBAL wsrep_slave_threads = 1; --connection node_2 -INSERT INTO t1 VALUES (1); -INSERT INTO t1 VALUES (2); -INSERT INTO t1 VALUES (3); -INSERT INTO t1 VALUES (4); -INSERT INTO t1 VALUES (5); -INSERT INTO t1 VALUES (6); -INSERT INTO t1 VALUES (7); -INSERT INTO t1 VALUES (8); -INSERT INTO t1 VALUES (9); -INSERT INTO t1 VALUES (10); -INSERT INTO t1 VALUES (11); -INSERT INTO t1 VALUES (12); -INSERT INTO t1 VALUES (13); -INSERT INTO t1 VALUES (14); -INSERT INTO t1 VALUES (16); -INSERT INTO t1 VALUES (17); -INSERT INTO t1 VALUES (18); -INSERT INTO t1 VALUES (19); -INSERT INTO t1 VALUES (20); +--disable_query_log +let $c = 50; +while ($c) { +INSERT INTO t1 VALUES(NULL); COMMIT; +dec $c; +} +--enable_query_log --connection node_1 +--let $wait_condition = SELECT COUNT(*) = 51 FROM t1; +--let $wait_condition_on_error_output = SELECT COUNT(*) FROM t1; +--source include/wait_condition_with_debug.inc + --echo # Wait until 19 of the appliers has exited --let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_applier_thread_count'; --let $wait_condition_on_error_output = SELECT COUNT(*), 1 as EXPECTED_VALUE FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE = 'wsrep applier idle'; show processlist @@ -82,7 +75,7 @@ INSERT INTO t1 VALUES (20); SELECT VARIABLE_VALUE AS EXPECT_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_applier_thread_count'; -SELECT COUNT(*) FROM t1; +SELECT COUNT(*) AS EXPECT_51 FROM t1; SET GLOBAL wsrep_slave_threads = 10; --echo # Set slave threads to 10 step 3 @@ -96,16 +89,13 @@ SELECT VARIABLE_VALUE AS EXPECT_10 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE V SET GLOBAL wsrep_slave_threads = 1; --connection node_2 -INSERT INTO t1 VALUES (21); -INSERT INTO t1 VALUES (22); -INSERT INTO t1 VALUES (23); -INSERT INTO t1 VALUES (24); -INSERT INTO t1 VALUES (25); -INSERT INTO t1 VALUES (26); -INSERT INTO t1 VALUES (27); -INSERT INTO t1 VALUES (28); -INSERT INTO t1 VALUES (29); -INSERT INTO t1 VALUES (30); +--disable_query_log +let $c = 50; +while ($c) { +INSERT INTO t1 VALUES(NULL); COMMIT; +dec $c; +} +--enable_query_log --connection node_1 --echo # Wait until slave threads back to 1 @@ -115,6 +105,10 @@ INSERT INTO t1 VALUES (30); SELECT VARIABLE_VALUE AS EXPECT_1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_applier_thread_count'; -SELECT COUNT(*) FROM t1; +SELECT COUNT(*) AS EXPECT_101 FROM t1; DROP TABLE t1; + +--disable_query_log +SET GLOBAL wsrep_slave_threads = @wsrep_slave_threads_orig; +--enable_query_log From 5b4456b38a4cac479a03f09e55620d263481d8c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Fri, 29 Dec 2023 10:20:51 +0200 Subject: [PATCH 009/568] MDEV-33036 : Galera test case galera_3nodes.galera_ist_gcache_rollover has warning Correct used configuration and force server restarts before test case. Add wait condition instead of sleep to verify that all expected nodes are back to cluster. Signed-off-by: Julius Goryavsky --- .../r/galera_ist_gcache_rollover.result | 27 ++++++++------- .../r/galera_join_with_cc_B.result | 7 ++++ .../t/galera_ist_gcache_rollover.cnf | 14 +++++++- .../t/galera_ist_gcache_rollover.test | 33 ++++++++++++++----- .../t/galera_join_with_cc_B.test | 13 ++++++++ 5 files changed, 73 insertions(+), 21 deletions(-) diff --git a/mysql-test/suite/galera_3nodes/r/galera_ist_gcache_rollover.result b/mysql-test/suite/galera_3nodes/r/galera_ist_gcache_rollover.result index 9f1d3fec16e..a69cef11358 100644 --- a/mysql-test/suite/galera_3nodes/r/galera_ist_gcache_rollover.result +++ b/mysql-test/suite/galera_3nodes/r/galera_ist_gcache_rollover.result @@ -9,6 +9,7 @@ INSERT INTO t1 VALUES (01), (02), (03), (04), (05); connection node_2; Unloading wsrep provider ... SET GLOBAL wsrep_cluster_address = ''; +connection node_1; connection node_3; Unloading wsrep provider ... SET GLOBAL wsrep_cluster_address = ''; @@ -33,14 +34,16 @@ SET GLOBAL wsrep_provider_options = 'dbug='; SET GLOBAL wsrep_provider_options = 'signal=ist_sender_send_after_get_buffers'; INSERT INTO t1 VALUES (51), (52), (53), (54), (55); connection node_2; +connection node_1; connection node_3; +connection node_1; connection node_2; -SELECT COUNT(*) = 30 FROM t1; -COUNT(*) = 30 -1 -SELECT COUNT(*) = 3 FROM t2; -COUNT(*) = 3 -1 +SELECT COUNT(*) AS EXPECT_30 FROM t1; +EXPECT_30 +30 +SELECT COUNT(*) AS EXPECT_3 FROM t2; +EXPECT_3 +3 SELECT LENGTH(f1) = 512 * 1024 FROM t2; LENGTH(f1) = 512 * 1024 1 @@ -48,12 +51,12 @@ LENGTH(f1) = 512 * 1024 1 CALL mtr.add_suppression("WSREP: Unsupported protocol downgrade: incremental data collection disabled"); connection node_3; -SELECT COUNT(*) = 30 FROM t1; -COUNT(*) = 30 -1 -SELECT COUNT(*) = 3 FROM t2; -COUNT(*) = 3 -1 +SELECT COUNT(*) AS EXPECT_30 FROM t1; +EXPECT_30 +30 +SELECT COUNT(*) AS EXPECT_3 FROM t2; +EXPECT_3 +3 SELECT LENGTH(f1) = 512 * 1024 FROM t2; LENGTH(f1) = 512 * 1024 1 diff --git a/mysql-test/suite/galera_3nodes/r/galera_join_with_cc_B.result b/mysql-test/suite/galera_3nodes/r/galera_join_with_cc_B.result index 7e75bc4b08a..a88909f4bfb 100644 --- a/mysql-test/suite/galera_3nodes/r/galera_join_with_cc_B.result +++ b/mysql-test/suite/galera_3nodes/r/galera_join_with_cc_B.result @@ -1,6 +1,9 @@ connection node_2; connection node_1; connection node_1; +connection node_2; +connection node_3; +connection node_1; CREATE TABLE t1 (pk INT PRIMARY KEY, node INT) ENGINE=innodb; INSERT INTO t1 VALUES (1, 1); connection node_2; @@ -89,3 +92,7 @@ connection node_2; call mtr.add_suppression("WSREP: Rejecting JOIN message from \(.*\): new State Transfer required."); connection node_3; call mtr.add_suppression("WSREP: Rejecting JOIN message from \(.*\): new State Transfer required."); +disconnect node_1a; +disconnect node_3; +disconnect node_2; +disconnect node_1; diff --git a/mysql-test/suite/galera_3nodes/t/galera_ist_gcache_rollover.cnf b/mysql-test/suite/galera_3nodes/t/galera_ist_gcache_rollover.cnf index 303087dffbb..29563657262 100644 --- a/mysql-test/suite/galera_3nodes/t/galera_ist_gcache_rollover.cnf +++ b/mysql-test/suite/galera_3nodes/t/galera_ist_gcache_rollover.cnf @@ -2,10 +2,22 @@ [mysqld.1] wsrep_provider_options='repl.causal_read_timeout=PT90S;base_port=@mysqld.1.#galera_port;evs.suspect_timeout=PT10S;evs.inactive_timeout=PT30S;evs.install_timeout=PT15S;pc.ignore_sb=true;gcache.size=1M' +auto_increment_increment=1 +auto_increment_offset=1 +# this will force server restarts before this test +loose-galera-ist-gcache-rollover=1 +wsrep-debug=1 [mysqld.2] wsrep_provider_options='repl.causal_read_timeout=PT90S;base_port=@mysqld.2.#galera_port;evs.suspect_timeout=PT10S;evs.inactive_timeout=PT30S;evs.install_timeout=PT15S;pc.ignore_sb=true;gcache.size=1M' +auto_increment_increment=2 +auto_increment_offset=2 +loose-galera-ist-gcache-rollover=2 +wsrep-debug=1 [mysqld.3] wsrep_provider_options='repl.causal_read_timeout=PT90S;base_port=@mysqld.3.#galera_port;evs.suspect_timeout=PT10S;evs.inactive_timeout=PT30S;evs.install_timeout=PT15S;pc.ignore_sb=true;gcache.size=1M' - +auto_increment_increment=3 +auto_increment_offset=3 +loose-galera-ist-gcache-rollover=3 +wsrep-debug=1 diff --git a/mysql-test/suite/galera_3nodes/t/galera_ist_gcache_rollover.test b/mysql-test/suite/galera_3nodes/t/galera_ist_gcache_rollover.test index 210a4c2331e..16b9bdb2d02 100644 --- a/mysql-test/suite/galera_3nodes/t/galera_ist_gcache_rollover.test +++ b/mysql-test/suite/galera_3nodes/t/galera_ist_gcache_rollover.test @@ -12,6 +12,7 @@ --source include/have_innodb.inc --source include/have_debug_sync.inc --source include/galera_have_debug_sync.inc +--source include/force_restart.inc --let $galera_connection_name = node_3 --let $galera_server_number = 3 @@ -24,6 +25,9 @@ --source ../galera/include/auto_increment_offset_save.inc --connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' +--let $wait_condition_on_error_output = SELECT * FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME LIKE 'wsrep%'; show processlist +--source include/wait_condition_with_debug.inc CREATE TABLE t1 (f1 INTEGER PRIMARY KEY); INSERT INTO t1 VALUES (01), (02), (03), (04), (05); @@ -32,12 +36,15 @@ INSERT INTO t1 VALUES (01), (02), (03), (04), (05); --let $wsrep_cluster_address_orig2 = `select @@wsrep_cluster_address` --source suite/galera/include/galera_stop_replication.inc +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' +--source include/wait_condition.inc + --connection node_3 --let $wsrep_cluster_address_orig3 = `select @@wsrep_cluster_address` --source suite/galera/include/galera_stop_replication.inc --connection node_1 ---source include/wait_until_connected_again.inc INSERT INTO t1 VALUES (11), (12), (13), (14), (15); # Wait until nodes #2 and #3 have left @@ -88,29 +95,39 @@ INSERT INTO t1 VALUES (51), (52), (53), (54), (55); --connection node_2 --source include/wait_until_connected_again.inc +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 2 OR VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' +--source include/wait_condition.inc + --connection node_3 --source include/wait_until_connected_again.inc -sleep 5; +--connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' +--source include/wait_condition.inc # Final checks --connection node_2 -SELECT COUNT(*) = 30 FROM t1; -SELECT COUNT(*) = 3 FROM t2; +--let $wait_condition = SELECT COUNT(*) = 30 FROM t1 +--source include/wait_condition.inc + +SELECT COUNT(*) AS EXPECT_30 FROM t1; +SELECT COUNT(*) AS EXPECT_3 FROM t2; SELECT LENGTH(f1) = 512 * 1024 FROM t2; CALL mtr.add_suppression("WSREP: Unsupported protocol downgrade: incremental data collection disabled"); # Final checks --connection node_3 -SELECT COUNT(*) = 30 FROM t1; -SELECT COUNT(*) = 3 FROM t2; +--let $wait_condition = SELECT COUNT(*) = 30 FROM t1 +--source include/wait_condition.inc +SELECT COUNT(*) AS EXPECT_30 FROM t1; +SELECT COUNT(*) AS EXPECT_3 FROM t2; SELECT LENGTH(f1) = 512 * 1024 FROM t2; CALL mtr.add_suppression("WSREP: Unsupported protocol downgrade: incremental data collection disabled"); DROP TABLE t1, t2; # Restore original auto_increment_offset values. ---source ../galera/include/auto_increment_offset_restore.inc - --let $galera_cluster_size=3 +--source ../galera/include/auto_increment_offset_restore.inc --source include/galera_end.inc diff --git a/mysql-test/suite/galera_3nodes/t/galera_join_with_cc_B.test b/mysql-test/suite/galera_3nodes/t/galera_join_with_cc_B.test index 2fb0e78c759..d06cdcc8ae4 100644 --- a/mysql-test/suite/galera_3nodes/t/galera_join_with_cc_B.test +++ b/mysql-test/suite/galera_3nodes/t/galera_join_with_cc_B.test @@ -15,6 +15,12 @@ --let $galera_server_number = 3 --source include/galera_connect.inc +# Save original auto_increment_offset values. +--let $node_1=node_1 +--let $node_2=node_2 +--let $node_3=node_3 +--source ../galera/include/auto_increment_offset_save.inc + --connection node_1 --let $wait_condition = SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; --source include/wait_condition.inc @@ -271,3 +277,10 @@ call mtr.add_suppression("WSREP: Rejecting JOIN message from \(.*\): new State T --connection node_3 call mtr.add_suppression("WSREP: Rejecting JOIN message from \(.*\): new State Transfer required."); + +--disconnect node_1a + +# Restore original auto_increment_offset values. +--let $galera_cluster_size=3 +--source ../galera/include/auto_increment_offset_restore.inc +--source include/galera_end.inc From ddb27a29b1381c35bde970c41c6f0bbe674661c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Thu, 4 Jan 2024 15:27:15 +0200 Subject: [PATCH 010/568] MDEV-33172 : Galera test case galera_mdl_race unstable Add wait_condition between debug sync SIGNAL points and other expected state conditions and refactor actual sync point for easier to use in test case. Signed-off-by: Julius Goryavsky --- .../suite/galera/r/galera_mdl_race.result | 50 +++++++++++---- .../suite/galera/t/galera_mdl_race.test | 62 +++++++++++++------ sql/mdl.cc | 11 +--- 3 files changed, 81 insertions(+), 42 deletions(-) diff --git a/mysql-test/suite/galera/r/galera_mdl_race.result b/mysql-test/suite/galera/r/galera_mdl_race.result index cf747ed8efb..a7f0bc8e672 100644 --- a/mysql-test/suite/galera/r/galera_mdl_race.result +++ b/mysql-test/suite/galera/r/galera_mdl_race.result @@ -1,44 +1,68 @@ connection node_2; connection node_1; +connection node_1; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1)) engine=innodb; CREATE TABLE t2 (f1 INTEGER PRIMARY KEY, f2 CHAR(1)) engine=innodb; INSERT INTO t1 VALUES (1, 'a'); INSERT INTO t1 VALUES (2, 'a'); -connection node_1; SET AUTOCOMMIT=ON; START TRANSACTION; UPDATE t1 SET f2 = 'b' WHERE f1 = 1; connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1; connection node_1a; +SET SESSION wsrep_sync_wait=0; LOCK TABLE t2 WRITE; connection node_1; -SET @@debug_dbug = "d,sync.wsrep_before_mdl_wait"; +SET DEBUG_SYNC= 'wsrep_before_mdl_wait SIGNAL before_mdl_wait WAIT_FOR mdl_wait_continue'; SELECT * FROM t2;; connection node_1a; +# Wait until select is blocked before MDL lock wait +SET DEBUG_SYNC= 'now WAIT_FOR before_mdl_wait'; +connection node_1a; SET @@debug_dbug = "d,sync.wsrep_after_BF_victim_lock"; connection node_2; UPDATE t1 SET f2 = 'c' WHERE f1 = 1; -connection node_1a; -SET @@debug_dbug = ""; -SET DEBUG_SYNC = "now SIGNAL signal.wsrep_before_mdl_wait"; +connect node_1b, 127.0.0.1, root, , test, $NODE_MYPORT_1; +connection node_1b; +SET SESSION wsrep_sync_wait=0; +# Wait for conflicting update to block SET DEBUG_SYNC = "now SIGNAL signal.wsrep_after_BF_victim_lock"; +connect node_1c, 127.0.0.1, root, , test, $NODE_MYPORT_1; +connection node_1c; +connection node_1a; +SET DEBUG_SYNC = "now SIGNAL BF_victim_continue"; UNLOCK TABLES; connection node_1; ERROR 40001: Deadlock found when trying to get lock; try restarting transaction -SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'a'; -COUNT(*) = 1 +connection node_1; +SELECT COUNT(*) AS EXPECT_1 FROM t1 WHERE f2 = 'a'; +EXPECT_1 1 -SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'c'; -COUNT(*) = 1 +SELECT COUNT(*) AS EXPECT_1 FROM t1 WHERE f2 = 'c'; +EXPECT_1 1 +SELECT * FROM t1; +f1 f2 +1 c +2 a connection node_2; -SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'a'; -COUNT(*) = 1 +SELECT COUNT(*) AS EXPECT_1 FROM t1 WHERE f2 = 'a'; +EXPECT_1 1 -SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'c'; -COUNT(*) = 1 +SELECT COUNT(*) AS EXPECT_1 FROM t1 WHERE f2 = 'c'; +EXPECT_1 1 +SELECT * FROM t1; +f1 f2 +1 c +2 a DROP TABLE t1; DROP TABLE t2; connection node_1a; SET DEBUG_SYNC = "RESET"; +connection node_1b; +SET DEBUG_SYNC = "RESET"; +connection node_1; +disconnect node_1a; +disconnect node_1b; +disconnect node_1c; diff --git a/mysql-test/suite/galera/t/galera_mdl_race.test b/mysql-test/suite/galera/t/galera_mdl_race.test index ad6770f9991..3341a3792f1 100644 --- a/mysql-test/suite/galera/t/galera_mdl_race.test +++ b/mysql-test/suite/galera/t/galera_mdl_race.test @@ -3,70 +3,92 @@ # --source include/galera_cluster.inc +--source include/have_debug.inc --source include/have_debug_sync.inc +--connection node_1 CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1)) engine=innodb; CREATE TABLE t2 (f1 INTEGER PRIMARY KEY, f2 CHAR(1)) engine=innodb; INSERT INTO t1 VALUES (1, 'a'); INSERT INTO t1 VALUES (2, 'a'); ---connection node_1 SET AUTOCOMMIT=ON; START TRANSACTION; - UPDATE t1 SET f2 = 'b' WHERE f1 = 1; # block access to t2 --connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 --connection node_1a +SET SESSION wsrep_sync_wait=0; +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't2' +--let $wait_condition_on_error_output = SELECT * FROM INFORMATION_SCHEMA.TABLES +--source include/wait_condition_with_debug.inc LOCK TABLE t2 WRITE; -# Block before MLD lock wait +# Block before MDL lock wait --connection node_1 - SET @@debug_dbug = "d,sync.wsrep_before_mdl_wait"; +SET DEBUG_SYNC= 'wsrep_before_mdl_wait SIGNAL before_mdl_wait WAIT_FOR mdl_wait_continue'; --send SELECT * FROM t2; -# Wait for SELECT to be blocked --connection node_1a -#--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIS WHERE STATE = 'System lock'; -#--source include/wait_condition.inc -#--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'init' AND INFO = 'COMMIT'; -#--source include/wait_condition.inc +--echo # Wait until select is blocked before MDL lock wait +SET DEBUG_SYNC= 'now WAIT_FOR before_mdl_wait'; # block applier to wait after BF victim is locked +--connection node_1a SET @@debug_dbug = "d,sync.wsrep_after_BF_victim_lock"; # Issue a conflicting update on node #2 --connection node_2 UPDATE t1 SET f2 = 'c' WHERE f1 = 1; -# Unblock the SELECT, to enter wsrep_thd_is_BF ---connection node_1a -SET @@debug_dbug = ""; -SET DEBUG_SYNC = "now SIGNAL signal.wsrep_before_mdl_wait"; +--connect node_1b, 127.0.0.1, root, , test, $NODE_MYPORT_1 +--connection node_1b +SET SESSION wsrep_sync_wait=0; +--echo # Wait for conflicting update to block +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE 'Update_rows_log_event:%'; +--source include/wait_condition.inc -# unblock applier to try to BF the SELECT +# Unblock the SELECT, to enter wsrep_thd_is_BF SET DEBUG_SYNC = "now SIGNAL signal.wsrep_after_BF_victim_lock"; +--connect node_1c, 127.0.0.1, root, , test, $NODE_MYPORT_1 +--connection node_1c +--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE 'Update_rows_log_event:%'; +--source include/wait_condition.inc + +--connection node_1a +# unblock applier to try to BF the SELECT +SET DEBUG_SYNC = "now SIGNAL BF_victim_continue"; + # table lock is not needed anymore UNLOCK TABLES; -# SELECT succeeds +# SELECT returns deadlock --connection node_1 - --error ER_LOCK_DEADLOCK --reap -SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'a'; -SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'c'; +--connection node_1 +SELECT COUNT(*) AS EXPECT_1 FROM t1 WHERE f2 = 'a'; +SELECT COUNT(*) AS EXPECT_1 FROM t1 WHERE f2 = 'c'; +SELECT * FROM t1; --connection node_2 -SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'a'; -SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'c'; +SELECT COUNT(*) AS EXPECT_1 FROM t1 WHERE f2 = 'a'; +SELECT COUNT(*) AS EXPECT_1 FROM t1 WHERE f2 = 'c'; +SELECT * FROM t1; DROP TABLE t1; DROP TABLE t2; --connection node_1a SET DEBUG_SYNC = "RESET"; +--connection node_1b +SET DEBUG_SYNC = "RESET"; + +--connection node_1 +--disconnect node_1a +--disconnect node_1b +--disconnect node_1c diff --git a/sql/mdl.cc b/sql/mdl.cc index 7aae1c16022..b2a9d52bd82 100644 --- a/sql/mdl.cc +++ b/sql/mdl.cc @@ -1176,15 +1176,8 @@ MDL_wait::timed_wait(MDL_context_owner *owner, struct timespec *abs_timeout, { #ifdef WITH_WSREP # ifdef ENABLED_DEBUG_SYNC - // Allow tests to block the applier thread using the DBUG facilities - DBUG_EXECUTE_IF("sync.wsrep_before_mdl_wait", - { - const char act[]= - "now " - "wait_for signal.wsrep_before_mdl_wait"; - DBUG_ASSERT(!debug_sync_set_action((owner->get_thd()), - STRING_WITH_LEN(act))); - };); + // Allow tests to block thread before MDL-wait + DEBUG_SYNC(owner->get_thd(), "wsrep_before_mdl_wait"); # endif if (WSREP_ON && wsrep_thd_is_BF(owner->get_thd(), false)) { From f8fa3c55c66e6ebec889299ec9db3e4e83b38c61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Thu, 4 Jan 2024 16:46:47 +0200 Subject: [PATCH 011/568] MDEV-33173 : Galera test case galera_sr_kill_slave_before_apply unstable Add wait_condition to make sure tables are created before next operations. Signed-off-by: Julius Goryavsky --- .../r/galera_sr_kill_slave_before_apply.result | 16 ++++++++-------- .../t/galera_sr_kill_slave_before_apply.test | 13 +++++++++---- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/mysql-test/suite/galera_3nodes_sr/r/galera_sr_kill_slave_before_apply.result b/mysql-test/suite/galera_3nodes_sr/r/galera_sr_kill_slave_before_apply.result index 933038e00f1..ef2bd7a45e1 100644 --- a/mysql-test/suite/galera_3nodes_sr/r/galera_sr_kill_slave_before_apply.result +++ b/mysql-test/suite/galera_3nodes_sr/r/galera_sr_kill_slave_before_apply.result @@ -7,11 +7,11 @@ connection node_3; connection node_1; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; connection node_2; -SELECT COUNT(*) = 0 FROM t1; -COUNT(*) = 0 -1 +SELECT COUNT(*) AS EXPECT_0 FROM t1; +EXPECT_0 +0 connection node_1; -CREATE TABLE t2 (f1 INTEGER); +CREATE TABLE t2 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2; LOCK TABLE t2 WRITE; connection node_1; @@ -37,12 +37,12 @@ count_match count_match 1 connection node_1; -SELECT COUNT(*) FROM mysql.wsrep_streaming_log; -COUNT(*) +SELECT COUNT(*) AS EXPECT_0 FROM mysql.wsrep_streaming_log; +EXPECT_0 0 connection node_2; -SELECT COUNT(*) FROM mysql.wsrep_streaming_log; -COUNT(*) +SELECT COUNT(*) AS EXPECT_0 FROM mysql.wsrep_streaming_log; +EXPECT_0 0 connection node_1; DROP TABLE t1; diff --git a/mysql-test/suite/galera_3nodes_sr/t/galera_sr_kill_slave_before_apply.test b/mysql-test/suite/galera_3nodes_sr/t/galera_sr_kill_slave_before_apply.test index 08a59296e41..355db2de456 100644 --- a/mysql-test/suite/galera_3nodes_sr/t/galera_sr_kill_slave_before_apply.test +++ b/mysql-test/suite/galera_3nodes_sr/t/galera_sr_kill_slave_before_apply.test @@ -15,18 +15,23 @@ --source ../galera/include/auto_increment_offset_save.inc --connection node_1 +--let $wait_condition = SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; +--source include/wait_condition.inc + CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; # Block node #2's applier before table t1's inserts have come into play --connection node_2 -SELECT COUNT(*) = 0 FROM t1; +SELECT COUNT(*) AS EXPECT_0 FROM t1; --connection node_1 -CREATE TABLE t2 (f1 INTEGER); +CREATE TABLE t2 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; --connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't2' +--source include/wait_condition.inc LOCK TABLE t2 WRITE; --connection node_1 @@ -77,10 +82,10 @@ if ($mysql_errno == 1213) { --enable_query_log --connection node_1 -SELECT COUNT(*) FROM mysql.wsrep_streaming_log; +SELECT COUNT(*) AS EXPECT_0 FROM mysql.wsrep_streaming_log; --connection node_2 -SELECT COUNT(*) FROM mysql.wsrep_streaming_log; +SELECT COUNT(*) AS EXPECT_0 FROM mysql.wsrep_streaming_log; --connection node_1 DROP TABLE t1; From 6914b7804dd29b71f9a85a120f6352d8cd855e38 Mon Sep 17 00:00:00 2001 From: Tuukka Pasanen Date: Mon, 4 Dec 2023 10:01:36 +0200 Subject: [PATCH 012/568] MDEV-32935: Remove unneeded CMAKE_SYSTEM_PROCESSOR parameter from Debian There is no need for CMAKE_SYSTEM_PROCESSOR parameter in Debian build as dh_auto_configure should handle things better and more reliable --- debian/rules | 1 - 1 file changed, 1 deletion(-) diff --git a/debian/rules b/debian/rules index 3f8f747a02f..052bf865e52 100755 --- a/debian/rules +++ b/debian/rules @@ -89,7 +89,6 @@ endif -DCOMPILATION_COMMENT="mariadb.org binary distribution" \ -DMYSQL_SERVER_SUFFIX="-$(DEB_VERSION_REVISION)" \ -DSYSTEM_TYPE="debian-$(DEB_HOST_GNU_SYSTEM)" \ - -DCMAKE_SYSTEM_PROCESSOR=$(DEB_HOST_ARCH) \ -DBUILD_CONFIG=mysql_release \ -DPLUGIN_TOKUDB=NO \ -DPLUGIN_CASSANDRA=NO \ From f5ca4077d805c3dab1f119f1192c082851205db2 Mon Sep 17 00:00:00 2001 From: Dishon Merkhai Date: Mon, 13 Mar 2023 15:04:54 -0400 Subject: [PATCH 013/568] MDEV-30839: Add new options to mini-benchmark and fixes Add new options to mini-benchmark.sh so it is more useful, such as `--log` to avoid output from `lscpu` and other commands being lost. Also fix following errors: - Fix if condition for the cycle count regression verdict. The condition checked if the cycle count was greater than 850 billion, but `$RESULT` is only 3 digits and represents the number of cycles in billions. - Fix flamegraph width. The original width caused the flamegraph to be cut-off on most screen sizes in the browser. - Fix ShellCheck warnings and suggestions. - Fix condition to check if perf has permission to run on the system. All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc. --- support-files/mini-benchmark.sh | 91 +++++++++++++++++++++++++-------- 1 file changed, 71 insertions(+), 20 deletions(-) diff --git a/support-files/mini-benchmark.sh b/support-files/mini-benchmark.sh index 18de6dbec51..9b7cb6dc698 100755 --- a/support-files/mini-benchmark.sh +++ b/support-files/mini-benchmark.sh @@ -10,6 +10,18 @@ display_help() { echo "regressions." echo echo "optional arguments:" + echo " --name STRING identifier for the benchmark, added to the " + echo " folder name and (if --log is set) the log file " + echo " --threads \"STRING\" quoted string of space-separated integers " + echo " representing the threads to run." + echo " example: --threads \"1 32 64 128\"" + echo " default: \"1 2 4 8 16\"" + echo " --duration INTEGER duration of each thread run in seconds" + echo " default: 60" + echo " --workload STRING sysbench workload to execute" + echo " default: oltp_read_write" + echo " --log logs the mini-benchmark stdout/stderr into the" + echo " benchmark folder." echo " --perf measure CPU cycles and instruction count in for " echo " sysbench runs" echo " --perf-flamegraph record performance counters in perf.data.* and" @@ -17,6 +29,12 @@ display_help() { echo " -h, --help display this help and exit" } +# Default parameters +BENCHMARK_NAME='mini-benchmark' +THREADS='1 2 4 8 16' +DURATION=60 +WORKLOAD='oltp_read_write' + while : do case "$1" in @@ -28,6 +46,31 @@ do display_version exit 0 ;; + --name) + shift + BENCHMARK_NAME+='-' + BENCHMARK_NAME+=$1 + shift + ;; + --threads) + shift + THREADS=$1 + shift + ;; + --duration) + shift + DURATION=$1 + shift + ;; + --workload) + shift + WORKLOAD=$1 + shift + ;; + --log) + LOG=true + shift + ;; --perf) PERF=true shift @@ -47,6 +90,13 @@ do esac done +# Save results of this run in a subdirectory so that they are not overwritten by +# the next run +TIMESTAMP="$(date -Iseconds)" +mkdir "$BENCHMARK_NAME-$TIMESTAMP" +cd "$BENCHMARK_NAME-$TIMESTAMP" || exit 1 + +( # Check that the dependencies of this script are available if [ ! -e /usr/bin/pgrep ] then @@ -62,6 +112,7 @@ fi # If there are multiple processes, assume the last one is the actual server and # any potential other ones were just part of the service wrapper chain +# shellcheck disable=SC2005 MARIADB_SERVER_PID="$(echo "$(pgrep -f mariadbd || pgrep -f mysqld)" | tail -n 1)" if [ -z "$MARIADB_SERVER_PID" ] @@ -102,12 +153,13 @@ then echo "Ensure the MariaDB Server debug symbols are installed" for x in $(ldd /usr/sbin/mariadbd | grep -oE " /.* ") do - rpm -q --whatprovides --qf '%{name}' $x | cut -d : -f 1 + rpm -q --whatprovides --qf '%{name}' "$x" | cut -d : -f 1 done | sort -u > mariadbd-dependencies.txt # shellcheck disable=SC2046 debuginfo-install -y mariadb-server $(cat mariadbd-dependencies.txt) - - if [ ! $(perf record echo "testing perf" > /dev/null 2>&1) ] + + perf record echo "testing perf" > /dev/null 2>&1 + if [ $? -ne 0 ] then echo "perf does not have permission to run on this system. Skipping." PERF="" @@ -120,7 +172,8 @@ elif [ -e /usr/bin/perf ] then # If flamegraphs were not requested, log normal perf counters if possible - if [ ! $(perf stat echo "testing perf" > /dev/null 2>&1) ] + perf stat echo "testing perf" > /dev/null 2>&1 + if [ $? -ne 0 ] then echo "perf does not have permission to run on this system. Skipping." PERF="" @@ -156,28 +209,23 @@ mariadb -e " CREATE USER IF NOT EXISTS sbtest@localhost; GRANT ALL PRIVILEGES ON sbtest.* TO sbtest@localhost" -sysbench oltp_read_write prepare --tables=20 --table-size=100000 | tee sysbench-prepare.log +sysbench "$WORKLOAD" prepare --tables=20 --table-size=100000 | tee sysbench-prepare.log sync && sleep 1 # Ensure writes were propagated to disk -# Save results of this run in a subdirectory so that they are not overwritten by -# the next run -TIMESTAMP="$(date -Iseconds)" -mkdir "mini-benchmark-$TIMESTAMP" -cd "mini-benchmark-$TIMESTAMP" || exit 1 - # Run benchmark with increasing thread counts. The MariaDB Server will be using # around 300 MB of RAM and mostly reading and writing in RAM, so I/O usage is # also low. The benchmark will most likely be CPU bound to due to the load # profile, and also guaranteed to be CPU bound because of being limited to a # single CPU with 'tasksel'. -for t in 1 2 4 8 16 +for t in $THREADS do # Prepend command with perf if defined - # Output stderr to stdout as perf outpus everything in stderr - $PERF $TASKSET_SYSBENCH sysbench oltp_read_write run --threads=$t --time=60 --report-interval=10 2>&1 | tee sysbench-run-$t.log + # Output stderr to stdout as perf outputs everything in stderr + # shellcheck disable=SC2086 + $PERF $TASKSET_SYSBENCH sysbench "$WORKLOAD" run --threads=$t --time=$DURATION --report-interval=10 2>&1 | tee sysbench-run-$t.log done -sysbench oltp_read_write cleanup --tables=20 | tee sysbench-cleanup.log +sysbench "$WORKLOAD" cleanup --tables=20 | tee sysbench-cleanup.log # Store results from 4 thread run in a Gitlab-CI compatible metrics file grep -oE '[a-z]+:[ ]+[0-9.]+' sysbench-run-4.log | sed -r 's/\s+/ /g' | tail -n 15 > metrics.txt @@ -197,10 +245,10 @@ then # Final verdict based on cpu cycle count RESULT="$(grep -h -e cycles sysbench-run-*.log | sort -k 1 | awk '{s+=$1}END{print s}')" - if [ "$RESULT" -gt 850000000000 ] + if [ "$RESULT" -gt 850 ] then echo # Newline improves readability - echo "Benchmark exceeded 8.5 billion cpu cycles, performance most likely regressed!" + echo "Benchmark exceeded 850 billion cpu cycles, performance most likely regressed!" exit 1 fi fi @@ -216,12 +264,12 @@ if [ "$PERF_RECORD" == true ] then for f in perf.data.* do - perf script -i $f | stackcollapse-perf.pl | flamegraph.pl --width 3000 > $f.svg + perf script -i "$f" | stackcollapse-perf.pl | flamegraph.pl --width 1800 > "$f".svg done - echo "Flamegraphs stored in folder mini-benchmark-$TIMESTAMP/" + echo "Flamegraphs stored in folder $BENCHMARK_NAME-$TIMESTAMP/" fi -# Fallback if CPU cycle count not availalbe: final verdict based on peak QPS +# Fallback if CPU cycle count not available: final verdict based on peak QPS RESULT="$(sort -k 9 -h sysbench-run-*.log | tail -n 1 | grep -oE "qps: [0-9]+" | grep -oE "[0-9]+")" case $RESULT in ''|*[!0-9]*) @@ -240,3 +288,6 @@ case $RESULT in fi ;; esac +# Record the output into the log file, if requested +) 2>&1 | ($LOG && tee "$BENCHMARK_NAME"-"$TIMESTAMP".log) + From c2e16b3ad521d7e7b86b73c5ace546c7fc942571 Mon Sep 17 00:00:00 2001 From: Nikita Malyavin Date: Fri, 17 Nov 2023 23:40:10 +0100 Subject: [PATCH 014/568] MDEV-32803 Assertion `total == 0' failed in Event_log::write_cache_raw A second DML in a transaction for a table of non-rollbackable engine leads to a cache corruption, because the cache wasn't reset after a statement end, but also wasn't destroyed. This patch resets the cache for a reuse by subsequent statements in current transaction. --- .../main/alter_table_online_debug.result | 22 ++++++++++++++++ mysql-test/main/alter_table_online_debug.test | 25 +++++++++++++++++++ sql/online_alter.cc | 3 +++ 3 files changed, 50 insertions(+) diff --git a/mysql-test/main/alter_table_online_debug.result b/mysql-test/main/alter_table_online_debug.result index 1d20d40e7e4..c987ff4d2f6 100644 --- a/mysql-test/main/alter_table_online_debug.result +++ b/mysql-test/main/alter_table_online_debug.result @@ -1785,6 +1785,28 @@ a d 0 qwe 0 qwe drop table t; +# +# MDEV-32803 Assertion `total == 0' failed in Event_log::write_cache_raw +# +create or replace table t1 (a int) engine=aria; +insert t1 values (5); +set debug_sync= 'alter_table_copy_end SIGNAL ended WAIT_FOR end'; +alter table t1 add b int NULL, algorithm= copy, lock= none; +connection con2; +set debug_sync= 'now WAIT_FOR ended'; +begin; +insert into t1 values (123); +insert into t1 values (456), (789); +commit; +set debug_sync= 'now SIGNAL end'; +connection default; +select * from t1; +a b +5 NULL +123 NULL +456 NULL +789 NULL +drop table t1; set global default_storage_engine= MyISAM; disconnect con1; disconnect con2; diff --git a/mysql-test/main/alter_table_online_debug.test b/mysql-test/main/alter_table_online_debug.test index cf0062da269..2a37f6a0c46 100644 --- a/mysql-test/main/alter_table_online_debug.test +++ b/mysql-test/main/alter_table_online_debug.test @@ -2041,6 +2041,31 @@ select * from t; drop table t; +--echo # +--echo # MDEV-32803 Assertion `total == 0' failed in Event_log::write_cache_raw +--echo # + +create or replace table t1 (a int) engine=aria; +insert t1 values (5); +set debug_sync= 'alter_table_copy_end SIGNAL ended WAIT_FOR end'; + +send alter table t1 add b int NULL, algorithm= copy, lock= none; + +--connection con2 +set debug_sync= 'now WAIT_FOR ended'; +begin; +insert into t1 values (123); +insert into t1 values (456), (789); +commit; +set debug_sync= 'now SIGNAL end'; + +--connection default +--reap +select * from t1; + +drop table t1; + + eval set global default_storage_engine= $default_storage_engine; --disconnect con1 diff --git a/sql/online_alter.cc b/sql/online_alter.cc index e0afe602ca8..5f418d8ec29 100644 --- a/sql/online_alter.cc +++ b/sql/online_alter.cc @@ -152,6 +152,7 @@ int online_alter_log_row(TABLE* table, const uchar *before_record, if (!table->online_alter_cache) { table->online_alter_cache= get_cache_data(thd, table); + DBUG_ASSERT(table->online_alter_cache->cache_log.type == WRITE_CACHE); trans_register_ha(thd, false, online_alter_hton, 0); if (thd->in_multi_stmt_transaction_mode()) trans_register_ha(thd, true, online_alter_hton, 0); @@ -237,6 +238,8 @@ int online_alter_end_trans(Online_alter_cache_list &cache_list, THD *thd, mysql_mutex_lock(binlog->get_log_lock()); error= binlog->write_cache_raw(thd, &cache.cache_log); mysql_mutex_unlock(binlog->get_log_lock()); + if (!is_ending_transaction) + cache.reset(); } } else if (!commit) // rollback From 50095046f3f5e8b6600a0095156f7ba3817699ba Mon Sep 17 00:00:00 2001 From: Nikita Malyavin Date: Tue, 2 Jan 2024 18:45:43 +0100 Subject: [PATCH 015/568] MDEV-32614 LeakSanitizer errors in copy_data_between_tables The memory leak occurs on error when backup_reset_alter_copy_lock fails with timeout. This leads to the alter rollback, but flush_unused is not called. Move table flushing on error handling to a single place and mind more possible failures this time. --- .../main/alter_table_online_debug.result | 22 ++++++++++ mysql-test/main/alter_table_online_debug.test | 35 ++++++++++++++++ sql/sql_table.cc | 40 ++++++++++--------- 3 files changed, 78 insertions(+), 19 deletions(-) diff --git a/mysql-test/main/alter_table_online_debug.result b/mysql-test/main/alter_table_online_debug.result index c987ff4d2f6..16e9fd190be 100644 --- a/mysql-test/main/alter_table_online_debug.result +++ b/mysql-test/main/alter_table_online_debug.result @@ -1807,6 +1807,28 @@ a b 456 NULL 789 NULL drop table t1; +# MDEV-32614 LeakSanitizer errors in copy_data_between_tables +create table t (a int, b int) engine=aria; +insert into t select seq, seq from seq_1_to_5; +backup stage start; +connect con_lock,localhost,root,,; +set lock_wait_timeout= 1; +set debug_sync='copy_data_between_tables_before_reset_backup_lock wait_for continue'; +alter table t add index (b), algorithm=copy, lock=none; +connection default; +backup stage block_commit; +set debug_sync='now signal continue'; +connection con_lock; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +set debug_sync='copy_data_between_tables_before_reset_backup_lock wait_for continue'; +alter table t add index (a), algorithm=copy, lock=none; +connection default; +backup stage end; +set debug_sync='now signal continue'; +connection con_lock; +disconnect con_lock; +connection default; +drop table t; set global default_storage_engine= MyISAM; disconnect con1; disconnect con2; diff --git a/mysql-test/main/alter_table_online_debug.test b/mysql-test/main/alter_table_online_debug.test index 2a37f6a0c46..a45226b277a 100644 --- a/mysql-test/main/alter_table_online_debug.test +++ b/mysql-test/main/alter_table_online_debug.test @@ -2066,6 +2066,41 @@ select * from t1; drop table t1; +--echo # MDEV-32614 LeakSanitizer errors in copy_data_between_tables +create table t (a int, b int) engine=aria; +insert into t select seq, seq from seq_1_to_5; +backup stage start; + +--connect (con_lock,localhost,root,,) +set lock_wait_timeout= 1; + +set debug_sync='copy_data_between_tables_before_reset_backup_lock wait_for continue'; +send alter table t add index (b), algorithm=copy, lock=none; + +--connection default +backup stage block_commit; + +set debug_sync='now signal continue'; + +--connection con_lock +--error ER_LOCK_WAIT_TIMEOUT +--reap +# --echo # error $mysql_errno + +set debug_sync='copy_data_between_tables_before_reset_backup_lock wait_for continue'; +send alter table t add index (a), algorithm=copy, lock=none; + +--connection default +backup stage end; +set debug_sync='now signal continue'; + +--connection con_lock +--reap +--disconnect con_lock +--connection default +drop table t; + + eval set global default_storage_engine= $default_storage_engine; --disconnect con1 diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 20eeeb545bf..2b1228ac82f 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -12130,6 +12130,7 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to, #ifdef HAVE_REPLICATION if (online) { + DBUG_ASSERT(from->s->online_alter_binlog == NULL); from->s->online_alter_binlog= new Cache_flip_event_log(); if (!from->s->online_alter_binlog) goto err; @@ -12363,29 +12364,10 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to, thd_progress_next_stage(thd); error= online_alter_read_from_binlog(thd, &rgi, binlog, &found_count); } - if (error) - from->s->tdc->flush_unused(1); // to free the binlog to->pos_in_table_list= NULL; // Safety DBUG_ASSERT(thd->lex->sql_command == saved_sql_command); thd->lex->sql_command= saved_sql_command; // Just in case } - else if (online) // error was on copy stage - { - /* - We can't free the resources properly now, as we can still be in - non-exclusive state. So this s->online_alter_binlog will be used - until all transactions will release it. - Once the transaction commits, it can release online_alter_binlog - by decreasing ref_count. - - online_alter_binlog->ref_count can be reached 0 only once. - Proof: - If share exists, we'll always have ref_count >= 1. - Once it reaches destroy(), nobody can acquire it again, - therefore, only release() is possible at this moment. - */ - from->s->tdc->flush_unused(1); // to free the binlog - } #endif if (error > 0 && !from->s->tmp_table) @@ -12400,6 +12382,26 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to, if (unlikely(mysql_trans_commit_alter_copy_data(thd))) error= 1; + + if (unlikely(error) && online) + { + /* + We can't free the resources properly now, as we can still be in + non-exclusive state. So this s->online_alter_binlog will be used + until all transactions will release it. + Once the transaction commits, it can release online_alter_binlog + by decreasing ref_count. + + online_alter_binlog->ref_count can be reached 0 only once. + Proof: + If share exists, we'll always have ref_count >= 1. + Once it reaches destroy(), nobody can acquire it again, + therefore, only release() is possible at this moment. + + Also, this will release the binlog. + */ + from->s->tdc->flush_unused(1); + } err: if (bulk_insert_started) From 9599cbc28d1be2d3a81b2f67b0d5b70738bc56c3 Mon Sep 17 00:00:00 2001 From: Nikita Malyavin Date: Tue, 9 Jan 2024 12:37:26 +0100 Subject: [PATCH 016/568] online_alter: clean up usage of cleanup_cache_list --- sql/online_alter.cc | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/sql/online_alter.cc b/sql/online_alter.cc index 5f418d8ec29..a3adb273a2f 100644 --- a/sql/online_alter.cc +++ b/sql/online_alter.cc @@ -182,23 +182,19 @@ int online_alter_log_row(TABLE* table, const uchar *before_record, } -static void -cleanup_cache_list(ilist &list, bool ending_trans) +static void cleanup_cache_list(ilist &list) { - if (ending_trans) + auto it= list.begin(); + while (it != list.end()) { - auto it= list.begin(); - while (it != list.end()) - { - auto &cache= *it++; - cache.sink_log->release(); - cache.reset(); - cache.cleanup_sv(); - delete &cache; - } - list.clear(); - DBUG_ASSERT(list.empty()); + auto &cache= *it++; + cache.sink_log->release(); + cache.reset(); + cache.cleanup_sv(); + delete &cache; } + list.clear(); + DBUG_ASSERT(list.empty()); } @@ -258,12 +254,12 @@ int online_alter_end_trans(Online_alter_cache_list &cache_list, THD *thd, { my_error(ER_ERROR_ON_WRITE, MYF(ME_ERROR_LOG), binlog->get_name(), errno); - cleanup_cache_list(cache_list, is_ending_transaction); - DBUG_RETURN(error); + break; } } - cleanup_cache_list(cache_list, is_ending_transaction); + if (is_ending_transaction) + cleanup_cache_list(cache_list); DBUG_RETURN(error); } From dccce98388f63548230a0e8666d9a8e31c270dc8 Mon Sep 17 00:00:00 2001 From: Nikita Malyavin Date: Wed, 17 Jan 2024 21:26:52 +0100 Subject: [PATCH 017/568] unpack_row+binlog_cache_data: fix unused variable --- sql/log_cache.h | 3 ++- sql/rpl_record.cc | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sql/log_cache.h b/sql/log_cache.h index 31342768942..d688a69fee6 100644 --- a/sql/log_cache.h +++ b/sql/log_cache.h @@ -237,7 +237,8 @@ private: delete pending(); set_pending(0); } - my_bool res= reinit_io_cache(&cache_log, WRITE_CACHE, pos, 0, reset_cache); + IF_DBUG(my_bool res=,) + reinit_io_cache(&cache_log, WRITE_CACHE, pos, 0, reset_cache); DBUG_ASSERT(res == 0); cache_log.end_of_file= saved_max_binlog_cache_size; } diff --git a/sql/rpl_record.cc b/sql/rpl_record.cc index b4254b7b163..2f6dd10e35b 100644 --- a/sql/rpl_record.cc +++ b/sql/rpl_record.cc @@ -439,7 +439,8 @@ int unpack_row(const rpl_group_info *rgi, TABLE *table, uint const colcnt, { DBUG_ASSERT(bitmap_is_set(cols, i)); Field *f= conv_table->field[i]; - bool result= unpack_field(tabledef, f, &st, i); + IF_DBUG(bool result=,) + unpack_field(tabledef, f, &st, i); DBUG_ASSERT(result); } From 57ffcd686ffa6c3b26a0da5f3f08f1f2117677d7 Mon Sep 17 00:00:00 2001 From: Monty Date: Mon, 29 Jan 2024 15:51:29 +0200 Subject: [PATCH 018/568] MDEV-21472: ALTER TABLE ... ANALYZE PARTITION ... with EITS reads and locks all rows This was fixed in 10.2 in 2020 but merging the code to 10.3 caused the bug to come back. --- .../main/column_compression_parts.result | 1 - mysql-test/main/partition.result | 1 - mysql-test/main/partition_binlog.result | 1 - mysql-test/main/stat_tables_partition.result | 3 +-- mysql-test/main/stat_tables_rbr.result | 1 - .../parts/r/partition_alter4_innodb.result | 24 ------------------- .../parts/r/partition_alter4_myisam.result | 24 ------------------- .../parts/r/partition_mgm_lc0_innodb.result | 1 - .../parts/r/partition_mgm_lc0_memory.result | 1 - .../parts/r/partition_mgm_lc0_myisam.result | 1 - .../parts/r/partition_mgm_lc1_innodb.result | 1 - .../parts/r/partition_mgm_lc1_memory.result | 1 - .../parts/r/partition_mgm_lc1_myisam.result | 1 - .../rpl/r/rpl_mark_optimize_tbl_ddl.result | 1 - sql/sql_admin.cc | 2 +- 15 files changed, 2 insertions(+), 62 deletions(-) diff --git a/mysql-test/main/column_compression_parts.result b/mysql-test/main/column_compression_parts.result index fa12217ce22..5f5539b723c 100644 --- a/mysql-test/main/column_compression_parts.result +++ b/mysql-test/main/column_compression_parts.result @@ -12,7 +12,6 @@ INSERT INTO t1 VALUES (1,REPEAT('a',100)),(2,REPEAT('v',200)),(3,REPEAT('r',300) INSERT INTO t1 VALUES (5,REPEAT('k',500)),(6,'April'),(7,7),(8,""),(9,"M"),(10,DEFAULT); ALTER TABLE t1 ANALYZE PARTITION p1; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK ALTER TABLE t1 CHECK PARTITION p2; Table Op Msg_type Msg_text diff --git a/mysql-test/main/partition.result b/mysql-test/main/partition.result index 79bfef652f4..b847b6b1b50 100644 --- a/mysql-test/main/partition.result +++ b/mysql-test/main/partition.result @@ -2063,7 +2063,6 @@ ALTER TABLE t1 ANALYZE PARTITION p1 EXTENDED; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'EXTENDED' at line 1 ALTER TABLE t1 ANALYZE PARTITION p1; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK ALTER TABLE t1 CHECK PARTITION p1; Table Op Msg_type Msg_text diff --git a/mysql-test/main/partition_binlog.result b/mysql-test/main/partition_binlog.result index 3e6100b51d8..21eca8f1c00 100644 --- a/mysql-test/main/partition_binlog.result +++ b/mysql-test/main/partition_binlog.result @@ -27,7 +27,6 @@ Table Op Msg_type Msg_text test.t1 repair error Error in list of partitions to test.t1 ALTER TABLE t1 ANALYZE PARTITION p0; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK ALTER TABLE t1 CHECK PARTITION p0; Table Op Msg_type Msg_text diff --git a/mysql-test/main/stat_tables_partition.result b/mysql-test/main/stat_tables_partition.result index 2619026b231..2dd63e858d4 100644 --- a/mysql-test/main/stat_tables_partition.result +++ b/mysql-test/main/stat_tables_partition.result @@ -34,13 +34,12 @@ set session use_stat_tables='preferably'; # Must NOT show "Engine-independent statistics collected": alter table t1 analyze partition p0; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK # Should not have Handler_read_rnd_next=34 show session status like 'Handler_read_rnd%'; Variable_name Value Handler_read_rnd 0 Handler_read_rnd_deleted 0 -Handler_read_rnd_next 34 +Handler_read_rnd_next 0 drop table t1; SET use_stat_tables = DEFAULT; diff --git a/mysql-test/main/stat_tables_rbr.result b/mysql-test/main/stat_tables_rbr.result index 38f774412bd..9d5e7f85530 100644 --- a/mysql-test/main/stat_tables_rbr.result +++ b/mysql-test/main/stat_tables_rbr.result @@ -17,7 +17,6 @@ SET use_stat_tables = PREFERABLY; CREATE TABLE t1 ( a INT ) ENGINE=MyISAM PARTITION BY HASH(a) PARTITIONS 2; ALTER TABLE t1 ANALYZE PARTITION p1; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK include/show_binlog_events.inc Log_name Pos Event_type Server_id End_log_pos Info diff --git a/mysql-test/suite/parts/r/partition_alter4_innodb.result b/mysql-test/suite/parts/r/partition_alter4_innodb.result index c9a80c6035b..c91d140b393 100644 --- a/mysql-test/suite/parts/r/partition_alter4_innodb.result +++ b/mysql-test/suite/parts/r/partition_alter4_innodb.result @@ -60,7 +60,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -521,7 +520,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -993,7 +991,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -1466,7 +1463,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -1933,7 +1929,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -2406,7 +2401,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -2884,7 +2878,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -3360,7 +3353,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -3826,7 +3818,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1,part_2; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -4287,7 +4278,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1,part_2; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -4759,7 +4749,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1,part_2; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -5232,7 +5221,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1,part_2; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -5699,7 +5687,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1,part_2; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -6172,7 +6159,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1,part_2; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -6650,7 +6636,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1,part_2; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -7126,7 +7111,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1,part_2; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -15108,7 +15092,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION ALL; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -15569,7 +15552,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION ALL; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -16041,7 +16023,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION ALL; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -16514,7 +16495,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION ALL; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -16981,7 +16961,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION ALL; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -17454,7 +17433,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION ALL; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -17932,7 +17910,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION ALL; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -18408,7 +18385,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION ALL; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template diff --git a/mysql-test/suite/parts/r/partition_alter4_myisam.result b/mysql-test/suite/parts/r/partition_alter4_myisam.result index 4e9e5c83248..01d368dbe75 100644 --- a/mysql-test/suite/parts/r/partition_alter4_myisam.result +++ b/mysql-test/suite/parts/r/partition_alter4_myisam.result @@ -60,7 +60,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -530,7 +529,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -1017,7 +1015,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -1511,7 +1508,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -1995,7 +1991,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -2489,7 +2484,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -2988,7 +2982,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -3485,7 +3478,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -3974,7 +3966,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1,part_2; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -4444,7 +4435,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1,part_2; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -4931,7 +4921,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1,part_2; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -5425,7 +5414,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1,part_2; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -5909,7 +5897,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1,part_2; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -6403,7 +6390,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1,part_2; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -6902,7 +6888,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1,part_2; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -7399,7 +7384,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION part_1,part_2; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -15700,7 +15684,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION ALL; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -16170,7 +16153,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION ALL; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -16657,7 +16639,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION ALL; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -17151,7 +17132,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION ALL; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -17635,7 +17615,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION ALL; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -18129,7 +18108,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION ALL; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -18628,7 +18606,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION ALL; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template @@ -19125,7 +19102,6 @@ SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1; ALTER TABLE t1 ANALYZE PARTITION ALL; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template diff --git a/mysql-test/suite/parts/r/partition_mgm_lc0_innodb.result b/mysql-test/suite/parts/r/partition_mgm_lc0_innodb.result index 88784224723..28dcddd9aef 100644 --- a/mysql-test/suite/parts/r/partition_mgm_lc0_innodb.result +++ b/mysql-test/suite/parts/r/partition_mgm_lc0_innodb.result @@ -1020,7 +1020,6 @@ a b 2001 Second in MAX ALTER TABLE t1 ANALYZE PARTITION MAX; Table Op Msg_type Msg_text -MySQL_Test_DB.t1 analyze status Engine-independent statistics collected MySQL_Test_DB.t1 analyze status OK # Truncate without FLUSH ALTER TABLE t1 TRUNCATE PARTITION MAX; diff --git a/mysql-test/suite/parts/r/partition_mgm_lc0_memory.result b/mysql-test/suite/parts/r/partition_mgm_lc0_memory.result index 92457a21043..204ef94da6e 100644 --- a/mysql-test/suite/parts/r/partition_mgm_lc0_memory.result +++ b/mysql-test/suite/parts/r/partition_mgm_lc0_memory.result @@ -1020,7 +1020,6 @@ a b 2001 Second in MAX ALTER TABLE t1 ANALYZE PARTITION MAX; Table Op Msg_type Msg_text -MySQL_Test_DB.t1 analyze status Engine-independent statistics collected MySQL_Test_DB.t1 analyze note The storage engine for the table doesn't support analyze # Truncate without FLUSH ALTER TABLE t1 TRUNCATE PARTITION MAX; diff --git a/mysql-test/suite/parts/r/partition_mgm_lc0_myisam.result b/mysql-test/suite/parts/r/partition_mgm_lc0_myisam.result index fea80a3feb3..10f8fbe11a4 100644 --- a/mysql-test/suite/parts/r/partition_mgm_lc0_myisam.result +++ b/mysql-test/suite/parts/r/partition_mgm_lc0_myisam.result @@ -1020,7 +1020,6 @@ a b 2001 Second in MAX ALTER TABLE t1 ANALYZE PARTITION MAX; Table Op Msg_type Msg_text -MySQL_Test_DB.t1 analyze status Engine-independent statistics collected MySQL_Test_DB.t1 analyze status OK # Truncate without FLUSH ALTER TABLE t1 TRUNCATE PARTITION MAX; diff --git a/mysql-test/suite/parts/r/partition_mgm_lc1_innodb.result b/mysql-test/suite/parts/r/partition_mgm_lc1_innodb.result index 418650eb438..d9b677acf5a 100644 --- a/mysql-test/suite/parts/r/partition_mgm_lc1_innodb.result +++ b/mysql-test/suite/parts/r/partition_mgm_lc1_innodb.result @@ -987,7 +987,6 @@ a b 2001 Second in MAX ALTER TABLE t1 ANALYZE PARTITION MAX; Table Op Msg_type Msg_text -mysql_test_db.t1 analyze status Engine-independent statistics collected mysql_test_db.t1 analyze status OK # Truncate without FLUSH ALTER TABLE t1 TRUNCATE PARTITION MAX; diff --git a/mysql-test/suite/parts/r/partition_mgm_lc1_memory.result b/mysql-test/suite/parts/r/partition_mgm_lc1_memory.result index 96e72cbfb41..601f6cb7812 100644 --- a/mysql-test/suite/parts/r/partition_mgm_lc1_memory.result +++ b/mysql-test/suite/parts/r/partition_mgm_lc1_memory.result @@ -987,7 +987,6 @@ a b 2001 Second in MAX ALTER TABLE t1 ANALYZE PARTITION MAX; Table Op Msg_type Msg_text -mysql_test_db.t1 analyze status Engine-independent statistics collected mysql_test_db.t1 analyze note The storage engine for the table doesn't support analyze # Truncate without FLUSH ALTER TABLE t1 TRUNCATE PARTITION MAX; diff --git a/mysql-test/suite/parts/r/partition_mgm_lc1_myisam.result b/mysql-test/suite/parts/r/partition_mgm_lc1_myisam.result index 0ab07cdc993..936f972ddb8 100644 --- a/mysql-test/suite/parts/r/partition_mgm_lc1_myisam.result +++ b/mysql-test/suite/parts/r/partition_mgm_lc1_myisam.result @@ -987,7 +987,6 @@ a b 2001 Second in MAX ALTER TABLE t1 ANALYZE PARTITION MAX; Table Op Msg_type Msg_text -mysql_test_db.t1 analyze status Engine-independent statistics collected mysql_test_db.t1 analyze status OK # Truncate without FLUSH ALTER TABLE t1 TRUNCATE PARTITION MAX; diff --git a/mysql-test/suite/rpl/r/rpl_mark_optimize_tbl_ddl.result b/mysql-test/suite/rpl/r/rpl_mark_optimize_tbl_ddl.result index 9aa31a73e49..09edd28827b 100644 --- a/mysql-test/suite/rpl/r/rpl_mark_optimize_tbl_ddl.result +++ b/mysql-test/suite/rpl/r/rpl_mark_optimize_tbl_ddl.result @@ -55,7 +55,6 @@ PARTITION pmax VALUES LESS THAN (MAXVALUE)); INSERT INTO t1 VALUES (1), (10), (100), (1000); ALTER TABLE t1 ANALYZE PARTITION p0; Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK ALTER TABLE t1 OPTIMIZE PARTITION p0; Table Op Msg_type Msg_text diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc index 09deef9f590..8c9c185781e 100644 --- a/sql/sql_admin.cc +++ b/sql/sql_admin.cc @@ -853,7 +853,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, */ collect_eis= (table->table->s->table_category == TABLE_CATEGORY_USER && - !(lex->alter_info.flags & ALTER_PARTITION_ADMIN) && + !(lex->alter_info.partition_flags & ALTER_PARTITION_ADMIN) && (check_eits_collection_allowed(thd) || lex->with_persistent_for_clause)); } From bc2849579b4ababc7f990255245e0d26ba36c87f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 30 Jan 2024 13:10:46 +0200 Subject: [PATCH 019/568] MDEV-33251 Redundant check on prebuilt::n_rows_fetched overflow row_search_mvcc(): Revise an overflow check, disabling it on 64-bit systems. The maximum number of consecutive record reads in a key range scan should be limited by the maximum number of records per page (less than 2^13) and the maximum number of pages per tablespace (2^32) to less than 2^45. On 32-bit systems we can simplify the overflow check. Reviewed by: Vladislav Lesin --- storage/innobase/row/row0sel.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/storage/innobase/row/row0sel.cc b/storage/innobase/row/row0sel.cc index 4504fabd4e0..b217f6d20fe 100644 --- a/storage/innobase/row/row0sel.cc +++ b/storage/innobase/row/row0sel.cc @@ -4406,13 +4406,11 @@ row_search_mvcc( goto func_exit; } +#if SIZEOF_SIZE_T < 8 + if (UNIV_LIKELY(~prebuilt->n_rows_fetched)) +#endif prebuilt->n_rows_fetched++; - if (prebuilt->n_rows_fetched > 1000000000) { - /* Prevent wrap-over */ - prebuilt->n_rows_fetched = 500000000; - } - mode = pcur->search_mode; } From b7d1f65b819296dde35beb92771958e9ab8c0e3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 30 Jan 2024 13:10:53 +0200 Subject: [PATCH 020/568] MDEV-12266 fixup: Remove dead code Ever since commit 5e84ea9634ac491f3da84f6c15987d4c1b1a5a3a this "else if" branch was unreachable because the preceding "if" condition covered it. --- storage/innobase/handler/ha_innodb.cc | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 1f181032333..62fe6bda283 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -14840,16 +14840,6 @@ ha_innobase::check( table->s->table_name.str); DBUG_RETURN(HA_ADMIN_CORRUPT); - - } else if (!m_prebuilt->table->is_readable() && - !m_prebuilt->table->space) { - - ib_senderrf( - thd, IB_LOG_LEVEL_ERROR, - ER_TABLESPACE_MISSING, - table->s->table_name.str); - - DBUG_RETURN(HA_ADMIN_CORRUPT); } m_prebuilt->trx->op_info = "checking table"; From f4ee7c110cd6faee3fa80b61ae572f471341c906 Mon Sep 17 00:00:00 2001 From: Denis Protivensky Date: Thu, 30 Nov 2023 12:52:53 +0300 Subject: [PATCH 021/568] MDEV-22232 Fix test after changing behavior of ALTER DROP FOREIGN KEY Signed-off-by: Julius Goryavsky --- mysql-test/suite/galera/r/MDEV-22232.result | 12 +++++----- mysql-test/suite/galera/t/MDEV-22232.test | 26 ++++++++------------- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/mysql-test/suite/galera/r/MDEV-22232.result b/mysql-test/suite/galera/r/MDEV-22232.result index a6a619458f0..79db271bc50 100644 --- a/mysql-test/suite/galera/r/MDEV-22232.result +++ b/mysql-test/suite/galera/r/MDEV-22232.result @@ -3,21 +3,21 @@ connection node_1; connect con1,127.0.0.1,root,,test,$NODE_MYPORT_1; --- CTAS with empty result set --- CREATE TABLE t1 (a INT) ENGINE=InnoDB; -SET DEBUG_SYNC = 'create_table_select_before_create SIGNAL may_alter WAIT_FOR bf_abort'; +SET DEBUG_SYNC = 'create_table_select_before_create SIGNAL may_run WAIT_FOR bf_abort'; CREATE TABLE t2 SELECT * FROM t1; connection node_1; -SET DEBUG_SYNC = 'now WAIT_FOR may_alter'; -ALTER TABLE t1 DROP FOREIGN KEY b, ALGORITHM=COPY; +SET DEBUG_SYNC = 'now WAIT_FOR may_run'; +TRUNCATE TABLE t1; connection con1; ERROR 70100: Query execution was interrupted SET DEBUG_SYNC = 'RESET'; --- CTAS with non-empty result set --- INSERT INTO t1 VALUES (10), (20), (30); -SET DEBUG_SYNC = 'create_table_select_before_create SIGNAL may_alter WAIT_FOR bf_abort'; +SET DEBUG_SYNC = 'create_table_select_before_create SIGNAL may_run WAIT_FOR bf_abort'; CREATE TABLE t2 SELECT * FROM t1; connection node_1; -SET DEBUG_SYNC = 'now WAIT_FOR may_alter'; -ALTER TABLE t1 DROP FOREIGN KEY b, ALGORITHM=COPY; +SET DEBUG_SYNC = 'now WAIT_FOR may_run'; +TRUNCATE TABLE t1; connection con1; ERROR 70100: Query execution was interrupted SET DEBUG_SYNC = 'RESET'; diff --git a/mysql-test/suite/galera/t/MDEV-22232.test b/mysql-test/suite/galera/t/MDEV-22232.test index edb42ee603c..087d6417b01 100644 --- a/mysql-test/suite/galera/t/MDEV-22232.test +++ b/mysql-test/suite/galera/t/MDEV-22232.test @@ -18,19 +18,16 @@ CREATE TABLE t1 (a INT) ENGINE=InnoDB; # Run CTAS until the resulting table gets created, -# then it gets BF aborted by ALTER. -SET DEBUG_SYNC = 'create_table_select_before_create SIGNAL may_alter WAIT_FOR bf_abort'; +# then it gets BF aborted by other DDL. +SET DEBUG_SYNC = 'create_table_select_before_create SIGNAL may_run WAIT_FOR bf_abort'; --send CREATE TABLE t2 SELECT * FROM t1; # Wait for CTAS to reach the table create point, -# start executing ALTER and BF abort CTAS. +# start executing other DDL and BF abort CTAS. --connection node_1 -SET DEBUG_SYNC = 'now WAIT_FOR may_alter'; ---disable_result_log ---error ER_ERROR_ON_RENAME -ALTER TABLE t1 DROP FOREIGN KEY b, ALGORITHM=COPY; ---enable_result_log +SET DEBUG_SYNC = 'now WAIT_FOR may_run'; +TRUNCATE TABLE t1; --connection con1 # CTAS gets BF aborted. @@ -46,19 +43,16 @@ SET DEBUG_SYNC = 'RESET'; INSERT INTO t1 VALUES (10), (20), (30); # Run CTAS until the resulting table gets created, -# then it gets BF aborted by ALTER. -SET DEBUG_SYNC = 'create_table_select_before_create SIGNAL may_alter WAIT_FOR bf_abort'; +# then it gets BF aborted by other DDL. +SET DEBUG_SYNC = 'create_table_select_before_create SIGNAL may_run WAIT_FOR bf_abort'; --send CREATE TABLE t2 SELECT * FROM t1; # Wait for CTAS to reach the table create point, -# start executing ALTER and BF abort CTAS. +# start executing other DDL and BF abort CTAS. --connection node_1 -SET DEBUG_SYNC = 'now WAIT_FOR may_alter'; ---disable_result_log ---error ER_ERROR_ON_RENAME -ALTER TABLE t1 DROP FOREIGN KEY b, ALGORITHM=COPY; ---enable_result_log +SET DEBUG_SYNC = 'now WAIT_FOR may_run'; +TRUNCATE TABLE t1; --connection con1 # CTAS gets BF aborted. From 21f18bd9d7fe23679af0d8785d744b9c63ed5642 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Wed, 31 Jan 2024 14:58:15 +0530 Subject: [PATCH 022/568] MDEV-33341 innodb.undo_space_dblwr test case fails with Unknown Storage Engine InnoDB Reason: ====== undo_space_dblwr test case fails if the first page of undo tablespace is not flushed before restart the server. While restarting the server, InnoDB fails to detect the first page of undo tablespace from doublewrite buffer. Fix: === Use "ib_log_checkpoint_avoid_hard" debug sync point to avoid checkpoint and make sure to flush the dirtied page before killing the server. innodb_make_page_dirty(): Fails to set srv_fil_make_page_dirty_debug variable. --- mysql-test/suite/innodb/r/undo_space_dblwr.result | 10 ++++------ mysql-test/suite/innodb/t/undo_space_dblwr.test | 13 ++++++------- .../r/innodb_fil_make_page_dirty_debug_basic.result | 5 +---- .../t/innodb_fil_make_page_dirty_debug_basic.test | 4 +--- storage/innobase/handler/ha_innodb.cc | 11 +++++++---- 5 files changed, 19 insertions(+), 24 deletions(-) diff --git a/mysql-test/suite/innodb/r/undo_space_dblwr.result b/mysql-test/suite/innodb/r/undo_space_dblwr.result index 7954c426341..4466df9857b 100644 --- a/mysql-test/suite/innodb/r/undo_space_dblwr.result +++ b/mysql-test/suite/innodb/r/undo_space_dblwr.result @@ -4,16 +4,14 @@ Variable_name Value innodb_doublewrite ON create table t1(f1 int not null, f2 int not null)engine=innodb; insert into t1 values (1, 1); -SET GLOBAL innodb_purge_rseg_truncate_frequency=1; -InnoDB 0 transactions not purged -set GLOBAL innodb_log_checkpoint_now=1; +SET GLOBAL innodb_fast_shutdown = 0; +# restart: --debug_dbug=+d,ib_log_checkpoint_avoid_hard --innodb_flush_sync=0 # Make the first page dirty for undo tablespace set global innodb_saved_page_number_debug = 0; set global innodb_fil_make_page_dirty_debug = 1; -SET GLOBAL innodb_max_dirty_pages_pct_lwm=0.0; -SET GLOBAL innodb_max_dirty_pages_pct=0.0; +SET GLOBAL innodb_buf_flush_list_now = 1; # Kill the server -# restart +# restart: --debug_dbug=+d,ib_log_checkpoint_avoid_hard --innodb_flush_sync=0 FOUND 1 /Checksum mismatch in the first page of file/ in mysqld.1.err check table t1; Table Op Msg_type Msg_text diff --git a/mysql-test/suite/innodb/t/undo_space_dblwr.test b/mysql-test/suite/innodb/t/undo_space_dblwr.test index c746f37ead7..3f61e91ddf5 100644 --- a/mysql-test/suite/innodb/t/undo_space_dblwr.test +++ b/mysql-test/suite/innodb/t/undo_space_dblwr.test @@ -9,20 +9,19 @@ show variables like 'innodb_doublewrite'; create table t1(f1 int not null, f2 int not null)engine=innodb; insert into t1 values (1, 1); -SET GLOBAL innodb_purge_rseg_truncate_frequency=1; ---source include/wait_all_purged.inc +# Slow shutdown and restart to make sure ibuf merge is finished +SET GLOBAL innodb_fast_shutdown = 0; +let $shutdown_timeout=; +let $restart_parameters="--debug_dbug=+d,ib_log_checkpoint_avoid_hard --innodb_flush_sync=0"; +--source include/restart_mysqld.inc -set GLOBAL innodb_log_checkpoint_now=1; --source ../include/no_checkpoint_start.inc - --echo # Make the first page dirty for undo tablespace set global innodb_saved_page_number_debug = 0; set global innodb_fil_make_page_dirty_debug = 1; -SET GLOBAL innodb_max_dirty_pages_pct_lwm=0.0; -SET GLOBAL innodb_max_dirty_pages_pct=0.0; +SET GLOBAL innodb_buf_flush_list_now = 1; -sleep 1; --let CLEANUP_IF_CHECKPOINT=drop table t1; --source ../include/no_checkpoint_end.inc diff --git a/mysql-test/suite/sys_vars/r/innodb_fil_make_page_dirty_debug_basic.result b/mysql-test/suite/sys_vars/r/innodb_fil_make_page_dirty_debug_basic.result index 477eb7fcb61..db0de5e389a 100644 --- a/mysql-test/suite/sys_vars/r/innodb_fil_make_page_dirty_debug_basic.result +++ b/mysql-test/suite/sys_vars/r/innodb_fil_make_page_dirty_debug_basic.result @@ -22,7 +22,4 @@ Warning 1287 ' INTO ;' is deprecated and will be set sql_mode='ansi'; create procedure `a'b` () select 1; set sql_mode=''; +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -2891,6 +2948,7 @@ d 2003-10-26 02:00:00 2003-10-26 02:00:00 set global time_zone='Europe/Moscow'; +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -2930,6 +2988,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -2990,6 +3049,7 @@ a2 1 2 3 +/*!999999\- enable the sandbox mode */ /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; @@ -3064,6 +3124,7 @@ a b c 1 first value xxxx 2 second value tttt 3 third value vvv vvv +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -3189,6 +3250,7 @@ BEGIN SET new.a = 0; END| SET SQL_MODE = @old_sql_mode; +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -3252,6 +3314,7 @@ DROP TABLE t1; # create table t1 (a binary(1), b blob); insert into t1 values ('',''); +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -3287,6 +3350,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -3386,6 +3450,7 @@ insert into t values(5, 51); create view v1 as select qty, price, qty*price as value from t; create view v2 as select qty from v1; mysqldump { +/*!999999\- enable the sandbox mode */ /*!50001 DROP VIEW IF EXISTS `v1`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; @@ -3401,6 +3466,7 @@ mysqldump { /*!50001 SET collation_connection = @saved_col_connection */; } mysqldump { +/*!999999\- enable the sandbox mode */ /*!50001 DROP VIEW IF EXISTS `v2`*/; /*!50001 SET @saved_cs_client = @@character_set_client */; /*!50001 SET @saved_cs_results = @@character_set_results */; @@ -3446,6 +3512,7 @@ drop table t1; mysqldump { mariadb-dump: Got error: 1356: "View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them" when using LOCK TABLES mariadb-dump: Couldn't execute 'SHOW FIELDS FROM `v1`': View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them (1356) +/*!999999\- enable the sandbox mode */ -- failed on view `v1`: CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `test`.`t1`.`id` AS `id` from `t1` @@ -3462,6 +3529,7 @@ insert into t1 values (1232131); insert into t1 values (4711); insert into t1 values (3231); insert into t1 values (0815); +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -3536,6 +3604,7 @@ create table basetable ( id serial, tag varchar(64) ); create database mysqldump_views; use mysqldump_views; create view nasishnasifu as select mysqldump_tables.basetable.id from mysqldump_tables.basetable; +/*!999999\- enable the sandbox mode */ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqldump_tables` /*!40100 DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci */; @@ -3620,10 +3689,14 @@ create user mysqltest_1@localhost; create table t1(a int, b varchar(34)); reset master; mariadb-dump: Couldn't execute 'FLUSH /*!40101 LOCAL */ TABLES': Access denied; you need (at least one of) the RELOAD privilege(s) for this operation (1227) +/*!999999\- enable the sandbox mode */ mariadb-dump: Couldn't execute 'FLUSH /*!40101 LOCAL */ TABLES': Access denied; you need (at least one of) the RELOAD privilege(s) for this operation (1227) +/*!999999\- enable the sandbox mode */ grant RELOAD on *.* to mysqltest_1@localhost; mariadb-dump: Couldn't execute 'SHOW MASTER STATUS': Access denied; you need (at least one of) the SUPER, BINLOG MONITOR privilege(s) for this operation (1227) +/*!999999\- enable the sandbox mode */ mariadb-dump: Couldn't execute 'SHOW MASTER STATUS': Access denied; you need (at least one of) the SUPER, BINLOG MONITOR privilege(s) for this operation (1227) +/*!999999\- enable the sandbox mode */ grant REPLICATION CLIENT on *.* to mysqltest_1@localhost; drop table t1; drop user mysqltest_1@localhost; @@ -3682,6 +3755,7 @@ use test; # # Bug #33762: mysqldump can not dump INFORMATION_SCHEMA # +/*!999999\- enable the sandbox mode */ DROP TABLE IF EXISTS `TABLES`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -3746,6 +3820,7 @@ DROP TABLE t1; CREATE TABLE t2 (a INT) ENGINE=MyISAM; CREATE TABLE t3 (a INT) ENGINE=MyISAM; CREATE TABLE t1 (a INT) ENGINE=merge UNION=(t2, t3); +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -3836,10 +3911,12 @@ connect user27293,localhost,user1,,mysqldump_test_db,$MASTER_MYPORT,$MASTER_MYS connection user27293; create procedure mysqldump_test_db.sp1() select 'hello'; mariadb-dump: user2 has insufficient privileges to SHOW CREATE PROCEDURE `sp1`! +/*!999999\- enable the sandbox mode */ -- insufficient privileges to SHOW CREATE PROCEDURE `sp1` -- does user2 have permissions on mysql.proc? +/*!999999\- enable the sandbox mode */ /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 SET @saved_cs_client = @@character_set_client */ ; @@ -3867,6 +3944,7 @@ drop database mysqldump_test_db; # CREATE TABLE t1 (c1 INT, c2 LONGBLOB); INSERT INTO t1 SET c1=11, c2=REPEAT('q',509); +/*!999999\- enable the sandbox mode */ /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `t1` ( @@ -3939,6 +4017,7 @@ use db42635; create table t1 (id int); create view db42635.v1 (c) as select * from db42635.t1; create view db42635.v2 (c) as select * from db42635.t1; +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -3999,6 +4078,7 @@ drop database db42635; # SET NAMES utf8; CREATE TABLE `straße` ( f1 INT ); +/*!999999\- enable the sandbox mode */ /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; @@ -4021,6 +4101,7 @@ UNLOCK TABLES; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; +/*!999999\- enable the sandbox mode */ /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; @@ -4045,6 +4126,7 @@ UNLOCK TABLES; DROP TABLE `straße`; CREATE TABLE `כדשגכחךלדגכחשךדגחכךלדגכ` ( f1 INT ); +/*!999999\- enable the sandbox mode */ /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; @@ -4068,6 +4150,7 @@ UNLOCK TABLES; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; mariadb-dump: Got error: 1146: "Table 'test.???????????????????????' doesn't exist" when using LOCK TABLES +/*!999999\- enable the sandbox mode */ /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; @@ -4084,6 +4167,7 @@ CREATE TABLE t1(a int, b int); INSERT INTO t1 VALUES (1,1); INSERT INTO t1 VALUES (2,3); INSERT INTO t1 VALUES (3,4), (4,5); +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -4354,6 +4438,7 @@ insert into t1 values (1232131); insert into t1 values (4711); insert into t1 values (3231); insert into t1 values (0815); +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -4482,6 +4567,7 @@ CREATE DATABASE test; create database `test-database`; use `test-database`; create table test (a int); +/*!999999\- enable the sandbox mode */ DROP TABLE IF EXISTS `test`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; @@ -4704,6 +4790,7 @@ CREATE TRIGGER `trig` BEFORE INSERT ON `test` FOR EACH ROW BEGIN END | ALTER DATABASE `test-database` CHARACTER SET latin1 COLLATE latin1_swedish_ci; ALTER DATABASE `test-database` CHARACTER SET utf8 COLLATE utf8_unicode_ci ; +/*!999999\- enable the sandbox mode */ /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `test` ( @@ -5187,6 +5274,7 @@ USE test; # Also verify that a prefix of the mode's name is enough. # CREATE TABLE t1 (a INT); +/*!999999\- enable the sandbox mode */ /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; @@ -5419,6 +5507,7 @@ CREATE DATABASE `a\"'``b`; USE `a\"'``b`; CREATE PROCEDURE p1() BEGIN END; ALTER DATABASE `a\"'``b` COLLATE utf8_general_ci; +/*!999999\- enable the sandbox mode */ /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = '' */ ; ALTER DATABASE `a\"'``b` CHARACTER SET latin1 COLLATE latin1_swedish_ci ; @@ -5467,6 +5556,7 @@ CREATE VIEW nonunique_table_view_name AS SELECT 1; ################################################## # --compact --databases db1 db2 +/*!999999\- enable the sandbox mode */ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `db1` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci */; @@ -5529,6 +5619,7 @@ USE `db2`; ################################################## # --compact db2 +/*!999999\- enable the sandbox mode */ /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `nonunique_table_name` ( @@ -5547,6 +5638,7 @@ INSERT INTO `nonunique_table_view_name` VALUES (3),(4); ################################################## # --compact --delayed-insert --no-data-med=0 --databases db2 db1 +/*!999999\- enable the sandbox mode */ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `db2` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci */; @@ -5670,6 +5762,7 @@ CREATE TABLE t1 (a int, b int); CREATE TRIGGER tt1_t1 BEFORE INSERT ON t1 FOR EACH ROW SET NEW.b=NEW.a + 10; INSERT INTO t1 (a) VALUES (1),(2),(3); +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -5718,6 +5811,7 @@ DROP TABLE t1; # # Without --replace and --insert-ignore # +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -5813,6 +5907,7 @@ CREATE TABLE IF NOT EXISTS `transaction_registry` ( # # With --replace # +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -5918,6 +6013,7 @@ CREATE TABLE IF NOT EXISTS `transaction_registry` ( # # With --insert-ignore # +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -6042,6 +6138,7 @@ insert into t3 values(2); insert into t3(`invisible`, `a b c & $!@#$%^&*( )`, `ds=~!@ \# $% ^ & * ( ) _ - = +` ) values(1,2,3); CREATE TABLE t4(ËÏÌÏÎËÁ1 INT); insert into t4 values(1); +/*!999999\- enable the sandbox mode */ /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `t1` ( @@ -6075,6 +6172,7 @@ CREATE TABLE `t4` ( /*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO `t4` VALUES (1); #Check side effect on --complete insert +/*!999999\- enable the sandbox mode */ /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `t1` ( @@ -6315,7 +6413,7 @@ j integer INSERT INTO t VALUES (1,1),(2,2),(3,3),(4,4); # Dump database 1 # Restore from database 1 to database 2 -ERROR 1100 (HY000) at line 45: Table 'seq_t_i' was not locked with LOCK TABLES +ERROR 1100 (HY000) at line 46: Table 'seq_t_i' was not locked with LOCK TABLES SETVAL(`seq_t_i`, 1, 0) 1 DROP DATABASE IF EXISTS test1; @@ -6436,10 +6534,8 @@ TABLE 1 SET GLOBAL LOG_OUTPUT=DEFAULT, GLOBAL GENERAL_LOG=@save_general_log; TRUNCATE TABLE mysql.general_log; DROP DATABASE test1; -# # End of 10.3 tests # -# # MDEV-31092 mysqldump --force doesn't ignore error as it should # create function f1() returns int return 1; @@ -6450,6 +6546,7 @@ Warnings: Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. update mysql.event set body ='select not_a_value' where db='test' and name='e1'; create table t1 (i int); +/*!999999\- enable the sandbox mode */ /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `t1` ( @@ -6497,6 +6594,19 @@ drop function f1; drop function f2; drop event e1; drop table t1; -# # End of 10.4 tests # +# MDEV-33727 mariadb-dump trusts the server and does not validate the data +# +create table t1 (a int); +/*!999999\- enable the sandbox mode */ +DROP TABLE IF EXISTS `t1`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t1` ( +`a` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci; +/*!40101 SET character_set_client = @saved_cs_client */; +ERROR at line 9: Not allowed in the sandbox mode +drop table t1; +# End of 10.5 tests diff --git a/mysql-test/main/mysqldump.test b/mysql-test/main/mysqldump.test index df31a046f09..00569a9db7a 100644 --- a/mysql-test/main/mysqldump.test +++ b/mysql-test/main/mysqldump.test @@ -2983,9 +2983,7 @@ TRUNCATE TABLE mysql.general_log; DROP DATABASE test1; --remove_file $MYSQLTEST_VARDIR/tmp/dumptest1.sql ---echo # --echo # End of 10.3 tests ---echo # --echo # --echo # MDEV-31092 mysqldump --force doesn't ignore error as it should @@ -3004,6 +3002,25 @@ drop function f2; drop event e1; drop table t1; ---echo # --echo # End of 10.4 tests + --echo # +--echo # MDEV-33727 mariadb-dump trusts the server and does not validate the data +--echo # + +create table t1 (a int); +--exec $MYSQL_DUMP --compact --add-drop-table test > $MYSQLTEST_VARDIR/tmp/mdev33727.sql + +# first let's verify it can be loaded not only by mariadb client +--source $MYSQLTEST_VARDIR/tmp/mdev33727.sql + +# and now test the mariadb client sandbox protection +--append_file $MYSQLTEST_VARDIR/tmp/mdev33727.sql +\! echo foo +EOF +--error 1 +--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/mdev33727.sql 2>&1 +--remove_file $MYSQLTEST_VARDIR/tmp/mdev33727.sql +drop table t1; + +--echo # End of 10.5 tests diff --git a/mysql-test/main/openssl_1.result b/mysql-test/main/openssl_1.result index 029fa47f263..15fc5e63845 100644 --- a/mysql-test/main/openssl_1.result +++ b/mysql-test/main/openssl_1.result @@ -77,6 +77,7 @@ DROP TABLE thread_status; SET GLOBAL event_scheduler=0; CREATE TABLE t1(a int); INSERT INTO t1 VALUES (1), (2); +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -111,6 +112,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -145,6 +147,7 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; diff --git a/mysql-test/main/plugin_auth.result b/mysql-test/main/plugin_auth.result index 621e09f9504..de595e35fa0 100644 --- a/mysql-test/main/plugin_auth.result +++ b/mysql-test/main/plugin_auth.result @@ -338,6 +338,7 @@ FLUSH PRIVILEGES; # Executing 'mysqladmin' mysqld is alive # Executing 'mysqldump' +/*!999999\- enable the sandbox mode */ # Executing 'mysql_upgrade' # # Bug #59657: Move the client authentication_pam plugin into the diff --git a/mysql-test/main/rpl_mysqldump_slave.result b/mysql-test/main/rpl_mysqldump_slave.result index 0d0378abd5b..d50422bd763 100644 --- a/mysql-test/main/rpl_mysqldump_slave.result +++ b/mysql-test/main/rpl_mysqldump_slave.result @@ -7,14 +7,17 @@ connection slave; connection master; use test; connection slave; +/*!999999\- enable the sandbox mode */ -- SET GLOBAL gtid_slave_pos=''; CHANGE MASTER '' TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=BINLOG_START; +/*!999999\- enable the sandbox mode */ STOP ALL SLAVES; -- SET GLOBAL gtid_slave_pos=''; CHANGE MASTER '' TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=BINLOG_START; START ALL SLAVES; +/*!999999\- enable the sandbox mode */ STOP ALL SLAVES; -- SET GLOBAL gtid_slave_pos=''; CHANGE MASTER '' TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_MYPORT, MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=BINLOG_START; @@ -23,6 +26,7 @@ START ALL SLAVES; start slave; Warnings: Note 1254 Slave is already running +/*!999999\- enable the sandbox mode */ -- SET GLOBAL gtid_slave_pos=''; CHANGE MASTER '' TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=BINLOG_START; @@ -41,6 +45,7 @@ DROP TABLE t2; 1. --dump-slave=1 --gtid +/*!999999\- enable the sandbox mode */ SET GLOBAL gtid_slave_pos='0-1-1001'; CHANGE MASTER '' TO MASTER_USE_GTID=slave_pos; -- CHANGE MASTER '' TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=BINLOG_START; @@ -48,12 +53,14 @@ CHANGE MASTER '' TO MASTER_USE_GTID=slave_pos; 1a. --dump-slave=1 +/*!999999\- enable the sandbox mode */ -- SET GLOBAL gtid_slave_pos='0-1-1001'; CHANGE MASTER '' TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=BINLOG_START; 2. --dump-slave=2 --gtid +/*!999999\- enable the sandbox mode */ -- SET GLOBAL gtid_slave_pos='0-1-1001'; -- CHANGE MASTER '' TO MASTER_USE_GTID=slave_pos; -- CHANGE MASTER '' TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=BINLOG_START; @@ -61,6 +68,7 @@ CHANGE MASTER '' TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=BINLOG_S 2. --dump-slave=2 +/*!999999\- enable the sandbox mode */ -- SET GLOBAL gtid_slave_pos='0-1-1001'; -- CHANGE MASTER '' TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=BINLOG_START; @@ -68,39 +76,46 @@ CHANGE MASTER '' TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=BINLOG_S 1. --master-data=1 --gtid +/*!999999\- enable the sandbox mode */ CHANGE MASTER TO MASTER_USE_GTID=slave_pos; SET GLOBAL gtid_slave_pos='0-2-1003'; -- CHANGE MASTER TO MASTER_LOG_FILE='slave-bin.000001', MASTER_LOG_POS=BINLOG_START; 1a. --master-data=1 +/*!999999\- enable the sandbox mode */ -- SET GLOBAL gtid_slave_pos='0-2-1003'; CHANGE MASTER TO MASTER_LOG_FILE='slave-bin.000001', MASTER_LOG_POS=BINLOG_START; 2. --master-data=2 --gtid +/*!999999\- enable the sandbox mode */ -- CHANGE MASTER TO MASTER_USE_GTID=slave_pos; -- SET GLOBAL gtid_slave_pos='0-2-1003'; -- CHANGE MASTER TO MASTER_LOG_FILE='slave-bin.000001', MASTER_LOG_POS=BINLOG_START; 2a. --master-data=2 +/*!999999\- enable the sandbox mode */ -- SET GLOBAL gtid_slave_pos='0-2-1003'; -- CHANGE MASTER TO MASTER_LOG_FILE='slave-bin.000001', MASTER_LOG_POS=BINLOG_START; 3. --master-data --single-transaction --gtid +/*!999999\- enable the sandbox mode */ CHANGE MASTER TO MASTER_USE_GTID=slave_pos; SET GLOBAL gtid_slave_pos='0-2-1003'; -- CHANGE MASTER TO MASTER_LOG_FILE='slave-bin.000001', MASTER_LOG_POS=BINLOG_START; 3a. --master-data --single-transaction +/*!999999\- enable the sandbox mode */ -- SET GLOBAL gtid_slave_pos='0-2-1003'; CHANGE MASTER TO MASTER_LOG_FILE='slave-bin.000001', MASTER_LOG_POS=BINLOG_START; 4. --master-data=2 --dump-slave=2 --single-transaction --gtid (MDEV-4827) +/*!999999\- enable the sandbox mode */ -- MariaDB dump-- -- Host: localhost Database: test -- ------------------------------------------------------ @@ -156,6 +171,7 @@ CHANGE MASTER TO MASTER_LOG_FILE='slave-bin.000001', MASTER_LOG_POS=BINLOG_START 4a. --master-data=2 --dump-slave=2 --single-transaction (MDEV-4827) +/*!999999\- enable the sandbox mode */ -- MariaDB dump-- -- Host: localhost Database: test -- ------------------------------------------------------ @@ -215,6 +231,7 @@ include/stop_slave.inc change master to master_use_gtid=slave_pos; connection master; # Ensuring the binlog dump thread is killed on primary... +/*!999999\- enable the sandbox mode */ -- SET GLOBAL gtid_slave_pos='0-1-1005'; -- CHANGE MASTER TO MASTER_LOG_FILE='master-bin.000002', MASTER_LOG_POS=BINLOG_START; connection slave; diff --git a/mysql-test/main/trigger_wl3253.result b/mysql-test/main/trigger_wl3253.result index ed08b336c19..e501b2640b0 100644 --- a/mysql-test/main/trigger_wl3253.result +++ b/mysql-test/main/trigger_wl3253.result @@ -310,6 +310,7 @@ CREATE TABLE t1 (a INT); CREATE TRIGGER tr1_bi BEFORE INSERT ON t1 FOR EACH ROW SET @a:=1; CREATE TRIGGER tr2_bi BEFORE INSERT ON t1 FOR EACH ROW SET @a:=2; CREATE TRIGGER tr1_bu BEFORE UPDATE ON t1 FOR EACH ROW SET @a:=3; +/*!999999\- enable the sandbox mode */ /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `t1` ( @@ -372,6 +373,7 @@ CREATE TRIGGER tr2_bi BEFORE INSERT ON t1 FOR EACH ROW SET @a:=2; CREATE TRIGGER tr0_bi BEFORE INSERT ON t1 FOR EACH ROW PRECEDES tr1_bi SET @a:=0; CREATE TRIGGER tr1_1_bi BEFORE INSERT ON t1 FOR EACH ROW FOLLOWS tr1_bi SET @a:=0; # Expected order of triggers in the dump is: tr0_bi, tr1_bi, tr1_1_bi, tr2_i. +/*!999999\- enable the sandbox mode */ /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `t1` ( diff --git a/mysql-test/suite/archive/archive_bitfield.result b/mysql-test/suite/archive/archive_bitfield.result index 8c30a5f88f6..8cb4190e842 100644 --- a/mysql-test/suite/archive/archive_bitfield.result +++ b/mysql-test/suite/archive/archive_bitfield.result @@ -180,6 +180,7 @@ INSERT INTO `t1` VALUES (NULL,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'100000',b'010010',b'011111',4,5,5,5,5,5,5,5,5,5,3,2,1), (NULL,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'000000',b'001100',b'111111',4,5,5,5,5,5,5,5,5,5,3,2,1), (NULL,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,b'111111',b'000000',b'000000',4,5,5,5,5,5,5,5,5,5,3,2,1); +/*!999999\- enable the sandbox mode */ INSERT INTO `t1` VALUES (1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x01,0x3F,0x3E,4,5,5,5,5,5,5,5,5,5,3,2,1); INSERT INTO `t1` VALUES (2,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x02,0x00,0x3D,4,5,5,5,5,5,5,5,5,5,3,2,1); INSERT INTO `t1` VALUES (3,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x04,0x0F,0x3B,4,5,5,5,5,5,5,5,5,5,3,2,1); diff --git a/mysql-test/suite/compat/oracle/r/mysqldump_restore_func_qualified.result b/mysql-test/suite/compat/oracle/r/mysqldump_restore_func_qualified.result index fd3dd787f1e..c01524b3cfa 100644 --- a/mysql-test/suite/compat/oracle/r/mysqldump_restore_func_qualified.result +++ b/mysql-test/suite/compat/oracle/r/mysqldump_restore_func_qualified.result @@ -24,6 +24,7 @@ b1 VARCHAR(64) AS (LPAD(b0,10)) PERSISTENT CREATE VIEW v2 AS SELECT LTRIM(now()) AS a0, LPAD(now(),10) AS b0; +/*!999999\- enable the sandbox mode */ /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `t1` ( diff --git a/mysql-test/suite/compat/oracle/r/sp-package-mysqldump.result b/mysql-test/suite/compat/oracle/r/sp-package-mysqldump.result index 24211c6318e..508aea0e74f 100644 --- a/mysql-test/suite/compat/oracle/r/sp-package-mysqldump.result +++ b/mysql-test/suite/compat/oracle/r/sp-package-mysqldump.result @@ -34,6 +34,7 @@ PROCEDURE p1; FUNCTION f1 RETURN INT; END; $$ +/*!999999\- enable the sandbox mode */ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; diff --git a/mysql-test/suite/federated/federatedx.result b/mysql-test/suite/federated/federatedx.result index 49deff81c4c..3054060b090 100644 --- a/mysql-test/suite/federated/federatedx.result +++ b/mysql-test/suite/federated/federatedx.result @@ -2243,6 +2243,7 @@ connection master; CREATE TABLE t1(id VARCHAR(20) NOT NULL, PRIMARY KEY(id)) ENGINE=FEDERATED CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/test/t1'; # Dump table t1 using mysqldump tool +/*!999999\- enable the sandbox mode */ /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `t1` ( diff --git a/mysql-test/suite/roles/definer.result b/mysql-test/suite/roles/definer.result index 249fb8198a7..0c16fec9edc 100644 --- a/mysql-test/suite/roles/definer.result +++ b/mysql-test/suite/roles/definer.result @@ -274,6 +274,7 @@ a b c 111 4 0 2 20 200 delete from t1 where a=111; +/*!999999\- enable the sandbox mode */ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci */; diff --git a/mysql-test/suite/sql_sequence/mysqldump.result b/mysql-test/suite/sql_sequence/mysqldump.result index 47b93eff7d1..b07f07a605b 100644 --- a/mysql-test/suite/sql_sequence/mysqldump.result +++ b/mysql-test/suite/sql_sequence/mysqldump.result @@ -3,6 +3,7 @@ CREATE TABLE t1(a INT, KEY (a)) KEY_BLOCK_SIZE=1024; insert into t1 values (1),(2); CREATE SEQUENCE x1 engine=innodb; # dump whole database +/*!999999\- enable the sandbox mode */ CREATE SEQUENCE `a1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=Aria; SELECT SETVAL(`a1`, 1, 0); CREATE SEQUENCE `x1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=InnoDB; @@ -16,6 +17,7 @@ CREATE TABLE `t1` ( /*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO `t1` VALUES (1),(2); # dump by tables order 1 +/*!999999\- enable the sandbox mode */ CREATE SEQUENCE `a1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=Aria; SELECT SETVAL(`a1`, 1, 0); CREATE SEQUENCE `x1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=InnoDB; @@ -29,6 +31,7 @@ CREATE TABLE `t1` ( /*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO `t1` VALUES (1),(2); # dump by tables order 2 +/*!999999\- enable the sandbox mode */ CREATE SEQUENCE `a1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=Aria; SELECT SETVAL(`a1`, 1, 0); CREATE SEQUENCE `x1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=InnoDB; @@ -42,6 +45,7 @@ CREATE TABLE `t1` ( /*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO `t1` VALUES (1),(2); # dump by tables only tables +/*!999999\- enable the sandbox mode */ /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `t1` ( @@ -51,6 +55,7 @@ CREATE TABLE `t1` ( /*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO `t1` VALUES (1),(2); # dump by tables only sequences +/*!999999\- enable the sandbox mode */ CREATE SEQUENCE `a1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=Aria; SELECT SETVAL(`a1`, 1, 0); CREATE SEQUENCE `x1` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=InnoDB; diff --git a/storage/connect/mysql-test/connect/r/mysql.result b/storage/connect/mysql-test/connect/r/mysql.result index 1dcbca88a7b..d1c68dcc96a 100644 --- a/storage/connect/mysql-test/connect/r/mysql.result +++ b/storage/connect/mysql-test/connect/r/mysql.result @@ -229,6 +229,7 @@ a 20 30 # Start of mysqldump ------ +/*!999999\- enable the sandbox mode */ /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `t2` ( From 7ed9d2ac0012b8fe118e598c06f509c76bcfd2d0 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 6 May 2024 20:12:32 +0200 Subject: [PATCH 541/568] MDEV-9179 When binlog_annotate_row_events on , event of binlog file is truncated cnt counter was incremented one extra time per line --- .../main/mysqlbinlog_row_minimal.result | 2 +- .../r/binlog_mysqlbinlog_row_innodb.result | 119 +++++++++++++++--- .../r/binlog_mysqlbinlog_row_myisam.result | 119 +++++++++++++++--- .../suite/binlog/r/binlog_row_annotate.result | 12 +- .../r/binlog_row_mysqlbinlog_options.result | 4 +- .../binlog_row_annotate.result | 6 +- sql/log_event_client.cc | 25 ++-- 7 files changed, 223 insertions(+), 64 deletions(-) diff --git a/mysql-test/main/mysqlbinlog_row_minimal.result b/mysql-test/main/mysqlbinlog_row_minimal.result index a05a778105f..a44f07a66ea 100644 --- a/mysql-test/main/mysqlbinlog_row_minimal.result +++ b/mysql-test/main/mysqlbinlog_row_minimal.result @@ -382,7 +382,7 @@ START TRANSACTION # server id 1 end_log_pos END_LOG_POS CRC32 XXX Annotate_rows: #Q> UPDATE t1 t1 INNER JOIN t2 t2 ON t1.ref_id = t2.id #Q> SET t1.is_deleted = TRUE -#Q> WHERE t1.id = +#Q> WHERE t1.id = 1 # server id 1 end_log_pos END_LOG_POS CRC32 XXX Table_map: `test`.`t1` mapped to number TID # at POS # server id 1 end_log_pos END_LOG_POS CRC32 XXX Update_rows: table id TID flags: STMT_END_F diff --git a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_innodb.result b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_innodb.result index 01a28690a03..bb2cfc02e56 100644 --- a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_innodb.result +++ b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_innodb.result @@ -2458,7 +2458,10 @@ START TRANSACTION #Q> '', -- c76 #Q> # #Q> 'a', -- c77 -#Q> '', +#Q> '', -- c78 +#Q> # +#Q> 1 -- crn -- row number +#Q> ) #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Table_map: `test`.`t1` mapped to number # # at # #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Write_rows: table id # flags: STMT_END_F @@ -2640,7 +2643,10 @@ START TRANSACTION #Q> 'longtext-ucs2', -- c76 not using maximum value here #Q> # #Q> 'c', -- c77 -#Q> 'a,b,c +#Q> 'a,b,c', -- c78 +#Q> # +#Q> 2 -- crn -- row number +#Q> ) #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Table_map: `test`.`t1` mapped to number # # at # #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Write_rows: table id # flags: STMT_END_F @@ -2907,7 +2913,13 @@ START TRANSACTION #Q> 'mediumtext-ucs2', -- c73 #Q> 'longblob', -- c74 #Q> 'longtext', -- c75 -#Q> 'longtext +#Q> 'longtext-ucs2', -- c76 +#Q> # +#Q> 'b', -- c77 +#Q> 'b,c', -- c78 +#Q> # +#Q> 4 -- crn -- row number +#Q> ) #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Table_map: `test`.`t1` mapped to number # # at # #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Write_rows: table id # flags: STMT_END_F @@ -3248,7 +3260,21 @@ START TRANSACTION #Q> # #Q> c65 = '' AND #Q> c66 = '' AND -#Q> c67 = +#Q> c67 = '' AND +#Q> c68 = '' AND +#Q> c69 = '' AND +#Q> c70 = '' AND +#Q> c71 = '' AND +#Q> c72 = '' AND +#Q> c73 = '' AND +#Q> c74 = '' AND +#Q> c75 = '' AND +#Q> c76 = '' AND +#Q> # +#Q> c77 = 'a' AND +#Q> c78 = '' AND +#Q> # +#Q> crn = 1 #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Table_map: `test`.`t1` mapped to number # # at # #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Update_rows: table id # flags: STMT_END_F @@ -3593,7 +3619,17 @@ START TRANSACTION #Q> c68 = 'blob' AND #Q> c69 = 'text' AND #Q> c70 = 'text-ucs2' AND -#Q> c71 = 'mediumblob +#Q> c71 = 'mediumblob' AND +#Q> c72 = 'mediumtext' AND +#Q> c73 = 'mediumtext-ucs2' AND +#Q> c74 = 'longblob' AND +#Q> c75 = 'longtext' AND +#Q> c76 = 'longtext-ucs2' AND +#Q> # +#Q> c77 = 'c' AND +#Q> c78 = 'a,b,c' AND +#Q> # +#Q> crn = 2 #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Table_map: `test`.`t1` mapped to number # # at # #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Update_rows: table id # flags: STMT_END_F @@ -3936,7 +3972,18 @@ START TRANSACTION #Q> c67 IS NULL AND #Q> c68 IS NULL AND #Q> c69 IS NULL AND -#Q> c70 IS NULL +#Q> c70 IS NULL AND +#Q> c71 IS NULL AND +#Q> c72 IS NULL AND +#Q> c73 IS NULL AND +#Q> c74 IS NULL AND +#Q> c75 IS NULL AND +#Q> c76 IS NULL AND +#Q> # +#Q> c77 IS NULL AND +#Q> c78 IS NULL AND +#Q> # +#Q> crn = 3 #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Table_map: `test`.`t1` mapped to number # # at # #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Update_rows: table id # flags: STMT_END_F @@ -4282,7 +4329,16 @@ START TRANSACTION #Q> c69 = 'text' AND #Q> c70 = 'text-ucs2' AND #Q> c71 = 'mediumblob' AND -#Q> c72 = 'me +#Q> c72 = 'mediumtext' AND +#Q> c73 = 'mediumtext-ucs2' AND +#Q> c74 = 'longblob' AND +#Q> c75 = 'longtext' AND +#Q> c76 = 'longtext-ucs2' AND +#Q> # +#Q> c77 = 'b' AND +#Q> c78 = 'b,c' AND +#Q> # +#Q> crn = 4 #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Table_map: `test`.`t1` mapped to number # # at # #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Update_rows: table id # flags: STMT_END_F @@ -4542,7 +4598,13 @@ START TRANSACTION #Q> c72 = 'mediumtext' AND #Q> c73 = 'mediumtext-ucs2' AND #Q> c74 = 'longblob' AND -#Q> c75 = ' +#Q> c75 = 'longtext' AND +#Q> c76 = 'longtext-ucs2' AND +#Q> # +#Q> c77 = 'c' AND +#Q> c78 = 'a,b,c' AND +#Q> # +#Q> crn = 1 #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Table_map: `test`.`t1` mapped to number # # at # #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Delete_rows: table id # flags: STMT_END_F @@ -4719,7 +4781,15 @@ START TRANSACTION #Q> c70 = '' AND #Q> c71 = '' AND #Q> c72 = '' AND -#Q> c73 = '' A +#Q> c73 = '' AND +#Q> c74 = '' AND +#Q> c75 = '' AND +#Q> c76 = '' AND +#Q> # +#Q> c77 = 'a' AND +#Q> c78 = '' AND +#Q> # +#Q> crn = 2 #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Table_map: `test`.`t1` mapped to number # # at # #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Delete_rows: table id # flags: STMT_END_F @@ -4899,7 +4969,13 @@ START TRANSACTION #Q> c72 = 'mediumtext' AND #Q> c73 = 'mediumtext-ucs2' AND #Q> c74 = 'longblob' AND -#Q> c75 = 'longtext' +#Q> c75 = 'longtext' AND +#Q> c76 = 'longtext-ucs2' AND +#Q> # +#Q> c77 = 'b' AND +#Q> c78 = 'b,c' AND +#Q> # +#Q> crn = 3 #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Table_map: `test`.`t1` mapped to number # # at # #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Delete_rows: table id # flags: STMT_END_F @@ -5077,7 +5153,14 @@ START TRANSACTION #Q> c71 IS NULL AND #Q> c72 IS NULL AND #Q> c73 IS NULL AND -#Q> c74 IS NUL +#Q> c74 IS NULL AND +#Q> c75 IS NULL AND +#Q> c76 IS NULL AND +#Q> # +#Q> c77 IS NULL AND +#Q> c78 IS NULL AND +#Q> # +#Q> crn = 4 #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Table_map: `test`.`t1` mapped to number # # at # #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Delete_rows: table id # flags: STMT_END_F @@ -5307,7 +5390,7 @@ START TRANSACTION #Q> ('2008-08-06','VARCHAR-06',6), #Q> ('2008-08-07','VARCHAR-07',7), #Q> ('2008-08-08','VARCHAR-08',8), -#Q> ('2008-08-09','VARCH +#Q> ('2008-08-09','VARCHAR-09',9) #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Table_map: `test`.`t1` mapped to number # # at # #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Write_rows: table id # flags: STMT_END_F @@ -5731,7 +5814,7 @@ START TRANSACTION #Q> ('2008-01-06','VARCHAR-01-06',6), #Q> ('2008-01-07','VARCHAR-01-07',7), #Q> ('2008-01-08','VARCHAR-01-08',18), -#Q> ('2008-01-09','VARCHAR-0 +#Q> ('2008-01-09','VARCHAR-01-09',19) #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Table_map: `test`.`t1` mapped to number # # at # #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Write_rows: table id # flags: STMT_END_F @@ -5801,7 +5884,7 @@ START TRANSACTION #Q> ('2008-02-06','VARCHAR-02-06',6), #Q> ('2008-02-07','VARCHAR-02-07',7), #Q> ('2008-02-08','VARCHAR-02-08',28), -#Q> ('2008-02-09','VARCHAR-0 +#Q> ('2008-02-09','VARCHAR-02-09',29) #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Table_map: `test`.`t2` mapped to number # # at # #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Write_rows: table id # flags: STMT_END_F @@ -5871,7 +5954,7 @@ START TRANSACTION #Q> ('2008-03-06','VARCHAR-03-06',6), #Q> ('2008-03-07','VARCHAR-03-07',7), #Q> ('2008-03-08','VARCHAR-03-08',38), -#Q> ('2008-03-09','VARCHAR-0 +#Q> ('2008-03-09','VARCHAR-03-09',39) #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Table_map: `test`.`t3` mapped to number # # at # #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Write_rows: table id # flags: STMT_END_F @@ -5936,7 +6019,7 @@ START TRANSACTION #Q> c_1_1 = ADDDATE(c_1_1,INTERVAL 10 YEAR), #Q> c_2_1 = ADDDATE(c_2_1,INTERVAL 20 YEAR), #Q> c_3_1 = ADDDATE(c_3_1,INTERVAL 30 YEAR) -#Q> WHERE c_1_n = c_2_n AND c_2_n = c +#Q> WHERE c_1_n = c_2_n AND c_2_n = c_3_n #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Table_map: `test`.`t1` mapped to number # # at # #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Table_map: `test`.`t2` mapped to number # @@ -6123,7 +6206,7 @@ START TRANSACTION # at # #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Annotate_rows: #Q> DELETE FROM t1,t2,t3 USING t1 INNER JOIN t2 INNER JOIN t3 -#Q> WHERE c_1_n = c_2_n AND c_2_n = c_3_ +#Q> WHERE c_1_n = c_2_n AND c_2_n = c_3_n #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Table_map: `test`.`t1` mapped to number # # at # #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Table_map: `test`.`t2` mapped to number # @@ -6338,7 +6421,7 @@ START TRANSACTION #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Annotate_rows: #Q> LOAD DATA INFILE '../../std_data/loaddata5.dat' #Q> INTO TABLE t1 FIELDS TERMINATED BY '' ENCLOSED BY '' (c1,c2) -#Q> SET c3 = 'Wo +#Q> SET c3 = 'Wow' #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Table_map: `test`.`t1` mapped to number # # at # #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Write_rows: table id # flags: STMT_END_F diff --git a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_myisam.result b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_myisam.result index 123e2d53ae4..5b0f40ea087 100644 --- a/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_myisam.result +++ b/mysql-test/suite/binlog/r/binlog_mysqlbinlog_row_myisam.result @@ -2458,7 +2458,10 @@ START TRANSACTION #Q> '', -- c76 #Q> # #Q> 'a', -- c77 -#Q> '', +#Q> '', -- c78 +#Q> # +#Q> 1 -- crn -- row number +#Q> ) #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Table_map: `test`.`t1` mapped to number # # at # #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Write_rows: table id # flags: STMT_END_F @@ -2643,7 +2646,10 @@ START TRANSACTION #Q> 'longtext-ucs2', -- c76 not using maximum value here #Q> # #Q> 'c', -- c77 -#Q> 'a,b,c +#Q> 'a,b,c', -- c78 +#Q> # +#Q> 2 -- crn -- row number +#Q> ) #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Table_map: `test`.`t1` mapped to number # # at # #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Write_rows: table id # flags: STMT_END_F @@ -2912,7 +2918,13 @@ START TRANSACTION #Q> 'mediumtext-ucs2', -- c73 #Q> 'longblob', -- c74 #Q> 'longtext', -- c75 -#Q> 'longtext +#Q> 'longtext-ucs2', -- c76 +#Q> # +#Q> 'b', -- c77 +#Q> 'b,c', -- c78 +#Q> # +#Q> 4 -- crn -- row number +#Q> ) #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Table_map: `test`.`t1` mapped to number # # at # #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Write_rows: table id # flags: STMT_END_F @@ -3255,7 +3267,21 @@ START TRANSACTION #Q> # #Q> c65 = '' AND #Q> c66 = '' AND -#Q> c67 = +#Q> c67 = '' AND +#Q> c68 = '' AND +#Q> c69 = '' AND +#Q> c70 = '' AND +#Q> c71 = '' AND +#Q> c72 = '' AND +#Q> c73 = '' AND +#Q> c74 = '' AND +#Q> c75 = '' AND +#Q> c76 = '' AND +#Q> # +#Q> c77 = 'a' AND +#Q> c78 = '' AND +#Q> # +#Q> crn = 1 #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Table_map: `test`.`t1` mapped to number # # at # #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Update_rows: table id # flags: STMT_END_F @@ -3602,7 +3628,17 @@ START TRANSACTION #Q> c68 = 'blob' AND #Q> c69 = 'text' AND #Q> c70 = 'text-ucs2' AND -#Q> c71 = 'mediumblob +#Q> c71 = 'mediumblob' AND +#Q> c72 = 'mediumtext' AND +#Q> c73 = 'mediumtext-ucs2' AND +#Q> c74 = 'longblob' AND +#Q> c75 = 'longtext' AND +#Q> c76 = 'longtext-ucs2' AND +#Q> # +#Q> c77 = 'c' AND +#Q> c78 = 'a,b,c' AND +#Q> # +#Q> crn = 2 #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Table_map: `test`.`t1` mapped to number # # at # #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Update_rows: table id # flags: STMT_END_F @@ -3947,7 +3983,18 @@ START TRANSACTION #Q> c67 IS NULL AND #Q> c68 IS NULL AND #Q> c69 IS NULL AND -#Q> c70 IS NULL +#Q> c70 IS NULL AND +#Q> c71 IS NULL AND +#Q> c72 IS NULL AND +#Q> c73 IS NULL AND +#Q> c74 IS NULL AND +#Q> c75 IS NULL AND +#Q> c76 IS NULL AND +#Q> # +#Q> c77 IS NULL AND +#Q> c78 IS NULL AND +#Q> # +#Q> crn = 3 #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Table_map: `test`.`t1` mapped to number # # at # #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Update_rows: table id # flags: STMT_END_F @@ -4295,7 +4342,16 @@ START TRANSACTION #Q> c69 = 'text' AND #Q> c70 = 'text-ucs2' AND #Q> c71 = 'mediumblob' AND -#Q> c72 = 'me +#Q> c72 = 'mediumtext' AND +#Q> c73 = 'mediumtext-ucs2' AND +#Q> c74 = 'longblob' AND +#Q> c75 = 'longtext' AND +#Q> c76 = 'longtext-ucs2' AND +#Q> # +#Q> c77 = 'b' AND +#Q> c78 = 'b,c' AND +#Q> # +#Q> crn = 4 #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Table_map: `test`.`t1` mapped to number # # at # #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Update_rows: table id # flags: STMT_END_F @@ -4557,7 +4613,13 @@ START TRANSACTION #Q> c72 = 'mediumtext' AND #Q> c73 = 'mediumtext-ucs2' AND #Q> c74 = 'longblob' AND -#Q> c75 = ' +#Q> c75 = 'longtext' AND +#Q> c76 = 'longtext-ucs2' AND +#Q> # +#Q> c77 = 'c' AND +#Q> c78 = 'a,b,c' AND +#Q> # +#Q> crn = 1 #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Table_map: `test`.`t1` mapped to number # # at # #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Delete_rows: table id # flags: STMT_END_F @@ -4736,7 +4798,15 @@ START TRANSACTION #Q> c70 = '' AND #Q> c71 = '' AND #Q> c72 = '' AND -#Q> c73 = '' A +#Q> c73 = '' AND +#Q> c74 = '' AND +#Q> c75 = '' AND +#Q> c76 = '' AND +#Q> # +#Q> c77 = 'a' AND +#Q> c78 = '' AND +#Q> # +#Q> crn = 2 #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Table_map: `test`.`t1` mapped to number # # at # #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Delete_rows: table id # flags: STMT_END_F @@ -4918,7 +4988,13 @@ START TRANSACTION #Q> c72 = 'mediumtext' AND #Q> c73 = 'mediumtext-ucs2' AND #Q> c74 = 'longblob' AND -#Q> c75 = 'longtext' +#Q> c75 = 'longtext' AND +#Q> c76 = 'longtext-ucs2' AND +#Q> # +#Q> c77 = 'b' AND +#Q> c78 = 'b,c' AND +#Q> # +#Q> crn = 3 #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Table_map: `test`.`t1` mapped to number # # at # #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Delete_rows: table id # flags: STMT_END_F @@ -5098,7 +5174,14 @@ START TRANSACTION #Q> c71 IS NULL AND #Q> c72 IS NULL AND #Q> c73 IS NULL AND -#Q> c74 IS NUL +#Q> c74 IS NULL AND +#Q> c75 IS NULL AND +#Q> c76 IS NULL AND +#Q> # +#Q> c77 IS NULL AND +#Q> c78 IS NULL AND +#Q> # +#Q> crn = 4 #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Table_map: `test`.`t1` mapped to number # # at # #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Delete_rows: table id # flags: STMT_END_F @@ -5330,7 +5413,7 @@ START TRANSACTION #Q> ('2008-08-06','VARCHAR-06',6), #Q> ('2008-08-07','VARCHAR-07',7), #Q> ('2008-08-08','VARCHAR-08',8), -#Q> ('2008-08-09','VARCH +#Q> ('2008-08-09','VARCHAR-09',9) #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Table_map: `test`.`t1` mapped to number # # at # #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Write_rows: table id # flags: STMT_END_F @@ -5760,7 +5843,7 @@ START TRANSACTION #Q> ('2008-01-06','VARCHAR-01-06',6), #Q> ('2008-01-07','VARCHAR-01-07',7), #Q> ('2008-01-08','VARCHAR-01-08',18), -#Q> ('2008-01-09','VARCHAR-0 +#Q> ('2008-01-09','VARCHAR-01-09',19) #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Table_map: `test`.`t1` mapped to number # # at # #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Write_rows: table id # flags: STMT_END_F @@ -5832,7 +5915,7 @@ START TRANSACTION #Q> ('2008-02-06','VARCHAR-02-06',6), #Q> ('2008-02-07','VARCHAR-02-07',7), #Q> ('2008-02-08','VARCHAR-02-08',28), -#Q> ('2008-02-09','VARCHAR-0 +#Q> ('2008-02-09','VARCHAR-02-09',29) #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Table_map: `test`.`t2` mapped to number # # at # #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Write_rows: table id # flags: STMT_END_F @@ -5904,7 +5987,7 @@ START TRANSACTION #Q> ('2008-03-06','VARCHAR-03-06',6), #Q> ('2008-03-07','VARCHAR-03-07',7), #Q> ('2008-03-08','VARCHAR-03-08',38), -#Q> ('2008-03-09','VARCHAR-0 +#Q> ('2008-03-09','VARCHAR-03-09',39) #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Table_map: `test`.`t3` mapped to number # # at # #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Write_rows: table id # flags: STMT_END_F @@ -5971,7 +6054,7 @@ START TRANSACTION #Q> c_1_1 = ADDDATE(c_1_1,INTERVAL 10 YEAR), #Q> c_2_1 = ADDDATE(c_2_1,INTERVAL 20 YEAR), #Q> c_3_1 = ADDDATE(c_3_1,INTERVAL 30 YEAR) -#Q> WHERE c_1_n = c_2_n AND c_2_n = c +#Q> WHERE c_1_n = c_2_n AND c_2_n = c_3_n #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Table_map: `test`.`t1` mapped to number # # at # #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Table_map: `test`.`t2` mapped to number # @@ -6160,7 +6243,7 @@ START TRANSACTION # at # #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Annotate_rows: #Q> DELETE FROM t1,t2,t3 USING t1 INNER JOIN t2 INNER JOIN t3 -#Q> WHERE c_1_n = c_2_n AND c_2_n = c_3_ +#Q> WHERE c_1_n = c_2_n AND c_2_n = c_3_n #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Table_map: `test`.`t1` mapped to number # # at # #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Table_map: `test`.`t2` mapped to number # @@ -6377,7 +6460,7 @@ START TRANSACTION #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Annotate_rows: #Q> LOAD DATA INFILE '../../std_data/loaddata5.dat' #Q> INTO TABLE t1 FIELDS TERMINATED BY '' ENCLOSED BY '' (c1,c2) -#Q> SET c3 = 'Wo +#Q> SET c3 = 'Wow' #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Table_map: `test`.`t1` mapped to number # # at # #010909 4:46:40 server id 1 end_log_pos # CRC32 XXX Write_rows: table id # flags: STMT_END_F diff --git a/mysql-test/suite/binlog/r/binlog_row_annotate.result b/mysql-test/suite/binlog/r/binlog_row_annotate.result index 05e4060c10b..6a15fd47d55 100644 --- a/mysql-test/suite/binlog/r/binlog_row_annotate.result +++ b/mysql-test/suite/binlog/r/binlog_row_annotate.result @@ -232,7 +232,7 @@ START TRANSACTION #010909 4:46:40 server id # end_log_pos # Annotate_rows: #Q> DELETE test1.t1, test2.t2 #Q> FROM test1.t1 INNER JOIN test2.t2 INNER JOIN test3.t3 -#Q> WHERE test1.t1.a=test2.t2.a AND test2.t2.a=test3.t3 +#Q> WHERE test1.t1.a=test2.t2.a AND test2.t2.a=test3.t3.a #010909 4:46:40 server id # end_log_pos # Table_map: `test1`.`t1` mapped to number # # at # #010909 4:46:40 server id # end_log_pos # Table_map: `test2`.`t2` mapped to number # @@ -301,7 +301,7 @@ START TRANSACTION #010909 4:46:40 server id # end_log_pos # Annotate_rows: #Q> DELETE xtest1.xt1, test2.t2 #Q> FROM xtest1.xt1 INNER JOIN test2.t2 INNER JOIN test3.t3 -#Q> WHERE xtest1.xt1.a=test2.t2.a AND test2.t2.a=test3.t3 +#Q> WHERE xtest1.xt1.a=test2.t2.a AND test2.t2.a=test3.t3.a #010909 4:46:40 server id # end_log_pos # Table_map: `test2`.`t2` mapped to number # # at # #010909 4:46:40 server id # end_log_pos # Delete_rows: table id # flags: STMT_END_F @@ -434,7 +434,7 @@ START TRANSACTION #010909 4:46:40 server id # end_log_pos # Annotate_rows: #Q> DELETE test1.t1, test2.t2 #Q> FROM test1.t1 INNER JOIN test2.t2 INNER JOIN test3.t3 -#Q> WHERE test1.t1.a=test2.t2.a AND test2.t2.a=test3.t3 +#Q> WHERE test1.t1.a=test2.t2.a AND test2.t2.a=test3.t3.a #010909 4:46:40 server id # end_log_pos # Table_map: `test1`.`t1` mapped to number # # at # # at # @@ -855,7 +855,7 @@ START TRANSACTION #010909 4:46:40 server id # end_log_pos # Annotate_rows: #Q> DELETE test1.t1, test2.t2 #Q> FROM test1.t1 INNER JOIN test2.t2 INNER JOIN test3.t3 -#Q> WHERE test1.t1.a=test2.t2.a AND test2.t2.a=test3.t3 +#Q> WHERE test1.t1.a=test2.t2.a AND test2.t2.a=test3.t3.a #010909 4:46:40 server id # end_log_pos # Table_map: `test1`.`t1` mapped to number # # at # #010909 4:46:40 server id # end_log_pos # Table_map: `test2`.`t2` mapped to number # @@ -924,7 +924,7 @@ START TRANSACTION #010909 4:46:40 server id # end_log_pos # Annotate_rows: #Q> DELETE xtest1.xt1, test2.t2 #Q> FROM xtest1.xt1 INNER JOIN test2.t2 INNER JOIN test3.t3 -#Q> WHERE xtest1.xt1.a=test2.t2.a AND test2.t2.a=test3.t3 +#Q> WHERE xtest1.xt1.a=test2.t2.a AND test2.t2.a=test3.t3.a #010909 4:46:40 server id # end_log_pos # Table_map: `test2`.`t2` mapped to number # # at # #010909 4:46:40 server id # end_log_pos # Delete_rows: table id # flags: STMT_END_F @@ -1057,7 +1057,7 @@ START TRANSACTION #010909 4:46:40 server id # end_log_pos # Annotate_rows: #Q> DELETE test1.t1, test2.t2 #Q> FROM test1.t1 INNER JOIN test2.t2 INNER JOIN test3.t3 -#Q> WHERE test1.t1.a=test2.t2.a AND test2.t2.a=test3.t3 +#Q> WHERE test1.t1.a=test2.t2.a AND test2.t2.a=test3.t3.a #010909 4:46:40 server id # end_log_pos # Table_map: `test1`.`t1` mapped to number # # at # # at # diff --git a/mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_options.result b/mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_options.result index 80d74a951cb..2452c47573e 100644 --- a/mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_options.result +++ b/mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_options.result @@ -204,7 +204,7 @@ START TRANSACTION # at # #010909 4:46:40 server id # end_log_pos # CRC32 XXX Annotate_rows: #Q> LOAD DATA INFILE '../../std_data/loaddata7.dat' INTO TABLE t1 -#Q> FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n +#Q> FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n' #010909 4:46:40 server id # end_log_pos # CRC32 XXX Table_map: `new_test1`.`t1` mapped to number # # at # #010909 4:46:40 server id # end_log_pos # CRC32 XXX Write_rows: table id # flags: STMT_END_F @@ -445,7 +445,7 @@ START TRANSACTION # at # #010909 4:46:40 server id # end_log_pos # CRC32 XXX Annotate_rows: #Q> LOAD DATA INFILE '../../std_data/loaddata7.dat' INTO TABLE t1 -#Q> FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n +#Q> FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n' #010909 4:46:40 server id # end_log_pos # CRC32 XXX Table_map: `new_test1`.`t1` mapped to number # # at # #010909 4:46:40 server id # end_log_pos # CRC32 XXX Write_rows: table id # flags: STMT_END_F diff --git a/mysql-test/suite/binlog_encryption/binlog_row_annotate.result b/mysql-test/suite/binlog_encryption/binlog_row_annotate.result index 052a07f10a6..31b988a2c03 100644 --- a/mysql-test/suite/binlog_encryption/binlog_row_annotate.result +++ b/mysql-test/suite/binlog_encryption/binlog_row_annotate.result @@ -236,7 +236,7 @@ START TRANSACTION #010909 4:46:40 server id # end_log_pos # Annotate_rows: #Q> DELETE test1.t1, test2.t2 #Q> FROM test1.t1 INNER JOIN test2.t2 INNER JOIN test3.t3 -#Q> WHERE test1.t1.a=test2.t2.a AND test2.t2.a=test3.t3 +#Q> WHERE test1.t1.a=test2.t2.a AND test2.t2.a=test3.t3.a #010909 4:46:40 server id # end_log_pos # Table_map: `test1`.`t1` mapped to number # # at # #010909 4:46:40 server id # end_log_pos # Table_map: `test2`.`t2` mapped to number # @@ -305,7 +305,7 @@ START TRANSACTION #010909 4:46:40 server id # end_log_pos # Annotate_rows: #Q> DELETE xtest1.xt1, test2.t2 #Q> FROM xtest1.xt1 INNER JOIN test2.t2 INNER JOIN test3.t3 -#Q> WHERE xtest1.xt1.a=test2.t2.a AND test2.t2.a=test3.t3 +#Q> WHERE xtest1.xt1.a=test2.t2.a AND test2.t2.a=test3.t3.a #010909 4:46:40 server id # end_log_pos # Table_map: `test2`.`t2` mapped to number # # at # #010909 4:46:40 server id # end_log_pos # Delete_rows: table id # flags: STMT_END_F @@ -441,7 +441,7 @@ START TRANSACTION #010909 4:46:40 server id # end_log_pos # Annotate_rows: #Q> DELETE test1.t1, test2.t2 #Q> FROM test1.t1 INNER JOIN test2.t2 INNER JOIN test3.t3 -#Q> WHERE test1.t1.a=test2.t2.a AND test2.t2.a=test3.t3 +#Q> WHERE test1.t1.a=test2.t2.a AND test2.t2.a=test3.t3.a #010909 4:46:40 server id # end_log_pos # Table_map: `test1`.`t1` mapped to number # # at # # at # diff --git a/sql/log_event_client.cc b/sql/log_event_client.cc index c20b41e9632..052110fa235 100644 --- a/sql/log_event_client.cc +++ b/sql/log_event_client.cc @@ -3033,7 +3033,7 @@ bool Annotate_rows_log_event::print(FILE *file, PRINT_EVENT_INFO *pinfo) { char *pbeg; // beginning of the next line char *pend; // end of the next line - uint cnt= 0; // characters counter + char *qend= m_query_txt + m_query_len; if (!pinfo->short_form) { @@ -3044,28 +3044,21 @@ bool Annotate_rows_log_event::print(FILE *file, PRINT_EVENT_INFO *pinfo) else if (my_b_printf(&pinfo->head_cache, "# Annotate_rows:\n")) goto err; - for (pbeg= m_query_txt; ; pbeg= pend) + for (pbeg= m_query_txt; pbeg < qend; pbeg= pend) { // skip all \r's and \n's at the beginning of the next line - for (;; pbeg++) - { - if (++cnt > m_query_len) - return 0; - - if (*pbeg != '\r' && *pbeg != '\n') - break; - } + for (; pbeg < qend && (*pbeg == '\r' || *pbeg == '\n'); pbeg++) + ; // find end of the next line - for (pend= pbeg + 1; - ++cnt <= m_query_len && *pend != '\r' && *pend != '\n'; - pend++) + for (pend= pbeg + 1; pend < qend && *pend != '\r' && *pend != '\n'; pend++) ; // print next line - if (my_b_write(&pinfo->head_cache, (const uchar*) "#Q> ", 4) || - my_b_write(&pinfo->head_cache, (const uchar*) pbeg, pend - pbeg) || - my_b_write(&pinfo->head_cache, (const uchar*) "\n", 1)) + if (pbeg < qend && + (my_b_write(&pinfo->head_cache, (const uchar*) "#Q> ", 4) || + my_b_write(&pinfo->head_cache, (const uchar*) pbeg, pend - pbeg) || + my_b_write(&pinfo->head_cache, (const uchar*) "\n", 1))) goto err; } From 89084c2ea48c590d3f6e66f83f559dec7452475c Mon Sep 17 00:00:00 2001 From: Dave Gosselin Date: Thu, 2 May 2024 11:44:02 -0400 Subject: [PATCH 542/568] MDEV-33078 SysInfo.pm reports incorrect CPU count on macOS When running on macOS, MTR will ask the operating system for the core count when --parallel=auto --- mysql-test/lib/My/Platform.pm | 10 +++++++++- mysql-test/mysql-test-run.pl | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/mysql-test/lib/My/Platform.pm b/mysql-test/lib/My/Platform.pm index 2b32ef87b81..f33875e14aa 100644 --- a/mysql-test/lib/My/Platform.pm +++ b/mysql-test/lib/My/Platform.pm @@ -23,7 +23,7 @@ use File::Path; use Carp; use base qw(Exporter); -our @EXPORT= qw(IS_CYGWIN IS_MSYS IS_WINDOWS IS_WIN32PERL IS_AIX +our @EXPORT= qw(IS_CYGWIN IS_MSYS IS_WINDOWS IS_WIN32PERL IS_AIX IS_MAC native_path posix_path mixed_path check_socket_path_length process_alive open_for_append); @@ -70,6 +70,14 @@ BEGIN { } } +BEGIN { + if ($^O eq "darwin") { + eval 'sub IS_MAC { 1 }'; + } + else { + eval 'sub IS_MAC { 0 }'; + } +} # # native_path diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 602d68cdfac..117252cb6f0 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -427,6 +427,10 @@ sub main { { $opt_parallel= $ENV{NUMBER_OF_PROCESSORS} || 1; } + elsif (IS_MAC) + { + $opt_parallel= `sysctl -n hw.ncpu`; + } else { my $sys_info= My::SysInfo->new(); From 64314d3094ef5eb52223c613632292be96bd7732 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Mon, 6 May 2024 12:46:31 +1000 Subject: [PATCH 543/568] MDEV-30929 spider.spider_fixes_part: wait and restart slave In the absence of insight of the cause of spider.spider_fixes_part failure as described in MDEV-30929, This is a workaround, which could help narrow the possibility down to whether slave SQL thread attempts to read from file that maybe not yet on disk. It does not otherwise affect the coverage of the test. I have pushed this commit 4 times, but have yet to encounter the failure as described in MDEV-30929, so it could also fix the test and stop the CI pollution. Also replaced START SLAVE; with --source include/start_slave.inc inside the slave_test_init.inc files. --- .../mysql-test/spider/bg/r/spider3_fixes.result | 1 + .../spider/bg/r/spider3_fixes_part.result | 1 + .../mysql-test/spider/bg/r/spider_fixes.result | 1 + .../spider/bg/r/spider_fixes_part.result | 1 + .../mysql-test/spider/bg/t/slave_test_init.inc | 2 +- .../r/delete_with_float_column_default.result | 1 + .../r/delete_with_float_column_mariadb.result | 1 + .../r/delete_with_float_column_mysql.result | 1 + .../slave_transaction_retry_errors_5digit.result | 1 + .../spider/bugfix/r/slave_trx_isolation.result | 1 + .../r/slave_transaction_retry_errors.result | 1 + .../spider/r/slave_trx_isolation.result | 1 + .../mysql-test/spider/r/spider3_fixes.result | 1 + .../spider/r/spider3_fixes_part.result | 1 + .../mysql-test/spider/r/spider_fixes.result | 1 + .../mysql-test/spider/r/spider_fixes_part.result | 2 ++ .../mysql-test/spider/t/slave_test_init.inc | 2 +- .../mysql-test/spider/t/spider_fixes_part.opt | 1 + .../mysql-test/spider/t/spider_fixes_part.test | 16 ++++++++++++++++ 19 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 storage/spider/mysql-test/spider/t/spider_fixes_part.opt diff --git a/storage/spider/mysql-test/spider/bg/r/spider3_fixes.result b/storage/spider/mysql-test/spider/bg/r/spider3_fixes.result index aa734573a1a..e35100428d7 100644 --- a/storage/spider/mysql-test/spider/bg/r/spider3_fixes.result +++ b/storage/spider/mysql-test/spider/bg/r/spider3_fixes.result @@ -8,6 +8,7 @@ child3_1 child3_2 child3_3 for slave1_1 +include/start_slave.inc drop and create databases connection master_1; diff --git a/storage/spider/mysql-test/spider/bg/r/spider3_fixes_part.result b/storage/spider/mysql-test/spider/bg/r/spider3_fixes_part.result index b793346df4b..361fd336f16 100644 --- a/storage/spider/mysql-test/spider/bg/r/spider3_fixes_part.result +++ b/storage/spider/mysql-test/spider/bg/r/spider3_fixes_part.result @@ -8,6 +8,7 @@ child3_1 child3_2 child3_3 for slave1_1 +include/start_slave.inc drop and create databases connection master_1; diff --git a/storage/spider/mysql-test/spider/bg/r/spider_fixes.result b/storage/spider/mysql-test/spider/bg/r/spider_fixes.result index 51045e0ba8f..a751d8034cd 100644 --- a/storage/spider/mysql-test/spider/bg/r/spider_fixes.result +++ b/storage/spider/mysql-test/spider/bg/r/spider_fixes.result @@ -8,6 +8,7 @@ child3_1 child3_2 child3_3 for slave1_1 +include/start_slave.inc drop and create databases connection master_1; diff --git a/storage/spider/mysql-test/spider/bg/r/spider_fixes_part.result b/storage/spider/mysql-test/spider/bg/r/spider_fixes_part.result index faf0b6efbea..3ce8dfbfdc7 100644 --- a/storage/spider/mysql-test/spider/bg/r/spider_fixes_part.result +++ b/storage/spider/mysql-test/spider/bg/r/spider_fixes_part.result @@ -8,6 +8,7 @@ child3_1 child3_2 child3_3 for slave1_1 +include/start_slave.inc drop and create databases connection master_1; diff --git a/storage/spider/mysql-test/spider/bg/t/slave_test_init.inc b/storage/spider/mysql-test/spider/bg/t/slave_test_init.inc index 739d88970c5..84de2c7d2e6 100644 --- a/storage/spider/mysql-test/spider/bg/t/slave_test_init.inc +++ b/storage/spider/mysql-test/spider/bg/t/slave_test_init.inc @@ -19,7 +19,7 @@ if (!$SLAVE1_1_SLAVE_STATUS) MASTER_PORT = $MASTER_1_MYPORT ; } -START SLAVE; +--source include/start_slave.inc --connection master_1 call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); --connection slave1_1 diff --git a/storage/spider/mysql-test/spider/bugfix/r/delete_with_float_column_default.result b/storage/spider/mysql-test/spider/bugfix/r/delete_with_float_column_default.result index cb1b190f71d..8b193975886 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/delete_with_float_column_default.result +++ b/storage/spider/mysql-test/spider/bugfix/r/delete_with_float_column_default.result @@ -5,6 +5,7 @@ child2_2 child2_3 for child3 for slave1_1 +include/start_slave.inc connection slave1_1; connection master_1; set @old_binlog_format= @@binlog_format; diff --git a/storage/spider/mysql-test/spider/bugfix/r/delete_with_float_column_mariadb.result b/storage/spider/mysql-test/spider/bugfix/r/delete_with_float_column_mariadb.result index cb1b190f71d..8b193975886 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/delete_with_float_column_mariadb.result +++ b/storage/spider/mysql-test/spider/bugfix/r/delete_with_float_column_mariadb.result @@ -5,6 +5,7 @@ child2_2 child2_3 for child3 for slave1_1 +include/start_slave.inc connection slave1_1; connection master_1; set @old_binlog_format= @@binlog_format; diff --git a/storage/spider/mysql-test/spider/bugfix/r/delete_with_float_column_mysql.result b/storage/spider/mysql-test/spider/bugfix/r/delete_with_float_column_mysql.result index 1131021258d..1e5d7d31686 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/delete_with_float_column_mysql.result +++ b/storage/spider/mysql-test/spider/bugfix/r/delete_with_float_column_mysql.result @@ -5,6 +5,7 @@ child2_2 child2_3 for child3 for slave1_1 +include/start_slave.inc connection slave1_1; connection master_1; set @old_binlog_format= @@binlog_format; diff --git a/storage/spider/mysql-test/spider/bugfix/r/slave_transaction_retry_errors_5digit.result b/storage/spider/mysql-test/spider/bugfix/r/slave_transaction_retry_errors_5digit.result index c8b1de982eb..83dab07f622 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/slave_transaction_retry_errors_5digit.result +++ b/storage/spider/mysql-test/spider/bugfix/r/slave_transaction_retry_errors_5digit.result @@ -5,6 +5,7 @@ child2_2 child2_3 for child3 for slave1_1 +include/start_slave.inc connection slave1_1; SHOW VARIABLES LIKE 'slave_transaction_retry_errors'; diff --git a/storage/spider/mysql-test/spider/bugfix/r/slave_trx_isolation.result b/storage/spider/mysql-test/spider/bugfix/r/slave_trx_isolation.result index e84d42bbc8a..239402a549a 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/slave_trx_isolation.result +++ b/storage/spider/mysql-test/spider/bugfix/r/slave_trx_isolation.result @@ -5,6 +5,7 @@ child2_2 child2_3 for child3 for slave1_1 +include/start_slave.inc connection slave1_1; set @old_spider_slave_trx_isolation= @@spider_slave_trx_isolation; set global spider_slave_trx_isolation= 1; diff --git a/storage/spider/mysql-test/spider/feature/r/slave_transaction_retry_errors.result b/storage/spider/mysql-test/spider/feature/r/slave_transaction_retry_errors.result index 1de1ba04528..f7d4341c5da 100644 --- a/storage/spider/mysql-test/spider/feature/r/slave_transaction_retry_errors.result +++ b/storage/spider/mysql-test/spider/feature/r/slave_transaction_retry_errors.result @@ -5,6 +5,7 @@ child2_2 child2_3 for child3 for slave1_1 +include/start_slave.inc connection slave1_1; SHOW VARIABLES LIKE 'slave_transaction_retry_errors'; diff --git a/storage/spider/mysql-test/spider/r/slave_trx_isolation.result b/storage/spider/mysql-test/spider/r/slave_trx_isolation.result index 28aaf74fa3d..2f850b26a04 100644 --- a/storage/spider/mysql-test/spider/r/slave_trx_isolation.result +++ b/storage/spider/mysql-test/spider/r/slave_trx_isolation.result @@ -8,6 +8,7 @@ child3_1 child3_2 child3_3 for slave1_1 +include/start_slave.inc connection slave1_1; set @old_spider_slave_trx_isolation= @@spider_slave_trx_isolation; set global spider_slave_trx_isolation= 1; diff --git a/storage/spider/mysql-test/spider/r/spider3_fixes.result b/storage/spider/mysql-test/spider/r/spider3_fixes.result index 7a80e102462..614920bee65 100644 --- a/storage/spider/mysql-test/spider/r/spider3_fixes.result +++ b/storage/spider/mysql-test/spider/r/spider3_fixes.result @@ -8,6 +8,7 @@ child3_1 child3_2 child3_3 for slave1_1 +include/start_slave.inc drop and create databases connection master_1; diff --git a/storage/spider/mysql-test/spider/r/spider3_fixes_part.result b/storage/spider/mysql-test/spider/r/spider3_fixes_part.result index 937f222f02f..94390ff71b5 100644 --- a/storage/spider/mysql-test/spider/r/spider3_fixes_part.result +++ b/storage/spider/mysql-test/spider/r/spider3_fixes_part.result @@ -8,6 +8,7 @@ child3_1 child3_2 child3_3 for slave1_1 +include/start_slave.inc drop and create databases connection master_1; diff --git a/storage/spider/mysql-test/spider/r/spider_fixes.result b/storage/spider/mysql-test/spider/r/spider_fixes.result index 273f37a8a2f..9083ad7079a 100644 --- a/storage/spider/mysql-test/spider/r/spider_fixes.result +++ b/storage/spider/mysql-test/spider/r/spider_fixes.result @@ -8,6 +8,7 @@ child3_1 child3_2 child3_3 for slave1_1 +include/start_slave.inc drop and create databases connection master_1; diff --git a/storage/spider/mysql-test/spider/r/spider_fixes_part.result b/storage/spider/mysql-test/spider/r/spider_fixes_part.result index 571af94c1f2..a59d2d2bfdb 100644 --- a/storage/spider/mysql-test/spider/r/spider_fixes_part.result +++ b/storage/spider/mysql-test/spider/r/spider_fixes_part.result @@ -8,6 +8,7 @@ child3_1 child3_2 child3_3 for slave1_1 +include/start_slave.inc drop and create databases connection master_1; @@ -109,6 +110,7 @@ a b c 2.26 auto_increment with partition connection master_1; +include/save_master_pos.inc connection slave1_1; connection master_1; DROP TABLE IF EXISTS t1; diff --git a/storage/spider/mysql-test/spider/t/slave_test_init.inc b/storage/spider/mysql-test/spider/t/slave_test_init.inc index 739d88970c5..84de2c7d2e6 100644 --- a/storage/spider/mysql-test/spider/t/slave_test_init.inc +++ b/storage/spider/mysql-test/spider/t/slave_test_init.inc @@ -19,7 +19,7 @@ if (!$SLAVE1_1_SLAVE_STATUS) MASTER_PORT = $MASTER_1_MYPORT ; } -START SLAVE; +--source include/start_slave.inc --connection master_1 call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); --connection slave1_1 diff --git a/storage/spider/mysql-test/spider/t/spider_fixes_part.opt b/storage/spider/mysql-test/spider/t/spider_fixes_part.opt new file mode 100644 index 00000000000..1f24df45b33 --- /dev/null +++ b/storage/spider/mysql-test/spider/t/spider_fixes_part.opt @@ -0,0 +1 @@ +--log-warnings=3 diff --git a/storage/spider/mysql-test/spider/t/spider_fixes_part.test b/storage/spider/mysql-test/spider/t/spider_fixes_part.test index bff2e574cc4..9604f83b283 100644 --- a/storage/spider/mysql-test/spider/t/spider_fixes_part.test +++ b/storage/spider/mysql-test/spider/t/spider_fixes_part.test @@ -488,7 +488,23 @@ if ($HAVE_PARTITION) if ($USE_REPLICATION) { save_master_pos; + --source include/save_master_pos.inc --connection slave1_1 + --let $rc= `select master_pos_wait('$_master_file', $_master_pos, 300, '')` + if (`select $rc is NULL OR $rc < 0`) + { + --vertical_results + show slave status; + --horizontal_results + show global status; + show global variables; + --let $MYSQLD_DATADIR= `select @@datadir` + --exec $MYSQL_BINLOG -v $MYSQLD_DATADIR/mysqld-relay-bin.000001; + # Check that the relay-log file is fully on disk. + --exec ls -l $MYSQLD_DATADIR; + # After that try to restart the slave SQL thread + start slave sql_thread; + } sync_with_master; --connection master_1 --disable_query_log From bca366e4a1ed339c4c80188206649551393ad53f Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Tue, 7 May 2024 10:16:38 +1000 Subject: [PATCH 544/568] MDEV-34098 source start_slave.inc in spider suites The spider suite should --source include/start_slave.inc to make sure the slave is up before proceeding. --- storage/spider/mysql-test/spider/bg/r/spider3_fixes.result | 1 + storage/spider/mysql-test/spider/bg/r/spider3_fixes_part.result | 1 + storage/spider/mysql-test/spider/bg/r/spider_fixes.result | 1 + storage/spider/mysql-test/spider/bg/r/spider_fixes_part.result | 1 + storage/spider/mysql-test/spider/bg/t/slave_test_init.inc | 2 +- .../spider/bugfix/r/delete_with_float_column_mariadb.result | 1 + .../spider/bugfix/r/delete_with_float_column_mysql.result | 1 + .../bugfix/r/slave_transaction_retry_errors_5digit.result | 1 + .../mysql-test/spider/bugfix/r/slave_trx_isolation.result | 1 + .../spider/feature/r/slave_transaction_retry_errors.result | 1 + storage/spider/mysql-test/spider/handler/r/spider3_fixes.result | 1 + .../mysql-test/spider/handler/r/spider3_fixes_part.result | 1 + storage/spider/mysql-test/spider/handler/r/spider_fixes.result | 1 + .../spider/mysql-test/spider/handler/r/spider_fixes_part.result | 1 + storage/spider/mysql-test/spider/handler/t/slave_test_init.inc | 2 +- storage/spider/mysql-test/spider/r/slave_trx_isolation.result | 1 + storage/spider/mysql-test/spider/r/spider3_fixes.result | 1 + storage/spider/mysql-test/spider/r/spider3_fixes_part.result | 1 + storage/spider/mysql-test/spider/r/spider_fixes.result | 1 + storage/spider/mysql-test/spider/r/spider_fixes_part.result | 1 + storage/spider/mysql-test/spider/t/slave_test_init.inc | 2 +- 21 files changed, 21 insertions(+), 3 deletions(-) diff --git a/storage/spider/mysql-test/spider/bg/r/spider3_fixes.result b/storage/spider/mysql-test/spider/bg/r/spider3_fixes.result index aa734573a1a..e35100428d7 100644 --- a/storage/spider/mysql-test/spider/bg/r/spider3_fixes.result +++ b/storage/spider/mysql-test/spider/bg/r/spider3_fixes.result @@ -8,6 +8,7 @@ child3_1 child3_2 child3_3 for slave1_1 +include/start_slave.inc drop and create databases connection master_1; diff --git a/storage/spider/mysql-test/spider/bg/r/spider3_fixes_part.result b/storage/spider/mysql-test/spider/bg/r/spider3_fixes_part.result index b793346df4b..361fd336f16 100644 --- a/storage/spider/mysql-test/spider/bg/r/spider3_fixes_part.result +++ b/storage/spider/mysql-test/spider/bg/r/spider3_fixes_part.result @@ -8,6 +8,7 @@ child3_1 child3_2 child3_3 for slave1_1 +include/start_slave.inc drop and create databases connection master_1; diff --git a/storage/spider/mysql-test/spider/bg/r/spider_fixes.result b/storage/spider/mysql-test/spider/bg/r/spider_fixes.result index 1db31ca9f95..0baf6ef5d7c 100644 --- a/storage/spider/mysql-test/spider/bg/r/spider_fixes.result +++ b/storage/spider/mysql-test/spider/bg/r/spider_fixes.result @@ -8,6 +8,7 @@ child3_1 child3_2 child3_3 for slave1_1 +include/start_slave.inc drop and create databases connection master_1; diff --git a/storage/spider/mysql-test/spider/bg/r/spider_fixes_part.result b/storage/spider/mysql-test/spider/bg/r/spider_fixes_part.result index faf0b6efbea..3ce8dfbfdc7 100644 --- a/storage/spider/mysql-test/spider/bg/r/spider_fixes_part.result +++ b/storage/spider/mysql-test/spider/bg/r/spider_fixes_part.result @@ -8,6 +8,7 @@ child3_1 child3_2 child3_3 for slave1_1 +include/start_slave.inc drop and create databases connection master_1; diff --git a/storage/spider/mysql-test/spider/bg/t/slave_test_init.inc b/storage/spider/mysql-test/spider/bg/t/slave_test_init.inc index 739d88970c5..84de2c7d2e6 100644 --- a/storage/spider/mysql-test/spider/bg/t/slave_test_init.inc +++ b/storage/spider/mysql-test/spider/bg/t/slave_test_init.inc @@ -19,7 +19,7 @@ if (!$SLAVE1_1_SLAVE_STATUS) MASTER_PORT = $MASTER_1_MYPORT ; } -START SLAVE; +--source include/start_slave.inc --connection master_1 call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); --connection slave1_1 diff --git a/storage/spider/mysql-test/spider/bugfix/r/delete_with_float_column_mariadb.result b/storage/spider/mysql-test/spider/bugfix/r/delete_with_float_column_mariadb.result index d9fb00a09fc..5de4f51a6f6 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/delete_with_float_column_mariadb.result +++ b/storage/spider/mysql-test/spider/bugfix/r/delete_with_float_column_mariadb.result @@ -5,6 +5,7 @@ child2_2 child2_3 for child3 for slave1_1 +include/start_slave.inc connection slave1_1; connection master_1; set @old_binlog_format= @@binlog_format; diff --git a/storage/spider/mysql-test/spider/bugfix/r/delete_with_float_column_mysql.result b/storage/spider/mysql-test/spider/bugfix/r/delete_with_float_column_mysql.result index 9b11de7cff6..7127ae1ca4a 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/delete_with_float_column_mysql.result +++ b/storage/spider/mysql-test/spider/bugfix/r/delete_with_float_column_mysql.result @@ -5,6 +5,7 @@ child2_2 child2_3 for child3 for slave1_1 +include/start_slave.inc connection slave1_1; connection master_1; set @old_binlog_format= @@binlog_format; diff --git a/storage/spider/mysql-test/spider/bugfix/r/slave_transaction_retry_errors_5digit.result b/storage/spider/mysql-test/spider/bugfix/r/slave_transaction_retry_errors_5digit.result index f2cab6b0a95..9ae1f143da3 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/slave_transaction_retry_errors_5digit.result +++ b/storage/spider/mysql-test/spider/bugfix/r/slave_transaction_retry_errors_5digit.result @@ -5,6 +5,7 @@ child2_2 child2_3 for child3 for slave1_1 +include/start_slave.inc connection slave1_1; SHOW VARIABLES LIKE 'slave_transaction_retry_errors'; diff --git a/storage/spider/mysql-test/spider/bugfix/r/slave_trx_isolation.result b/storage/spider/mysql-test/spider/bugfix/r/slave_trx_isolation.result index d50da8a7613..cc98550e581 100644 --- a/storage/spider/mysql-test/spider/bugfix/r/slave_trx_isolation.result +++ b/storage/spider/mysql-test/spider/bugfix/r/slave_trx_isolation.result @@ -5,6 +5,7 @@ child2_2 child2_3 for child3 for slave1_1 +include/start_slave.inc connection slave1_1; set @old_spider_slave_trx_isolation= @@spider_slave_trx_isolation; set global spider_slave_trx_isolation= 1; diff --git a/storage/spider/mysql-test/spider/feature/r/slave_transaction_retry_errors.result b/storage/spider/mysql-test/spider/feature/r/slave_transaction_retry_errors.result index 0a147c0356a..3d7e1b6bfb6 100644 --- a/storage/spider/mysql-test/spider/feature/r/slave_transaction_retry_errors.result +++ b/storage/spider/mysql-test/spider/feature/r/slave_transaction_retry_errors.result @@ -5,6 +5,7 @@ child2_2 child2_3 for child3 for slave1_1 +include/start_slave.inc connection slave1_1; SHOW VARIABLES LIKE 'slave_transaction_retry_errors'; diff --git a/storage/spider/mysql-test/spider/handler/r/spider3_fixes.result b/storage/spider/mysql-test/spider/handler/r/spider3_fixes.result index 9a8a59153f0..1f6f396f6c9 100644 --- a/storage/spider/mysql-test/spider/handler/r/spider3_fixes.result +++ b/storage/spider/mysql-test/spider/handler/r/spider3_fixes.result @@ -8,6 +8,7 @@ child3_1 child3_2 child3_3 for slave1_1 +include/start_slave.inc drop and create databases connection master_1; diff --git a/storage/spider/mysql-test/spider/handler/r/spider3_fixes_part.result b/storage/spider/mysql-test/spider/handler/r/spider3_fixes_part.result index f8747cff5ea..e88d78b144e 100644 --- a/storage/spider/mysql-test/spider/handler/r/spider3_fixes_part.result +++ b/storage/spider/mysql-test/spider/handler/r/spider3_fixes_part.result @@ -8,6 +8,7 @@ child3_1 child3_2 child3_3 for slave1_1 +include/start_slave.inc drop and create databases connection master_1; diff --git a/storage/spider/mysql-test/spider/handler/r/spider_fixes.result b/storage/spider/mysql-test/spider/handler/r/spider_fixes.result index c171167a1b7..654dcb140f4 100644 --- a/storage/spider/mysql-test/spider/handler/r/spider_fixes.result +++ b/storage/spider/mysql-test/spider/handler/r/spider_fixes.result @@ -8,6 +8,7 @@ child3_1 child3_2 child3_3 for slave1_1 +include/start_slave.inc drop and create databases connection master_1; diff --git a/storage/spider/mysql-test/spider/handler/r/spider_fixes_part.result b/storage/spider/mysql-test/spider/handler/r/spider_fixes_part.result index c99c02071b6..8bfaa2f6bb1 100644 --- a/storage/spider/mysql-test/spider/handler/r/spider_fixes_part.result +++ b/storage/spider/mysql-test/spider/handler/r/spider_fixes_part.result @@ -8,6 +8,7 @@ child3_1 child3_2 child3_3 for slave1_1 +include/start_slave.inc drop and create databases connection master_1; diff --git a/storage/spider/mysql-test/spider/handler/t/slave_test_init.inc b/storage/spider/mysql-test/spider/handler/t/slave_test_init.inc index 739d88970c5..84de2c7d2e6 100644 --- a/storage/spider/mysql-test/spider/handler/t/slave_test_init.inc +++ b/storage/spider/mysql-test/spider/handler/t/slave_test_init.inc @@ -19,7 +19,7 @@ if (!$SLAVE1_1_SLAVE_STATUS) MASTER_PORT = $MASTER_1_MYPORT ; } -START SLAVE; +--source include/start_slave.inc --connection master_1 call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); --connection slave1_1 diff --git a/storage/spider/mysql-test/spider/r/slave_trx_isolation.result b/storage/spider/mysql-test/spider/r/slave_trx_isolation.result index a9b88d50628..42665ffd114 100644 --- a/storage/spider/mysql-test/spider/r/slave_trx_isolation.result +++ b/storage/spider/mysql-test/spider/r/slave_trx_isolation.result @@ -8,6 +8,7 @@ child3_1 child3_2 child3_3 for slave1_1 +include/start_slave.inc connection slave1_1; set @old_spider_slave_trx_isolation= @@spider_slave_trx_isolation; set global spider_slave_trx_isolation= 1; diff --git a/storage/spider/mysql-test/spider/r/spider3_fixes.result b/storage/spider/mysql-test/spider/r/spider3_fixes.result index 7a80e102462..614920bee65 100644 --- a/storage/spider/mysql-test/spider/r/spider3_fixes.result +++ b/storage/spider/mysql-test/spider/r/spider3_fixes.result @@ -8,6 +8,7 @@ child3_1 child3_2 child3_3 for slave1_1 +include/start_slave.inc drop and create databases connection master_1; diff --git a/storage/spider/mysql-test/spider/r/spider3_fixes_part.result b/storage/spider/mysql-test/spider/r/spider3_fixes_part.result index 937f222f02f..94390ff71b5 100644 --- a/storage/spider/mysql-test/spider/r/spider3_fixes_part.result +++ b/storage/spider/mysql-test/spider/r/spider3_fixes_part.result @@ -8,6 +8,7 @@ child3_1 child3_2 child3_3 for slave1_1 +include/start_slave.inc drop and create databases connection master_1; diff --git a/storage/spider/mysql-test/spider/r/spider_fixes.result b/storage/spider/mysql-test/spider/r/spider_fixes.result index 1db31ca9f95..0baf6ef5d7c 100644 --- a/storage/spider/mysql-test/spider/r/spider_fixes.result +++ b/storage/spider/mysql-test/spider/r/spider_fixes.result @@ -8,6 +8,7 @@ child3_1 child3_2 child3_3 for slave1_1 +include/start_slave.inc drop and create databases connection master_1; diff --git a/storage/spider/mysql-test/spider/r/spider_fixes_part.result b/storage/spider/mysql-test/spider/r/spider_fixes_part.result index 571af94c1f2..05596c3006e 100644 --- a/storage/spider/mysql-test/spider/r/spider_fixes_part.result +++ b/storage/spider/mysql-test/spider/r/spider_fixes_part.result @@ -8,6 +8,7 @@ child3_1 child3_2 child3_3 for slave1_1 +include/start_slave.inc drop and create databases connection master_1; diff --git a/storage/spider/mysql-test/spider/t/slave_test_init.inc b/storage/spider/mysql-test/spider/t/slave_test_init.inc index 739d88970c5..84de2c7d2e6 100644 --- a/storage/spider/mysql-test/spider/t/slave_test_init.inc +++ b/storage/spider/mysql-test/spider/t/slave_test_init.inc @@ -19,7 +19,7 @@ if (!$SLAVE1_1_SLAVE_STATUS) MASTER_PORT = $MASTER_1_MYPORT ; } -START SLAVE; +--source include/start_slave.inc --connection master_1 call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); --connection slave1_1 From 33e4fbf04578c40c02306b65083c6d9a90ca8b2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Fri, 12 Apr 2024 15:40:11 +0300 Subject: [PATCH 545/568] MDEV-33898 : Galera test failure on galera.MW-369 Additional changes for the galera_vote_rejoin_ddl test (for 10.5+). Signed-off-by: Julius Goryavsky --- .../galera/r/galera_vote_rejoin_ddl.result | 5 +++-- .../suite/galera/t/galera_vote_rejoin_ddl.cnf | 6 ------ .../suite/galera/t/galera_vote_rejoin_ddl.test | 18 ++++++------------ 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/mysql-test/suite/galera/r/galera_vote_rejoin_ddl.result b/mysql-test/suite/galera/r/galera_vote_rejoin_ddl.result index c6b3d8fa554..ff0063fbf7b 100644 --- a/mysql-test/suite/galera/r/galera_vote_rejoin_ddl.result +++ b/mysql-test/suite/galera/r/galera_vote_rejoin_ddl.result @@ -1,7 +1,5 @@ connection node_2; connection node_1; -connection node_1; -connection node_2; connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3; connect node_4, 127.0.0.1, root, , test, $NODE_MYPORT_4; connection node_1; @@ -55,6 +53,7 @@ expect_0 SELECT COUNT(*) AS expect_1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't2'; expect_1 1 +CALL mtr.add_suppression("WSREP: Vote 0 \\(success\\) on .* is inconsistent with group. Leaving cluster."); connection node_4; SELECT COUNT(*) AS expect_0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; expect_0 @@ -64,3 +63,5 @@ expect_1 1 CALL mtr.add_suppression("WSREP: Vote 0 \\(success\\) on .* is inconsistent with group. Leaving cluster."); DROP TABLE t2; +disconnect node_3; +disconnect node_4; diff --git a/mysql-test/suite/galera/t/galera_vote_rejoin_ddl.cnf b/mysql-test/suite/galera/t/galera_vote_rejoin_ddl.cnf index 022cfcdc0b0..b2cba42c0bd 100644 --- a/mysql-test/suite/galera/t/galera_vote_rejoin_ddl.cnf +++ b/mysql-test/suite/galera/t/galera_vote_rejoin_ddl.cnf @@ -2,9 +2,3 @@ [mysqld] wsrep-ignore-apply-errors=0 - -[mysqld.3] -auto_increment_offset=3 - -[mysqld.4] -auto_increment_offset=4 diff --git a/mysql-test/suite/galera/t/galera_vote_rejoin_ddl.test b/mysql-test/suite/galera/t/galera_vote_rejoin_ddl.test index 90a90052b7f..c14dd7b8a0e 100644 --- a/mysql-test/suite/galera/t/galera_vote_rejoin_ddl.test +++ b/mysql-test/suite/galera/t/galera_vote_rejoin_ddl.test @@ -6,25 +6,15 @@ --source include/galera_cluster.inc --source include/big_test.inc -# Save original auto_increment_offset values. ---let $node_1=node_1 ---let $node_2=node_2 ---source include/auto_increment_offset_save.inc -# The following has to be set hard as these connection doesn't yet exists and -# the auto_increment_offset value changes during the lifetime of the servers. ---let $node_3=node_3 ---let $auto_increment_offset_node_3 = 3; ---let $node_4=node_4 ---let $auto_increment_offset_node_4 = 4; - --connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 --connect node_4, 127.0.0.1, root, , test, $NODE_MYPORT_4 +# Save original auto_increment_offset values. --let $node_1=node_1 --let $node_2=node_2 --let $node_3=node_3 --let $node_4=node_4 ---source suite/galera/include/auto_increment_offset_save.inc +--source include/auto_increment_offset_save.inc --connection node_3 # Isolate node #3 @@ -92,6 +82,7 @@ CALL mtr.add_suppression("Slave SQL: Error 'Unknown table"); --connection node_3 SELECT COUNT(*) AS expect_0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; SELECT COUNT(*) AS expect_1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't2'; +CALL mtr.add_suppression("WSREP: Vote 0 \\(success\\) on .* is inconsistent with group. Leaving cluster."); --connection node_4 SELECT COUNT(*) AS expect_0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; @@ -101,3 +92,6 @@ CALL mtr.add_suppression("WSREP: Vote 0 \\(success\\) on .* is inconsistent with DROP TABLE t2; --source suite/galera/include/auto_increment_offset_restore.inc + +--disconnect node_3 +--disconnect node_4 From 421eeb18b85d653314f1be1971763c0922505388 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 7 May 2024 09:39:02 +0200 Subject: [PATCH 546/568] Revert "MDEV-19949 mariabackup option of '--password' or '-p' without specifying password in commandline" This reverts commit 91fb8b7fd3224767fe7eb81e82f5ec0926751420. Incompatible change, see tests in the next commit --- extra/mariabackup/xtrabackup.cc | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index c464c7937d3..500ae683d80 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -370,7 +370,6 @@ my_bool opt_no_backup_locks = FALSE; my_bool opt_decompress = FALSE; my_bool opt_remove_original; my_bool opt_log_innodb_page_corruption; -my_bool tty_password= FALSE; my_bool opt_lock_ddl_per_table = FALSE; static my_bool opt_check_privileges; @@ -1368,7 +1367,7 @@ struct my_option xb_client_options[]= { "This option specifies the password to use " "when connecting to the database. It accepts a string argument. " "See mysql --help for details.", - 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, + 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"protocol", OPT_PROTOCOL, "The protocol to use for connection (tcp, socket, pipe, memory).", 0, 0, @@ -2044,7 +2043,6 @@ xb_get_one_option(const struct my_option *opt, break; case 'p': opt_password = argument; - tty_password = argument == NULL; break; case OPT_PROTOCOL: if (argument) @@ -6751,8 +6749,6 @@ void handle_options(int argc, char **argv, char ***argv_server, if (*start) start[1]= 0; } - else if (tty_password) - opt_password= my_get_tty_password(NullS); /* 4) Process --mysqld-args options, ignore unknown options */ From 42c99ef0d4aeba1565520364d4950f9add4c6132 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 7 May 2024 09:38:29 +0200 Subject: [PATCH 547/568] MDEV-19949 `mariadb-backup --password` test --- .../suite/mariabackup/backup_grants.result | 2 +- .../suite/mariabackup/backup_grants.test | 20 +++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/mysql-test/suite/mariabackup/backup_grants.result b/mysql-test/suite/mariabackup/backup_grants.result index 6bd6c9f42cd..77cc3dd65d1 100644 --- a/mysql-test/suite/mariabackup/backup_grants.result +++ b/mysql-test/suite/mariabackup/backup_grants.result @@ -1,4 +1,4 @@ -CREATE user backup@localhost; +CREATE user backup@localhost IDENTIFIED BY 'xyz'; FOUND 1 /missing required privilege RELOAD/ in backup.log FOUND 1 /missing required privilege PROCESS/ in backup.log FOUND 1 /GRANT USAGE ON/ in backup.log diff --git a/mysql-test/suite/mariabackup/backup_grants.test b/mysql-test/suite/mariabackup/backup_grants.test index 18db3489a94..7b8c9b39b57 100644 --- a/mysql-test/suite/mariabackup/backup_grants.test +++ b/mysql-test/suite/mariabackup/backup_grants.test @@ -1,16 +1,16 @@ let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; -CREATE user backup@localhost; +CREATE user backup@localhost IDENTIFIED BY 'xyz'; # backup possible for unprivileges user, with --no-lock --disable_result_log -exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup --no-lock --target-dir=$targetdir; +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup -pxyz --no-lock --target-dir=$targetdir; --enable_result_log rmdir $targetdir; # backup fails without --no-lock, because of FTWRL --disable_result_log error 1; -exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup --target-dir=$targetdir > $MYSQLTEST_VARDIR/tmp/backup.log 2>&1; +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup -pxyz --target-dir=$targetdir > $MYSQLTEST_VARDIR/tmp/backup.log 2>&1; --enable_result_log let SEARCH_FILE=$MYSQLTEST_VARDIR/tmp/backup.log; @@ -23,7 +23,7 @@ let SEARCH_FILE=$MYSQLTEST_VARDIR/tmp/backup.log; # backup succeeds with RELOAD privilege GRANT RELOAD, PROCESS on *.* to backup@localhost; --disable_result_log -exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup --target-dir=$targetdir; +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --user=backup --password=xyz --target-dir=$targetdir; --enable_result_log rmdir $targetdir; @@ -31,7 +31,7 @@ rmdir $targetdir; # --slave-info and galera info require REPLICA MONITOR --disable_result_log error 1; -exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup --slave-info --target-dir=$targetdir > $MYSQLTEST_VARDIR/tmp/backup.log 2>&1; +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --user backup --password xyz --slave-info --target-dir=$targetdir > $MYSQLTEST_VARDIR/tmp/backup.log 2>&1; --enable_result_log rmdir $targetdir; @@ -40,7 +40,7 @@ rmdir $targetdir; GRANT REPLICA MONITOR ON *.* TO backup@localhost; --disable_result_log -exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup --slave-info --target-dir=$targetdir; +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup -pxyz --slave-info --target-dir=$targetdir; --enable_result_log rmdir $targetdir; REVOKE REPLICA MONITOR ON *.* FROM backup@localhost; @@ -50,7 +50,7 @@ REVOKE REPLICA MONITOR ON *.* FROM backup@localhost; # kill-long-query-type=(not empty) requires CONNECTION ADMIN --disable_result_log ---exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup --kill-long-query-type=ALL --kill-long-queries-timeout=4 --target-dir=$targetdir > $MYSQLTEST_VARDIR/tmp/backup.log 2>&1; +--exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup -pxyz --kill-long-query-type=ALL --kill-long-queries-timeout=4 --target-dir=$targetdir > $MYSQLTEST_VARDIR/tmp/backup.log 2>&1; --enable_result_log rmdir $targetdir; @@ -59,14 +59,14 @@ rmdir $targetdir; GRANT CONNECTION ADMIN ON *.* TO backup@localhost; --disable_result_log -exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup --kill-long-query-type=all --kill-long-queries-timeout=1 --target-dir=$targetdir; +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --user=backup --password=xyz --kill-long-query-type=all --kill-long-queries-timeout=1 --target-dir=$targetdir; --enable_result_log rmdir $targetdir; # --safe-slave-backup requires REPLICATION SLAVE ADMIN, and REPLICA MONITOR --disable_result_log error 1; -exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup --safe-slave-backup --target-dir=$targetdir > $MYSQLTEST_VARDIR/tmp/backup.log; +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --user backup --password xyz --safe-slave-backup --target-dir=$targetdir > $MYSQLTEST_VARDIR/tmp/backup.log; --enable_result_log rmdir $targetdir; @@ -78,7 +78,7 @@ rmdir $targetdir; GRANT REPLICATION SLAVE ADMIN ON *.* TO backup@localhost; GRANT REPLICA MONITOR ON *.* TO backup@localhost; --disable_result_log -exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup --safe-slave-backup --target-dir=$targetdir; +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup -ubackup -pxyz --safe-slave-backup --target-dir=$targetdir; --enable_result_log rmdir $targetdir; From 10a759928611243d88f607437bcd723fa7dae078 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Tue, 30 Apr 2024 14:00:43 +1000 Subject: [PATCH 548/568] MDEV-34036 Reset spider_hton_ptr in spider_db_done() Otherwise spider_direct_sql may still think the spider plugin is available even after spider_db_done() was called. --- storage/spider/spd_table.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index 5eedda46523..9a2f41ca658 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -6847,6 +6847,7 @@ int spider_db_done( pthread_attr_destroy(&spider_pt_attr); #endif + spider_hton_ptr= NULL; for (roop_count = 0; roop_count < SPIDER_MEM_CALC_LIST_NUM; roop_count++) { if (spider_alloc_func_name[roop_count]) From 4bc1860eb4baf168fdde69734b38ceecbd0cb9ec Mon Sep 17 00:00:00 2001 From: Galina Shalygina Date: Tue, 30 Apr 2024 21:31:47 +0200 Subject: [PATCH 549/568] MDEV-23878 Wrong result with semi-join and splittable derived table Due to this bug a wrong result might be expected from queries with an IN subquery predicate in the WHERE clause and a derived table in the FROM clause to which split optimization could be applied. The function JOIN::fix_all_splittings_in_plan() used the value of the bitmap JOIN::sjm_lookup_tables() such as it had been left after the search for the best plan for the select containing the splittable derived table. That value could not be guaranteed to be correct. So the recalculation of this bitmap is needed to exclude the plans with key accesses from SJM lookup tables. Approved by Igor Babaev --- mysql-test/main/derived_split_innodb.result | 57 +++++++++++++++++++++ mysql-test/main/derived_split_innodb.test | 42 +++++++++++++++ sql/opt_split.cc | 5 +- 3 files changed, 103 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/derived_split_innodb.result b/mysql-test/main/derived_split_innodb.result index cf5076724d1..894384d5bfc 100644 --- a/mysql-test/main/derived_split_innodb.result +++ b/mysql-test/main/derived_split_innodb.result @@ -848,4 +848,61 @@ SELECT * FROM t1 WHERE t1.a IN (SELECT b FROM (SELECT t2.b FROM t2 WHERE NOT EXISTS (SELECT 1 FROM t3) GROUP BY b) sq); a DROP TABLE t1, t2, t3; +# +# MDEV-23878: Wrong result with semi-join and splittable derived table +# +CREATE TABLE t1 ( +groupId int, +id int unsigned, +PRIMARY KEY (groupId, id) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES +(8,1),(8,2),(8,3),(8,4),(8,5),(8,6),(8,7),(8,8),(8,9),(8,10), +(8,11),(8,12),(8,13),(8,14),(8,15),(8,16),(8,17),(8,18),(8,19); +set statement in_predicate_conversion_threshold=2 for SELECT COUNT(*) AS cnt FROM t1 +JOIN +( +SELECT groupId, id +FROM t1 +WHERE id IN (1,2,3,4,5,6) +GROUP BY groupId, id +) AS t2 +USING (groupId, id) +WHERE id IN (1,2,3,4,5,6,7,8); +cnt +6 +set statement in_predicate_conversion_threshold=2 for EXPLAIN SELECT COUNT(*) AS cnt FROM t1 +JOIN +( +SELECT groupId, id +FROM t1 +WHERE id IN (1,2,3,4,5,6) +GROUP BY groupId, id +) AS t2 +USING (groupId, id) +WHERE id IN (1,2,3,4,5,6,7,8); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 index PRIMARY PRIMARY 8 NULL 19 Using index +1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 Using where +1 PRIMARY ref key0 key0 8 test.t1.groupId,test.t1.id 2 +4 MATERIALIZED ALL NULL NULL NULL NULL 8 +5 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used +3 LATERAL DERIVED t1 eq_ref PRIMARY PRIMARY 8 test.t1.groupId,test.t1.id 1 Using index +3 LATERAL DERIVED ref key0 key0 4 test.t1.id 2 Using where; FirstMatch(t1) +7 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used +set statement optimizer_switch='split_materialized=off, loosescan=off' for +set statement in_predicate_conversion_threshold=2 for +SELECT COUNT(*) AS cnt FROM t1 +JOIN +( +SELECT groupId, id +FROM t1 +WHERE id IN (1,2,3,4,5,6) +GROUP BY groupId, id +) AS t2 +USING (groupId, id) +WHERE id IN (1,2,3,4,5,6,7,8); +cnt +6 +DROP TABLE t1; # End of 10.4 tests diff --git a/mysql-test/main/derived_split_innodb.test b/mysql-test/main/derived_split_innodb.test index 0909e3de9a6..d7756cb8fc5 100644 --- a/mysql-test/main/derived_split_innodb.test +++ b/mysql-test/main/derived_split_innodb.test @@ -503,4 +503,46 @@ SELECT * FROM t1 WHERE t1.a IN (SELECT b FROM DROP TABLE t1, t2, t3; +--echo # +--echo # MDEV-23878: Wrong result with semi-join and splittable derived table +--echo # + +CREATE TABLE t1 ( + groupId int, + id int unsigned, + PRIMARY KEY (groupId, id) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +INSERT INTO t1 VALUES + (8,1),(8,2),(8,3),(8,4),(8,5),(8,6),(8,7),(8,8),(8,9),(8,10), + (8,11),(8,12),(8,13),(8,14),(8,15),(8,16),(8,17),(8,18),(8,19); + +let $query= +SELECT COUNT(*) AS cnt FROM t1 +JOIN +( + SELECT groupId, id + FROM t1 + WHERE id IN (1,2,3,4,5,6) + GROUP BY groupId, id +) AS t2 +USING (groupId, id) +WHERE id IN (1,2,3,4,5,6,7,8); + +let $tvc_conversion_threshold = + set statement in_predicate_conversion_threshold=2 for; + +eval $tvc_conversion_threshold $query; +eval $tvc_conversion_threshold EXPLAIN $query; + +let $no_split_materialized_loosescan= + set statement optimizer_switch='split_materialized=off, loosescan=off' for; + +# Correct result with split materializied optimization disabled +eval $no_split_materialized_loosescan + $tvc_conversion_threshold + $query; + +DROP TABLE t1; + --echo # End of 10.4 tests diff --git a/sql/opt_split.cc b/sql/opt_split.cc index 63d430384b8..0d479bbda3e 100644 --- a/sql/opt_split.cc +++ b/sql/opt_split.cc @@ -1332,6 +1332,7 @@ bool JOIN::fix_all_splittings_in_plan() { table_map prev_tables= 0; table_map all_tables= (table_map(1) << table_count) - 1; + table_map prev_sjm_lookup_tables= 0; for (uint tablenr= 0; tablenr < table_count; tablenr++) { POSITION *cur_pos= &best_positions[tablenr]; @@ -1340,7 +1341,7 @@ bool JOIN::fix_all_splittings_in_plan() { SplM_plan_info *spl_plan= cur_pos->spl_plan; table_map excluded_tables= (all_tables & ~prev_tables) | - sjm_lookup_tables; + prev_sjm_lookup_tables; ; if (spl_plan) { @@ -1358,6 +1359,8 @@ bool JOIN::fix_all_splittings_in_plan() return true; } prev_tables|= tab->table->map; + if (cur_pos->sj_strategy == SJ_OPT_MATERIALIZE) + prev_sjm_lookup_tables|= tab->table->map; } return false; } From ec6aa9ac42b8fada5927687c6e81a04fa0004393 Mon Sep 17 00:00:00 2001 From: Monty Date: Tue, 7 May 2024 17:21:01 +0300 Subject: [PATCH 550/568] MDEV-34055 Assertion '...' failure or corruption errors upon REPAIR on Aria tables The problem was two fold: - REPAIR TABLE t1 USE_FRM did not work for transactional Aria tables (Table was thought to be repaired, which it was not) which caused issues in later usage of the table. - When swapping tmp_data file to data file, sort_info files where not updated. This caused problems if there was several unique keys and there was a duplicate for the second key. --- mysql-test/suite/maria/repair.result | 23 +++++++++++++++++++++++ mysql-test/suite/maria/repair.test | 19 +++++++++++++++++++ storage/maria/ma_check.c | 12 ++++++++++-- 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/maria/repair.result b/mysql-test/suite/maria/repair.result index 458b5503602..7905cb02f28 100644 --- a/mysql-test/suite/maria/repair.result +++ b/mysql-test/suite/maria/repair.result @@ -62,3 +62,26 @@ SET SESSION aria_sort_buffer_size=default; # # End of 10.3 tests # +# +# MDEV-34055 Assertion `readbytes != (size_t)-1 || +# (*__errno_location ()) != 9' failure or corruption errors upon +# REPAIR on Aria tables +# +CREATE OR REPLACE TABLE t1 (a INT, b INT, UNIQUE(b), UNIQUE(a)) ENGINE=Aria; +INSERT INTO t1 VALUES (1,2); +REPAIR TABLE t1 EXTENDED QUICK USE_FRM; +Table Op Msg_type Msg_text +test.t1 repair warning Number of rows changed from 0 to 1 +test.t1 repair status OK +CREATE TABLE t2 (c INT) ENGINE=Aria; +SELECT * FROM t2; +c +REPLACE INTO t1 VALUES (1,3); +REPAIR TABLE t2, t1 QUICK; +Table Op Msg_type Msg_text +test.t2 repair status OK +test.t1 repair status OK +DROP TABLE t1, t2; +# +# End of 10.5 tests +# diff --git a/mysql-test/suite/maria/repair.test b/mysql-test/suite/maria/repair.test index 688ac076e1d..08234a5a546 100644 --- a/mysql-test/suite/maria/repair.test +++ b/mysql-test/suite/maria/repair.test @@ -74,3 +74,22 @@ SET SESSION aria_sort_buffer_size=default; --echo # --echo # End of 10.3 tests --echo # + +--echo # +--echo # MDEV-34055 Assertion `readbytes != (size_t)-1 || +--echo # (*__errno_location ()) != 9' failure or corruption errors upon +--echo # REPAIR on Aria tables +--echo # + +CREATE OR REPLACE TABLE t1 (a INT, b INT, UNIQUE(b), UNIQUE(a)) ENGINE=Aria; +INSERT INTO t1 VALUES (1,2); +REPAIR TABLE t1 EXTENDED QUICK USE_FRM; +CREATE TABLE t2 (c INT) ENGINE=Aria; +SELECT * FROM t2; +REPLACE INTO t1 VALUES (1,3); +REPAIR TABLE t2, t1 QUICK; +DROP TABLE t1, t2; + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c index 4c2232f07c4..0017a045bbf 100644 --- a/storage/maria/ma_check.c +++ b/storage/maria/ma_check.c @@ -2505,6 +2505,11 @@ static int initialize_variables_for_repair(HA_CHECK *param, maria_versioning(info, 0); /* remember original number of rows */ *info->state= info->s->state.state; + if (share->data_file_type == BLOCK_RECORD) + share->state.state.data_file_length= MY_ALIGN(sort_info->filelength, + share->block_size); + else + share->state.state.data_file_length= sort_info->filelength; return 0; } @@ -2741,7 +2746,7 @@ int maria_repair(HA_CHECK *param, register MARIA_HA *info, READ_CACHE, share->pack.header_length, 1, MYF(MY_WME))) goto err; } - if (sort_info.new_info->s->data_file_type != BLOCK_RECORD) + if (!block_record) { /* When writing to not block records, we need a write buffer */ if (!rep_quick) @@ -2754,7 +2759,7 @@ int maria_repair(HA_CHECK *param, register MARIA_HA *info, sort_info.new_info->opt_flag|=WRITE_CACHE_USED; } } - else if (block_record) + else { scan_inited= 1; if (maria_scan_init(sort_info.info)) @@ -4102,6 +4107,9 @@ int maria_repair_by_sort(HA_CHECK *param, register MARIA_HA *info, _ma_check_print_error(param, "Couldn't change to new data file"); goto err; } + /* Inform sort_delete_record that we are using the new file */ + sort_info.new_info->dfile.file= info->rec_cache.file= info->dfile.file; + if (param->testflag & T_UNPACK) restore_data_file_type(share); From 40b3525fcc79aef62ea1ae057ec5687a55c0630b Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Tue, 7 May 2024 14:10:35 +0300 Subject: [PATCH 551/568] MDEV-28621: group by optimization incorrectly removing subquery where subject buried in a function Workaround patch: Do not remove GROUP BY clause when it has subquer(ies) in it. remove_redundant_subquery_clauses() removes redundant GROUP BY clause from queries in form: expr IN (SELECT no_aggregates GROUP BY ...) expr {CMP} {ALL|ANY|SOME} (SELECT no_aggregates GROUP BY ...) This hits problems when the GROUP BY clause itself has subquer(y/ies). This patch is just a workaround: it disables removal of GROUP BY clause if the clause has one or more subqueries in it. Tests: - subselect_elimination.test has all known crashing cases. - subselect4.result, insert_select.result are updated. Note that in some cases results of SELECT are changed too (not just EXPLAINs). These are caused by non-deterministic SQL: when running a query like: x > ANY( SELECT col1 FROM t1 GROUP BY constant_expression) without removing the GROUP BY, the executor is free to pick the value of t1.col1 from any row in the GROUP BY group (denote it $COL1_VAL). Then, it computes x > ANY(SELECT $COL1_VAL). When running the same query and removing the GROUP BY: x > ANY( SELECT col1 FROM t1) the executor will actually check all rows of t1. --- mysql-test/main/insert_select.result | 8 +- mysql-test/main/subselect4.result | 74 ++--- mysql-test/main/subselect_elimination.result | 268 +++++++++++++++++++ mysql-test/main/subselect_elimination.test | 242 +++++++++++++++++ sql/sql_select.cc | 72 +++-- 5 files changed, 599 insertions(+), 65 deletions(-) create mode 100644 mysql-test/main/subselect_elimination.result create mode 100644 mysql-test/main/subselect_elimination.test diff --git a/mysql-test/main/insert_select.result b/mysql-test/main/insert_select.result index 29618c6ddd4..463f571b096 100644 --- a/mysql-test/main/insert_select.result +++ b/mysql-test/main/insert_select.result @@ -973,7 +973,6 @@ select * from t1; a 3 1 -2 delete from t1; insert into t1 values (3), (1); insert into t1 @@ -984,8 +983,6 @@ select * from t1; a 3 1 -3 -2 delete from t1; insert into t1 values (3), (1); insert into t1 @@ -996,6 +993,7 @@ select * from t1; a 3 1 +3 2 delete from t1; insert into t1 values (3), (1); @@ -1022,7 +1020,6 @@ select * from t1; a 3 1 -2 delete from t1; insert into t1 values (3), (1); execute stmt; @@ -1030,7 +1027,6 @@ select * from t1; a 3 1 -2 delete from t1; insert into t1 values (3), (1); delete from t1 @@ -1040,6 +1036,8 @@ group by (select * from (select a from t1) dt where a = 1))); select * from t1; a +3 +1 deallocate prepare stmt; drop table t1,t2,t3; # diff --git a/mysql-test/main/subselect4.result b/mysql-test/main/subselect4.result index b29a26d8ac5..7bf2f3bf373 100644 --- a/mysql-test/main/subselect4.result +++ b/mysql-test/main/subselect4.result @@ -2979,34 +2979,31 @@ where a >= any (select b from t2 group by (select c from t3 where c = 1)); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00 +3 SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a`,(/* select#2 */ select min(`test`.`t2`.`b`) from `test`.`t2`) <= (`test`.`t1`.`a`))) +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` group by (/* select#3 */ select `test`.`t3`.`c` from `test`.`t3` where `test`.`t3`.`c` = 1)) <= (`test`.`t1`.`a`))) select a from t1 where a >= any (select b from t2 group by (select c from t3 where c = 1)); a -3 -2 prepare stmt from "select a from t1 where a >= any (select b from t2 group by (select c from t3 where c = 1))"; execute stmt; a -3 -2 execute stmt; a -3 -2 deallocate prepare stmt; explain extended select a from t1 where a <= all (select b from t2 group by (select c from t3 where c = 1)); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00 +3 SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a`,(/* select#2 */ select min(`test`.`t2`.`b`) from `test`.`t2`) < (`test`.`t1`.`a`))) +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` group by (/* select#3 */ select `test`.`t3`.`c` from `test`.`t3` where `test`.`t3`.`c` = 1)) < (`test`.`t1`.`a`))) select a from t1 where a <= all (select b from t2 group by (select c from t3 where c = 1)); a +3 1 2 explain extended select a from t1 @@ -3014,13 +3011,12 @@ where a >= any (select b from t2 group by 1 + (select c from t3 where c = 1)); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where 2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00 +3 SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: -Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a`,(/* select#2 */ select min(`test`.`t2`.`b`) from `test`.`t2`) <= (`test`.`t1`.`a`))) +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where ((`test`.`t1`.`a`,(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` group by 1 + (/* select#3 */ select `test`.`t3`.`c` from `test`.`t3` where `test`.`t3`.`c` = 1)) <= (`test`.`t1`.`a`))) select a from t1 where a >= any (select b from t2 group by 1 + (select c from t3 where c = 1)); a -3 -2 drop table t1,t2,t3; # # MDEV-29139: Redundant IN/ALL/ANY predicand in GROUP BY clause of @@ -3040,8 +3036,10 @@ group by (select a from t1 where a = 1) in (select d from t4)); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 2 SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00 +4 SUBQUERY t4 ALL NULL NULL NULL NULL 2 100.00 Using where +3 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: -Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` where 1 +Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` where (1,exists(/* select#2 */ select `test`.`t3`.`c` from `test`.`t3` group by ((/* select#3 */ select `test`.`t1`.`a` from `test`.`t1` where `test`.`t1`.`a` = 1),(/* select#4 */ select `test`.`t4`.`d` from `test`.`t4` where trigcond(((/* select#3 */ select `test`.`t1`.`a` from `test`.`t1` where `test`.`t1`.`a` = 1)) = `test`.`t4`.`d` or `test`.`t4`.`d` is null) having trigcond(`test`.`t4`.`d` is null))) limit 1)) select b from t2 where exists (select c from t3 group by (select a from t1 where a = 1) in (select d from t4)); @@ -3067,8 +3065,10 @@ any (select d from t4)); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 2 SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00 +4 SUBQUERY t4 ALL NULL NULL NULL NULL 2 100.00 Using where +3 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: -Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` where 1 +Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` where (1,exists(/* select#2 */ select `test`.`t3`.`c` from `test`.`t3` group by (<(/* select#3 */ select `test`.`t1`.`a` from `test`.`t1` where `test`.`t1`.`a` = 1)>(((/* select#3 */ select `test`.`t1`.`a` from `test`.`t1` where `test`.`t1`.`a` = 1),(/* select#4 */ select `test`.`t4`.`d` from `test`.`t4` where trigcond(((/* select#3 */ select `test`.`t1`.`a` from `test`.`t1` where `test`.`t1`.`a` = 1)) >= `test`.`t4`.`d` or `test`.`t4`.`d` is null) having trigcond(`test`.`t4`.`d` is null))))) limit 1)) select b from t2 where exists (select c from t3 group by (select a from t1 where a = 1) >= @@ -3083,8 +3083,10 @@ all (select d from t4)); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 2 SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00 +4 SUBQUERY t4 ALL NULL NULL NULL NULL 2 100.00 Using where +3 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: -Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` where 1 +Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` where (1,exists(/* select#2 */ select `test`.`t3`.`c` from `test`.`t3` group by (<(/* select#3 */ select `test`.`t1`.`a` from `test`.`t1` where `test`.`t1`.`a` = 1)>(((/* select#3 */ select `test`.`t1`.`a` from `test`.`t1` where `test`.`t1`.`a` = 1),(/* select#4 */ select `test`.`t4`.`d` from `test`.`t4` where trigcond(((/* select#3 */ select `test`.`t1`.`a` from `test`.`t1` where `test`.`t1`.`a` = 1)) >= `test`.`t4`.`d` or `test`.`t4`.`d` is null) having trigcond(`test`.`t4`.`d` is null))))) limit 1)) select b from t2 where exists (select c from t3 group by (select a from t1 where a = 1) < @@ -3096,16 +3098,17 @@ explain extended select b from t2 where b in (select c from t3 group by (select a from t1 where a = 1) in (select d from t4)); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 -1 PRIMARY eq_ref distinct_key distinct_key 4 func 1 100.00 +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where +1 PRIMARY eq_ref distinct_key distinct_key 4 test.t2.b 1 100.00 2 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 100.00 +4 SUBQUERY t4 ALL NULL NULL NULL NULL 2 100.00 Using where +3 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: -Note 1003 select `test`.`t2`.`b` AS `b` from `test`.`t2` semi join (`test`.`t3`) where 1 +Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b` from (/* select#2 */ select `test`.`t3`.`c` from `test`.`t3` group by ((/* select#3 */ select `test`.`t1`.`a` from `test`.`t1` where `test`.`t1`.`a` = 1),(/* select#4 */ select `test`.`t4`.`d` from `test`.`t4` where trigcond(((/* select#3 */ select `test`.`t1`.`a` from `test`.`t1` where `test`.`t1`.`a` = 1)) = `test`.`t4`.`d` or `test`.`t4`.`d` is null) having trigcond(`test`.`t4`.`d` is null)))) join `test`.`t2` where ``.`c` = `test`.`t2`.`b` select b from t2 where b in (select c from t3 group by (select a from t1 where a = 1) in (select d from t4)); b -2 explain extended select b from t2 where b >= any (select c from t3 group by (select a from t1 where a = 1) in @@ -3113,30 +3116,33 @@ group by (select a from t1 where a = 1) in id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where 2 SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00 +4 SUBQUERY t4 ALL NULL NULL NULL NULL 2 100.00 Using where +3 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: -Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` where ((`test`.`t2`.`b`,(/* select#2 */ select min(`test`.`t3`.`c`) from `test`.`t3`) <= (`test`.`t2`.`b`))) +Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` where ((`test`.`t2`.`b`,(/* select#2 */ select `test`.`t3`.`c` from `test`.`t3` group by ((/* select#3 */ select `test`.`t1`.`a` from `test`.`t1` where `test`.`t1`.`a` = 1),(/* select#4 */ select `test`.`t4`.`d` from `test`.`t4` where trigcond(((/* select#3 */ select `test`.`t1`.`a` from `test`.`t1` where `test`.`t1`.`a` = 1)) = `test`.`t4`.`d` or `test`.`t4`.`d` is null) having trigcond(`test`.`t4`.`d` is null)))) <= (`test`.`t2`.`b`))) select b from t2 where b >= any (select c from t3 group by (select a from t1 where a = 1) in (select d from t4)); b +explain extended select b from t2 +where b <= all (select c from t3 +group by (select a from t1 where a = 1) in +(select d from t4)); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where +2 SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00 +4 SUBQUERY t4 ALL NULL NULL NULL NULL 2 100.00 Using where +3 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` where ((`test`.`t2`.`b`,(/* select#2 */ select `test`.`t3`.`c` from `test`.`t3` group by ((/* select#3 */ select `test`.`t1`.`a` from `test`.`t1` where `test`.`t1`.`a` = 1),(/* select#4 */ select `test`.`t4`.`d` from `test`.`t4` where trigcond(((/* select#3 */ select `test`.`t1`.`a` from `test`.`t1` where `test`.`t1`.`a` = 1)) = `test`.`t4`.`d` or `test`.`t4`.`d` is null) having trigcond(`test`.`t4`.`d` is null)))) < (`test`.`t2`.`b`))) +select b from t2 +where b <= all (select c from t3 +group by (select a from t1 where a = 1) in +(select d from t4)); +b 3 2 -explain extended select b from t2 -where b <= all (select c from t3 -group by (select a from t1 where a = 1) in -(select d from t4)); -id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where -2 SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00 -Warnings: -Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` where ((`test`.`t2`.`b`,(/* select#2 */ select `test`.`t3`.`c` from `test`.`t3`) < (`test`.`t2`.`b`))) -select b from t2 -where b <= all (select c from t3 -group by (select a from t1 where a = 1) in -(select d from t4)); -b -2 drop table t1,t2,t3,t4; # End of 10.3 tests # diff --git a/mysql-test/main/subselect_elimination.result b/mysql-test/main/subselect_elimination.result new file mode 100644 index 00000000000..17400e490bc --- /dev/null +++ b/mysql-test/main/subselect_elimination.result @@ -0,0 +1,268 @@ +# +# MDEV-28621 group by optimization incorrectly removing subquery where +# subject buried in a function +# +CREATE TABLE t1 (i int) ; +INSERT INTO t1 VALUES (1),(2),(3); +SELECT 1 FROM t1 +WHERE i in +( SELECT a+1 +FROM +(SELECT (SELECT i FROM (SELECT 1 FROM t1) dt) AS a FROM t1) dt2 +GROUP BY a +); +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +create table t1 (a int, b int, c int); +insert into t1 select seq, seq, seq from seq_1_to_10; +create table t2 as select * from t1; +create table t20 as select * from t1; +create table t21 as select * from t1; +create table t3 as select * from t1; +select a, a in +( +select +( +select max(c) from t20 where t20.a<=t2.a +) as SUBQ1 from t2 group by SUBQ1+1 +) as COL +from t1; +a COL +1 1 +2 1 +3 1 +4 1 +5 1 +6 1 +7 1 +8 1 +9 1 +10 1 +create view v2 as +select +a, b, +(select max(c) from t20 where t20.a<=t2.a) as SUBQ1, +(select max(c) from t21 where t21.a<=t2.a) as SUBQ2 +from t2; +# test partial elimination +explain +select +a, +a in (select a from v2 where a>3 and v2.SUBQ2>=0 group by v2.SUBQ1, v2.SUBQ2) +from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 10 +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 10 Using where; Using temporary +5 DEPENDENT SUBQUERY t21 ALL NULL NULL NULL NULL 10 Using where +4 DEPENDENT SUBQUERY t20 ALL NULL NULL NULL NULL 10 Using where +# test buried subselects in group by clause +select a, a in +( +select +( +select max(c) from t20 where t20.a<=t2.a +)*2 as SUBQ1 from t2 group by SUBQ1+1 +) as COL +from t1; +a COL +1 0 +2 1 +3 0 +4 1 +5 0 +6 1 +7 0 +8 1 +9 0 +10 1 +drop view v2; +drop table t1, t2, t20, t21, t3; +# Testcase from MDEV-32311 +SELECT ( +( WITH x ( x ) AS +(SELECT ( SELECT 'x' UNION SELECT 'x' ) FROM ( SELECT ( 'x' ) ) x) +SELECT x FROM x +WHERE x IN ( ( SELECT 'x' AND x GROUP BY x ) ) +) +) AS SUBQ; +SUBQ +x +# MDEV-32390: +CREATE TABLE t0 ( c43 DECIMAL ( 31 ) DEFAULT ( 45 ) ) ; +INSERT INTO t0 VALUES ( 13 ) , ( 29 ) ; +ALTER TABLE t0 ADD COLUMN c24 INT AFTER c43 ; +INSERT INTO t0 VALUES ( DEFAULT , DEFAULT ) , ( DEFAULT , DEFAULT ) ; +SELECT t1 . c22 AS c9 FROM ( SELECT ( SELECT + EXISTS ( SELECT -128 AS c29 ) << +LOCATE ( t0 . c43 , t0 . c24 <= t0 . c24 NOT BETWEEN 4642475734208631537 AND +-108 , NULLIF ( 57 , -8 ) SOUNDS LIKE TRIM( TRAILING FROM 6107036197732405580 ) +) - t0 . c43 AS c57 FROM t0 LIMIT 1 ) AS c22 FROM t0 ) AS t1 HAVING TRIM( CASE +t1 . c22 WHEN -16 THEN RAND ( ) % HEX ( t1 . c22 ) - SUBSTRING_INDEX ( t1 . c22, +':A9SEZxtjN,fKN*zR' , 'V*vhJb}&c%Op,[T[S,j`F9NDsK;\'8 4;m" +P,ce}1r"3ID1DN' ) >> NULLIF ( t1 . c22 , -95 ) ELSE -2 END IS TRUE +FROM t1 . c22 >= EXISTS ( SELECT t2 . c57 AS c59 FROM ( SELECT CASE c24 WHEN +-103 THEN 85 ELSE 22 END IS TRUE AS c57 FROM t0 ) AS t2 WHERE MOD ( 64 , 46 ) = +CONVERT ( 73 , BINARY ) % RAND ( ) IS NOT NULL = -65 GROUP BY c57 , c22 , c22 +WINDOW w0 AS ( PARTITION BY t2 . c57 ) ) & PI ( ) ) ; +c9 +DROP TABLE t0; +# MDEV-32309 +SELECT +( WITH x ( x ) AS +( +WITH x ( x ) AS ( SELECT 1 ) SELECT ( SELECT x ) FROM x +) +SELECT x FROM x WHERE x IN ( SELECT NULL GROUP BY x ) +) as col1 ; +col1 +NULL +# MDEV-32391 +CREATE TABLE t0 ( c15 INT , c33 INT ) engine=innodb; +INSERT INTO t0 ( c15 ) WITH t1 AS ( SELECT SQRT ( 123 ) NOT +REGEXP MOD ( 91 , -121 ) = ALL ( SELECT c15 AS c33 FROM t0 ) AS c49 FROM t0 ) +SELECT t1 . c49 IS UNKNOWN AS c59 FROM t1 CROSS JOIN t0 AS t2 +WHERE t1 . c49 = + EXISTS ( SELECT -5839312620871436105 AS c17 GROUP BY c49 ) +BETWEEN -109 AND CHAR_LENGTH ( 2694839150676403988 ) - - LOWER ( -13 ) ; +DROP TABLE t0; +# MDEV-28620 +CREATE TABLE t1 ( a int); +INSERT INTO t1 VALUES (1),(2); +SELECT EXISTS +( SELECT 1 FROM t1 GROUP BY 1 IN (SELECT a FROM t1) +ORDER BY a + (SELECT 1 FROM t1 WHERE (1,2) NOT IN (SELECT 1,0)) +) as SUBQ; +ERROR 21000: Subquery returns more than 1 row +DROP TABLE t1; +# MDEV-30842 Item_subselect::get_cache_parameters and UBSAN member +# access within null pointer +CREATE TABLE x (x INT) ENGINE=InnoDB; +INSERT INTO x (x) VALUES (0); +INSERT INTO x (x) VALUES (x IN (SELECT (SELECT x FROM (SELECT x FROM +(SELECT 0 IN (SELECT x=0 FROM (SELECT x FROM (SELECT (SELECT (SELECT (SELECT +(SELECT 0 AS x) FROM x AS x) IN (SELECT 0 AS x) AS x) FROM x AS x) IN +(SELECT x WHERE x=0) AS x FROM x AS x) AS x) AS x GROUP BY x) AS x FROM x) AS x) +AS x) IN (SELECT 0 AS x) AS x FROM x)); +ERROR HY000: Table 'x' is specified twice, both as a target for 'INSERT' and as a separate source for data +DROP TABLE x; +# MDEV-28622: Item_subselect eliminated flag set but Item still +# evaluated/used. +CREATE TABLE t1 ( a int) ; +CREATE VIEW v1 (i) AS SELECT EXISTS(SELECT 1) FROM t1; +SELECT 1 FROM v1 WHERE i NOT IN (SELECT i = 0 FROM v1 WHERE i = -1 GROUP BY i); +1 +DROP TABLE t1; +DROP VIEW v1; +CREATE TABLE t(c1 INT); +SELECT 0 +WHERE 0 IN +( +SELECT 0 FROM +( +SELECT 0 IN +( +SELECT +( +SELECT c1 FROM t +) +) AS c +FROM t +) AS dt +WHERE c GROUP BY c +); +0 +DROP TABLE t; +create table t1 (a int, b int, c int); +insert into t1 select seq, seq, seq from seq_1_to_10; +create table t2 as select * from t1; +create table t20 as select * from t1; +create table t3 as select * from t1; +create view v2 as +select +a, b, (select max(c) from t20 where t20.a<=t2.a) as SUBQ1 +from t2; +explain +select +a, a in (select a from v2 where a>3 group by v2.SUBQ1) +from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 10 +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 10 Using where; Using temporary +4 DEPENDENT SUBQUERY t20 ALL NULL NULL NULL NULL 10 Using where +prepare s from ' +explain +select + a, a in (select a from v2 where a>3 group by v2.SUBQ1) +from t1'; +execute s; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 10 +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 10 Using where; Using temporary +4 DEPENDENT SUBQUERY t20 ALL NULL NULL NULL NULL 10 Using where +execute s; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 10 +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 10 Using where; Using temporary +4 DEPENDENT SUBQUERY t20 ALL NULL NULL NULL NULL 10 Using where +execute s; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 10 +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 10 Using where; Using temporary +4 DEPENDENT SUBQUERY t20 ALL NULL NULL NULL NULL 10 Using where +prepare s from ' +explain +select + a, a in (select a from v2 where a>3 and SUBQ1+1 group by v2.SUBQ1) +from t1'; +execute s; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 10 +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 10 Using where; Using temporary +4 DEPENDENT SUBQUERY t20 ALL NULL NULL NULL NULL 10 Using where +execute s; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 10 +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 10 Using where; Using temporary +4 DEPENDENT SUBQUERY t20 ALL NULL NULL NULL NULL 10 Using where +execute s; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 10 +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 10 Using where; Using temporary +4 DEPENDENT SUBQUERY t20 ALL NULL NULL NULL NULL 10 Using where +create procedure p1() +begin +explain +select +a, a in (select a from v2 where a>3 group by v2.SUBQ1) +from t1; +end// +create procedure p2() +begin +explain +select +a, a in (select a from v2 where a>3 and SUBQ1+1 group by v2.SUBQ1) +from t1; +end// +call p1(); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 10 +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 10 Using where; Using temporary +4 DEPENDENT SUBQUERY t20 ALL NULL NULL NULL NULL 10 Using where +call p1(); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 10 +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 10 Using where; Using temporary +4 DEPENDENT SUBQUERY t20 ALL NULL NULL NULL NULL 10 Using where +call p2(); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 10 +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 10 Using where; Using temporary +4 DEPENDENT SUBQUERY t20 ALL NULL NULL NULL NULL 10 Using where +call p2(); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 10 +2 MATERIALIZED t2 ALL NULL NULL NULL NULL 10 Using where; Using temporary +4 DEPENDENT SUBQUERY t20 ALL NULL NULL NULL NULL 10 Using where +drop procedure p1; +drop procedure p2; +drop view v2; +drop table t1,t2,t3,t20; +# end of 10.4 tests diff --git a/mysql-test/main/subselect_elimination.test b/mysql-test/main/subselect_elimination.test new file mode 100644 index 00000000000..9d973477b28 --- /dev/null +++ b/mysql-test/main/subselect_elimination.test @@ -0,0 +1,242 @@ +--source include/have_innodb.inc +--source include/have_sequence.inc + +--echo # +--echo # MDEV-28621 group by optimization incorrectly removing subquery where +--echo # subject buried in a function +--echo # + +CREATE TABLE t1 (i int) ; +INSERT INTO t1 VALUES (1),(2),(3); + +--error ER_SUBQUERY_NO_1_ROW +SELECT 1 FROM t1 +WHERE i in +( SELECT a+1 + FROM + (SELECT (SELECT i FROM (SELECT 1 FROM t1) dt) AS a FROM t1) dt2 + GROUP BY a +); + +DROP TABLE t1; + +create table t1 (a int, b int, c int); +insert into t1 select seq, seq, seq from seq_1_to_10; +create table t2 as select * from t1; +create table t20 as select * from t1; +create table t21 as select * from t1; +create table t3 as select * from t1; +select a, a in +( + select + ( + select max(c) from t20 where t20.a<=t2.a + ) as SUBQ1 from t2 group by SUBQ1+1 +) as COL +from t1; + +create view v2 as +select + a, b, + (select max(c) from t20 where t20.a<=t2.a) as SUBQ1, + (select max(c) from t21 where t21.a<=t2.a) as SUBQ2 +from t2; + +--echo # test partial elimination + +explain +select + a, + a in (select a from v2 where a>3 and v2.SUBQ2>=0 group by v2.SUBQ1, v2.SUBQ2) +from t1; + +--echo # test buried subselects in group by clause + +select a, a in +( + select + ( + select max(c) from t20 where t20.a<=t2.a + )*2 as SUBQ1 from t2 group by SUBQ1+1 +) as COL +from t1; + +drop view v2; +drop table t1, t2, t20, t21, t3; + +--echo # Testcase from MDEV-32311 + +# some warning duplicated using ps-protocol +--disable_warnings +SELECT ( + ( WITH x ( x ) AS + (SELECT ( SELECT 'x' UNION SELECT 'x' ) FROM ( SELECT ( 'x' ) ) x) + SELECT x FROM x + WHERE x IN ( ( SELECT 'x' AND x GROUP BY x ) ) + ) +) AS SUBQ; +--enable_warnings + +--echo # MDEV-32390: + +CREATE TABLE t0 ( c43 DECIMAL ( 31 ) DEFAULT ( 45 ) ) ; +INSERT INTO t0 VALUES ( 13 ) , ( 29 ) ; +ALTER TABLE t0 ADD COLUMN c24 INT AFTER c43 ; +INSERT INTO t0 VALUES ( DEFAULT , DEFAULT ) , ( DEFAULT , DEFAULT ) ; +SELECT t1 . c22 AS c9 FROM ( SELECT ( SELECT + EXISTS ( SELECT -128 AS c29 ) << +LOCATE ( t0 . c43 , t0 . c24 <= t0 . c24 NOT BETWEEN 4642475734208631537 AND +-108 , NULLIF ( 57 , -8 ) SOUNDS LIKE TRIM( TRAILING FROM 6107036197732405580 ) +) - t0 . c43 AS c57 FROM t0 LIMIT 1 ) AS c22 FROM t0 ) AS t1 HAVING TRIM( CASE +t1 . c22 WHEN -16 THEN RAND ( ) % HEX ( t1 . c22 ) - SUBSTRING_INDEX ( t1 . c22, +':A9SEZxtjN,fKN*zR' , 'V*vhJb}&c%Op,[T[S,j`F9NDsK;\'8 4;m" +P,ce}1r"3ID1DN' ) >> NULLIF ( t1 . c22 , -95 ) ELSE -2 END IS TRUE +FROM t1 . c22 >= EXISTS ( SELECT t2 . c57 AS c59 FROM ( SELECT CASE c24 WHEN +-103 THEN 85 ELSE 22 END IS TRUE AS c57 FROM t0 ) AS t2 WHERE MOD ( 64 , 46 ) = +CONVERT ( 73 , BINARY ) % RAND ( ) IS NOT NULL = -65 GROUP BY c57 , c22 , c22 +WINDOW w0 AS ( PARTITION BY t2 . c57 ) ) & PI ( ) ) ; + +DROP TABLE t0; + +--echo # MDEV-32309 + +SELECT + ( WITH x ( x ) AS + ( + WITH x ( x ) AS ( SELECT 1 ) SELECT ( SELECT x ) FROM x + ) + SELECT x FROM x WHERE x IN ( SELECT NULL GROUP BY x ) +) as col1 ; + +--echo # MDEV-32391 + +CREATE TABLE t0 ( c15 INT , c33 INT ) engine=innodb; +INSERT INTO t0 ( c15 ) WITH t1 AS ( SELECT SQRT ( 123 ) NOT +REGEXP MOD ( 91 , -121 ) = ALL ( SELECT c15 AS c33 FROM t0 ) AS c49 FROM t0 ) +SELECT t1 . c49 IS UNKNOWN AS c59 FROM t1 CROSS JOIN t0 AS t2 +WHERE t1 . c49 = + EXISTS ( SELECT -5839312620871436105 AS c17 GROUP BY c49 ) +BETWEEN -109 AND CHAR_LENGTH ( 2694839150676403988 ) - - LOWER ( -13 ) ; +DROP TABLE t0; + +--echo # MDEV-28620 +CREATE TABLE t1 ( a int); +INSERT INTO t1 VALUES (1),(2); + +--error ER_SUBQUERY_NO_1_ROW +SELECT EXISTS +( SELECT 1 FROM t1 GROUP BY 1 IN (SELECT a FROM t1) + ORDER BY a + (SELECT 1 FROM t1 WHERE (1,2) NOT IN (SELECT 1,0)) +) as SUBQ; +DROP TABLE t1; + +--echo # MDEV-30842 Item_subselect::get_cache_parameters and UBSAN member +--echo # access within null pointer + +CREATE TABLE x (x INT) ENGINE=InnoDB; +INSERT INTO x (x) VALUES (0); +--error ER_UPDATE_TABLE_USED +INSERT INTO x (x) VALUES (x IN (SELECT (SELECT x FROM (SELECT x FROM +(SELECT 0 IN (SELECT x=0 FROM (SELECT x FROM (SELECT (SELECT (SELECT (SELECT +(SELECT 0 AS x) FROM x AS x) IN (SELECT 0 AS x) AS x) FROM x AS x) IN +(SELECT x WHERE x=0) AS x FROM x AS x) AS x) AS x GROUP BY x) AS x FROM x) AS x) +AS x) IN (SELECT 0 AS x) AS x FROM x)); +DROP TABLE x; + +--echo # MDEV-28622: Item_subselect eliminated flag set but Item still +--echo # evaluated/used. + +CREATE TABLE t1 ( a int) ; +CREATE VIEW v1 (i) AS SELECT EXISTS(SELECT 1) FROM t1; + +SELECT 1 FROM v1 WHERE i NOT IN (SELECT i = 0 FROM v1 WHERE i = -1 GROUP BY i); +DROP TABLE t1; +DROP VIEW v1; + +CREATE TABLE t(c1 INT); + +SELECT 0 +WHERE 0 IN +( + SELECT 0 FROM + ( + SELECT 0 IN + ( + SELECT + ( + SELECT c1 FROM t + ) + ) AS c + FROM t + ) AS dt + WHERE c GROUP BY c +); + +DROP TABLE t; + +create table t1 (a int, b int, c int); +insert into t1 select seq, seq, seq from seq_1_to_10; +create table t2 as select * from t1; +create table t20 as select * from t1; +create table t3 as select * from t1; + +create view v2 as +select + a, b, (select max(c) from t20 where t20.a<=t2.a) as SUBQ1 +from t2; + +explain +select + a, a in (select a from v2 where a>3 group by v2.SUBQ1) +from t1; + +prepare s from ' +explain +select + a, a in (select a from v2 where a>3 group by v2.SUBQ1) +from t1'; + +execute s; +execute s; +execute s; + +prepare s from ' +explain +select + a, a in (select a from v2 where a>3 and SUBQ1+1 group by v2.SUBQ1) +from t1'; + +execute s; +execute s; +execute s; + +delimiter //; + +create procedure p1() +begin +explain +select + a, a in (select a from v2 where a>3 group by v2.SUBQ1) +from t1; +end// + +create procedure p2() +begin +explain +select + a, a in (select a from v2 where a>3 and SUBQ1+1 group by v2.SUBQ1) +from t1; +end// + +delimiter ;// + +call p1(); +call p1(); +call p2(); +call p2(); +drop procedure p1; +drop procedure p2; + + +drop view v2; +drop table t1,t2,t3,t20; + +--echo # end of 10.4 tests diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 54251e2d3ad..215a7113b71 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -671,37 +671,57 @@ void remove_redundant_subquery_clauses(st_select_lex *subq_select_lex) if (subq_select_lex->group_list.elements && !subq_select_lex->with_sum_func && !subq_select_lex->join->having) { + /* + Temporary workaround for MDEV-28621: Do not remove GROUP BY expression + if it has any subqueries in it. + */ + bool have_subquery= false; for (ORDER *ord= subq_select_lex->group_list.first; ord; ord= ord->next) { - /* - Do not remove the item if it is used in select list and then referred - from GROUP BY clause by its name or number. Example: - - select (select ... ) as SUBQ ... group by SUBQ - - Here SUBQ cannot be removed. - */ - if (!ord->in_field_list) + if ((*ord->item)->with_subquery()) { - (*ord->item)->walk(&Item::eliminate_subselect_processor, FALSE, NULL); - /* - Remove from the JOIN::all_fields list any reference to the elements - of the eliminated GROUP BY list unless it is 'in_field_list'. - This is needed in order not to confuse JOIN::make_aggr_tables_info() - when it constructs different structure for execution phase. - */ - List_iterator li(subq_select_lex->join->all_fields); - Item *item; - while ((item= li++)) - { - if (item == *ord->item) - li.remove(); - } + have_subquery= true; + break; } } - subq_select_lex->join->group_list= NULL; - subq_select_lex->group_list.empty(); - DBUG_PRINT("info", ("GROUP BY removed")); + + if (!have_subquery) + { + for (ORDER *ord= subq_select_lex->group_list.first; ord; ord= ord->next) + { + /* + Do not remove the item if it is used in select list and then referred + from GROUP BY clause by its name or number. Example: + + select (select ... ) as SUBQ ... group by SUBQ + + Here SUBQ cannot be removed. + */ + if (!ord->in_field_list) + { + /* + Not necessary due to workaround for MDEV-28621: + (*ord->item)->walk(&Item::eliminate_subselect_processor, FALSE, NULL); + */ + /* + Remove from the JOIN::all_fields list any reference to the elements + of the eliminated GROUP BY list unless it is 'in_field_list'. + This is needed in order not to confuse JOIN::make_aggr_tables_info() + when it constructs different structure for execution phase. + */ + List_iterator li(subq_select_lex->join->all_fields); + Item *item; + while ((item= li++)) + { + if (item == *ord->item) + li.remove(); + } + } + } + subq_select_lex->join->group_list= NULL; + subq_select_lex->group_list.empty(); + DBUG_PRINT("info", ("GROUP BY removed")); + } } /* From 22d4fbeb62ed75c5debdf61072ab3ac7e5cbe2c5 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Sat, 4 May 2024 10:02:21 +0200 Subject: [PATCH 552/568] Define CMake policy list, like it is done in 10.6+ Makes easier to add new policy to the list, and merge to newer versions- --- CMakeLists.txt | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 05bd751be21..5f3ab5289cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,22 +31,11 @@ ENDIF() # in RPM's: #set(CPACK_RPM_SPEC_MORE_DEFINE "%define __spec_install_post /bin/true") - -IF(POLICY CMP0022) - CMAKE_POLICY(SET CMP0022 NEW) -ENDIF() -IF(POLICY CMP0048) - CMAKE_POLICY(SET CMP0048 NEW) -ENDIF() -IF(POLICY CMP0054) - CMAKE_POLICY(SET CMP0054 NEW) -ENDIF() -IF(POLICY CMP0075) - CMAKE_POLICY(SET CMP0075 NEW) -ENDIF() -IF(POLICY CMP0069) - CMAKE_POLICY(SET CMP0069 NEW) -ENDIF() +FOREACH(p CMP0022 CMP0046 CMP0040 CMP0048 CMP0054 CMP0075 CMP0069 CMP0135) + IF(POLICY ${p}) + CMAKE_POLICY(SET ${p} NEW) + ENDIF() +ENDFOREACH() PROJECT(MySQL) From 6f003b5d0797b77822c4fac57f353a046faf2760 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Sat, 4 May 2024 10:06:11 +0200 Subject: [PATCH 553/568] MDEV-29955 post-fix - add CMake policy CMP0074, so ZLIB_ROOT is not ignored --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f3ab5289cf..6897fee02af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,7 +31,7 @@ ENDIF() # in RPM's: #set(CPACK_RPM_SPEC_MORE_DEFINE "%define __spec_install_post /bin/true") -FOREACH(p CMP0022 CMP0046 CMP0040 CMP0048 CMP0054 CMP0075 CMP0069 CMP0135) +FOREACH(p CMP0022 CMP0046 CMP0040 CMP0048 CMP0054 CMP0074 CMP0075 CMP0069 CMP0135) IF(POLICY ${p}) CMAKE_POLICY(SET ${p} NEW) ENDIF() From 30d3cfad69b45486f3c71dfb4de039b525abed70 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 8 May 2024 17:20:04 +0200 Subject: [PATCH 554/568] new C/C 3.3 --- debian/libmariadb-dev.install | 1 - libmariadb | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/debian/libmariadb-dev.install b/debian/libmariadb-dev.install index 08be370ca6d..c8f180789f2 100644 --- a/debian/libmariadb-dev.install +++ b/debian/libmariadb-dev.install @@ -19,7 +19,6 @@ usr/include/mariadb/mysql.h usr/include/mariadb/mysql/ usr/include/mariadb/mysql/client_plugin.h usr/include/mariadb/mysql/plugin_auth.h -usr/include/mariadb/mysql/plugin_auth_common.h usr/include/mariadb/mysql_com.h usr/include/mariadb/mysql_version.h usr/include/mariadb/mysqld_error.h diff --git a/libmariadb b/libmariadb index e714a674827..923a0092e35 160000 --- a/libmariadb +++ b/libmariadb @@ -1 +1 @@ -Subproject commit e714a674827fbb8373dd71da634dd04736d7b5a6 +Subproject commit 923a0092e3508b9567b0d695e72eb4d58bf15c8f From 1c425a8d854061d1987ad4ea352c7270652e31c4 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 8 May 2024 10:31:28 +0200 Subject: [PATCH 555/568] MDEV-33727 update test results followup for 13663cb5c455 --- mysql-test/suite/s3/mysqldump.result | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mysql-test/suite/s3/mysqldump.result b/mysql-test/suite/s3/mysqldump.result index 513dd397a17..81219a6fcc4 100644 --- a/mysql-test/suite/s3/mysqldump.result +++ b/mysql-test/suite/s3/mysqldump.result @@ -4,6 +4,7 @@ alter table t1 engine=S3; ##### # mysqldump with --copy-s3-tables=0 (by default) ### +/*!999999\- enable the sandbox mode */ ##### # mysqldump with --copy-s3-tables=0 (by default) XML ### @@ -15,6 +16,7 @@ alter table t1 engine=S3; ##### # mysqldump with --copy-s3-tables=1 ### +/*!999999\- enable the sandbox mode */ /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `t1` ( From 360a7ff7607ebe662b48fb4244fbde0c86de00ab Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 8 May 2024 10:52:28 +0200 Subject: [PATCH 556/568] fix tests after 349ca2be7437 .opt files, unlike combinations, accumulate, let's not overuse them --- mysql-test/include/innodb_rollback_on_timeout.inc | 1 - mysql-test/suite/gcol/inc/innodb_v_large_col.inc | 2 -- mysql-test/suite/innodb/r/innodb_timeout_rollback.result | 2 +- mysql-test/suite/innodb/t/innodb_timeout_rollback.test | 3 ++- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/mysql-test/include/innodb_rollback_on_timeout.inc b/mysql-test/include/innodb_rollback_on_timeout.inc index 274bbe12566..6be47397e4b 100644 --- a/mysql-test/include/innodb_rollback_on_timeout.inc +++ b/mysql-test/include/innodb_rollback_on_timeout.inc @@ -1,4 +1,3 @@ ---source include/have_innodb.inc # # Bug #24200: Provide backwards compatibility mode for 4.x "rollback on # transaction timeout" diff --git a/mysql-test/suite/gcol/inc/innodb_v_large_col.inc b/mysql-test/suite/gcol/inc/innodb_v_large_col.inc index 70e188635fa..8ba6920fea4 100644 --- a/mysql-test/suite/gcol/inc/innodb_v_large_col.inc +++ b/mysql-test/suite/gcol/inc/innodb_v_large_col.inc @@ -1,5 +1,3 @@ ---source include/have_innodb.inc - eval CREATE TABLE `t` ( `a` VARCHAR(10000), `b` VARCHAR(3000), `c` VARCHAR(14000) GENERATED ALWAYS AS (CONCAT(a,b)) VIRTUAL, diff --git a/mysql-test/suite/innodb/r/innodb_timeout_rollback.result b/mysql-test/suite/innodb/r/innodb_timeout_rollback.result index 30db5a21a4d..5dc7038aae0 100644 --- a/mysql-test/suite/innodb/r/innodb_timeout_rollback.result +++ b/mysql-test/suite/innodb/r/innodb_timeout_rollback.result @@ -41,4 +41,4 @@ a drop table t1; disconnect con1; disconnect con2; -End of 5.0 tests +# End of 5.0 tests diff --git a/mysql-test/suite/innodb/t/innodb_timeout_rollback.test b/mysql-test/suite/innodb/t/innodb_timeout_rollback.test index 44e8acdde13..aa282352356 100644 --- a/mysql-test/suite/innodb/t/innodb_timeout_rollback.test +++ b/mysql-test/suite/innodb/t/innodb_timeout_rollback.test @@ -1,4 +1,5 @@ +--source include/have_innodb.inc --source include/innodb_rollback_on_timeout.inc ---echo End of 5.0 tests +--echo # End of 5.0 tests From 938b92937247b7f581609ad45728b199f3354e1c Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 8 May 2024 18:29:45 +0200 Subject: [PATCH 557/568] don't wait indefinitely for signal handler in --bootstrap FreeBSD doesn't like it and hangs. As we don't wait for signal handler, let's disable SIGHUP in bootstrap too --- sql/mysqld.cc | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 93afee25dcf..cfc16209251 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2104,11 +2104,10 @@ static void wait_for_signal_thread_to_end() if (err && err != ESRCH) { sql_print_error("Failed to send kill signal to signal handler thread, " - "pthread_kill() errno: %d", - err); + "pthread_kill() errno: %d", err); } - if (i == n_waits && signal_thread_in_use) + if (i == n_waits && signal_thread_in_use && !opt_bootstrap) { sql_print_warning("Signal handler thread did not exit in a timely manner. " "Continuing to wait for it to stop.."); @@ -2895,10 +2894,8 @@ void init_signals(void) (void) sigemptyset(&set); my_sigset(SIGPIPE,SIG_IGN); sigaddset(&set,SIGPIPE); -#ifndef IGNORE_SIGHUP_SIGQUIT sigaddset(&set,SIGQUIT); sigaddset(&set,SIGHUP); -#endif sigaddset(&set,SIGTERM); /* Fix signals if blocked by parents (can happen on Mac OS X) */ @@ -2980,20 +2977,20 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused))) (void) sigaddset(&set,SIGINT); (void) pthread_sigmask(SIG_UNBLOCK,&set,NULL); } - (void) sigemptyset(&set); // Setup up SIGINT for debug + (void) sigemptyset(&set); #ifdef USE_ONE_SIGNAL_HAND (void) sigaddset(&set,THR_SERVER_ALARM); // For alarms #endif -#ifndef IGNORE_SIGHUP_SIGQUIT (void) sigaddset(&set,SIGQUIT); - (void) sigaddset(&set,SIGHUP); -#endif (void) sigaddset(&set,SIGTERM); (void) sigaddset(&set,SIGTSTP); /* Save pid to this process (or thread on Linux) */ if (!opt_bootstrap) + { + (void) sigaddset(&set,SIGHUP); create_pid_file(); + } /* signal to start_signal_handler that we are ready From 29c185bd771ac441121468b3850d6dc8d13b8a1f Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 8 May 2024 09:31:10 +0200 Subject: [PATCH 558/568] test needs to cleanup after itself --- mysql-test/main/mysql.test | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/mysql.test b/mysql-test/main/mysql.test index d71c0b59575..2f189e70b18 100644 --- a/mysql-test/main/mysql.test +++ b/mysql-test/main/mysql.test @@ -610,6 +610,7 @@ EOF create database `aa``bb````cc`; --exec $MYSQL < $MYSQLTEST_VARDIR/tmp/backticks.sql drop database `aa``bb````cc`; +--remove_file $MYSQLTEST_VARDIR/tmp/backticks.sql # # MySQL Bug#13639125 DELIMITER STRIPS THE NEXT NEW LINE IN A SQL STATEMENT @@ -620,6 +621,7 @@ delimiter <<" as a; EOF --exec $MYSQL < $MYSQLTEST_VARDIR/tmp/13639125.sql +--remove_file $MYSQLTEST_VARDIR/tmp/13639125.sql # # --skip-column-names and alignment @@ -702,7 +704,7 @@ select count(*) from t1; truncate table t1; --exec $MYSQL --disable-local-infile -e "/*q*/$ldli" select count(*) from t1; truncate table t1; drop table t1; - +--remove_file $MYSQLTEST_VARDIR/tmp/bug.sql --echo # --echo # MDEV-15538 '-N' Produce html output wrong From 887bb3f73555ff8a50138a580ca8308b9b5c069c Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 9 May 2024 00:04:20 +0200 Subject: [PATCH 559/568] columnstore 6.4.8-2 --- storage/columnstore/columnstore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/columnstore/columnstore b/storage/columnstore/columnstore index 07e7301631a..9f905c07b9c 160000 --- a/storage/columnstore/columnstore +++ b/storage/columnstore/columnstore @@ -1 +1 @@ -Subproject commit 07e7301631a5ac5ce86c3449d539eb4856119e1c +Subproject commit 9f905c07b9c5ba68590a7cec24e71859d4082d56 From 3a069644682e336e445039e48baae9693f9a08ee Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 9 May 2024 20:37:40 +0200 Subject: [PATCH 560/568] MDEV-33852 start the server after deb installation and fix installation of mysql.service on buster followup for ec09c034d84f --- debian/mariadb-server.install | 8 ++++---- debian/not-installed | 8 ++++---- debian/rules | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/debian/mariadb-server.install b/debian/mariadb-server.install index ba4d77ee0ec..322b770258c 100644 --- a/debian/mariadb-server.install +++ b/debian/mariadb-server.install @@ -9,12 +9,12 @@ etc/logrotate.d/mariadb etc/security/user_map.conf lib/*/security/pam_user_map.so lib/systemd/system/mariadb@bootstrap.service.d/use_galera_new_cluster.conf +lib/systemd/system/mariadb-extra@.socket +lib/systemd/system/mariadb.service +lib/systemd/system/mariadb@.service +lib/systemd/system/mariadb@.socket lib/systemd/system/mysql.service lib/systemd/system/mysqld.service -usr/share/mysql/systemd/mariadb-extra@.socket -usr/share/mysql/systemd/mariadb.service -usr/share/mysql/systemd/mariadb@.service -usr/share/mysql/systemd/mariadb@.socket support-files/rpm/enable_encryption.preset etc/mysql/mariadb.conf.d/99-enable-encryption.cnf.preset usr/bin/aria_chk usr/bin/aria_dump_log diff --git a/debian/not-installed b/debian/not-installed index a7dada6a434..814a5c9544d 100644 --- a/debian/not-installed +++ b/debian/not-installed @@ -5,11 +5,7 @@ etc/mysql/mariadb.conf.d/enable_encryption.preset # Debian packaging uses files etc/mysql/mariadb.conf.d/mysql-clients.cnf # Debian packaging uses files from debian/additions/mariadb.cnf.d/ etc/mysql/mariadb.conf.d/server.cnf # Debian packaging uses files from debian/additions/mariadb.cnf.d/ lib/systemd/system/mariadb-extra.socket # Installed by rules file -lib/systemd/system/mariadb-extra@.socket # Installed by rules file -lib/systemd/system/mariadb.service # Installed by rules file lib/systemd/system/mariadb.socket # Installed by rules file -lib/systemd/system/mariadb@.service # Installed by rules file -lib/systemd/system/mariadb@.socket # Installed by rules file usr/bin/mariadb-embedded # Shipping the embedded server in distro packaging does not make sense usr/bin/mysql_config # Debian packaging has mysql_config as symlink to mariadb_config usr/bin/mysql_embedded # Symlink to mariadb-embedded which is intentionally not included @@ -64,6 +60,10 @@ usr/share/mysql/policy/selinux/README # In MariaDB we don't want to use SELinux usr/share/mysql/policy/selinux/mariadb-server.fc # In MariaDB we don't want to use SELinux at the moment usr/share/mysql/policy/selinux/mariadb-server.te # In MariaDB we don't want to use SELinux at the moment usr/share/mysql/policy/selinux/mariadb.te # In MariaDB we don't want to use SELinux at the moment +usr/share/mysql/systemd/mariadb-extra@.socket # Installed by rules file +usr/share/mysql/systemd/mariadb.service # Installed by rules file +usr/share/mysql/systemd/mariadb@.service # Installed by rules file +usr/share/mysql/systemd/mariadb@.socket # Installed by rules file usr/share/mysql/systemd/mysql.service # Installed by rules file usr/share/mysql/systemd/mysqld.service # Installed by rules file usr/share/mysql/systemd/use_galera_new_cluster.conf diff --git a/debian/rules b/debian/rules index f28a37c00a4..4dbbe68ba23 100755 --- a/debian/rules +++ b/debian/rules @@ -179,7 +179,7 @@ override_dh_installsystemd: # Start MariaDB at sequence number 19 before 20 where apache, proftpd etc gets # started which might depend on a running database server. override_dh_installinit-arch: - dh_installinit --name=mariadb --no-start -- defaults 19 21 + dh_installinit --name=mariadb -- defaults 19 21 dh_systemd_start --restart-after-upgrade # Use custom server version string variable From 466ae1cf81f54b729058357bb19c4cf3982e1367 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 12 May 2024 11:25:32 +0200 Subject: [PATCH 561/568] sporadic failures of galera.galera_sst_mariabackup the test failed almost always in release (but not in debug) builds with --- galera_sst_mariabackup.result +++ galera_sst_mariabackup.reject @@ -5,7 +5,7 @@ connection node_1; select @@innodb_undo_tablespaces; @@innodb_undo_tablespaces -0 +3 connection node_2; select @@innodb_undo_tablespaces; @@innodb_undo_tablespaces and [Warning] InnoDB: Cannot change innodb_undo_tablespaces=0 because previous shutdown was not with innodb_fast_shutdown=0 because mariadbd *before this test* wasn't using innodb_fast_shutdown=0 Fix the bootstrap to use innodb_fast_shutdown=0 (and the bootstrap creates a starting point for any test that uses a .cnf file) followup for cac0fc97cca4 also, remove redundant include/have_innodb.inc --- mysql-test/include/galera_cluster.inc | 2 -- mysql-test/include/have_wsrep_enabled.inc | 2 -- mysql-test/mariadb-test-run.pl | 1 + mysql-test/suite/galera/t/galera_sst_mariabackup.test | 1 - mysql-test/suite/wsrep/t/pool_of_threads.test | 1 + 5 files changed, 2 insertions(+), 5 deletions(-) diff --git a/mysql-test/include/galera_cluster.inc b/mysql-test/include/galera_cluster.inc index 48b5bc631db..12708bfcc5f 100644 --- a/mysql-test/include/galera_cluster.inc +++ b/mysql-test/include/galera_cluster.inc @@ -13,10 +13,8 @@ if (!$galera_cluster_size) } --source include/galera_init.inc ---source include/have_innodb.inc --source include/galera_wait_ready.inc - --let $_galera_node= $galera_cluster_size while ($_galera_node != 1) diff --git a/mysql-test/include/have_wsrep_enabled.inc b/mysql-test/include/have_wsrep_enabled.inc index 7eb8b4372cf..33ff58b93ab 100644 --- a/mysql-test/include/have_wsrep_enabled.inc +++ b/mysql-test/include/have_wsrep_enabled.inc @@ -1,8 +1,6 @@ # To be used in a test which requires wsrep plugin to be ACTIVE and enabled # (i.e. wsrep_on=ON). It includes have_wsrep.inc. ---source include/have_innodb.inc - if (`SELECT COUNT(*)=0 FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME = 'wsrep_on' AND VARIABLE_VALUE='ON'`) { --skip Test requires wsrep_on=ON diff --git a/mysql-test/mariadb-test-run.pl b/mysql-test/mariadb-test-run.pl index 16a6af9f511..f8fa113e463 100755 --- a/mysql-test/mariadb-test-run.pl +++ b/mysql-test/mariadb-test-run.pl @@ -3103,6 +3103,7 @@ sub mysql_install_db { # starting from 10.0 bootstrap scripts require InnoDB mtr_add_arg($args, "--loose-innodb"); mtr_add_arg($args, "--loose-innodb-log-file-size=10M"); + mtr_add_arg($args, "--loose-innodb-fast-shutdown=0"); mtr_add_arg($args, "--disable-sync-frm"); mtr_add_arg($args, "--tmpdir=%s", "$opt_vardir/tmp/"); mtr_add_arg($args, "--core-file"); diff --git a/mysql-test/suite/galera/t/galera_sst_mariabackup.test b/mysql-test/suite/galera/t/galera_sst_mariabackup.test index 7dead49eb98..96f8b4dca55 100644 --- a/mysql-test/suite/galera/t/galera_sst_mariabackup.test +++ b/mysql-test/suite/galera/t/galera_sst_mariabackup.test @@ -1,6 +1,5 @@ --source include/big_test.inc --source include/galera_cluster.inc ---source include/have_innodb.inc --source include/have_mariabackup.inc # Save original auto_increment_offset values. diff --git a/mysql-test/suite/wsrep/t/pool_of_threads.test b/mysql-test/suite/wsrep/t/pool_of_threads.test index 8e95d0ca495..f035236da0e 100644 --- a/mysql-test/suite/wsrep/t/pool_of_threads.test +++ b/mysql-test/suite/wsrep/t/pool_of_threads.test @@ -1,3 +1,4 @@ +--source include/have_innodb.inc --source include/have_wsrep_enabled.inc --source include/have_binlog_format_row.inc From fe41171c96a0eee9c026f96d5971ed281e76d488 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Fri, 3 May 2024 13:40:06 +0300 Subject: [PATCH 562/568] MDEV-33533: Crash at execution of DELETE when trying to use rowid filter (Based on original patch by Oleksandr Byelkin) Multi-table DELETE can execute via "buffered" mode: at phase #1 it collects rowids of rows to be deleted, then at phase #2 in multi_delete::do_deletes() it calls handler->rnd_pos() to read rows to be deleted and deletes them. The problem occurred when phase #1 used Rowid Filter on the table that phase #2 would be deleting from. In InnoDB, h->rnd_init(scan=false) and h->rnd_pos() is an index scan over PK under the hood. So, at phase #2 ha_innobase::rnd_init() would try to use the Rowid Filter and hit an assertion inside ha_innobase::rnd_init(). Note that multi-table UPDATE works similarly but was not affected, because patch for MDEV-7487 added code to disable rowid filter for phase #2 in multi_update::do_updates(). This patch changes the approach: - It makes InnoDB not use Rowid Filter in rnd_pos() scans: it is disabled in ha_innobase::rnd_init() and enabled back in ha_innobase::rnd_end(). - multi_update::do_updates() no longer disables Rowid Filter for phase#2 as it is no longer necessary. --- mysql-test/main/delete_innodb.result | 514 ++++++++++++++++++++++++++ mysql-test/main/delete_innodb.test | 171 +++++++++ mysql-test/main/update_innodb.result | 108 ++++++ mysql-test/main/update_innodb.test | 47 +++ sql/sql_update.cc | 8 +- storage/innobase/handler/ha_innodb.cc | 20 +- storage/innobase/handler/ha_innodb.h | 4 + 7 files changed, 863 insertions(+), 9 deletions(-) diff --git a/mysql-test/main/delete_innodb.result b/mysql-test/main/delete_innodb.result index 662c0c558ea..c171e8d0fe0 100644 --- a/mysql-test/main/delete_innodb.result +++ b/mysql-test/main/delete_innodb.result @@ -69,4 +69,518 @@ c1 5 6 DROP TABLE t1, t2; +# +# MDEV-33533: multi-delete using rowid filter +# +set @save_default_storage_engine=@@default_storage_engine; +set default_storage_engine=InnoDB; +CREATE DATABASE dbt3_s001; +use dbt3_s001; +create index i_n_name on nation(n_name); +analyze table +nation, lineitem, customer, orders, part, supplier, partsupp, region +persistent for all; +Table Op Msg_type Msg_text +dbt3_s001.nation analyze status Engine-independent statistics collected +dbt3_s001.nation analyze status OK +dbt3_s001.lineitem analyze status Engine-independent statistics collected +dbt3_s001.lineitem analyze status OK +dbt3_s001.customer analyze status Engine-independent statistics collected +dbt3_s001.customer analyze status OK +dbt3_s001.orders analyze status Engine-independent statistics collected +dbt3_s001.orders analyze status OK +dbt3_s001.part analyze status Engine-independent statistics collected +dbt3_s001.part analyze status OK +dbt3_s001.supplier analyze status Engine-independent statistics collected +dbt3_s001.supplier analyze status OK +dbt3_s001.partsupp analyze status Engine-independent statistics collected +dbt3_s001.partsupp analyze status OK +dbt3_s001.region analyze status Engine-independent statistics collected +dbt3_s001.region analyze status OK +explain +select o_orderkey, o_totalprice from orders, customer, nation where o_orderDATE between '1992-01-01' and '1992-06-30' and +o_custkey = c_custkey and +c_nationkey = n_nationkey and +n_name='PERU'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using where; Using index +1 SIMPLE customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey 6 Using index +1 SIMPLE orders ref|filter i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 15 (8%) Using where; Using rowid filter +explain format=json +select o_orderkey, o_totalprice from orders, customer, nation where o_orderDATE between '1992-01-01' and '1992-06-30' and +o_custkey = c_custkey and +c_nationkey = n_nationkey and +n_name='PERU'; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost": "COST_REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "nation", + "access_type": "ref", + "possible_keys": ["PRIMARY", "i_n_name"], + "key": "i_n_name", + "key_length": "26", + "used_key_parts": ["n_name"], + "ref": ["const"], + "loops": 1, + "rows": 1, + "cost": "COST_REPLACED", + "filtered": 100, + "attached_condition": "nation.n_name = 'PERU'", + "using_index": true + } + }, + { + "table": { + "table_name": "customer", + "access_type": "ref", + "possible_keys": ["PRIMARY", "i_c_nationkey"], + "key": "i_c_nationkey", + "key_length": "5", + "used_key_parts": ["c_nationkey"], + "ref": ["dbt3_s001.nation.n_nationkey"], + "loops": 1, + "rows": 6, + "cost": "COST_REPLACED", + "filtered": 100, + "using_index": true + } + }, + { + "table": { + "table_name": "orders", + "access_type": "ref", + "possible_keys": ["i_o_orderdate", "i_o_custkey"], + "key": "i_o_custkey", + "key_length": "5", + "used_key_parts": ["o_custkey"], + "ref": ["dbt3_s001.customer.c_custkey"], + "rowid_filter": { + "range": { + "key": "i_o_orderdate", + "used_key_parts": ["o_orderDATE"] + }, + "rows": 119, + "selectivity_pct": 7.933333333 + }, + "loops": 6, + "rows": 15, + "cost": "COST_REPLACED", + "filtered": 7.933333397, + "attached_condition": "orders.o_orderDATE between '1992-01-01' and '1992-06-30'" + } + } + ] + } +} +select o_orderkey, o_totalprice from orders, customer, nation where o_orderDATE between '1992-01-01' and '1992-06-30' and +o_custkey = c_custkey and +c_nationkey = n_nationkey and +n_name='PERU'; +o_orderkey o_totalprice +1729 12137.76 +2880 145761.99 +3142 16030.15 +5095 184583.99 +5121 150334.57 +5382 138423.03 +644 201268.06 +737 12984.85 +create table t as +select orders.* from orders, customer, nation where o_orderDATE between '1992-01-01' and '1992-06-30' and +o_custkey = c_custkey and +c_nationkey = n_nationkey and +n_name='PERU'; +explain +delete from orders using orders, customer, nation where o_orderDATE between '1992-01-01' and '1992-06-30' and +o_custkey = c_custkey and +c_nationkey = n_nationkey and +n_name='PERU'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using where; Using index +1 SIMPLE customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey 6 Using index +1 SIMPLE orders ref|filter i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 15 (8%) Using where; Using rowid filter +explain format=json +delete from orders using orders, customer, nation where o_orderDATE between '1992-01-01' and '1992-06-30' and +o_custkey = c_custkey and +c_nationkey = n_nationkey and +n_name='PERU'; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost": "COST_REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "nation", + "access_type": "ref", + "possible_keys": ["PRIMARY", "i_n_name"], + "key": "i_n_name", + "key_length": "26", + "used_key_parts": ["n_name"], + "ref": ["const"], + "loops": 1, + "rows": 1, + "cost": "COST_REPLACED", + "filtered": 100, + "attached_condition": "nation.n_name = 'PERU'", + "using_index": true + } + }, + { + "table": { + "table_name": "customer", + "access_type": "ref", + "possible_keys": ["PRIMARY", "i_c_nationkey"], + "key": "i_c_nationkey", + "key_length": "5", + "used_key_parts": ["c_nationkey"], + "ref": ["dbt3_s001.nation.n_nationkey"], + "loops": 1, + "rows": 6, + "cost": "COST_REPLACED", + "filtered": 100, + "using_index": true + } + }, + { + "table": { + "table_name": "orders", + "access_type": "ref", + "possible_keys": ["i_o_orderdate", "i_o_custkey"], + "key": "i_o_custkey", + "key_length": "5", + "used_key_parts": ["o_custkey"], + "ref": ["dbt3_s001.customer.c_custkey"], + "rowid_filter": { + "range": { + "key": "i_o_orderdate", + "used_key_parts": ["o_orderDATE"] + }, + "rows": 119, + "selectivity_pct": 7.933333333 + }, + "loops": 6, + "rows": 15, + "cost": "COST_REPLACED", + "filtered": 7.933333397, + "attached_condition": "orders.o_orderDATE between '1992-01-01' and '1992-06-30'" + } + } + ] + } +} +delete from orders using orders, customer, nation where o_orderDATE between '1992-01-01' and '1992-06-30' and +o_custkey = c_custkey and +c_nationkey = n_nationkey and +n_name='PERU'; +select o_orderkey, o_totalprice from orders, customer, nation where o_orderDATE between '1992-01-01' and '1992-06-30' and +o_custkey = c_custkey and +c_nationkey = n_nationkey and +n_name='PERU'; +o_orderkey o_totalprice +insert into orders select * from t; +select o_orderkey, o_totalprice from orders, customer, nation where o_orderDATE between '1992-01-01' and '1992-06-30' and +o_custkey = c_custkey and +c_nationkey = n_nationkey and +n_name='PERU'; +o_orderkey o_totalprice +1729 12137.76 +2880 145761.99 +3142 16030.15 +5095 184583.99 +5121 150334.57 +5382 138423.03 +644 201268.06 +737 12984.85 +prepare stmt from " +delete from orders using orders, customer, nation where o_orderDATE between '1992-01-01' and '1992-06-30' and +o_custkey = c_custkey and +c_nationkey = n_nationkey and +n_name='PERU'; +"; +execute stmt; +select o_orderkey, o_totalprice from orders, customer, nation where o_orderDATE between '1992-01-01' and '1992-06-30' and +o_custkey = c_custkey and +c_nationkey = n_nationkey and +n_name='PERU'; +o_orderkey o_totalprice +insert into orders select * from t; +select o_orderkey, o_totalprice from orders, customer, nation where o_orderDATE between '1992-01-01' and '1992-06-30' and +o_custkey = c_custkey and +c_nationkey = n_nationkey and +n_name='PERU'; +o_orderkey o_totalprice +1729 12137.76 +2880 145761.99 +3142 16030.15 +5095 184583.99 +5121 150334.57 +5382 138423.03 +644 201268.06 +737 12984.85 +execute stmt; +select o_orderkey, o_totalprice from orders, customer, nation where o_orderDATE between '1992-01-01' and '1992-06-30' and +o_custkey = c_custkey and +c_nationkey = n_nationkey and +n_name='PERU'; +o_orderkey o_totalprice +insert into orders select * from t; +select o_orderkey, o_totalprice from orders, customer, nation where o_orderDATE between '1992-01-01' and '1992-06-30' and +o_custkey = c_custkey and +c_nationkey = n_nationkey and +n_name='PERU'; +o_orderkey o_totalprice +1729 12137.76 +2880 145761.99 +3142 16030.15 +5095 184583.99 +5121 150334.57 +5382 138423.03 +644 201268.06 +737 12984.85 +deallocate prepare stmt; +drop table t; +explain +select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and +o_custkey in (select c_custkey from customer +where c_nationkey in (select n_nationkey from nation +where n_name='PERU')); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using where; Using index +1 PRIMARY customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey 6 Using index +1 PRIMARY orders ref|filter i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 15 (8%) Using where; Using rowid filter +explain format=json +select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and +o_custkey in (select c_custkey from customer +where c_nationkey in (select n_nationkey from nation +where n_name='PERU')); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost": "COST_REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "nation", + "access_type": "ref", + "possible_keys": ["PRIMARY", "i_n_name"], + "key": "i_n_name", + "key_length": "26", + "used_key_parts": ["n_name"], + "ref": ["const"], + "loops": 1, + "rows": 1, + "cost": "COST_REPLACED", + "filtered": 100, + "attached_condition": "nation.n_name = 'PERU'", + "using_index": true + } + }, + { + "table": { + "table_name": "customer", + "access_type": "ref", + "possible_keys": ["PRIMARY", "i_c_nationkey"], + "key": "i_c_nationkey", + "key_length": "5", + "used_key_parts": ["c_nationkey"], + "ref": ["dbt3_s001.nation.n_nationkey"], + "loops": 1, + "rows": 6, + "cost": "COST_REPLACED", + "filtered": 100, + "using_index": true + } + }, + { + "table": { + "table_name": "orders", + "access_type": "ref", + "possible_keys": ["i_o_orderdate", "i_o_custkey"], + "key": "i_o_custkey", + "key_length": "5", + "used_key_parts": ["o_custkey"], + "ref": ["dbt3_s001.customer.c_custkey"], + "rowid_filter": { + "range": { + "key": "i_o_orderdate", + "used_key_parts": ["o_orderDATE"] + }, + "rows": 119, + "selectivity_pct": 7.933333333 + }, + "loops": 6, + "rows": 15, + "cost": "COST_REPLACED", + "filtered": 7.933333397, + "attached_condition": "orders.o_orderDATE between '1992-01-01' and '1992-06-30'" + } + } + ] + } +} +select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and +o_custkey in (select c_custkey from customer +where c_nationkey in (select n_nationkey from nation +where n_name='PERU')); +o_orderkey o_totalprice +1729 12137.76 +2880 145761.99 +3142 16030.15 +5095 184583.99 +5121 150334.57 +5382 138423.03 +644 201268.06 +737 12984.85 +create table t as +select * from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and +o_custkey in (select c_custkey from customer +where c_nationkey in (select n_nationkey from nation +where n_name='PERU')); +explain +delete from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and +o_custkey in (select c_custkey from customer +where c_nationkey in (select n_nationkey from nation +where n_name='PERU')); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using where; Using index +1 PRIMARY customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey 6 Using index +1 PRIMARY orders ref|filter i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 15 (8%) Using where; Using rowid filter +explain format=json +delete from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and +o_custkey in (select c_custkey from customer +where c_nationkey in (select n_nationkey from nation +where n_name='PERU')); +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost": "COST_REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "nation", + "access_type": "ref", + "possible_keys": ["PRIMARY", "i_n_name"], + "key": "i_n_name", + "key_length": "26", + "used_key_parts": ["n_name"], + "ref": ["const"], + "loops": 1, + "rows": 1, + "cost": "COST_REPLACED", + "filtered": 100, + "attached_condition": "nation.n_name = 'PERU'", + "using_index": true + } + }, + { + "table": { + "table_name": "customer", + "access_type": "ref", + "possible_keys": ["PRIMARY", "i_c_nationkey"], + "key": "i_c_nationkey", + "key_length": "5", + "used_key_parts": ["c_nationkey"], + "ref": ["dbt3_s001.nation.n_nationkey"], + "loops": 1, + "rows": 6, + "cost": "COST_REPLACED", + "filtered": 100, + "using_index": true + } + }, + { + "table": { + "table_name": "orders", + "access_type": "ref", + "possible_keys": ["i_o_orderdate", "i_o_custkey"], + "key": "i_o_custkey", + "key_length": "5", + "used_key_parts": ["o_custkey"], + "ref": ["dbt3_s001.customer.c_custkey"], + "rowid_filter": { + "range": { + "key": "i_o_orderdate", + "used_key_parts": ["o_orderDATE"] + }, + "rows": 119, + "selectivity_pct": 7.933333333 + }, + "loops": 6, + "rows": 15, + "cost": "COST_REPLACED", + "filtered": 7.933333397, + "attached_condition": "orders.o_orderDATE between '1992-01-01' and '1992-06-30'" + } + } + ] + } +} +delete from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and +o_custkey in (select c_custkey from customer +where c_nationkey in (select n_nationkey from nation +where n_name='PERU')); +select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and +o_custkey in (select c_custkey from customer +where c_nationkey in (select n_nationkey from nation +where n_name='PERU')); +o_orderkey o_totalprice +insert into orders select * from t; +select o_orderkey, o_totalprice from orders where o_orderDATE between '1992-01-01' and '1992-06-30' and +o_custkey in (select c_custkey from customer +where c_nationkey in (select n_nationkey from nation +where n_name='PERU')); +o_orderkey o_totalprice +1729 12137.76 +2880 145761.99 +3142 16030.15 +5095 184583.99 +5121 150334.57 +5382 138423.03 +644 201268.06 +737 12984.85 +drop table t; +DROP DATABASE dbt3_s001; +set default_storage_engine=@save_default_storage_engine; +# +# Additional tests of first table and rowid filter +# +CREATE DATABASE dbt3_s001; +use dbt3_s001; +set @save_default_storage_engine=@@default_storage_engine; +set default_storage_engine=InnoDB; +CREATE INDEX i_l_quantity ON lineitem(l_quantity); +CREATE INDEX i_o_totalprice ON orders(o_totalprice); +ANALYZE TABLE lineitem, orders; +Table Op Msg_type Msg_text +dbt3_s001.lineitem analyze status Engine-independent statistics collected +dbt3_s001.lineitem analyze status OK +dbt3_s001.orders analyze status Engine-independent statistics collected +dbt3_s001.orders analyze status OK +set optimizer_use_condition_selectivity=2; +create table second(s_receiptDATE date, filler char(100), key(s_receiptDATE)) ; +insert into second select date_add(l_receiptDATE, interval 1 day), 'helllo' from lineitem ; +select count(*) from lineitem, second WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND l_quantity > 47 and second.s_receiptDATE = date_add(l_receiptDATE, interval 1 day); +count(*) +114 +# lineitem should be first and with "Using rowid filter" +explain delete lineitem FROM lineitem, second WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND l_quantity > 47 and second.s_receiptDATE = date_add(l_receiptDATE, interval 1 day); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE lineitem range|filter i_l_shipdate,i_l_quantity i_l_quantity|i_l_shipdate 9|4 NULL 349 (8%) Using where; Using rowid filter +1 SIMPLE second ref s_receiptDATE s_receiptDATE 4 func 1 Using where; Using index +delete lineitem FROM lineitem, second WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND l_quantity > 47 and second.s_receiptDATE = date_add(l_receiptDATE, interval 1 day); +# Should be 0 +select count(*) from lineitem, second WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND l_quantity > 47 and second.s_receiptDATE = date_add(l_receiptDATE, interval 1 day); +count(*) +0 +drop database dbt3_s001; +set default_storage_engine=@save_default_storage_engine; End of 11.1 tests diff --git a/mysql-test/main/delete_innodb.test b/mysql-test/main/delete_innodb.test index e29cf3fa922..86c32732ad9 100644 --- a/mysql-test/main/delete_innodb.test +++ b/mysql-test/main/delete_innodb.test @@ -49,4 +49,175 @@ analyze DELETE FROM t1 WHERE c1 IN (select c2 from t2) ORDER BY c1 limit 1; select * from t1; DROP TABLE t1, t2; + +--echo # +--echo # MDEV-33533: multi-delete using rowid filter +--echo # + +set @save_default_storage_engine=@@default_storage_engine; +set default_storage_engine=InnoDB; + +CREATE DATABASE dbt3_s001; + +use dbt3_s001; + +--disable_query_log +--disable_result_log +--disable_warnings +--source include/dbt3_s001.inc +--enable_warnings +--enable_result_log +--enable_query_log + +create index i_n_name on nation(n_name); +analyze table + nation, lineitem, customer, orders, part, supplier, partsupp, region +persistent for all; + +let $c1= + o_orderDATE between '1992-01-01' and '1992-06-30' and + o_custkey = c_custkey and + c_nationkey = n_nationkey and + n_name='PERU'; + +eval +explain +select o_orderkey, o_totalprice from orders, customer, nation where $c1; +--source include/explain-no-costs.inc +eval +explain format=json +select o_orderkey, o_totalprice from orders, customer, nation where $c1; +--sorted_result +eval +select o_orderkey, o_totalprice from orders, customer, nation where $c1; +eval +create table t as +select orders.* from orders, customer, nation where $c1; + +eval +explain +delete from orders using orders, customer, nation where $c1; +--source include/explain-no-costs.inc +eval +explain format=json +delete from orders using orders, customer, nation where $c1; +eval +delete from orders using orders, customer, nation where $c1; +eval +select o_orderkey, o_totalprice from orders, customer, nation where $c1; + +insert into orders select * from t; +--sorted_result +eval +select o_orderkey, o_totalprice from orders, customer, nation where $c1; + +eval +prepare stmt from " +delete from orders using orders, customer, nation where $c1; +"; + +execute stmt; +--sorted_result +eval +select o_orderkey, o_totalprice from orders, customer, nation where $c1; +insert into orders select * from t; +--sorted_result +eval +select o_orderkey, o_totalprice from orders, customer, nation where $c1; + +execute stmt; +--sorted_result +eval +select o_orderkey, o_totalprice from orders, customer, nation where $c1; +insert into orders select * from t; +--sorted_result +eval +select o_orderkey, o_totalprice from orders, customer, nation where $c1; + +deallocate prepare stmt; + +drop table t; + +let $c1= + o_orderDATE between '1992-01-01' and '1992-06-30' and + o_custkey in (select c_custkey from customer + where c_nationkey in (select n_nationkey from nation + where n_name='PERU')); + +eval +explain +select o_orderkey, o_totalprice from orders where $c1; +--source include/explain-no-costs.inc +eval +explain format=json +select o_orderkey, o_totalprice from orders where $c1; +--sorted_result +eval +select o_orderkey, o_totalprice from orders where $c1; +eval +create table t as +select * from orders where $c1; + +eval +explain +delete from orders where $c1; +--source include/explain-no-costs.inc +eval +explain format=json +delete from orders where $c1; +eval +delete from orders where $c1; +eval +select o_orderkey, o_totalprice from orders where $c1; + +insert into orders select * from t; +--sorted_result +eval +select o_orderkey, o_totalprice from orders where $c1; +drop table t; + +DROP DATABASE dbt3_s001; + +set default_storage_engine=@save_default_storage_engine; + +--echo # +--echo # Additional tests of first table and rowid filter +--echo # + +CREATE DATABASE dbt3_s001; + +use dbt3_s001; + +set @save_default_storage_engine=@@default_storage_engine; +set default_storage_engine=InnoDB; + +--disable_query_log +--disable_result_log +--disable_warnings +--source include/dbt3_s001.inc +--enable_warnings +--enable_result_log +--enable_query_log + +CREATE INDEX i_l_quantity ON lineitem(l_quantity); +CREATE INDEX i_o_totalprice ON orders(o_totalprice); +ANALYZE TABLE lineitem, orders; +set optimizer_use_condition_selectivity=2; +create table second(s_receiptDATE date, filler char(100), key(s_receiptDATE)) ; +insert into second select date_add(l_receiptDATE, interval 1 day), 'helllo' from lineitem ; + +select count(*) from lineitem, second WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND l_quantity > 47 and second.s_receiptDATE = date_add(l_receiptDATE, interval 1 day); + +--echo # lineitem should be first and with "Using rowid filter" +explain delete lineitem FROM lineitem, second WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND l_quantity > 47 and second.s_receiptDATE = date_add(l_receiptDATE, interval 1 day); + +delete lineitem FROM lineitem, second WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND l_quantity > 47 and second.s_receiptDATE = date_add(l_receiptDATE, interval 1 day); + +--echo # Should be 0 +select count(*) from lineitem, second WHERE l_shipdate BETWEEN '1997-01-01' AND '1997-06-30' AND l_quantity > 47 and second.s_receiptDATE = date_add(l_receiptDATE, interval 1 day); + +drop database dbt3_s001; +set default_storage_engine=@save_default_storage_engine; + + --echo End of 11.1 tests diff --git a/mysql-test/main/update_innodb.result b/mysql-test/main/update_innodb.result index beab54833d1..fbcbf78d865 100644 --- a/mysql-test/main/update_innodb.result +++ b/mysql-test/main/update_innodb.result @@ -143,3 +143,111 @@ connection default; disconnect con2; drop table t1,t2; # End of 10.4 tests +# +# MDEV-33533: multi-delete using rowid filter +# +set @save_default_storage_engine=@@default_storage_engine; +set default_storage_engine=InnoDB; +CREATE DATABASE dbt3_s001; +use dbt3_s001; +create index i_n_name on nation(n_name); +analyze table +nation, lineitem, customer, orders, part, supplier, partsupp, region +persistent for all; +Table Op Msg_type Msg_text +dbt3_s001.nation analyze status Engine-independent statistics collected +dbt3_s001.nation analyze status OK +dbt3_s001.lineitem analyze status Engine-independent statistics collected +dbt3_s001.lineitem analyze status OK +dbt3_s001.customer analyze status Engine-independent statistics collected +dbt3_s001.customer analyze status OK +dbt3_s001.orders analyze status Engine-independent statistics collected +dbt3_s001.orders analyze status OK +dbt3_s001.part analyze status Engine-independent statistics collected +dbt3_s001.part analyze status OK +dbt3_s001.supplier analyze status Engine-independent statistics collected +dbt3_s001.supplier analyze status OK +dbt3_s001.partsupp analyze status Engine-independent statistics collected +dbt3_s001.partsupp analyze status OK +dbt3_s001.region analyze status Engine-independent statistics collected +dbt3_s001.region analyze status OK +explain +update orders, customer, nation set orders.o_comment = "+++" where o_orderDATE between '1992-01-01' and '1992-06-30' and +o_custkey = c_custkey and c_nationkey = n_nationkey and n_name='PERU'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE nation ref PRIMARY,i_n_name i_n_name 26 const 1 Using where; Using index +1 SIMPLE customer ref PRIMARY,i_c_nationkey i_c_nationkey 5 dbt3_s001.nation.n_nationkey 6 Using index +1 SIMPLE orders ref|filter i_o_orderdate,i_o_custkey i_o_custkey|i_o_orderdate 5|4 dbt3_s001.customer.c_custkey 15 (8%) Using where; Using rowid filter +explain format=json +update orders, customer, nation set orders.o_comment = "+++" where o_orderDATE between '1992-01-01' and '1992-06-30' and +o_custkey = c_custkey and c_nationkey = n_nationkey and n_name='PERU'; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost": "COST_REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "nation", + "access_type": "ref", + "possible_keys": ["PRIMARY", "i_n_name"], + "key": "i_n_name", + "key_length": "26", + "used_key_parts": ["n_name"], + "ref": ["const"], + "loops": 1, + "rows": 1, + "cost": "COST_REPLACED", + "filtered": 100, + "attached_condition": "nation.n_name = 'PERU'", + "using_index": true + } + }, + { + "table": { + "table_name": "customer", + "access_type": "ref", + "possible_keys": ["PRIMARY", "i_c_nationkey"], + "key": "i_c_nationkey", + "key_length": "5", + "used_key_parts": ["c_nationkey"], + "ref": ["dbt3_s001.nation.n_nationkey"], + "loops": 1, + "rows": 6, + "cost": "COST_REPLACED", + "filtered": 100, + "using_index": true + } + }, + { + "table": { + "table_name": "orders", + "access_type": "ref", + "possible_keys": ["i_o_orderdate", "i_o_custkey"], + "key": "i_o_custkey", + "key_length": "5", + "used_key_parts": ["o_custkey"], + "ref": ["dbt3_s001.customer.c_custkey"], + "rowid_filter": { + "range": { + "key": "i_o_orderdate", + "used_key_parts": ["o_orderDATE"] + }, + "rows": 119, + "selectivity_pct": 7.933333333 + }, + "loops": 6, + "rows": 15, + "cost": "COST_REPLACED", + "filtered": 7.933333397, + "attached_condition": "orders.o_orderDATE between '1992-01-01' and '1992-06-30'" + } + } + ] + } +} +update orders, customer, nation set orders.o_comment = "+++" where o_orderDATE between '1992-01-01' and '1992-06-30' and +o_custkey = c_custkey and c_nationkey = n_nationkey and n_name='PERU'; +DROP DATABASE dbt3_s001; +set default_storage_engine=@save_default_storage_engine; diff --git a/mysql-test/main/update_innodb.test b/mysql-test/main/update_innodb.test index c213ba8b331..ad728fb8e28 100644 --- a/mysql-test/main/update_innodb.test +++ b/mysql-test/main/update_innodb.test @@ -162,3 +162,50 @@ drop table t1,t2; --enable_view_protocol --echo # End of 10.4 tests + +--echo # +--echo # MDEV-33533: multi-delete using rowid filter +--echo # + +set @save_default_storage_engine=@@default_storage_engine; +set default_storage_engine=InnoDB; + +CREATE DATABASE dbt3_s001; + +use dbt3_s001; + +--disable_query_log +--disable_result_log +--disable_warnings +--source include/dbt3_s001.inc +--enable_warnings +--enable_result_log +--enable_query_log + +create index i_n_name on nation(n_name); +analyze table + nation, lineitem, customer, orders, part, supplier, partsupp, region +persistent for all; + +let $c1= + o_orderDATE between '1992-01-01' and '1992-06-30' and + o_custkey = c_custkey and + c_nationkey = n_nationkey and + n_name='PERU'; + + +explain +update orders, customer, nation set orders.o_comment = "+++" where o_orderDATE between '1992-01-01' and '1992-06-30' and + o_custkey = c_custkey and c_nationkey = n_nationkey and n_name='PERU'; +--source include/explain-no-costs.inc +explain format=json +update orders, customer, nation set orders.o_comment = "+++" where o_orderDATE between '1992-01-01' and '1992-06-30' and + o_custkey = c_custkey and c_nationkey = n_nationkey and n_name='PERU'; + +update orders, customer, nation set orders.o_comment = "+++" where o_orderDATE between '1992-01-01' and '1992-06-30' and + o_custkey = c_custkey and c_nationkey = n_nationkey and n_name='PERU'; + +DROP DATABASE dbt3_s001; + +set default_storage_engine=@save_default_storage_engine; + diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 5ecd7f8ac22..0667d12a9e0 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -2502,8 +2502,6 @@ int multi_update::do_updates() table = cur_table->table; if (table == table_to_update) continue; // Already updated - if (table->file->pushed_rowid_filter) - table->file->disable_pushed_rowid_filter(); org_updated= updated; tmp_table= tmp_tables[cur_table->shared]; tmp_table->file->extra(HA_EXTRA_CACHE); // Change to read cache @@ -2697,9 +2695,7 @@ int multi_update::do_updates() (void) tmp_table->file->ha_rnd_end(); check_opt_it.rewind(); while (TABLE *tbl= check_opt_it++) - tbl->file->ha_rnd_end(); - if (table->file->save_pushed_rowid_filter) - table->file->enable_pushed_rowid_filter(); + tbl->file->ha_rnd_end(); } DBUG_RETURN(0); @@ -2710,8 +2706,6 @@ err: } err2: - if (table->file->save_pushed_rowid_filter) - table->file->enable_pushed_rowid_filter(); if (table->file->inited) (void) table->file->ha_rnd_end(); if (tmp_table->file->inited) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 4e794790917..1b3465d0812 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -5814,6 +5814,7 @@ ha_innobase::open(const char* name, int, uint) /* Will be allocated if it is needed in ::update_row() */ m_upd_buf = NULL; m_upd_buf_size = 0; + m_disable_rowid_filter = false; char* is_part = is_partition(norm_name); THD* thd = ha_thd(); @@ -7286,7 +7287,8 @@ ha_innobase::build_template( /* Below we check column by column if we need to access the clustered index. */ - if (pushed_rowid_filter && rowid_filter_is_active) { + if (pushed_rowid_filter && rowid_filter_is_active + && !m_disable_rowid_filter) { fetch_primary_key_cols = TRUE; m_prebuilt->pk_filter = this; } else { @@ -7343,7 +7345,8 @@ ha_innobase::build_template( simplified to handle both. It should handle the issues. */ const bool pushed_down = active_index != MAX_KEY - && active_index == pushed_idx_cond_keyno; + && active_index == pushed_idx_cond_keyno + && !m_disable_rowid_filter; m_prebuilt->idx_cond = pushed_down ? this : nullptr; @@ -9375,6 +9378,11 @@ ha_innobase::rnd_init( { int err; + /* Don't use rowid filter when doing full table scan or rnd_pos calls.*/ + if (!scan) { + m_disable_rowid_filter = true; + } + /* Store the active index value so that we can restore the original value after a scan */ @@ -9384,6 +9392,12 @@ ha_innobase::rnd_init( err = change_active_index(m_primary_key); } + if (err && !scan) { + /* Restore the original value in case of error */ + m_disable_rowid_filter = false; + } + + /* Don't use semi-consistent read in random row reads (by position). This means we must disable semi_consistent_read if scan is false */ @@ -9404,6 +9418,7 @@ int ha_innobase::rnd_end(void) /*======================*/ { + m_disable_rowid_filter = false; return(index_end()); } @@ -9455,6 +9470,7 @@ ha_innobase::rnd_pos( /* Note that we assume the length of the row reference is fixed for the table, and it is == ref_length */ + DBUG_ASSERT(m_disable_rowid_filter == true); int error = index_read(buf, pos, (uint)ref_length, HA_READ_KEY_EXACT); if (error != 0) { diff --git a/storage/innobase/handler/ha_innodb.h b/storage/innobase/handler/ha_innodb.h index 6796c75e426..200325edeb2 100644 --- a/storage/innobase/handler/ha_innodb.h +++ b/storage/innobase/handler/ha_innodb.h @@ -522,6 +522,10 @@ protected: /** If mysql has locked with external_lock() */ bool m_mysql_has_locked; + + /** If true, disable the Rowid Filter. It is disabled when + the enigne is intialized for making rnd_pos() calls */ + bool m_disable_rowid_filter; }; From f8621f2a162395c367abc03aa2fee355af10d2c5 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 12 May 2024 23:08:04 +0200 Subject: [PATCH 563/568] remove redundant slow tests --- mysql-test/suite/sys_vars/r/binlog_do_db.result | 12 ------------ .../suite/sys_vars/r/binlog_ignore_db.result | 12 ------------ .../sys_vars/r/binlog_row_event_max_size.result | 12 ------------ mysql-test/suite/sys_vars/t/binlog_do_db.test | 16 ---------------- .../suite/sys_vars/t/binlog_ignore_db.test | 16 ---------------- .../sys_vars/t/binlog_row_event_max_size.test | 16 ---------------- 6 files changed, 84 deletions(-) delete mode 100644 mysql-test/suite/sys_vars/r/binlog_do_db.result delete mode 100644 mysql-test/suite/sys_vars/r/binlog_ignore_db.result delete mode 100644 mysql-test/suite/sys_vars/r/binlog_row_event_max_size.result delete mode 100644 mysql-test/suite/sys_vars/t/binlog_do_db.test delete mode 100644 mysql-test/suite/sys_vars/t/binlog_ignore_db.test delete mode 100644 mysql-test/suite/sys_vars/t/binlog_row_event_max_size.test diff --git a/mysql-test/suite/sys_vars/r/binlog_do_db.result b/mysql-test/suite/sys_vars/r/binlog_do_db.result deleted file mode 100644 index cdcfe406b64..00000000000 --- a/mysql-test/suite/sys_vars/r/binlog_do_db.result +++ /dev/null @@ -1,12 +0,0 @@ -# -# MDEV-30188 Show "--binlog_do_db" state in SYSTEM VARIABLES -# -SELECT @@binlog_do_db AS EXPECT_NULL; -EXPECT_NULL - -SET @@GLOBAL.binlog_do_db='database1'; -ERROR HY000: Variable 'binlog_do_db' is a read only variable -# restart: --binlog_do_db=database1 --binlog_do_db=database2 -SELECT @@binlog_do_db AS EXPECT_database1_database2; -EXPECT_database1_database2 -database1,database2 diff --git a/mysql-test/suite/sys_vars/r/binlog_ignore_db.result b/mysql-test/suite/sys_vars/r/binlog_ignore_db.result deleted file mode 100644 index bd1ff69744e..00000000000 --- a/mysql-test/suite/sys_vars/r/binlog_ignore_db.result +++ /dev/null @@ -1,12 +0,0 @@ -# -# MDEV-30188 Show "--binlog_ignore_db" state in SYSTEM VARIABLES -# -SELECT @@binlog_ignore_db AS EXPECT_NULL; -EXPECT_NULL - -SET @@GLOBAL.binlog_ignore_db='database1'; -ERROR HY000: Variable 'binlog_ignore_db' is a read only variable -# restart: --binlog_ignore_db=database1 --binlog_ignore_db=database2 -SELECT @@binlog_ignore_db AS EXPECT_database1_database2; -EXPECT_database1_database2 -database1,database2 diff --git a/mysql-test/suite/sys_vars/r/binlog_row_event_max_size.result b/mysql-test/suite/sys_vars/r/binlog_row_event_max_size.result deleted file mode 100644 index a68267fe5e6..00000000000 --- a/mysql-test/suite/sys_vars/r/binlog_row_event_max_size.result +++ /dev/null @@ -1,12 +0,0 @@ -# -# MDEV-30188 Show "--binlog_row_event_max_size" state in SYSTEM VARIABLES -# -SELECT @@binlog_row_event_max_size AS EXPECT_8192; -EXPECT_8192 -8192 -SET @@GLOBAL.binlog_row_event_max_size=128; -ERROR HY000: Variable 'binlog_row_event_max_size' is a read only variable -# restart: --binlog_row_event_max_size=4096 -SELECT @@binlog_row_event_max_size AS EXPECT_4096; -EXPECT_4096 -4096 diff --git a/mysql-test/suite/sys_vars/t/binlog_do_db.test b/mysql-test/suite/sys_vars/t/binlog_do_db.test deleted file mode 100644 index 548f8bd6172..00000000000 --- a/mysql-test/suite/sys_vars/t/binlog_do_db.test +++ /dev/null @@ -1,16 +0,0 @@ ---echo # ---echo # MDEV-30188 Show "--binlog_do_db" state in SYSTEM VARIABLES ---echo # - -# Confirm that "--binlog_do_db" option has the default value. -SELECT @@binlog_do_db AS EXPECT_NULL; - -# `READ ONLY` variables must not be able to be reset. ---Error ER_INCORRECT_GLOBAL_LOCAL_VAR (1238): Variable 'binlog_do_db' is a read only variable -SET @@GLOBAL.binlog_do_db='database1'; - -# Restart the server with "--binlog_do_db='database1' --binlog_do_db='database2'" option ---let $restart_parameters = "--binlog_do_db='database1' --binlog_do_db='database2'" ---source include/restart_mysqld.inc -SELECT @@binlog_do_db AS EXPECT_database1_database2; - diff --git a/mysql-test/suite/sys_vars/t/binlog_ignore_db.test b/mysql-test/suite/sys_vars/t/binlog_ignore_db.test deleted file mode 100644 index 52d49683d9d..00000000000 --- a/mysql-test/suite/sys_vars/t/binlog_ignore_db.test +++ /dev/null @@ -1,16 +0,0 @@ ---echo # ---echo # MDEV-30188 Show "--binlog_ignore_db" state in SYSTEM VARIABLES ---echo # - -# Confirm that "--binlog_ignore_db" option has the default value. -SELECT @@binlog_ignore_db AS EXPECT_NULL; - -# `READ ONLY` variables must not be able to be reset. ---Error ER_INCORRECT_GLOBAL_LOCAL_VAR (1238): Variable 'binlog_ignore_db' is a read only variable -SET @@GLOBAL.binlog_ignore_db='database1'; - -# Restart the server with "--binlog_ignore_db='database1' --binlog_ignore_db='database2'" option ---let $restart_parameters = "--binlog_ignore_db='database1' --binlog_ignore_db='database2'" ---source include/restart_mysqld.inc -SELECT @@binlog_ignore_db AS EXPECT_database1_database2; - diff --git a/mysql-test/suite/sys_vars/t/binlog_row_event_max_size.test b/mysql-test/suite/sys_vars/t/binlog_row_event_max_size.test deleted file mode 100644 index fa1e5da7011..00000000000 --- a/mysql-test/suite/sys_vars/t/binlog_row_event_max_size.test +++ /dev/null @@ -1,16 +0,0 @@ ---echo # ---echo # MDEV-30188 Show "--binlog_row_event_max_size" state in SYSTEM VARIABLES ---echo # - -SELECT @@binlog_row_event_max_size AS EXPECT_8192; - -# `READ ONLY` variables must not be able to be reset. ---Error ER_INCORRECT_GLOBAL_LOCAL_VAR (1238): Variable 'binlog_row_event_max_size' is a read only variable -SET @@GLOBAL.binlog_row_event_max_size=128; - -# Restart the server the server with "--binlog_row_event_max_size=4096" option ---let $restart_parameters = "--binlog_row_event_max_size=4096" ---source include/restart_mysqld.inc -SELECT @@binlog_row_event_max_size AS EXPECT_4096; - - From db06c5dd07e6ffd6a569afe6950fa77c2f02f811 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 13 May 2024 11:09:55 +0200 Subject: [PATCH 564/568] main.alter_table_online fails in --view disable view protocol (DROP VIEW doesn't work very well with transactions) and cosmetic cleanups --- mysql-test/main/alter_table_online.result | 15 ++++----------- mysql-test/main/alter_table_online.test | 19 +++++++------------ 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/mysql-test/main/alter_table_online.result b/mysql-test/main/alter_table_online.result index c8c0c782115..fb5f2abf984 100644 --- a/mysql-test/main/alter_table_online.result +++ b/mysql-test/main/alter_table_online.result @@ -241,22 +241,17 @@ drop sequence s; # # MDEV-33348 ALTER TABLE lock waiting stages are indistinguishable # -connect con2, localhost, root,,; -create or replace table t1 (a int); -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) DEFAULT NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +connect con2, localhost, root; +create table t1 (a int); insert t1 values (5); -connection con2; -begin; +start transaction; select * from t1; a 5 connection default; alter table t1 add b int NULL, algorithm= copy, lock= none; connection con2; +set @con= $con; select stage, state, info from information_schema.processlist where id = @con; stage 4 state Waiting for table metadata lock @@ -265,6 +260,4 @@ rollback; connection default; drop table t1; disconnect con2; -# # End of 11.2 tests -# diff --git a/mysql-test/main/alter_table_online.test b/mysql-test/main/alter_table_online.test index f0d70b05884..4d8f831186f 100644 --- a/mysql-test/main/alter_table_online.test +++ b/mysql-test/main/alter_table_online.test @@ -250,25 +250,21 @@ drop sequence s; --echo # --echo # MDEV-33348 ALTER TABLE lock waiting stages are indistinguishable --echo # ---connect (con2, localhost, root,,) +--disable_view_protocol +--connect con2, localhost, root -create or replace table t1 (a int); -show create table t1; +create table t1 (a int); insert t1 values (5); ---connection con2 -begin; +start transaction; select * from t1; + --connection default --let $con= `select connection_id()` send alter table t1 add b int NULL, algorithm= copy, lock= none; - --connection con2 -disable_query_log; -eval set @con= $con; -enable_query_log; - +evalp set @con= $con; let $wait_condition= select stage = 4 and progress = 100 and state= "Waiting for table metadata lock" @@ -284,7 +280,6 @@ reap; drop table t1; --disconnect con2 +--enable_view_protocol ---echo # --echo # End of 11.2 tests ---echo # From d1e230d9db0609773f9df48fcccdffb278eac5c6 Mon Sep 17 00:00:00 2001 From: Hugo Wen Date: Tue, 7 May 2024 11:28:21 -0700 Subject: [PATCH 565/568] MDEV-34112 Replace one operator name keyword MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Alternative operator name keywords like `and`, `or`, `xor`, etc., are uncommon in MariaDB and can cause obscure build errors when the GCC flag `-fno-operator-names` is applied. Description of `-fno-operator-names`: https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Dialect-Options.html > Do not treat the operator name keywords `and`, `bitand`, `bitor`, > `compl`, `not`, `or` and `xor` as synonyms as keywords. Part of the build errors: /local/p4clients/pkgbuild-LdLa_/workspace/src/RDSMariaDB/sql/sql_select.cc:11171:28: error: expected ‘)’ before ‘and’ 11171 | DBUG_ASSERT(sel >= 0.0 and sel <= 1.00001); | ^~~ /local/p4clients/pkgbuild-LdLa_/workspace/src/RDSMariaDB/include/my_global.h:372:44: note: in definition of macro ‘unlikely’ 372 | #define unlikely(x) __builtin_expect(((x) != 0),0) | ^ ... The build failure is caused by using alternative operator name keywords `and` introduced in commit b66cdbd1e. Replace the `and` keyword with `&&` and target on MariaDB 11.0+ branches which include the commit. All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc. --- sql/sql_select.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index b6039d3e0e6..27e75a5593f 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -11125,7 +11125,7 @@ double table_after_join_selectivity(JOIN *join, uint idx, JOIN_TAB *s, else { sel= records_out / pos->records_read; - DBUG_ASSERT(sel >= 0.0 and sel <= 1.00001); + DBUG_ASSERT(sel >= 0.0 && sel <= 1.00001); if (sel > 1.0) sel= 1.0; } From 339aba04d382b9d0d304ff612722cedea5cf8653 Mon Sep 17 00:00:00 2001 From: Daniel Bartholomew Date: Wed, 15 May 2024 10:54:58 -0400 Subject: [PATCH 566/568] bump the VERSION --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 7e168219369..23aa5974ee6 100644 --- a/VERSION +++ b/VERSION @@ -1,4 +1,4 @@ MYSQL_VERSION_MAJOR=11 MYSQL_VERSION_MINOR=1 -MYSQL_VERSION_PATCH=5 +MYSQL_VERSION_PATCH=6 SERVER_MATURITY=stable From fcee83f01d4885ca1d7803b2bf6493118d7f6a48 Mon Sep 17 00:00:00 2001 From: Daniel Bartholomew Date: Wed, 15 May 2024 10:55:43 -0400 Subject: [PATCH 567/568] bump the VERSION --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 73546b92f32..58e713313cb 100644 --- a/VERSION +++ b/VERSION @@ -1,4 +1,4 @@ MYSQL_VERSION_MAJOR=11 MYSQL_VERSION_MINOR=2 -MYSQL_VERSION_PATCH=4 +MYSQL_VERSION_PATCH=5 SERVER_MATURITY=stable From 2e267a4a35f64fdce104e1a9c23266b8da241c52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 20 May 2024 11:02:25 +0300 Subject: [PATCH 568/568] MDEV-33588/MDEV-33325 after-merge fix In the merge commit f9807aadef7ede29ae3cecaf1edadfaa833dc9d3 there were some omissions or errors. ibuf_remove_free_page(): Return an error if the free list is corrupted when removing the change buffer on an upgrade. A special 11.0 version of commit 263932d505cb895367fea9f106a9e66664ae3832 would have been useful. buf_page_get_gen(): Correctly handle the case that a page was being concurrently read into the buffer pool and found out to be corrupted. This was part of commit a4cda66e2df93f039ee536421095e05f52ddd17c but had been discarded in the merge. Because MariaDB Server 11.0 has reached its end of life as of commit 466ae1cf81f54b729058357bb19c4cf3982e1367 this fix is being applied to the 11.1 branch. --- storage/innobase/buf/buf0buf.cc | 23 +++++++++++++++++++---- storage/innobase/ibuf/ibuf0ibuf.cc | 10 ++++++---- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 07375bcbd10..43401e9df2c 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -2706,6 +2706,7 @@ got_block: if (mode == BUF_PEEK_IF_IN_POOL) { ignore_block: block->unfix(); +ignore_unfixed: ut_ad(mode == BUF_GET_POSSIBLY_FREED || mode == BUF_PEEK_IF_IN_POOL); if (err) { @@ -2897,6 +2898,15 @@ wait_for_unfix: #endif /* UNIV_DEBUG */ ut_ad(block->page.frame); + /* The state = block->page.state() may be stale at this point, + and in fact, at any point of time if we consider its + buffer-fix component. If the block is being read into the + buffer pool, it is possible that buf_page_t::read_complete() + will invoke buf_pool_t::corrupted_evict() and therefore + invalidate it (invoke buf_page_t::set_corrupt_id() and set the + state to FREED). Therefore, after acquiring the page latch we + must recheck the state. */ + switch (rw_latch) { case RW_NO_LATCH: mtr->memo_push(block, MTR_MEMO_BUF_FIX); @@ -2919,6 +2929,15 @@ wait_for_unfix: } mtr->memo_push(block, mtr_memo_type_t(rw_latch)); + state = block->page.state(); + + if (UNIV_UNLIKELY(state < buf_page_t::UNFIXED)) { + mtr->release_last_page(); + goto ignore_unfixed; + } + + ut_ad(state < buf_page_t::READ_FIX || state > buf_page_t::WRITE_FIX); + #ifdef BTR_CUR_HASH_ADAPT btr_search_drop_page_hash_index(block, true); #endif /* BTR_CUR_HASH_ADAPT */ @@ -2929,10 +2948,6 @@ wait_for_unfix: return block; } -/********************************************************************//** -This is the general function used to get optimistic access to a database -page. -@return TRUE if success */ TRANSACTIONAL_TARGET buf_block_t *buf_page_optimistic_fix(buf_block_t *block, page_id_t id) { diff --git a/storage/innobase/ibuf/ibuf0ibuf.cc b/storage/innobase/ibuf/ibuf0ibuf.cc index 5d0b2557fe4..67a89f9402d 100644 --- a/storage/innobase/ibuf/ibuf0ibuf.cc +++ b/storage/innobase/ibuf/ibuf0ibuf.cc @@ -22,7 +22,6 @@ this program; if not, write to the Free Software Foundation, Inc., Upgrade and removal of the InnoDB change buffer */ -#include #include "ibuf0ibuf.h" #include "btr0sea.h" #include "btr0pcur.h" @@ -257,8 +256,7 @@ func_exit: const uint32_t page_no= flst_get_last(PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST + root->page.frame).page; - - if (page_no == FIL_NULL || page_no >= fil_system.sys_space->free_limit) + if (page_no == FIL_NULL) { mtr.set_modified(*root); fsp_init_file_page(fil_system.sys_space, root, &mtr); @@ -266,6 +264,9 @@ func_exit: goto func_exit; } + if (page_no >= fil_system.sys_space->free_limit) + goto corrupted; + /* Since pessimistic inserts were prevented, we know that the page is still in the free list. NOTE that also deletes may take pages from the free list, but they take them from the start, and @@ -281,6 +282,7 @@ func_exit: if (page_no != flst_get_last(PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST + root->page.frame).page) { + corrupted: err= DB_CORRUPTION; goto func_exit; } @@ -291,7 +293,7 @@ func_exit: &mtr, &err)) err= flst_remove(root, PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST, block, PAGE_HEADER + PAGE_BTR_IBUF_FREE_LIST_NODE, - fil_system.sys_space->free_limit, &mtr); + fil_system.sys_space->free_limit, &mtr); if (err == DB_SUCCESS) buf_page_free(fil_system.sys_space, page_no, &mtr);