From f6663bfbd3f1dd321cd7d53291e3fa08a190ab2f Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Tue, 11 Feb 2020 00:19:37 +0400 Subject: [PATCH 01/66] MDEV-17941 ALTER USER IF EXISTS does not work, although documentation says it should. Mistake in syntax definition fixed - should be ALTER USER IF EXISTS, not ALTER IF EXISTS USER. --- mysql-test/r/alter_user.result | 2 +- mysql-test/t/alter_user.test | 2 +- sql/sql_yacc.yy | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/alter_user.result b/mysql-test/r/alter_user.result index ac668bba8fa..b67705c4fc4 100644 --- a/mysql-test/r/alter_user.result +++ b/mysql-test/r/alter_user.result @@ -43,7 +43,7 @@ SET GLOBAL read_only = @start_read_only; alter user boo; ERROR HY000: Operation ALTER USER failed for 'boo' #--warning ER_CANNOT_USER -alter if exists user boo; +alter user if exists boo; Warnings: Error 1133 Can't find any matching row in the user table Note 1396 Operation ALTER USER failed for 'boo' diff --git a/mysql-test/t/alter_user.test b/mysql-test/t/alter_user.test index ca444f70a70..3a1052a98f6 100644 --- a/mysql-test/t/alter_user.test +++ b/mysql-test/t/alter_user.test @@ -41,7 +41,7 @@ SET GLOBAL read_only = @start_read_only; --error ER_CANNOT_USER alter user boo; --echo #--warning ER_CANNOT_USER -alter if exists user boo; +alter user if exists boo; --echo # Test password related altering. alter user foo identified by 'something'; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index fe7f3021be6..386c86cb3e2 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -7294,10 +7294,10 @@ alter: lex->server_options.reset($3); } OPTIONS_SYM '(' server_options_list ')' { } /* ALTER USER foo is allowed for MySQL compatibility. */ - | ALTER opt_if_exists USER_SYM clear_privileges grant_list + | ALTER USER_SYM opt_if_exists clear_privileges grant_list opt_require_clause opt_resource_options { - Lex->create_info.set($2); + Lex->create_info.set($3); Lex->sql_command= SQLCOM_ALTER_USER; } ; From a6b92690e612bf88b2c042b33878c04fec5c50ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Wed, 12 Feb 2020 10:32:30 +0200 Subject: [PATCH 02/66] MDEV-21556 : galera.lp1376747-4 MTR failed: Result length mismatch Add proper wait condition instead of sleeps. --- mysql-test/suite/galera/t/lp1376747-4.test | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/mysql-test/suite/galera/t/lp1376747-4.test b/mysql-test/suite/galera/t/lp1376747-4.test index 0c707d6d681..6ae89fe9df4 100644 --- a/mysql-test/suite/galera/t/lp1376747-4.test +++ b/mysql-test/suite/galera/t/lp1376747-4.test @@ -27,25 +27,24 @@ INSERT INTO t1 VALUES (2,3); --connection node_2a SET session wsrep_sync_wait=0; SET session wsrep_causal_reads=OFF; + SHOW CREATE TABLE t1; ---sleep 1 --send FLUSH TABLES t1 WITH READ LOCK; --connection node_2 -# let the flush table wait in pause state before we unlock -# table otherwise there is window where-in flush table is -# yet to wait in pause and unlock allows alter table to proceed. -# this is because send in asynchronous. ---sleep 3 -# this will release existing lock but will not resume -# the cluster as there is new FTRL that is still pausing it. +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'system user' AND STATE LIKE 'committed%'; +--source include/wait_condition.inc + UNLOCK TABLES; SHOW CREATE TABLE t1; --connection node_2a --reap UNLOCK TABLES; ---sleep 2 + +--let $wait_condition = SELECT COUNT(*) = 2 FROM t1; +--source include/wait_condition.inc + SHOW CREATE TABLE t1; SELECT * from t1; From be77fa914c30e92e33e60feb5a3e098c765798af Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Wed, 12 Feb 2020 14:30:31 +0100 Subject: [PATCH 03/66] MDEV-21646: Failure to compile my_addr_resolve.c with binutils-2.34 Emulate older API --- mysys/my_addr_resolve.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mysys/my_addr_resolve.c b/mysys/my_addr_resolve.c index 7b14a561ba5..d318f6bf965 100644 --- a/mysys/my_addr_resolve.c +++ b/mysys/my_addr_resolve.c @@ -49,6 +49,18 @@ static const char *strip_path(const char *s) static bfd *bfdh= 0; static asymbol **symtable= 0; +#ifndef bfd_get_section_flags +#define bfd_get_section_flags(H, S) bfd_section_flags(S) +#endif /* bfd_get_section_flags */ + +#ifndef bfd_get_section_size +#define bfd_get_section_size(S) bfd_section_size(S) +#endif /* bfd_get_section_size */ + +#ifndef bfd_get_section_vma +#define bfd_get_section_vma(H, S) bfd_section_vma(S) +#endif /* bfd_get_section_vma */ + /** finds a file name, a line number, and a function name corresponding to addr. From c5e00fea102f0f8d614f60f39737b55dd09b4062 Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Fri, 1 Nov 2019 19:18:47 +0400 Subject: [PATCH 04/66] MDEV-20867 - Perform careful review of "Server crashes with BACKUP STAGE and FLUSH TABLE table_name" Reverted original patch (c2e0a0b). For consistency with "LOCK TABLE READ" and "FLUSH TABLES WITH READ LOCK", which are forbidden under "BACKUP STAGE", forbid "FLUSH TABLE FOR EXPORT" and "FLUSH TABLE WITH READ LOCK" as well. It'd allow consistent fixes for problems like MDEV-18643. --- mysql-test/main/backup_interaction.result | 24 +++----------------- mysql-test/main/backup_interaction.test | 27 +++-------------------- sql/mdl.cc | 11 +++------ sql/sql_class.cc | 1 + sql/sql_reload.cc | 6 +++++ 5 files changed, 16 insertions(+), 53 deletions(-) diff --git a/mysql-test/main/backup_interaction.result b/mysql-test/main/backup_interaction.result index f1354f6778e..3c3071b8e70 100644 --- a/mysql-test/main/backup_interaction.result +++ b/mysql-test/main/backup_interaction.result @@ -521,26 +521,8 @@ BACKUP STAGE END; CREATE OR REPLACE TABLE t1 (pk INT PRIMARY KEY, f INT); BACKUP STAGE START; FLUSH TABLE t1 FOR EXPORT; -UNLOCK TABLES; -BACKUP STAGE END; -DROP TABLE t1; -CREATE TABLE t1 (a INT); -BACKUP STAGE START; -FLUSH TABLE t1 FOR EXPORT; -UNLOCK TABLES; -connect con1,localhost,root,,test; -BACKUP STAGE START; -connection default; -BACKUP STAGE END; -connection con1; -BACKUP STAGE END; -disconnect con1; -connection default; -DROP TABLE t1; -CREATE TABLE t1 (a INT); -BACKUP STAGE START; -FLUSH TABLES t1 WITH READ LOCK; -UNLOCK TABLES; -BACKUP STAGE BLOCK_COMMIT; +ERROR HY000: Can't execute the command as you have a BACKUP STAGE active +FLUSH TABLE t1 WITH READ LOCK; +ERROR HY000: Can't execute the command as you have a BACKUP STAGE active BACKUP STAGE END; DROP TABLE t1; diff --git a/mysql-test/main/backup_interaction.test b/mysql-test/main/backup_interaction.test index 8ac905cc6ff..09ed769c898 100644 --- a/mysql-test/main/backup_interaction.test +++ b/mysql-test/main/backup_interaction.test @@ -509,30 +509,9 @@ BACKUP STAGE END; CREATE OR REPLACE TABLE t1 (pk INT PRIMARY KEY, f INT); BACKUP STAGE START; +--error ER_BACKUP_LOCK_IS_ACTIVE FLUSH TABLE t1 FOR EXPORT; -UNLOCK TABLES; -BACKUP STAGE END; -DROP TABLE t1; - -CREATE TABLE t1 (a INT); -BACKUP STAGE START; -FLUSH TABLE t1 FOR EXPORT; -UNLOCK TABLES; ---connect (con1,localhost,root,,test) ---send BACKUP STAGE START ---connection default -BACKUP STAGE END; ---connection con1 -reap; -BACKUP STAGE END; ---disconnect con1 ---connection default -DROP TABLE t1; - -CREATE TABLE t1 (a INT); -BACKUP STAGE START; -FLUSH TABLES t1 WITH READ LOCK; -UNLOCK TABLES; -BACKUP STAGE BLOCK_COMMIT; +--error ER_BACKUP_LOCK_IS_ACTIVE +FLUSH TABLE t1 WITH READ LOCK; BACKUP STAGE END; DROP TABLE t1; diff --git a/sql/mdl.cc b/sql/mdl.cc index e7c0d699d76..591127dc1d8 100644 --- a/sql/mdl.cc +++ b/sql/mdl.cc @@ -3166,19 +3166,14 @@ void MDL_context::set_transaction_duration_for_all_locks() DBUG_ASSERT(m_tickets[MDL_STATEMENT].is_empty()); - /* Don't swap locks if this thread is running backup stages */ - if (current_thd->current_backup_stage == BACKUP_FINISHED) - m_tickets[MDL_TRANSACTION].swap(m_tickets[MDL_EXPLICIT]); + m_tickets[MDL_TRANSACTION].swap(m_tickets[MDL_EXPLICIT]); Ticket_iterator it_ticket(m_tickets[MDL_EXPLICIT]); while ((ticket= it_ticket++)) { - if (ticket->get_key()->mdl_namespace() != MDL_key::BACKUP) - { - m_tickets[MDL_EXPLICIT].remove(ticket); - m_tickets[MDL_TRANSACTION].push_front(ticket); - } + m_tickets[MDL_EXPLICIT].remove(ticket); + m_tickets[MDL_TRANSACTION].push_front(ticket); } #ifndef DBUG_OFF diff --git a/sql/sql_class.cc b/sql/sql_class.cc index d8d4b9a8d64..84e18e71a80 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -5580,6 +5580,7 @@ void THD::leave_locked_tables_mode() { if (locked_tables_mode == LTM_LOCK_TABLES) { + DBUG_ASSERT(current_backup_stage == BACKUP_FINISHED); /* When leaving LOCK TABLES mode we have to change the duration of most of the metadata locks being held, except for HANDLER and GRL locks, diff --git a/sql/sql_reload.cc b/sql/sql_reload.cc index 0e166b169aa..0898bea6d41 100644 --- a/sql/sql_reload.cc +++ b/sql/sql_reload.cc @@ -525,6 +525,12 @@ bool flush_tables_with_read_lock(THD *thd, TABLE_LIST *all_tables) goto error; } + if (thd->current_backup_stage != BACKUP_FINISHED) + { + my_error(ER_BACKUP_LOCK_IS_ACTIVE, MYF(0)); + return true; + } + if (thd->lex->type & REFRESH_READ_LOCK) { /* From 6c1e0c0493f09205bf9cd83c51c881e06d0e1305 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Thu, 13 Feb 2020 10:30:40 +0200 Subject: [PATCH 05/66] MDEV-21421 : Galera test sporadic failure on galera.galera_as_slave_gtid_myisam: Result length mismatch In Galera 3 nodes 2 and 3 are galera nodes and node_1 should be non galera. --- mysql-test/suite/galera/disabled.def | 1 - mysql-test/suite/galera/r/galera_as_slave_gtid_myisam.result | 3 +++ mysql-test/suite/galera/t/galera_as_slave_gtid_myisam.test | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index 6f0f1fbdde5..f7ba0b3c08c 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -15,7 +15,6 @@ MW-328A : MDEV-21483 galera.MW-328A galera.MW-328B MW-328B : MDEV-21483 galera.MW-328A galera.MW-328B MW-329 : MDEV-19962 Galera test failure on MW-329 galera.galera_defaults : MDEV-21494 Galera test sporadic failure on galera.galera_defaults -galera_as_slave_gtid_myisam : MDEV-21421 galera.galera_as_slave_gtid_myisam galera_as_slave_replication_bundle : MDEV-15785 OPTION_GTID_BEGIN is set in Gtid_log_event::do_apply_event() galera_autoinc_sst_mariabackup : Known issue, may require porting MDEV-17458 from later versions galera_binlog_stmt_autoinc : MDEV-19959 Galera test failure on galera_binlog_stmt_autoinc diff --git a/mysql-test/suite/galera/r/galera_as_slave_gtid_myisam.result b/mysql-test/suite/galera/r/galera_as_slave_gtid_myisam.result index 0e5c6425d6a..d8a9f0d6f57 100644 --- a/mysql-test/suite/galera/r/galera_as_slave_gtid_myisam.result +++ b/mysql-test/suite/galera/r/galera_as_slave_gtid_myisam.result @@ -1,4 +1,7 @@ connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2; +SELECT @@WSREP_ON; +@@WSREP_ON +0 connection node_2; ALTER TABLE mysql.gtid_slave_pos engine = InnoDB; START SLAVE; diff --git a/mysql-test/suite/galera/t/galera_as_slave_gtid_myisam.test b/mysql-test/suite/galera/t/galera_as_slave_gtid_myisam.test index faa9ddfd5c8..33668da11be 100644 --- a/mysql-test/suite/galera/t/galera_as_slave_gtid_myisam.test +++ b/mysql-test/suite/galera/t/galera_as_slave_gtid_myisam.test @@ -16,6 +16,7 @@ # As node #1 is not a Galera node, we connect to node #2 in order to run include/galera_cluster.inc --connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 --source include/galera_cluster.inc +SELECT @@WSREP_ON; --connection node_2 # make sure gtid_slave_pos is of innodb engine, mtr does not currently provide that From ed10a8cd97ab227e32c3218c538baac3e5735c78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Thu, 13 Feb 2020 12:51:50 +0200 Subject: [PATCH 06/66] MDEV-21515 : Galera test sporadic failure on galera.galera_wsrep_new_cluster: Result content mismatch Use correct configuration and wait for nodes to reach correct state with wait conditions. --- .../galera/r/galera_wsrep_new_cluster.result | 2 +- .../t/galera_wsrep_new_cluster-master.opt | 1 + .../galera/t/galera_wsrep_new_cluster.cnf | 10 ------- .../galera/t/galera_wsrep_new_cluster.test | 26 +++++++++++++++++++ 4 files changed, 28 insertions(+), 11 deletions(-) create mode 100644 mysql-test/suite/galera/t/galera_wsrep_new_cluster-master.opt delete mode 100644 mysql-test/suite/galera/t/galera_wsrep_new_cluster.cnf diff --git a/mysql-test/suite/galera/r/galera_wsrep_new_cluster.result b/mysql-test/suite/galera/r/galera_wsrep_new_cluster.result index 24484fb66d2..ca388496794 100644 --- a/mysql-test/suite/galera/r/galera_wsrep_new_cluster.result +++ b/mysql-test/suite/galera/r/galera_wsrep_new_cluster.result @@ -25,7 +25,7 @@ VARIABLE_VALUE = 'ON' 1 SELECT VARIABLE_VALUE = 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_index'; VARIABLE_VALUE = 0 -0 +1 SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready'; VARIABLE_VALUE = 'ON' 1 diff --git a/mysql-test/suite/galera/t/galera_wsrep_new_cluster-master.opt b/mysql-test/suite/galera/t/galera_wsrep_new_cluster-master.opt new file mode 100644 index 00000000000..c31150c46af --- /dev/null +++ b/mysql-test/suite/galera/t/galera_wsrep_new_cluster-master.opt @@ -0,0 +1 @@ +--wsrep-new-cluster diff --git a/mysql-test/suite/galera/t/galera_wsrep_new_cluster.cnf b/mysql-test/suite/galera/t/galera_wsrep_new_cluster.cnf deleted file mode 100644 index 0acbcfb7843..00000000000 --- a/mysql-test/suite/galera/t/galera_wsrep_new_cluster.cnf +++ /dev/null @@ -1,10 +0,0 @@ -!include ../galera_2nodes.cnf - -[mysqld.1] -wsrep-new-cluster - -[mysqld.2] - - - - diff --git a/mysql-test/suite/galera/t/galera_wsrep_new_cluster.test b/mysql-test/suite/galera/t/galera_wsrep_new_cluster.test index 6ba8ce786c8..59350222a4c 100644 --- a/mysql-test/suite/galera/t/galera_wsrep_new_cluster.test +++ b/mysql-test/suite/galera/t/galera_wsrep_new_cluster.test @@ -7,6 +7,19 @@ --source include/galera_cluster.inc --source include/have_innodb.inc +--let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +--source include/wait_condition.inc +--let $wait_condition = SELECT VARIABLE_VALUE = 'on' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_connected'; +--source include/wait_condition.inc +--let $wait_condition = SELECT VARIABLE_VALUE = 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_index'; +--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 +--let $wait_condition = SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state'; +--source include/wait_condition.inc +--let $wait_condition = SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; +--source include/wait_condition.inc + SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_connected'; SELECT VARIABLE_VALUE = 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_index'; @@ -16,6 +29,19 @@ SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VAR --connection node_2 +--let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; +--source include/wait_condition.inc +--let $wait_condition = SELECT VARIABLE_VALUE = 'on' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_connected'; +--source include/wait_condition.inc +--let $wait_condition = SELECT VARIABLE_VALUE = 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_index'; +--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 +--let $wait_condition = SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state'; +--source include/wait_condition.inc +--let $wait_condition = SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; +--source include/wait_condition.inc + SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_connected'; SELECT VARIABLE_VALUE = 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_index'; From 1394216e3db67152a1356fddd8ddcd563b4f38c3 Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Fri, 7 Feb 2020 23:43:52 +0400 Subject: [PATCH 07/66] MDEV-21669 InnoDB: Table ... contains indexes inside InnoDB, which is different from the number of indexes defined in the MariaDB compare_keys_but_name(): do not use KEY_PART_INFO::field for Field::is_equal(). Following the logic of that code we need to compare fields of a table. But KEY_PART_INFO::field sometimes (when key part is shorter than table field) is a different field. In that case Field::is_equal() returns incorrect result and problems occur. KEY_PART_INFO::field may become some strange field in open_frm_error open_table_from_share(). I think this is an incorrect logic, some tecnhical debt. I'm not fixing it right now, because I don't have time. But I'm making Field::field_length a const class member. Then, the only fishy code which changed that field requires now a const_cast<>. I'm bringing attention to that code with it. This change should not affect logic of the program in any way. --- .../innodb/r/instant_alter_index_rename.result | 17 ++++++++++++++++- .../innodb/t/instant_alter_index_rename.test | 15 ++++++++++++++- sql/field.h | 2 +- sql/sql_table.cc | 2 +- sql/table.cc | 2 +- 5 files changed, 33 insertions(+), 5 deletions(-) diff --git a/mysql-test/suite/innodb/r/instant_alter_index_rename.result b/mysql-test/suite/innodb/r/instant_alter_index_rename.result index 52051eff0bd..69f7cc8df4c 100644 --- a/mysql-test/suite/innodb/r/instant_alter_index_rename.result +++ b/mysql-test/suite/innodb/r/instant_alter_index_rename.result @@ -74,7 +74,6 @@ select @a_key_returns_id = get_index_id(@table_id, 'a_key_returns'), @a_key_returns_id = get_index_id(@table_id, 'a_key_returns') @b_key_id = get_index_id(@table_id, 'b_key') @c_key_id = get_index_id(@table_id, 'c_key2') @primary_id = get_index_id(@table_id, 'primary') 1 1 1 1 drop table t; -drop function get_index_id; create table errors ( a int, unique key a_key (a), @@ -183,3 +182,19 @@ CREATE TABLE t1 (f1 INT, f2 INT, f3 INT); ALTER TABLE t1 ADD FOREIGN KEY f (f2) REFERENCES xx(f2); ALTER TABLE t1 ADD FOREIGN KEY (f2) REFERENCES t1(f2), ADD KEY (f3), ADD KEY (f1); DROP TABLE t1; +# +# MDEV-21669 InnoDB: Table ... contains indexes inside InnoDB, which is different from the number of indexes defined in the MariaDB +# +CREATE TABLE t1 (col_int INTEGER, col_char CHAR(20), col_varchar VARCHAR(500)) ENGINE=InnoDB; +SET @table_id = (SELECT table_id FROM information_schema.innodb_sys_tables WHERE name='test/t1'); +ALTER TABLE t1 ADD KEY idx3 (col_varchar(9)), ADD KEY idX2 (col_char(9)); +SET @idx3_key_id = get_index_id(@table_id, 'iDx3'); +ALTER TABLE t1 DROP KEY iDx3, ADD KEY Idx3 (col_varchar(9)); +SELECT @idx3_key_id = get_index_id(@table_id, 'Idx3'); +@idx3_key_id = get_index_id(@table_id, 'Idx3') +1 +CHECK TABLE t1 EXTENDED ; +Table Op Msg_type Msg_text +test.t1 check status OK +DROP TABLE t1; +DROP FUNCTION get_index_id; diff --git a/mysql-test/suite/innodb/t/instant_alter_index_rename.test b/mysql-test/suite/innodb/t/instant_alter_index_rename.test index 3a608a00837..dd6cee7c860 100644 --- a/mysql-test/suite/innodb/t/instant_alter_index_rename.test +++ b/mysql-test/suite/innodb/t/instant_alter_index_rename.test @@ -73,7 +73,6 @@ select @a_key_returns_id = get_index_id(@table_id, 'a_key_returns'), @primary_id = get_index_id(@table_id, 'primary'); drop table t; -drop function get_index_id; create table errors ( a int, @@ -194,3 +193,17 @@ CREATE TABLE t1 (f1 INT, f2 INT, f3 INT); ALTER TABLE t1 ADD FOREIGN KEY f (f2) REFERENCES xx(f2); ALTER TABLE t1 ADD FOREIGN KEY (f2) REFERENCES t1(f2), ADD KEY (f3), ADD KEY (f1); DROP TABLE t1; + +--echo # +--echo # MDEV-21669 InnoDB: Table ... contains indexes inside InnoDB, which is different from the number of indexes defined in the MariaDB +--echo # +CREATE TABLE t1 (col_int INTEGER, col_char CHAR(20), col_varchar VARCHAR(500)) ENGINE=InnoDB; +SET @table_id = (SELECT table_id FROM information_schema.innodb_sys_tables WHERE name='test/t1'); +ALTER TABLE t1 ADD KEY idx3 (col_varchar(9)), ADD KEY idX2 (col_char(9)); +SET @idx3_key_id = get_index_id(@table_id, 'iDx3'); +ALTER TABLE t1 DROP KEY iDx3, ADD KEY Idx3 (col_varchar(9)); +SELECT @idx3_key_id = get_index_id(@table_id, 'Idx3'); +CHECK TABLE t1 EXTENDED ; +DROP TABLE t1; + +DROP FUNCTION get_index_id; diff --git a/sql/field.h b/sql/field.h index f07eab3a197..5fe3a9ed106 100644 --- a/sql/field.h +++ b/sql/field.h @@ -694,7 +694,7 @@ public: enum imagetype { itRAW, itMBR}; utype unireg_check; - uint32 field_length; // Length of field + const uint32 field_length; // Length of field uint32 flags; uint16 field_index; // field number in fields array uchar null_bit; // Bit used to test null bit diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 8c695988853..851a63bf05a 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -6634,7 +6634,7 @@ Compare_keys compare_keys_but_name(const KEY *table_key, const KEY *new_key, */ const Field *old_field= table->field[key_part->fieldnr - 1]; - bool is_equal= key_part->field->is_equal(*new_field); + bool is_equal= old_field->is_equal(*new_field); /* TODO: below is an InnoDB specific code which should be moved to InnoDB */ if (!is_equal) { diff --git a/sql/table.cc b/sql/table.cc index 6426cb57524..4962a002cb9 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -3759,7 +3759,7 @@ enum open_frm_error open_table_from_share(THD *thd, TABLE_SHARE *share, */ field= key_part->field=field->make_new_field(&outparam->mem_root, outparam, 0); - field->field_length= key_part->length; + const_cast(field->field_length)= key_part->length; } } if (!share->use_ext_keys) From c400a73d7a722f009b16a3ffddccf7f052abba31 Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Thu, 13 Feb 2020 16:26:47 +0300 Subject: [PATCH 08/66] micro optimization: avoid std::string copy --- storage/innobase/log/log0recv.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/storage/innobase/log/log0recv.cc b/storage/innobase/log/log0recv.cc index 84709b0c356..00e0b32610e 100644 --- a/storage/innobase/log/log0recv.cc +++ b/storage/innobase/log/log0recv.cc @@ -158,8 +158,9 @@ struct file_name_t { lsn_t enable_lsn; /** Constructor */ - file_name_t(std::string name_, bool deleted) : - name(name_), space(NULL), status(deleted ? DELETED: NORMAL), + file_name_t(std::string name_, bool deleted) + : name(std::move(name_)), space(NULL), + status(deleted ? DELETED: NORMAL), size(0), enable_lsn(0) {} /** Report a MLOG_INDEX_LOAD operation, meaning that From 1f0e72f874bde5096a5c5c22e320a7723ff66b37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Otto=20Kek=C3=A4l=C3=A4inen?= Date: Wed, 12 Feb 2020 10:44:46 +0200 Subject: [PATCH 09/66] Deb: Remove unnecessary manual libzstd1 dependency from RocksDB plugin The Debian build tools add all run-time dependencies automatically. For the mariadb-rocksdb-plugin the "${misc:Depends}, ${shlibs:Depends}" will become (based on the build dependencies at build time): Depends: mariadb-server-10.4 (= 1:10.4.12-1), rocksdb-tools, libc6 (>= 2.29), liblz4-1 (>= 0.0~r130), libsnappy1v5 (>= 1.1.8), libstdc++6 (>= 7), libzstd1 (>= 1.3.3), zlib1g (>= 1:1.1.4) There is no need to manually add run-time build dependencies. Only external dependencies need to be defined, for example rocksdb-tools could come in question for mariadb-plugin-rocksdb, and it will be eventually added when downstream official Debian packaging is merged upstream in a later commit. --- debian/autobake-deb.sh | 1 - debian/control | 1 - 2 files changed, 2 deletions(-) diff --git a/debian/autobake-deb.sh b/debian/autobake-deb.sh index 4dba4de26b7..919dbd61c4f 100755 --- a/debian/autobake-deb.sh +++ b/debian/autobake-deb.sh @@ -77,7 +77,6 @@ fi if ! apt-cache madison libzstd-dev | grep 'libzstd-dev' >/dev/null 2>&1 then sed '/libzstd-dev/d' -i debian/control - sed '/libzstd1/d' -i debian/control fi # The binaries should be fully hardened by default. However TokuDB compilation seems to fail on diff --git a/debian/control b/debian/control index 8896f4d1dcd..b4447c71580 100644 --- a/debian/control +++ b/debian/control @@ -538,7 +538,6 @@ Description: Connect storage engine for MariaDB Package: mariadb-plugin-rocksdb Architecture: amd64 arm64 mips64el ppc64el Depends: mariadb-server-10.3 (= ${binary:Version}), - libzstd1, ${misc:Depends}, ${shlibs:Depends} Breaks: mariadb-rocksdb-engine-10.2, From 85d4a45d15078512562d84273f489e8d225c1da7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Otto=20Kek=C3=A4l=C3=A4inen?= Date: Sun, 9 Feb 2020 22:27:51 +0200 Subject: [PATCH 10/66] Deb: Run 'wrap-and-sort -a' so comparison across releases is easier No functional changes. Apply this in 10.3 so eventually it is merged to 10.4 and 10.5, which in turn will have separate wrap-and-sort runs but only for new lines, and not affecting badly next merges from 10.3 to 10.4 to 10.5. Also remove a duplicate line that was found thanks to wrap-and-sort. --- debian/control | 7 ++++--- debian/libmariadb3.install | 1 - debian/libmariadbd-dev.install | 4 ++-- debian/mariadb-plugin-rocksdb.install | 2 +- debian/mariadb-server-10.3.install | 4 ++-- debian/mariadb-test-data.install | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/debian/control b/debian/control index b4447c71580..18fea70f073 100644 --- a/debian/control +++ b/debian/control @@ -234,7 +234,8 @@ Description: MariaDB database common files (e.g. /etc/mysql/conf.d/mariadb.cnf) Package: mariadb-client-core-10.3 Architecture: any -Depends: mariadb-common (>= ${source:Version}), libmariadb3, +Depends: libmariadb3, + mariadb-common (>= ${source:Version}), ${misc:Depends}, ${shlibs:Depends} Conflicts: mariadb-client-10.0, @@ -569,8 +570,8 @@ Description: OQGraph storage engine for MariaDB Package: mariadb-plugin-tokudb Architecture: amd64 -Depends: mariadb-server-10.3 (= ${binary:Version}), - libjemalloc1 (>= 3.0.0~) | libjemalloc2, +Depends: libjemalloc1 (>= 3.0.0~) | libjemalloc2, + mariadb-server-10.3 (= ${binary:Version}), ${misc:Depends}, ${shlibs:Depends} Breaks: mariadb-server-10.0, diff --git a/debian/libmariadb3.install b/debian/libmariadb3.install index 9783e7b0b01..8636166a493 100644 --- a/debian/libmariadb3.install +++ b/debian/libmariadb3.install @@ -3,4 +3,3 @@ usr/lib/mysql/plugin/client_ed25519.so usr/lib/mysql/plugin/dialog.so usr/lib/mysql/plugin/mysql_clear_password.so usr/lib/mysql/plugin/sha256_password.so -usr/lib/mysql/plugin/client_ed25519.so diff --git a/debian/libmariadbd-dev.install b/debian/libmariadbd-dev.install index 2c14af5ab31..13d961409cc 100644 --- a/debian/libmariadbd-dev.install +++ b/debian/libmariadbd-dev.install @@ -1,4 +1,4 @@ -usr/lib/*/libmysqld.a usr/lib/*/libmariadbd.a -usr/lib/*/libmysqld.so usr/lib/*/libmariadbd.so +usr/lib/*/libmysqld.a +usr/lib/*/libmysqld.so diff --git a/debian/mariadb-plugin-rocksdb.install b/debian/mariadb-plugin-rocksdb.install index b9a6f7dc432..403c7f291b6 100644 --- a/debian/mariadb-plugin-rocksdb.install +++ b/debian/mariadb-plugin-rocksdb.install @@ -1,5 +1,5 @@ etc/mysql/conf.d/rocksdb.cnf etc/mysql/mariadb.conf.d -usr/bin/mysql_ldb usr/bin/myrocks_hotbackup +usr/bin/mysql_ldb usr/bin/sst_dump usr/lib/mysql/plugin/ha_rocksdb.so diff --git a/debian/mariadb-server-10.3.install b/debian/mariadb-server-10.3.install index eca7d572251..7cd81e785bf 100644 --- a/debian/mariadb-server-10.3.install +++ b/debian/mariadb-server-10.3.install @@ -4,8 +4,8 @@ debian/additions/echo_stderr usr/share/mysql debian/additions/mysqld_safe_syslog.cnf etc/mysql/conf.d etc/apparmor.d/usr.sbin.mysqld etc/security/user_map.conf -lib/systemd/system/mariadb@bootstrap.service.d/use_galera_new_cluster.conf lib/*/security/pam_user_map.so +lib/systemd/system/mariadb@bootstrap.service.d/use_galera_new_cluster.conf usr/bin/aria_chk usr/bin/aria_dump_log usr/bin/aria_ftdump @@ -88,9 +88,9 @@ usr/share/man/man1/replace.1 usr/share/man/man1/resolve_stack_dump.1 usr/share/man/man1/resolveip.1 usr/share/man/man1/wsrep_sst_common.1 +usr/share/man/man1/wsrep_sst_mariabackup.1 usr/share/man/man1/wsrep_sst_mysqldump.1 usr/share/man/man1/wsrep_sst_rsync.1 -usr/share/man/man1/wsrep_sst_mariabackup.1 usr/share/mysql/errmsg-utf8.txt usr/share/mysql/fill_help_tables.sql usr/share/mysql/maria_add_gis_sp_bootstrap.sql diff --git a/debian/mariadb-test-data.install b/debian/mariadb-test-data.install index 9e5356d061f..26b69c2941b 100644 --- a/debian/mariadb-test-data.install +++ b/debian/mariadb-test-data.install @@ -1,7 +1,7 @@ usr/share/mysql/mysql-test/collections usr/share/mysql/mysql-test/include -usr/share/mysql/mysql-test/plugin usr/share/mysql/mysql-test/main +usr/share/mysql/mysql-test/plugin usr/share/mysql/mysql-test/std_data usr/share/mysql/mysql-test/suite usr/share/mysql/mysql-test/unstable-tests From 93dc3e2652634dc99bcd715ebf1e020614dfef9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Thu, 13 Feb 2020 13:33:41 +0200 Subject: [PATCH 11/66] MDEV-21488 : Galera test sporadic failure on galera.galera_var_notify_cmd Add wait condition and cleanup. --- mysql-test/suite/galera/disabled.def | 1 - .../suite/galera/r/galera_var_notify_cmd.result | 16 ++++++++-------- .../galera/t/galera_var_notify_cmd-master.opt | 1 + .../suite/galera/t/galera_var_notify_cmd.cnf | 13 ------------- .../suite/galera/t/galera_var_notify_cmd.test | 14 ++++++++++---- 5 files changed, 19 insertions(+), 26 deletions(-) create mode 100644 mysql-test/suite/galera/t/galera_var_notify_cmd-master.opt delete mode 100644 mysql-test/suite/galera/t/galera_var_notify_cmd.cnf diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index f7ba0b3c08c..bd505bfc490 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -30,7 +30,6 @@ galera_sst_mariabackup_encrypt_with_key : MDEV-21484 galera_sst_mariabackup_encr galera_sst_mariabackup_table_options: MDEV-19741 Galera test failure on galera.galera_sst_mariabackup_table_options galera_var_innodb_disallow_writes : MDEV-20928 galera.galera_var_innodb_disallow_writes galera_var_node_address : MDEV-20485 Galera test failure -galera_var_notify_cmd : MDEV-21488 galera.galera_var_notify_cmd galera_wan : MDEV-17259 Test failure on galera.galera_wan mysql-wsrep#33 : MDEV-21420 galera.mysql-wsrep#33 partition : MDEV-19958 Galera test failure on galera.partition diff --git a/mysql-test/suite/galera/r/galera_var_notify_cmd.result b/mysql-test/suite/galera/r/galera_var_notify_cmd.result index 2b390d0db8d..823407fbba7 100644 --- a/mysql-test/suite/galera/r/galera_var_notify_cmd.result +++ b/mysql-test/suite/galera/r/galera_var_notify_cmd.result @@ -1,11 +1,11 @@ connection node_1; -SET SESSION wsrep_sync_wait=15; -SELECT COUNT(DISTINCT uuid) FROM mtr_wsrep_notify.membership; -COUNT(DISTINCT uuid) +SELECT COUNT(DISTINCT uuid) AS EXPECT_2 FROM mtr_wsrep_notify.membership; +EXPECT_2 2 -SELECT MAX(size) FROM mtr_wsrep_notify.status; -MAX(size) +SELECT MAX(size) AS EXPECT_2 FROM mtr_wsrep_notify.status; +EXPECT_2 2 -SELECT COUNT(DISTINCT idx) FROM mtr_wsrep_notify.status; -COUNT(DISTINCT idx) -1 +SELECT COUNT(DISTINCT idx) AS EXPECT_2 FROM mtr_wsrep_notify.status; +EXPECT_2 +2 +DROP SCHEMA mtr_wsrep_notify; diff --git a/mysql-test/suite/galera/t/galera_var_notify_cmd-master.opt b/mysql-test/suite/galera/t/galera_var_notify_cmd-master.opt new file mode 100644 index 00000000000..70dfc98736b --- /dev/null +++ b/mysql-test/suite/galera/t/galera_var_notify_cmd-master.opt @@ -0,0 +1 @@ +--wsrep_notify_cmd=$MYSQL_TEST_DIR/std_data/wsrep_notify.sh --wsrep-sync-wait=0 diff --git a/mysql-test/suite/galera/t/galera_var_notify_cmd.cnf b/mysql-test/suite/galera/t/galera_var_notify_cmd.cnf deleted file mode 100644 index 69df4f0e7e0..00000000000 --- a/mysql-test/suite/galera/t/galera_var_notify_cmd.cnf +++ /dev/null @@ -1,13 +0,0 @@ -!include ../galera_2nodes.cnf - -[mysqld.1] -wsrep_notify_cmd=$MYSQL_TEST_DIR/std_data/wsrep_notify.sh -wsrep-sync-wait=0 - -[mysqld.2] - - - - - - diff --git a/mysql-test/suite/galera/t/galera_var_notify_cmd.test b/mysql-test/suite/galera/t/galera_var_notify_cmd.test index 2b0852b4870..fda61bf2914 100644 --- a/mysql-test/suite/galera/t/galera_var_notify_cmd.test +++ b/mysql-test/suite/galera/t/galera_var_notify_cmd.test @@ -4,9 +4,15 @@ # --source include/galera_cluster.inc +--source include/force_restart.inc --connection node_1 -SET SESSION wsrep_sync_wait=15; -SELECT COUNT(DISTINCT uuid) FROM mtr_wsrep_notify.membership; -SELECT MAX(size) FROM mtr_wsrep_notify.status; -SELECT COUNT(DISTINCT idx) FROM mtr_wsrep_notify.status; +--let $wait_condition = SELECT COUNT(DISTINCT uuid) = 2 FROM mtr_wsrep_notify.membership; +--source include/wait_condition.inc + +SELECT COUNT(DISTINCT uuid) AS EXPECT_2 FROM mtr_wsrep_notify.membership; +SELECT MAX(size) AS EXPECT_2 FROM mtr_wsrep_notify.status; +SELECT COUNT(DISTINCT idx) AS EXPECT_2 FROM mtr_wsrep_notify.status; + +# CLEANUP +DROP SCHEMA mtr_wsrep_notify; From 8eb0384556b68401f420b19a257aaedd6722a91c Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Fri, 14 Feb 2020 20:32:46 +1100 Subject: [PATCH 12/66] mysys: remove windac my_security_attr_create (#1391) No longer used. --- include/my_sys.h | 7 -- mysys/CMakeLists.txt | 1 - mysys/my_windac.c | 202 ------------------------------------------- 3 files changed, 210 deletions(-) delete mode 100644 mysys/my_windac.c diff --git a/include/my_sys.h b/include/my_sys.h index 19faf320b24..71ec7f917c6 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -1070,13 +1070,6 @@ extern void thd_increment_net_big_packet_count(void *thd, size_t length); #ifdef __WIN__ extern my_bool have_tcpip; /* Is set if tcpip is used */ -/* implemented in my_windac.c */ - -int my_security_attr_create(SECURITY_ATTRIBUTES **psa, const char **perror, - DWORD owner_rights, DWORD everybody_rights); - -void my_security_attr_free(SECURITY_ATTRIBUTES *sa); - /* implemented in my_conio.c */ char* my_cgets(char *string, size_t clen, size_t* plen); diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt index a8be235f5e2..4ee839c6d13 100644 --- a/mysys/CMakeLists.txt +++ b/mysys/CMakeLists.txt @@ -53,7 +53,6 @@ IF (WIN32) my_wincond.c my_winerr.c my_winfile.c - my_windac.c my_conio.c my_win_popen.cc) ENDIF() diff --git a/mysys/my_windac.c b/mysys/my_windac.c deleted file mode 100644 index 9a2686a44f4..00000000000 --- a/mysys/my_windac.c +++ /dev/null @@ -1,202 +0,0 @@ -/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ - -#include "mysys_priv.h" -#include "m_string.h" -#ifdef __WIN__ - -/* - Auxiliary structure to store pointers to the data which we need to keep - around while SECURITY_ATTRIBUTES is in use. -*/ - -typedef struct st_my_security_attr -{ - PSID everyone_sid; - PACL dacl; -} My_security_attr; - - -/* - Allocate and initialize SECURITY_ATTRIBUTES setting up access - rights for the owner and group `Everybody'. - - SYNOPSIS - my_security_attr_create() - psa [OUT] pointer to store the pointer to SA in - perror [OUT] pointer to store error message if there was an - error - owner_rights [IN] access rights for the owner - everyone_rights [IN] access rights for group Everybody - - DESCRIPTION - Set up the security attributes to provide clients with sufficient - access rights to a kernel object. We need this function - because if we simply grant all access to everybody (by installing - a NULL DACL) a mailicious user can attempt a denial of service - attack by taking ownership over the kernel object. Upon successful - return `psa' contains a pointer to SECUIRITY_ATTRIBUTES that can be used - to create kernel objects with proper access rights. - - RETURN - 0 success, psa is 0 or points to a valid SA structure, - perror is left intact - !0 error, SA is set to 0, error message is stored in perror -*/ - -int my_security_attr_create(SECURITY_ATTRIBUTES **psa, const char **perror, - DWORD owner_rights, DWORD everyone_rights) -{ - /* Top-level SID authority */ - SID_IDENTIFIER_AUTHORITY world_auth= SECURITY_WORLD_SID_AUTHORITY; - PSID everyone_sid= 0; - HANDLE htoken= 0; - SECURITY_ATTRIBUTES *sa= 0; - PACL dacl= 0; - DWORD owner_token_length, dacl_length; - SECURITY_DESCRIPTOR *sd; - PTOKEN_USER owner_token; - PSID owner_sid; - My_security_attr *attr; - - /* - Get SID of Everyone group. Easier to retrieve all SIDs each time - this function is called than worry about thread safety. - */ - if (! AllocateAndInitializeSid(&world_auth, 1, SECURITY_WORLD_RID, - 0, 0, 0, 0, 0, 0, 0, &everyone_sid)) - { - *perror= "Failed to retrieve the SID of Everyone group"; - goto error; - } - - /* - Get SID of the owner. Using GetSecurityInfo this task can be done - in just one call instead of five, but GetSecurityInfo declared in - aclapi.h, so I hesitate to use it. - SIC: OpenThreadToken works only if there is an active impersonation - token, hence OpenProcessToken is used. - */ - if (! OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &htoken)) - { - *perror= "Failed to retrieve thread access token"; - goto error; - } - GetTokenInformation(htoken, TokenUser, 0, 0, &owner_token_length); - - if (! my_multi_malloc(MYF(MY_WME), - &sa, ALIGN_SIZE(sizeof(SECURITY_ATTRIBUTES)) + - sizeof(My_security_attr), - &sd, sizeof(SECURITY_DESCRIPTOR), - &owner_token, owner_token_length, - 0)) - { - *perror= "Failed to allocate memory for SECURITY_ATTRIBUTES"; - goto error; - } - bzero(owner_token, owner_token_length); - if (! GetTokenInformation(htoken, TokenUser, owner_token, - owner_token_length, &owner_token_length)) - { - *perror= "GetTokenInformation failed"; - goto error; - } - owner_sid= owner_token->User.Sid; - - if (! IsValidSid(owner_sid)) - { - *perror= "IsValidSid failed"; - goto error; - } - - /* Calculate the amount of memory that must be allocated for the DACL */ - dacl_length= sizeof(ACL) + (sizeof(ACCESS_ALLOWED_ACE)-sizeof(DWORD)) * 2 + - GetLengthSid(everyone_sid) + GetLengthSid(owner_sid); - - /* Create an ACL */ - if (! (dacl= (PACL) my_malloc(dacl_length, MYF(MY_ZEROFILL|MY_WME)))) - { - *perror= "Failed to allocate memory for DACL"; - goto error; - } - if (! InitializeAcl(dacl, dacl_length, ACL_REVISION)) - { - *perror= "Failed to initialize DACL"; - goto error; - } - if (! AddAccessAllowedAce(dacl, ACL_REVISION, everyone_rights, everyone_sid)) - { - *perror= "Failed to set up DACL"; - goto error; - } - if (! AddAccessAllowedAce(dacl, ACL_REVISION, owner_rights, owner_sid)) - { - *perror= "Failed to set up DACL"; - goto error; - } - if (! InitializeSecurityDescriptor(sd, SECURITY_DESCRIPTOR_REVISION)) - { - *perror= "Could not initialize security descriptor"; - goto error; - } - if (! SetSecurityDescriptorDacl(sd, TRUE, dacl, FALSE)) - { - *perror= "Failed to install DACL"; - goto error; - } - - sa->nLength= sizeof(*sa); - sa->bInheritHandle= TRUE; - sa->lpSecurityDescriptor= sd; - /* Save pointers to everyone_sid and dacl to be able to clean them up */ - attr= (My_security_attr*) (((char*) sa) + ALIGN_SIZE(sizeof(*sa))); - attr->everyone_sid= everyone_sid; - attr->dacl= dacl; - *psa= sa; - - CloseHandle(htoken); - return 0; -error: - if (everyone_sid) - FreeSid(everyone_sid); - if (htoken) - CloseHandle(htoken); - my_free(sa); - my_free(dacl); - *psa= 0; - return 1; -} - -/* - Cleanup security attributes freeing used memory. - - SYNOPSIS - my_security_attr_free() - sa security attributes -*/ - -void my_security_attr_free(SECURITY_ATTRIBUTES *sa) -{ - if (sa) - { - My_security_attr *attr= (My_security_attr*) - (((char*)sa) + ALIGN_SIZE(sizeof(*sa))); - FreeSid(attr->everyone_sid); - my_free(attr->dacl); - my_free(sa); - } -} - -#endif /* __WIN__ */ From 9f718041101d81d612c38eaef52b64fc187d5619 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Thu, 13 Feb 2020 23:50:17 +0300 Subject: [PATCH 13/66] MDEV-21628: Index condition pushdown condition ... not used with BKA Partitioning storage now supports MRR but doesn't support Index Condition Pushdown (aka ICP). This causes counter-intuitive query plans for queries that use BKA and conditions that depend on index fields: - If the condition refers to other tables, BKA's variant of ICP is used to handle it. - If the condition depends on this table only, the optimizer will try to use regular ICP for it, which will fail because the storage engine doesn't support ICP. Make the optimizer be smarter in the second case: if we were not able to use regular ICP, use BKA's variant of ICP.. --- mysql-test/main/partition_mrr_myisam.result | 59 +++++++++++++++++++++ mysql-test/main/partition_mrr_myisam.test | 59 +++++++++++++++++++++ sql/opt_index_cond_pushdown.cc | 15 ++++++ 3 files changed, 133 insertions(+) diff --git a/mysql-test/main/partition_mrr_myisam.result b/mysql-test/main/partition_mrr_myisam.result index 1f1cea8e9d6..d989536324c 100644 --- a/mysql-test/main/partition_mrr_myisam.result +++ b/mysql-test/main/partition_mrr_myisam.result @@ -77,3 +77,62 @@ ID part_id key_col col2 28 8 2 123456 29 9 2 123456 drop table t1,t3; +# +# MDEV-21628: Index condition pushdown for a simple condition over +# index fields is not used for ref access of partitioned tables when employing BKA +# +create table t0 ( +tp int, a int, b int, c varchar(12), index idx (a,b) +); +insert into t0 values +(1,3,30,'yyzy'), (1,3,30,'yxxyy'), (1,3,30,'yyxy'), (1,3,30,'xxyy'), +(1,3,30,'yyxz'), (1,3,30,'yyzz'), (1,3,30,'xxyzy'), (1,3,30,'yyyy'), +(1,3,30,'yzzy'), (1,93,30,'zzzy'), +(2,3,40,'yxx'), (2,4,40,'xx'), (2,3,10,'zxz'), +(2,3,40,'yyx'), (2,4,40,'xxx'), (2,3,10,'zyyz'), +(2,3,40,'xzzzz'), (2,4,40,'yyyxx'), (2,3,10,'zyz'), +(2,3,40,'xxx'), (2,4,40,'xx'), (2,3,10,'zzz'), +(2,3,40,'yyxzx'), (2,4,40,'xyx'), (2,3,10,'xzz'), +(2,3,40,'xxxzz'), (2,4,40,'xxz'), (2,3,10,'zzzy'), +(2,3,40,'zzxxx'), (2,4,40,'zxx'), (2,3,10,'yzzz'), +(2,3,40,'xyyxx'), (2,4,40,'xzzzx'), (2,3,10,'zzxxz'), +(2,3,40,'yzxxx'), (2,4,40,'xxzy'), (2,3,10,'zzzyx'), +(2,93,40,'xzx'), (2,94,40,'xz'), (2,93,10,'zyyyz'), +(3,4,30,'yx'), (3,4,30,'yyxxx'), (3,4,30,'zzyy'), (3,4,30,'zxyy'), +(3,4,30,'xxyy'), (3,4,30,'yyzx'), (3,4,30,'zyyy'), (3,4,30,'yzy'), +(3,4,30,'zzzyy'), (3,94,30,'yyz'); +create table t1 ( +tp int, a int, b int, c varchar(12), index idx (a,b) +) engine=myisam +partition by list (tp) +( partition p1 values in (1), +partition p2 values in (2), +partition p3 values in (3)); +insert into t1 select * from t0; +create table t2 (a int, index idx(a)) engine=myisam; +insert into t2 values (1), (2), (3), (4), (5); +insert into t2 select a+10 from t2; +insert into t2 select a+20 from t2; +analyze table t0,t1,t2; +Table Op Msg_type Msg_text +test.t0 analyze status Engine-independent statistics collected +test.t0 analyze status OK +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +test.t2 analyze status Engine-independent statistics collected +test.t2 analyze status OK +set @tmp1=@@join_cache_level, @tmp2=@@optimizer_switch; +set join_cache_level=6, optimizer_switch='mrr=on'; +explain +select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = 4; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range idx idx 5 NULL 2 Using where; Using index +1 SIMPLE t0 ref idx idx 5 test.t2.a 12 Using index condition; Using join buffer (flat, BKA join); Rowid-ordered scan +# This will use "Using index condition(BKA)" +explain +select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = 4; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range idx idx 5 NULL 2 Using where; Using index +1 SIMPLE t1 ref idx idx 5 test.t2.a 12 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan +set join_cache_level=@tmp1, optimizer_switch=@tmp2; +drop table t0,t1,t2; diff --git a/mysql-test/main/partition_mrr_myisam.test b/mysql-test/main/partition_mrr_myisam.test index d67a37ab3d2..eb30319d81f 100644 --- a/mysql-test/main/partition_mrr_myisam.test +++ b/mysql-test/main/partition_mrr_myisam.test @@ -1,3 +1,62 @@ let $engine_type= myisam; --source include/partition_mrr.inc + +--echo # +--echo # MDEV-21628: Index condition pushdown for a simple condition over +--echo # index fields is not used for ref access of partitioned tables when employing BKA +--echo # + +create table t0 ( +tp int, a int, b int, c varchar(12), index idx (a,b) +); + +insert into t0 values +(1,3,30,'yyzy'), (1,3,30,'yxxyy'), (1,3,30,'yyxy'), (1,3,30,'xxyy'), +(1,3,30,'yyxz'), (1,3,30,'yyzz'), (1,3,30,'xxyzy'), (1,3,30,'yyyy'), +(1,3,30,'yzzy'), (1,93,30,'zzzy'), +(2,3,40,'yxx'), (2,4,40,'xx'), (2,3,10,'zxz'), +(2,3,40,'yyx'), (2,4,40,'xxx'), (2,3,10,'zyyz'), +(2,3,40,'xzzzz'), (2,4,40,'yyyxx'), (2,3,10,'zyz'), +(2,3,40,'xxx'), (2,4,40,'xx'), (2,3,10,'zzz'), +(2,3,40,'yyxzx'), (2,4,40,'xyx'), (2,3,10,'xzz'), +(2,3,40,'xxxzz'), (2,4,40,'xxz'), (2,3,10,'zzzy'), +(2,3,40,'zzxxx'), (2,4,40,'zxx'), (2,3,10,'yzzz'), +(2,3,40,'xyyxx'), (2,4,40,'xzzzx'), (2,3,10,'zzxxz'), +(2,3,40,'yzxxx'), (2,4,40,'xxzy'), (2,3,10,'zzzyx'), +(2,93,40,'xzx'), (2,94,40,'xz'), (2,93,10,'zyyyz'), +(3,4,30,'yx'), (3,4,30,'yyxxx'), (3,4,30,'zzyy'), (3,4,30,'zxyy'), +(3,4,30,'xxyy'), (3,4,30,'yyzx'), (3,4,30,'zyyy'), (3,4,30,'yzy'), +(3,4,30,'zzzyy'), (3,94,30,'yyz'); + +create table t1 ( +tp int, a int, b int, c varchar(12), index idx (a,b) +) engine=myisam +partition by list (tp) +( partition p1 values in (1), + partition p2 values in (2), + partition p3 values in (3)); +insert into t1 select * from t0; + +create table t2 (a int, index idx(a)) engine=myisam; +insert into t2 values (1), (2), (3), (4), (5); +insert into t2 select a+10 from t2; +insert into t2 select a+20 from t2; + +analyze table t0,t1,t2; + +set @tmp1=@@join_cache_level, @tmp2=@@optimizer_switch; +set join_cache_level=6, optimizer_switch='mrr=on'; + +explain +select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = 4; + +--echo # This will use "Using index condition(BKA)" +explain +select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = 4; + +set join_cache_level=@tmp1, optimizer_switch=@tmp2; + +drop table t0,t1,t2; + + diff --git a/sql/opt_index_cond_pushdown.cc b/sql/opt_index_cond_pushdown.cc index a87d5664e29..f8d11da1d5e 100644 --- a/sql/opt_index_cond_pushdown.cc +++ b/sql/opt_index_cond_pushdown.cc @@ -390,8 +390,23 @@ void push_index_cond(JOIN_TAB *tab, uint keyno) ~(tab->table->map | tab->join->const_table_map))) tab->cache_idx_cond= idx_cond; else + { idx_remainder_cond= tab->table->file->idx_cond_push(keyno, idx_cond); + /* + If (1) there is an index condition that we couldn't push using ICP, + (2) we are using Join Buffering + (3) and we are using BKA + then use BKA's Index Condition Pushdown mechanism to check it. + */ + if (idx_remainder_cond && tab->use_join_cache && // (1) && (2) + tab->icp_other_tables_ok) // (3) + { + tab->cache_idx_cond= idx_remainder_cond; + idx_remainder_cond= NULL; + } + } + /* Disable eq_ref's "lookup cache" if we've pushed down an index condition. From 5007633c10d8aa9a4e721802975ea333f2d92d6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Fri, 31 Jan 2020 08:05:41 +0200 Subject: [PATCH 14/66] MDEV-21601 : Cleanup Galera disabled tests * Remove those tests that will not be supported on that release. * Make sure that correct tests are disabled and have MDEVs * Sort test names This should not be merged upwards. --- mysql-test/suite/galera/disabled.def | 9 - mysql-test/suite/galera/r/MW-360.result | 41 --- .../galera/r/galera_account_management.result | 65 ---- .../galera/r/galera_as_master_gtid.result | 23 -- ...galera_as_master_gtid_change_master.result | 15 - ...alera_as_slave_gtid_replicate_do_db.result | 159 --------- ...ra_as_slave_gtid_replicate_do_db_cc.result | 321 ------------------ .../r/galera_as_slave_preordered.result | 19 -- ...galera_binlog_rows_query_log_events.result | 12 - mysql-test/suite/galera/r/galera_flush.result | 88 ----- .../suite/galera/r/galera_migrate.result | 79 ----- mysql-test/suite/galera/t/MW-360.test | 100 ------ .../galera/t/galera_account_management.test | 99 ------ .../suite/galera/t/galera_as_master_gtid.cnf | 6 - .../suite/galera/t/galera_as_master_gtid.test | 70 ---- .../t/galera_as_master_gtid_change_master.cnf | 6 - .../galera_as_master_gtid_change_master.test | 56 --- .../galera_as_slave_gtid_replicate_do_db.cnf | 17 - .../galera_as_slave_gtid_replicate_do_db.test | 150 -------- ...lera_as_slave_gtid_replicate_do_db_cc.test | 174 ---------- .../galera/t/galera_as_slave_preordered.cnf | 3 - .../galera/t/galera_as_slave_preordered.test | 87 ----- .../galera_binlog_rows_query_log_events.test | 28 -- mysql-test/suite/galera/t/galera_flush.cnf | 10 - mysql-test/suite/galera/t/galera_flush.test | 273 --------------- mysql-test/suite/galera/t/galera_migrate.cnf | 61 ---- mysql-test/suite/galera/t/galera_migrate.test | 204 ----------- mysql-test/suite/galera_sr/disabled.def | 7 +- mysql-test/suite/galera_sr/r/GCF-437.result | 12 - .../r/galera_sr_table_contents.result | 178 ---------- mysql-test/suite/galera_sr/t/GCF-437.test | 21 -- .../galera_sr/t/galera_sr_table_contents.test | 49 --- 32 files changed, 3 insertions(+), 2439 deletions(-) delete mode 100644 mysql-test/suite/galera/r/MW-360.result delete mode 100644 mysql-test/suite/galera/r/galera_account_management.result delete mode 100644 mysql-test/suite/galera/r/galera_as_master_gtid.result delete mode 100644 mysql-test/suite/galera/r/galera_as_master_gtid_change_master.result delete mode 100644 mysql-test/suite/galera/r/galera_as_slave_gtid_replicate_do_db.result delete mode 100644 mysql-test/suite/galera/r/galera_as_slave_gtid_replicate_do_db_cc.result delete mode 100644 mysql-test/suite/galera/r/galera_as_slave_preordered.result delete mode 100644 mysql-test/suite/galera/r/galera_binlog_rows_query_log_events.result delete mode 100644 mysql-test/suite/galera/r/galera_flush.result delete mode 100644 mysql-test/suite/galera/r/galera_migrate.result delete mode 100644 mysql-test/suite/galera/t/MW-360.test delete mode 100644 mysql-test/suite/galera/t/galera_account_management.test delete mode 100644 mysql-test/suite/galera/t/galera_as_master_gtid.cnf delete mode 100644 mysql-test/suite/galera/t/galera_as_master_gtid.test delete mode 100644 mysql-test/suite/galera/t/galera_as_master_gtid_change_master.cnf delete mode 100644 mysql-test/suite/galera/t/galera_as_master_gtid_change_master.test delete mode 100644 mysql-test/suite/galera/t/galera_as_slave_gtid_replicate_do_db.cnf delete mode 100644 mysql-test/suite/galera/t/galera_as_slave_gtid_replicate_do_db.test delete mode 100644 mysql-test/suite/galera/t/galera_as_slave_gtid_replicate_do_db_cc.test delete mode 100644 mysql-test/suite/galera/t/galera_as_slave_preordered.cnf delete mode 100644 mysql-test/suite/galera/t/galera_as_slave_preordered.test delete mode 100644 mysql-test/suite/galera/t/galera_binlog_rows_query_log_events.test delete mode 100644 mysql-test/suite/galera/t/galera_flush.cnf delete mode 100644 mysql-test/suite/galera/t/galera_flush.test delete mode 100644 mysql-test/suite/galera/t/galera_migrate.cnf delete mode 100644 mysql-test/suite/galera/t/galera_migrate.test delete mode 100644 mysql-test/suite/galera_sr/r/GCF-437.result delete mode 100644 mysql-test/suite/galera_sr/r/galera_sr_table_contents.result delete mode 100644 mysql-test/suite/galera_sr/t/GCF-437.test delete mode 100644 mysql-test/suite/galera_sr/t/galera_sr_table_contents.test diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index e00ce9e5d6f..304ab745f54 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -18,22 +18,14 @@ MW-286 : MDEV-18464 Killing thread can cause mutex deadlock if done concurrently MW-328A : MDEV-21483 galera.MW-328A galera.MW-328B MW-328B : MDEV-21483 galera.MW-328A galera.MW-328B MW-329 : MDEV-19962 Galera test failure on MW-329 -MW-360 : needs rewrite to be MariaDB gtid compatible galera.galera_defaults : MDEV-21494 Galera test sporadic failure on galera.galera_defaults -galera_account_management : MariaDB 10.0 does not support ALTER USER -galera_as_master_gtid : Requires MySQL GTID -galera_as_master_gtid_change_master : Requires MySQL GTID galera_as_slave_gtid_myisam : MDEV-21421 galera.galera_as_slave_gtid_myisam -galera_as_slave_gtid_replicate_do_db_cc : Requires MySQL GTID -galera_as_slave_preordered : wsrep-preordered feature not merged to MariaDB galera_as_slave_replication_bundle : MDEV-15785 OPTION_GTID_BEGIN is set in Gtid_log_event::do_apply_event() galera_autoinc_sst_mariabackup : Known issue, may require porting MDEV-17458 from later versions galera_bf_abort_group_commit : MDEV-18282 Galera test failure on galera.galera_bf_abort_group_commit -galera_binlog_rows_query_log_events: MariaDB does not support binlog_rows_query_log_events galera_binlog_stmt_autoinc : MDEV-19959 Galera test failure on galera_binlog_stmt_autoinc galera_concurrent_ctas : MDEV-18180 Galera test failure on galera.galera_concurrent_ctas galera_encrypt_tmp_files : Get error failed to enable encryption of temporary files -galera_flush : MariaDB does not have global.thread_statistics galera_ftwrl : MDEV-21525 galera.galera_ftwrl galera_gcache_recover_manytrx : MDEV-18834 Galera test failure galera_ist_mariabackup : MDEV-18829 test leaves port open @@ -43,7 +35,6 @@ galera_kill_nochanges : MDEV-18280 Galera test failure on galera_split_brain and galera_load_data : MDEV-19968 galera.galera_load_data galera_many_tables_nopk : MDEV-18182 Galera test failure on galera.galera_many_tables_nopk galera_mdl_race : MDEV-21524 galera.galera_mdl_race -galera_migrate : MariaDB does not support START SLAVE USER galera_parallel_autoinc_largetrx : MDEV-20916 galera.galera_parallel_autoinc_largetrx galera_parallel_simple : MDEV-20318 galera.galera_parallel_simple fails galera_pc_ignore_sb : MDEV-20888 galera.galera_pc_ignore_sb diff --git a/mysql-test/suite/galera/r/MW-360.result b/mysql-test/suite/galera/r/MW-360.result deleted file mode 100644 index f20d5be2135..00000000000 --- a/mysql-test/suite/galera/r/MW-360.result +++ /dev/null @@ -1,41 +0,0 @@ -SET GLOBAL wsrep_on=OFF; -RESET MASTER; -SET GLOBAL wsrep_on=ON; -SET GLOBAL wsrep_on=OFF; -RESET MASTER; -SET GLOBAL wsrep_on=ON; -CREATE TEMPORARY TABLE t1 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t1 VALUES (1); -DROP TABLE t1; -CREATE TEMPORARY TABLE t1 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t1 VALUES (1); -CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t2 VALUES (2); -DROP TABLE t1, t2; -CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t1 VALUES (1); -CREATE TEMPORARY TABLE t2 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t2 VALUES (2); -DROP TABLE t1, t2; -CREATE TEMPORARY TABLE t1 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t1 VALUES (1); -CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t2 VALUES (2); -CREATE TEMPORARY TABLE t3 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t3 VALUES (3); -DROP TABLE t1, t2, t3; -CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t1 VALUES (1); -CREATE TEMPORARY TABLE t2 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t2 VALUES (2); -CREATE TABLE t3 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t3 VALUES (3); -DROP TABLE t1, t2, t3; -CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t1 VALUES (1); -CREATE TEMPORARY TABLE t1 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t1 VALUES (2); -DROP TABLE t1; -DROP TABLE t1; -gtid_executed_equal -1 diff --git a/mysql-test/suite/galera/r/galera_account_management.result b/mysql-test/suite/galera/r/galera_account_management.result deleted file mode 100644 index 6c81d401136..00000000000 --- a/mysql-test/suite/galera/r/galera_account_management.result +++ /dev/null @@ -1,65 +0,0 @@ -connection node_1; -CREATE USER user1, user2 IDENTIFIED BY 'password'; -connection node_2; -SELECT COUNT(*) = 2 FROM mysql.user WHERE user IN ('user1', 'user2'); -COUNT(*) = 2 -1 -connection node_1; -ALTER USER user1 PASSWORD EXPIRE; -SELECT password_expired = 'Y' FROM mysql.user WHERE user = 'user1'; -password_expired = 'Y' -1 -connection node_2; -SELECT password_expired = 'Y' FROM mysql.user WHERE user = 'user1'; -password_expired = 'Y' -1 -connection node_1; -RENAME USER user2 TO user3; -connection node_2; -SELECT COUNT(*) = 0 FROM mysql.user WHERE user = 'user2'; -COUNT(*) = 0 -1 -SELECT COUNT(*) = 1 FROM mysql.user WHERE user = 'user3'; -COUNT(*) = 1 -1 -connection node_1; -SET PASSWORD FOR user3 = PASSWORD('foo'); -connection node_1; -SELECT password != '' FROM mysql.user WHERE user = 'user3'; -password != '' -1 -connection node_1; -DROP USER user1, user3; -connection node_2; -SELECT COUNT(*) = 0 FROM mysql.user WHERE user IN ('user1', 'user2'); -COUNT(*) = 0 -1 -connection node_1; -GRANT ALL ON *.* TO user4 IDENTIFIED BY 'password'; -connection node_2; -SELECT COUNT(*) = 1 FROM mysql.user WHERE user = 'user4'; -COUNT(*) = 1 -1 -SELECT Select_priv = 'Y' FROM mysql.user WHERE user = 'user4'; -Select_priv = 'Y' -1 -connection node_1; -CREATE USER user5; -GRANT PROXY ON user4 TO user5; -connection node_2; -SELECT COUNT(*) = 1 FROM mysql.proxies_priv WHERE user = 'user5'; -COUNT(*) = 1 -1 -connection node_1; -REVOKE ALL PRIVILEGES ON *.* FROM user4; -connection node_2; -SELECT Select_priv = 'N' FROM mysql.user WHERE user = 'user4'; -Select_priv = 'N' -1 -connection node_1; -REVOKE PROXY ON user4 FROM user5; -connection node_2; -SELECT COUNT(*) = 0 FROM mysql.proxies_priv WHERE user = 'user5'; -COUNT(*) = 0 -1 -DROP USER user4, user5; diff --git a/mysql-test/suite/galera/r/galera_as_master_gtid.result b/mysql-test/suite/galera/r/galera_as_master_gtid.result deleted file mode 100644 index 4f5c38b607a..00000000000 --- a/mysql-test/suite/galera/r/galera_as_master_gtid.result +++ /dev/null @@ -1,23 +0,0 @@ -START SLAVE USER='root'; -Warnings: -Note 1759 Sending passwords in plain text without SSL/TLS is extremely insecure. -CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; -INSERT INTO t1 VALUES(1); -uuids_do_not_match -1 -INSERT INTO t1 VALUES(2); -uuids_do_not_match -1 -uuids_match -1 -uuids_do_not_match -1 -uuids_match -1 -DROP TABLE t1; -gtid_executed_equal -1 -gtid_executed_equal -1 -STOP SLAVE; -RESET SLAVE ALL; diff --git a/mysql-test/suite/galera/r/galera_as_master_gtid_change_master.result b/mysql-test/suite/galera/r/galera_as_master_gtid_change_master.result deleted file mode 100644 index 80fbccf58e2..00000000000 --- a/mysql-test/suite/galera/r/galera_as_master_gtid_change_master.result +++ /dev/null @@ -1,15 +0,0 @@ -START SLAVE USER='root'; -Warnings: -Note 1759 Sending passwords in plain text without SSL/TLS is extremely insecure. -CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; -INSERT INTO t1 VALUES(1); -INSERT INTO t1 VALUES(2); -STOP SLAVE; -START SLAVE USER='root'; -Warnings: -Note 1759 Sending passwords in plain text without SSL/TLS is extremely insecure. -INSERT INTO t1 VALUES(3); -INSERT INTO t1 VALUES(4); -DROP TABLE t1; -STOP SLAVE; -RESET SLAVE ALL; diff --git a/mysql-test/suite/galera/r/galera_as_slave_gtid_replicate_do_db.result b/mysql-test/suite/galera/r/galera_as_slave_gtid_replicate_do_db.result deleted file mode 100644 index 9589d319991..00000000000 --- a/mysql-test/suite/galera/r/galera_as_slave_gtid_replicate_do_db.result +++ /dev/null @@ -1,159 +0,0 @@ -connection node_2; -connection node_1; -connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3; -connection node_1; -SET global wsrep_on=OFF; -RESET MASTER; -SET global wsrep_on=ON; -connection node_3; -RESET MASTER; -connection node_2; -SET global wsrep_on=OFF; -RESET MASTER; -SET global wsrep_on=ON; -START SLAVE; -connection node_3; -CREATE SCHEMA test1; -CREATE SCHEMA test2; -USE test1; -CREATE TABLE t1 (f1 INTEGER PRIMARY KEY,f2 CHAR(5) DEFAULT 'abc') ENGINE=InnoDB; -USE test2; -CREATE TABLE t1 (f1 INTEGER PRIMARY KEY,f2 CHAR(5) DEFAULT 'abc') ENGINE=InnoDB; -INSERT INTO test1.t1 (f1) VALUES (1); -INSERT INTO test2.t1 (f1) VALUES (1); -INSERT INTO test1.t1 (f1) VALUES (2); -INSERT INTO test2.t1 (f1) VALUES (2); -INSERT INTO test1.t1 (f1) VALUES (3); -INSERT INTO test2.t1 (f1) VALUES (3); -UPDATE test2.t1 SET test2.t1.f2 = 'cde'; -UPDATE test1.t1, test2.t1 SET test1.t1.f2 = 'klm', test2.t1.f2 = 'xyz'; -DELETE test1.t1, test2.t1 FROM test1.t1 INNER JOIN test2.t1 WHERE test1.t1.f1 = test2.t1.f1 AND test1.t1.f1 = 3; -SET AUTOCOMMIT=OFF; -START TRANSACTION; -INSERT INTO test2.t1 (f1) VALUES (999); -INSERT INTO test2.t1 (f1) VALUES (9999); -COMMIT; -START TRANSACTION; -INSERT INTO test1.t1 (f1) VALUES (111); -INSERT INTO test1.t1 (f1) VALUES (222); -COMMIT; -START TRANSACTION; -INSERT INTO test1.t1 (f1) VALUES (333); -INSERT INTO test2.t1 (f1) VALUES (99999); -COMMIT; -connection node_2; -SHOW BINLOG EVENTS IN 'master-bin.000001' FROM 256; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 256 Gtid_list 2 285 [] -master-bin.000001 285 Binlog_checkpoint 2 329 master-bin.000001 -master-bin.000001 329 Gtid 3 371 GTID 0-3-1 -master-bin.000001 371 Query 3 458 CREATE SCHEMA test1 -master-bin.000001 458 Gtid 3 500 GTID 0-3-3 -master-bin.000001 500 Query 3 647 use `test1`; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY,f2 CHAR(5) DEFAULT 'abc') ENGINE=InnoDB -master-bin.000001 647 Gtid 3 689 BEGIN GTID 0-3-5 -master-bin.000001 689 Annotate_rows 3 748 INSERT INTO test1.t1 (f1) VALUES (1) -master-bin.000001 748 Table_map 3 797 table_id: ### (test1.t1) -master-bin.000001 797 Write_rows_v1 3 839 table_id: ### flags: STMT_END_F -master-bin.000001 839 Xid 3 870 COMMIT /* xid=### */ -master-bin.000001 870 Gtid 3 912 BEGIN GTID 0-3-7 -master-bin.000001 912 Annotate_rows 3 971 INSERT INTO test1.t1 (f1) VALUES (2) -master-bin.000001 971 Table_map 3 1020 table_id: ### (test1.t1) -master-bin.000001 1020 Write_rows_v1 3 1062 table_id: ### flags: STMT_END_F -master-bin.000001 1062 Xid 3 1093 COMMIT /* xid=### */ -master-bin.000001 1093 Gtid 3 1135 BEGIN GTID 0-3-9 -master-bin.000001 1135 Annotate_rows 3 1194 INSERT INTO test1.t1 (f1) VALUES (3) -master-bin.000001 1194 Table_map 3 1243 table_id: ### (test1.t1) -master-bin.000001 1243 Write_rows_v1 3 1285 table_id: ### flags: STMT_END_F -master-bin.000001 1285 Xid 3 1316 COMMIT /* xid=### */ -master-bin.000001 1316 Gtid 3 1358 BEGIN GTID 0-3-12 -master-bin.000001 1358 Annotate_rows 3 1451 UPDATE test1.t1, test2.t1 SET test1.t1.f2 = 'klm', test2.t1.f2 = 'xyz' -master-bin.000001 1451 Table_map 3 1500 table_id: ### (test1.t1) -master-bin.000001 1500 Update_rows_v1 3 1588 table_id: ### flags: STMT_END_F -master-bin.000001 1588 Xid 3 1619 COMMIT /* xid=### */ -master-bin.000001 1619 Gtid 3 1661 BEGIN GTID 0-3-13 -master-bin.000001 1661 Annotate_rows 3 1795 DELETE test1.t1, test2.t1 FROM test1.t1 INNER JOIN test2.t1 WHERE test1.t1.f1 = test2.t1.f1 AND test1.t1.f1 = 3 -master-bin.000001 1795 Table_map 3 1844 table_id: ### (test1.t1) -master-bin.000001 1844 Delete_rows_v1 3 1886 table_id: ### flags: STMT_END_F -master-bin.000001 1886 Xid 3 1917 COMMIT /* xid=### */ -master-bin.000001 1917 Gtid 3 1959 BEGIN GTID 0-3-15 -master-bin.000001 1959 Annotate_rows 3 2020 INSERT INTO test1.t1 (f1) VALUES (111) -master-bin.000001 2020 Table_map 3 2069 table_id: ### (test1.t1) -master-bin.000001 2069 Write_rows_v1 3 2111 table_id: ### flags: STMT_END_F -master-bin.000001 2111 Annotate_rows 3 2172 INSERT INTO test1.t1 (f1) VALUES (222) -master-bin.000001 2172 Table_map 3 2221 table_id: ### (test1.t1) -master-bin.000001 2221 Write_rows_v1 3 2263 table_id: ### flags: STMT_END_F -master-bin.000001 2263 Xid 3 2294 COMMIT /* xid=### */ -master-bin.000001 2294 Gtid 3 2336 BEGIN GTID -master-bin.000001 2336 Annotate_rows 3 2397 INSERT INTO test1.t1 (f1) VALUES (333) -master-bin.000001 2397 Table_map 3 2446 table_id: ### (test1.t1) -master-bin.000001 2446 Write_rows_v1 3 2488 table_id: ### flags: STMT_END_F -master-bin.000001 2488 Xid 3 2519 COMMIT /* xid=### */ -connection node_1; -gtid_executed_equal -0 -SHOW BINLOG EVENTS IN 'master-bin.000001' FROM 256; -Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 256 Gtid_list 1 285 [] -master-bin.000001 285 Binlog_checkpoint 1 329 master-bin.000001 -master-bin.000001 329 Gtid 3 371 GTID 0-3-1 -master-bin.000001 371 Query 3 458 CREATE SCHEMA test1 -master-bin.000001 458 Gtid 3 500 GTID 0-3-2 -master-bin.000001 500 Query 3 647 use `test1`; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY,f2 CHAR(5) DEFAULT 'abc') ENGINE=InnoDB -master-bin.000001 647 Gtid 3 689 BEGIN GTID 0-3-3 -master-bin.000001 689 Annotate_rows 3 748 INSERT INTO test1.t1 (f1) VALUES (1) -master-bin.000001 748 Table_map 3 797 table_id: ### (test1.t1) -master-bin.000001 797 Write_rows_v1 3 839 table_id: ### flags: STMT_END_F -master-bin.000001 839 Xid 3 870 COMMIT /* xid=### */ -master-bin.000001 870 Gtid 3 912 BEGIN GTID 0-3-4 -master-bin.000001 912 Annotate_rows 3 971 INSERT INTO test1.t1 (f1) VALUES (2) -master-bin.000001 971 Table_map 3 1020 table_id: ### (test1.t1) -master-bin.000001 1020 Write_rows_v1 3 1062 table_id: ### flags: STMT_END_F -master-bin.000001 1062 Xid 3 1093 COMMIT /* xid=### */ -master-bin.000001 1093 Gtid 3 1135 BEGIN GTID 0-3-5 -master-bin.000001 1135 Annotate_rows 3 1194 INSERT INTO test1.t1 (f1) VALUES (3) -master-bin.000001 1194 Table_map 3 1243 table_id: ### (test1.t1) -master-bin.000001 1243 Write_rows_v1 3 1285 table_id: ### flags: STMT_END_F -master-bin.000001 1285 Xid 3 1316 COMMIT /* xid=### */ -master-bin.000001 1316 Gtid 3 1358 BEGIN GTID 0-3-6 -master-bin.000001 1358 Annotate_rows 3 1451 UPDATE test1.t1, test2.t1 SET test1.t1.f2 = 'klm', test2.t1.f2 = 'xyz' -master-bin.000001 1451 Table_map 3 1500 table_id: ### (test1.t1) -master-bin.000001 1500 Update_rows_v1 3 1588 table_id: ### flags: STMT_END_F -master-bin.000001 1588 Xid 3 1619 COMMIT /* xid=### */ -master-bin.000001 1619 Gtid 3 1661 BEGIN GTID 0-3-7 -master-bin.000001 1661 Annotate_rows 3 1795 DELETE test1.t1, test2.t1 FROM test1.t1 INNER JOIN test2.t1 WHERE test1.t1.f1 = test2.t1.f1 AND test1.t1.f1 = 3 -master-bin.000001 1795 Table_map 3 1844 table_id: ### (test1.t1) -master-bin.000001 1844 Delete_rows_v1 3 1886 table_id: ### flags: STMT_END_F -master-bin.000001 1886 Xid 3 1917 COMMIT /* xid=### */ -master-bin.000001 1917 Gtid 3 1959 BEGIN GTID 0-3-8 -master-bin.000001 1959 Annotate_rows 3 2020 INSERT INTO test1.t1 (f1) VALUES (111) -master-bin.000001 2020 Table_map 3 2069 table_id: ### (test1.t1) -master-bin.000001 2069 Write_rows_v1 3 2111 table_id: ### flags: STMT_END_F -master-bin.000001 2111 Annotate_rows 3 2172 INSERT INTO test1.t1 (f1) VALUES (222) -master-bin.000001 2172 Table_map 3 2221 table_id: ### (test1.t1) -master-bin.000001 2221 Write_rows_v1 3 2263 table_id: ### flags: STMT_END_F -master-bin.000001 2263 Xid 3 2294 COMMIT /* xid=### */ -master-bin.000001 2294 Gtid 3 2336 BEGIN GTID 0-3-9 -master-bin.000001 2336 Annotate_rows 3 2397 INSERT INTO test1.t1 (f1) VALUES (333) -master-bin.000001 2397 Table_map 3 2446 table_id: ### (test1.t1) -master-bin.000001 2446 Write_rows_v1 3 2488 table_id: ### flags: STMT_END_F -master-bin.000001 2488 Xid 3 2519 COMMIT /* xid=### */ -include/diff_servers.inc [servers=1 2] -connection node_1; -SELECT COUNT(*) = 2 FROM test1.t1 WHERE f1 IN (1,2); -COUNT(*) = 2 -1 -SELECT COUNT(*) = 3 FROM test1.t1 WHERE f1 IN (111,222,333); -COUNT(*) = 3 -1 -SELECT COUNT(*) = 2 FROM test1.t1 WHERE f2 = 'klm'; -COUNT(*) = 2 -1 -USE test2; -ERROR 42000: Unknown database 'test2' -connection node_3; -DROP SCHEMA test1; -DROP SCHEMA test2; -connection node_1; -connection node_2; -STOP SLAVE; -RESET SLAVE ALL; diff --git a/mysql-test/suite/galera/r/galera_as_slave_gtid_replicate_do_db_cc.result b/mysql-test/suite/galera/r/galera_as_slave_gtid_replicate_do_db_cc.result deleted file mode 100644 index aba5a098b69..00000000000 --- a/mysql-test/suite/galera/r/galera_as_slave_gtid_replicate_do_db_cc.result +++ /dev/null @@ -1,321 +0,0 @@ -connection node_2; -connection node_1; -connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3; -connection node_1; -SET global wsrep_on=OFF; -RESET MASTER; -SET global wsrep_on=ON; -connection node_3; -RESET MASTER; -connection node_2; -SET global wsrep_on=OFF; -RESET MASTER; -SET global wsrep_on=ON; -START SLAVE USER='root'; -Warnings: -Note 1759 Sending passwords in plain text without SSL/TLS is extremely insecure. -CREATE SCHEMA test1; -CREATE SCHEMA test2; -USE test1; -CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; -USE test2; -CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO test1.t1 (f1) VALUES (1); -INSERT INTO test2.t1 (f1) VALUES (1); -INSERT INTO test1.t1 (f1) VALUES (2); -INSERT INTO test2.t1 (f1) VALUES (2); -SET GLOBAL wsrep_provider_options='gmcast.isolate=1'; -INSERT INTO test1.t1 (f1) VALUES (3); -INSERT INTO test2.t1 (f1) VALUES (3); -INSERT INTO test1.t1 (f1) VALUES (3); -INSERT INTO test2.t1 (f1) VALUES (3); -INSERT INTO test1.t1 (f1) VALUES (3); -INSERT INTO test2.t1 (f1) VALUES (3); -INSERT INTO test1.t1 (f1) VALUES (3); -INSERT INTO test2.t1 (f1) VALUES (3); -SET SESSION wsrep_on=OFF; -include/wait_for_slave_sql_error.inc [errno=1047] -INSERT INTO test1.t1 (f1) VALUES (4); -INSERT INTO test2.t1 (f1) VALUES (4); -INSERT INTO test1.t1 (f1) VALUES (4); -INSERT INTO test2.t1 (f1) VALUES (4); -INSERT INTO test1.t1 (f1) VALUES (4); -INSERT INTO test2.t1 (f1) VALUES (4); -INSERT INTO test1.t1 (f1) VALUES (4); -INSERT INTO test2.t1 (f1) VALUES (4); -INSERT INTO test1.t1 (f1) VALUES (4); -INSERT INTO test2.t1 (f1) VALUES (4); -SET GLOBAL wsrep_provider_options='gmcast.isolate=0'; -INSERT INTO test1.t1 (f1) VALUES (5); -INSERT INTO test2.t1 (f1) VALUES (5); -SET SESSION wsrep_on=ON; -INSERT INTO test1.t1 (f1) VALUES (6); -INSERT INTO test2.t1 (f1) VALUES (6); -START SLAVE; -SHOW BINLOG EVENTS IN 'mysqld-bin.000001' FROM 120; -Log_name Pos Event_type Server_id End_log_pos Info -mysqld-bin.000001 120 Previous_gtids 2 151 -mysqld-bin.000001 151 Gtid 1 199 SET @@SESSION.GTID_NEXT= ':1' -mysqld-bin.000001 199 Query 1 294 CREATE SCHEMA test1 -mysqld-bin.000001 294 Gtid 1 342 SET @@SESSION.GTID_NEXT= ':2' -mysqld-bin.000001 342 Query 1 415 BEGIN -mysqld-bin.000001 415 Query 1 489 COMMIT -mysqld-bin.000001 489 Gtid 1 537 SET @@SESSION.GTID_NEXT= ':3' -mysqld-bin.000001 537 Query 1 655 use `test1`; CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB -mysqld-bin.000001 655 Gtid 1 703 SET @@SESSION.GTID_NEXT= ':4' -mysqld-bin.000001 703 Query 1 776 BEGIN -mysqld-bin.000001 776 Query 1 850 COMMIT -mysqld-bin.000001 850 Gtid 1 898 SET @@SESSION.GTID_NEXT= ':5' -mysqld-bin.000001 898 Query 1 961 BEGIN -mysqld-bin.000001 961 Table_map 1 1007 table_id: ### (test1.t1) -mysqld-bin.000001 1007 Write_rows 1 1047 table_id: ### flags: STMT_END_F -mysqld-bin.000001 1047 Xid 1 1078 COMMIT /* xid=### */ -mysqld-bin.000001 1078 Gtid 1 1126 SET @@SESSION.GTID_NEXT= ':6' -mysqld-bin.000001 1126 Query 1 1189 BEGIN -mysqld-bin.000001 1189 Query 1 1253 COMMIT -mysqld-bin.000001 1253 Gtid 1 1301 SET @@SESSION.GTID_NEXT= ':7' -mysqld-bin.000001 1301 Query 1 1364 BEGIN -mysqld-bin.000001 1364 Table_map 1 1410 table_id: ### (test1.t1) -mysqld-bin.000001 1410 Write_rows 1 1450 table_id: ### flags: STMT_END_F -mysqld-bin.000001 1450 Xid 1 1481 COMMIT /* xid=### */ -mysqld-bin.000001 1481 Gtid 1 1529 SET @@SESSION.GTID_NEXT= ':8' -mysqld-bin.000001 1529 Query 1 1592 BEGIN -mysqld-bin.000001 1592 Query 1 1656 COMMIT -mysqld-bin.000001 1656 Gtid 2 1704 SET @@SESSION.GTID_NEXT= ':12' -mysqld-bin.000001 1704 Query 2 1772 BEGIN -mysqld-bin.000001 1772 Ignorable 2 1795 # Unrecognized ignorable event -mysqld-bin.000001 1795 Query 2 1864 COMMIT -mysqld-bin.000001 1864 Gtid 2 1912 SET @@SESSION.GTID_NEXT= ':13' -mysqld-bin.000001 1912 Query 2 1980 BEGIN -mysqld-bin.000001 1980 Ignorable 2 2003 # Unrecognized ignorable event -mysqld-bin.000001 2003 Query 2 2072 COMMIT -mysqld-bin.000001 2072 Gtid 1 2120 SET @@SESSION.GTID_NEXT= ':9' -mysqld-bin.000001 2120 Query 1 2183 BEGIN -mysqld-bin.000001 2183 Table_map 1 2229 table_id: ### (test1.t1) -mysqld-bin.000001 2229 Write_rows 1 2269 table_id: ### flags: STMT_END_F -mysqld-bin.000001 2269 Xid 1 2300 COMMIT /* xid=### */ -mysqld-bin.000001 2300 Gtid 1 2348 SET @@SESSION.GTID_NEXT= ':10' -mysqld-bin.000001 2348 Query 1 2411 BEGIN -mysqld-bin.000001 2411 Query 1 2475 COMMIT -mysqld-bin.000001 2475 Gtid 1 2523 SET @@SESSION.GTID_NEXT= ':11' -mysqld-bin.000001 2523 Query 1 2586 BEGIN -mysqld-bin.000001 2586 Table_map 1 2632 table_id: ### (test1.t1) -mysqld-bin.000001 2632 Write_rows 1 2672 table_id: ### flags: STMT_END_F -mysqld-bin.000001 2672 Xid 1 2703 COMMIT /* xid=### */ -mysqld-bin.000001 2703 Gtid 1 2751 SET @@SESSION.GTID_NEXT= ':12' -mysqld-bin.000001 2751 Query 1 2814 BEGIN -mysqld-bin.000001 2814 Query 1 2878 COMMIT -mysqld-bin.000001 2878 Gtid 1 2926 SET @@SESSION.GTID_NEXT= ':13' -mysqld-bin.000001 2926 Query 1 2989 BEGIN -mysqld-bin.000001 2989 Table_map 1 3035 table_id: ### (test1.t1) -mysqld-bin.000001 3035 Write_rows 1 3075 table_id: ### flags: STMT_END_F -mysqld-bin.000001 3075 Xid 1 3106 COMMIT /* xid=### */ -mysqld-bin.000001 3106 Gtid 1 3154 SET @@SESSION.GTID_NEXT= ':14' -mysqld-bin.000001 3154 Query 1 3217 BEGIN -mysqld-bin.000001 3217 Query 1 3281 COMMIT -mysqld-bin.000001 3281 Gtid 1 3329 SET @@SESSION.GTID_NEXT= ':15' -mysqld-bin.000001 3329 Query 1 3392 BEGIN -mysqld-bin.000001 3392 Table_map 1 3438 table_id: ### (test1.t1) -mysqld-bin.000001 3438 Write_rows 1 3478 table_id: ### flags: STMT_END_F -mysqld-bin.000001 3478 Xid 1 3509 COMMIT /* xid=### */ -mysqld-bin.000001 3509 Gtid 1 3557 SET @@SESSION.GTID_NEXT= ':16' -mysqld-bin.000001 3557 Query 1 3620 BEGIN -mysqld-bin.000001 3620 Query 1 3684 COMMIT -mysqld-bin.000001 3684 Gtid 1 3732 SET @@SESSION.GTID_NEXT= ':17' -mysqld-bin.000001 3732 Query 1 3795 BEGIN -mysqld-bin.000001 3795 Table_map 1 3841 table_id: ### (test1.t1) -mysqld-bin.000001 3841 Write_rows 1 3881 table_id: ### flags: STMT_END_F -mysqld-bin.000001 3881 Xid 1 3912 COMMIT /* xid=### */ -mysqld-bin.000001 3912 Gtid 1 3960 SET @@SESSION.GTID_NEXT= ':18' -mysqld-bin.000001 3960 Query 1 4023 BEGIN -mysqld-bin.000001 4023 Query 1 4087 COMMIT -mysqld-bin.000001 4087 Gtid 1 4135 SET @@SESSION.GTID_NEXT= ':19' -mysqld-bin.000001 4135 Query 1 4198 BEGIN -mysqld-bin.000001 4198 Table_map 1 4244 table_id: ### (test1.t1) -mysqld-bin.000001 4244 Write_rows 1 4284 table_id: ### flags: STMT_END_F -mysqld-bin.000001 4284 Xid 1 4315 COMMIT /* xid=### */ -mysqld-bin.000001 4315 Gtid 1 4363 SET @@SESSION.GTID_NEXT= ':20' -mysqld-bin.000001 4363 Query 1 4426 BEGIN -mysqld-bin.000001 4426 Query 1 4490 COMMIT -mysqld-bin.000001 4490 Gtid 1 4538 SET @@SESSION.GTID_NEXT= ':21' -mysqld-bin.000001 4538 Query 1 4601 BEGIN -mysqld-bin.000001 4601 Table_map 1 4647 table_id: ### (test1.t1) -mysqld-bin.000001 4647 Write_rows 1 4687 table_id: ### flags: STMT_END_F -mysqld-bin.000001 4687 Xid 1 4718 COMMIT /* xid=### */ -mysqld-bin.000001 4718 Gtid 1 4766 SET @@SESSION.GTID_NEXT= ':22' -mysqld-bin.000001 4766 Query 1 4829 BEGIN -mysqld-bin.000001 4829 Query 1 4893 COMMIT -mysqld-bin.000001 4893 Gtid 1 4941 SET @@SESSION.GTID_NEXT= ':23' -mysqld-bin.000001 4941 Query 1 5004 BEGIN -mysqld-bin.000001 5004 Table_map 1 5050 table_id: ### (test1.t1) -mysqld-bin.000001 5050 Write_rows 1 5090 table_id: ### flags: STMT_END_F -mysqld-bin.000001 5090 Xid 1 5121 COMMIT /* xid=### */ -mysqld-bin.000001 5121 Gtid 1 5169 SET @@SESSION.GTID_NEXT= ':24' -mysqld-bin.000001 5169 Query 1 5232 BEGIN -mysqld-bin.000001 5232 Query 1 5296 COMMIT -mysqld-bin.000001 5296 Gtid 1 5344 SET @@SESSION.GTID_NEXT= ':25' -mysqld-bin.000001 5344 Query 1 5407 BEGIN -mysqld-bin.000001 5407 Table_map 1 5453 table_id: ### (test1.t1) -mysqld-bin.000001 5453 Write_rows 1 5493 table_id: ### flags: STMT_END_F -mysqld-bin.000001 5493 Xid 1 5524 COMMIT /* xid=### */ -mysqld-bin.000001 5524 Gtid 1 5572 SET @@SESSION.GTID_NEXT= ':26' -mysqld-bin.000001 5572 Query 1 5635 BEGIN -mysqld-bin.000001 5635 Query 1 5699 COMMIT -mysqld-bin.000001 5699 Gtid 1 5747 SET @@SESSION.GTID_NEXT= ':27' -mysqld-bin.000001 5747 Query 1 5810 BEGIN -mysqld-bin.000001 5810 Table_map 1 5856 table_id: ### (test1.t1) -mysqld-bin.000001 5856 Write_rows 1 5896 table_id: ### flags: STMT_END_F -mysqld-bin.000001 5896 Xid 1 5927 COMMIT /* xid=### */ -mysqld-bin.000001 5927 Gtid 1 5975 SET @@SESSION.GTID_NEXT= ':28' -mysqld-bin.000001 5975 Query 1 6038 BEGIN -mysqld-bin.000001 6038 Query 1 6102 COMMIT -mysqld-bin.000001 6102 Gtid 1 6150 SET @@SESSION.GTID_NEXT= ':29' -mysqld-bin.000001 6150 Query 1 6213 BEGIN -mysqld-bin.000001 6213 Table_map 1 6259 table_id: ### (test1.t1) -mysqld-bin.000001 6259 Write_rows 1 6299 table_id: ### flags: STMT_END_F -mysqld-bin.000001 6299 Xid 1 6330 COMMIT /* xid=### */ -mysqld-bin.000001 6330 Gtid 1 6378 SET @@SESSION.GTID_NEXT= ':30' -mysqld-bin.000001 6378 Query 1 6441 BEGIN -mysqld-bin.000001 6441 Query 1 6505 COMMIT -USE test2; -ERROR 42000: Unknown database 'test2' -gtid_executed_equal -1 -USE test2; -ERROR 42000: Unknown database 'test2' -SHOW BINLOG EVENTS IN 'mysqld-bin.000001' FROM 120; -Log_name Pos Event_type Server_id End_log_pos Info -mysqld-bin.000001 120 Previous_gtids 4 151 -mysqld-bin.000001 151 Gtid 1 199 SET @@SESSION.GTID_NEXT= ':1' -mysqld-bin.000001 199 Query 1 294 CREATE SCHEMA test1 -mysqld-bin.000001 294 Gtid 1 342 SET @@SESSION.GTID_NEXT= ':2' -mysqld-bin.000001 342 Query 1 415 BEGIN -mysqld-bin.000001 415 Query 1 489 COMMIT -mysqld-bin.000001 489 Gtid 1 537 SET @@SESSION.GTID_NEXT= ':3' -mysqld-bin.000001 537 Query 1 655 use `test1`; CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB -mysqld-bin.000001 655 Gtid 1 703 SET @@SESSION.GTID_NEXT= ':4' -mysqld-bin.000001 703 Query 1 776 BEGIN -mysqld-bin.000001 776 Query 1 850 COMMIT -mysqld-bin.000001 850 Gtid 1 898 SET @@SESSION.GTID_NEXT= ':5' -mysqld-bin.000001 898 Query 1 961 BEGIN -mysqld-bin.000001 961 Table_map 1 1007 table_id: ### (test1.t1) -mysqld-bin.000001 1007 Write_rows 1 1047 table_id: ### flags: STMT_END_F -mysqld-bin.000001 1047 Xid 1 1078 COMMIT /* xid=### */ -mysqld-bin.000001 1078 Gtid 1 1126 SET @@SESSION.GTID_NEXT= ':6' -mysqld-bin.000001 1126 Query 1 1189 BEGIN -mysqld-bin.000001 1189 Query 1 1253 COMMIT -mysqld-bin.000001 1253 Gtid 1 1301 SET @@SESSION.GTID_NEXT= ':7' -mysqld-bin.000001 1301 Query 1 1364 BEGIN -mysqld-bin.000001 1364 Table_map 1 1410 table_id: ### (test1.t1) -mysqld-bin.000001 1410 Write_rows 1 1450 table_id: ### flags: STMT_END_F -mysqld-bin.000001 1450 Xid 1 1481 COMMIT /* xid=### */ -mysqld-bin.000001 1481 Gtid 1 1529 SET @@SESSION.GTID_NEXT= ':8' -mysqld-bin.000001 1529 Query 1 1592 BEGIN -mysqld-bin.000001 1592 Query 1 1656 COMMIT -mysqld-bin.000001 1656 Gtid 4 1704 SET @@SESSION.GTID_NEXT= ':12' -mysqld-bin.000001 1704 Query 4 1772 BEGIN -mysqld-bin.000001 1772 Ignorable 4 1795 # Unrecognized ignorable event -mysqld-bin.000001 1795 Query 4 1864 COMMIT -mysqld-bin.000001 1864 Gtid 4 1912 SET @@SESSION.GTID_NEXT= ':13' -mysqld-bin.000001 1912 Query 4 1980 BEGIN -mysqld-bin.000001 1980 Ignorable 4 2003 # Unrecognized ignorable event -mysqld-bin.000001 2003 Query 4 2072 COMMIT -mysqld-bin.000001 2072 Gtid 1 2120 SET @@SESSION.GTID_NEXT= ':9' -mysqld-bin.000001 2120 Query 1 2183 BEGIN -mysqld-bin.000001 2183 Table_map 1 2229 table_id: ### (test1.t1) -mysqld-bin.000001 2229 Write_rows 1 2269 table_id: ### flags: STMT_END_F -mysqld-bin.000001 2269 Xid 1 2300 COMMIT /* xid=### */ -mysqld-bin.000001 2300 Gtid 1 2348 SET @@SESSION.GTID_NEXT= ':10' -mysqld-bin.000001 2348 Query 1 2411 BEGIN -mysqld-bin.000001 2411 Query 1 2475 COMMIT -mysqld-bin.000001 2475 Gtid 1 2523 SET @@SESSION.GTID_NEXT= ':11' -mysqld-bin.000001 2523 Query 1 2586 BEGIN -mysqld-bin.000001 2586 Table_map 1 2632 table_id: ### (test1.t1) -mysqld-bin.000001 2632 Write_rows 1 2672 table_id: ### flags: STMT_END_F -mysqld-bin.000001 2672 Xid 1 2703 COMMIT /* xid=### */ -mysqld-bin.000001 2703 Gtid 1 2751 SET @@SESSION.GTID_NEXT= ':12' -mysqld-bin.000001 2751 Query 1 2814 BEGIN -mysqld-bin.000001 2814 Query 1 2878 COMMIT -mysqld-bin.000001 2878 Gtid 1 2926 SET @@SESSION.GTID_NEXT= ':13' -mysqld-bin.000001 2926 Query 1 2989 BEGIN -mysqld-bin.000001 2989 Table_map 1 3035 table_id: ### (test1.t1) -mysqld-bin.000001 3035 Write_rows 1 3075 table_id: ### flags: STMT_END_F -mysqld-bin.000001 3075 Xid 1 3106 COMMIT /* xid=### */ -mysqld-bin.000001 3106 Gtid 1 3154 SET @@SESSION.GTID_NEXT= ':14' -mysqld-bin.000001 3154 Query 1 3217 BEGIN -mysqld-bin.000001 3217 Query 1 3281 COMMIT -mysqld-bin.000001 3281 Gtid 1 3329 SET @@SESSION.GTID_NEXT= ':15' -mysqld-bin.000001 3329 Query 1 3392 BEGIN -mysqld-bin.000001 3392 Table_map 1 3438 table_id: ### (test1.t1) -mysqld-bin.000001 3438 Write_rows 1 3478 table_id: ### flags: STMT_END_F -mysqld-bin.000001 3478 Xid 1 3509 COMMIT /* xid=### */ -mysqld-bin.000001 3509 Gtid 1 3557 SET @@SESSION.GTID_NEXT= ':16' -mysqld-bin.000001 3557 Query 1 3620 BEGIN -mysqld-bin.000001 3620 Query 1 3684 COMMIT -mysqld-bin.000001 3684 Gtid 1 3732 SET @@SESSION.GTID_NEXT= ':17' -mysqld-bin.000001 3732 Query 1 3795 BEGIN -mysqld-bin.000001 3795 Table_map 1 3841 table_id: ### (test1.t1) -mysqld-bin.000001 3841 Write_rows 1 3881 table_id: ### flags: STMT_END_F -mysqld-bin.000001 3881 Xid 1 3912 COMMIT /* xid=### */ -mysqld-bin.000001 3912 Gtid 1 3960 SET @@SESSION.GTID_NEXT= ':18' -mysqld-bin.000001 3960 Query 1 4023 BEGIN -mysqld-bin.000001 4023 Query 1 4087 COMMIT -mysqld-bin.000001 4087 Gtid 1 4135 SET @@SESSION.GTID_NEXT= ':19' -mysqld-bin.000001 4135 Query 1 4198 BEGIN -mysqld-bin.000001 4198 Table_map 1 4244 table_id: ### (test1.t1) -mysqld-bin.000001 4244 Write_rows 1 4284 table_id: ### flags: STMT_END_F -mysqld-bin.000001 4284 Xid 1 4315 COMMIT /* xid=### */ -mysqld-bin.000001 4315 Gtid 1 4363 SET @@SESSION.GTID_NEXT= ':20' -mysqld-bin.000001 4363 Query 1 4426 BEGIN -mysqld-bin.000001 4426 Query 1 4490 COMMIT -mysqld-bin.000001 4490 Gtid 1 4538 SET @@SESSION.GTID_NEXT= ':21' -mysqld-bin.000001 4538 Query 1 4601 BEGIN -mysqld-bin.000001 4601 Table_map 1 4647 table_id: ### (test1.t1) -mysqld-bin.000001 4647 Write_rows 1 4687 table_id: ### flags: STMT_END_F -mysqld-bin.000001 4687 Xid 1 4718 COMMIT /* xid=### */ -mysqld-bin.000001 4718 Gtid 1 4766 SET @@SESSION.GTID_NEXT= ':22' -mysqld-bin.000001 4766 Query 1 4829 BEGIN -mysqld-bin.000001 4829 Query 1 4893 COMMIT -mysqld-bin.000001 4893 Gtid 1 4941 SET @@SESSION.GTID_NEXT= ':23' -mysqld-bin.000001 4941 Query 1 5004 BEGIN -mysqld-bin.000001 5004 Table_map 1 5050 table_id: ### (test1.t1) -mysqld-bin.000001 5050 Write_rows 1 5090 table_id: ### flags: STMT_END_F -mysqld-bin.000001 5090 Xid 1 5121 COMMIT /* xid=### */ -mysqld-bin.000001 5121 Gtid 1 5169 SET @@SESSION.GTID_NEXT= ':24' -mysqld-bin.000001 5169 Query 1 5232 BEGIN -mysqld-bin.000001 5232 Query 1 5296 COMMIT -mysqld-bin.000001 5296 Gtid 1 5344 SET @@SESSION.GTID_NEXT= ':25' -mysqld-bin.000001 5344 Query 1 5407 BEGIN -mysqld-bin.000001 5407 Table_map 1 5453 table_id: ### (test1.t1) -mysqld-bin.000001 5453 Write_rows 1 5493 table_id: ### flags: STMT_END_F -mysqld-bin.000001 5493 Xid 1 5524 COMMIT /* xid=### */ -mysqld-bin.000001 5524 Gtid 1 5572 SET @@SESSION.GTID_NEXT= ':26' -mysqld-bin.000001 5572 Query 1 5635 BEGIN -mysqld-bin.000001 5635 Query 1 5699 COMMIT -mysqld-bin.000001 5699 Gtid 1 5747 SET @@SESSION.GTID_NEXT= ':27' -mysqld-bin.000001 5747 Query 1 5810 BEGIN -mysqld-bin.000001 5810 Table_map 1 5856 table_id: ### (test1.t1) -mysqld-bin.000001 5856 Write_rows 1 5896 table_id: ### flags: STMT_END_F -mysqld-bin.000001 5896 Xid 1 5927 COMMIT /* xid=### */ -mysqld-bin.000001 5927 Gtid 1 5975 SET @@SESSION.GTID_NEXT= ':28' -mysqld-bin.000001 5975 Query 1 6038 BEGIN -mysqld-bin.000001 6038 Query 1 6102 COMMIT -mysqld-bin.000001 6102 Gtid 1 6150 SET @@SESSION.GTID_NEXT= ':29' -mysqld-bin.000001 6150 Query 1 6213 BEGIN -mysqld-bin.000001 6213 Table_map 1 6259 table_id: ### (test1.t1) -mysqld-bin.000001 6259 Write_rows 1 6299 table_id: ### flags: STMT_END_F -mysqld-bin.000001 6299 Xid 1 6330 COMMIT /* xid=### */ -mysqld-bin.000001 6330 Gtid 1 6378 SET @@SESSION.GTID_NEXT= ':30' -mysqld-bin.000001 6378 Query 1 6441 BEGIN -mysqld-bin.000001 6441 Query 1 6505 COMMIT -DROP SCHEMA test1; -DROP SCHEMA test2; -STOP SLAVE; -RESET SLAVE ALL; -CALL mtr.add_suppression("GTID replication failed"); -CALL mtr.add_suppression("Slave SQL: Error in Xid_log_event: Commit could not be completed"); -CALL mtr.add_suppression("Slave SQL: Node has dropped from cluster, Error_code: 1047"); -CALL mtr.add_suppression("TO isolation failed for"); -CALL mtr.add_suppression("Slave SQL: Error 'Deadlock found when trying to get lock; try restarting transaction' on query"); -CALL mtr.add_suppression("Slave SQL: Error 'WSREP has not yet prepared node for application use' on query"); -CALL mtr.add_suppression("Slave: WSREP has not yet prepared node for application use Error_code: 1047"); diff --git a/mysql-test/suite/galera/r/galera_as_slave_preordered.result b/mysql-test/suite/galera/r/galera_as_slave_preordered.result deleted file mode 100644 index 27a08e73491..00000000000 --- a/mysql-test/suite/galera/r/galera_as_slave_preordered.result +++ /dev/null @@ -1,19 +0,0 @@ -START SLAVE USER='root'; -Warnings: -Note 1759 Sending passwords in plain text without SSL/TLS is extremely insecure. -CREATE TABLE ten (f1 INTEGER); -INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); -CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 INTEGER) ENGINE=InnoDB; -SELECT COUNT(DISTINCT f1) = 2 * 100 * 10 * 10 FROM t1; -COUNT(DISTINCT f1) = 2 * 100 * 10 * 10 -1 -SELECT COUNT(*) = 2 * 100 * 10 * 10 FROM t1; -COUNT(*) = 2 * 100 * 10 * 10 -1 -SELECT COUNT(DISTINCT f1) = 2 * 100 * 10 * 10 FROM t1; -COUNT(DISTINCT f1) = 2 * 100 * 10 * 10 -1 -DROP TABLE t1; -DROP TABLE ten; -STOP SLAVE; -RESET SLAVE ALL; diff --git a/mysql-test/suite/galera/r/galera_binlog_rows_query_log_events.result b/mysql-test/suite/galera/r/galera_binlog_rows_query_log_events.result deleted file mode 100644 index 80ae3d0de2c..00000000000 --- a/mysql-test/suite/galera/r/galera_binlog_rows_query_log_events.result +++ /dev/null @@ -1,12 +0,0 @@ -SET GLOBAL binlog_rows_query_log_events=TRUE; -CREATE TABLE t1 (f1 INT PRIMARY KEY) ENGINE=InnoDB; -INSERT INTO t1 VALUES (1); -SELECT COUNT(*) = 1 FROM t1; -COUNT(*) = 1 -1 -UPDATE t1 SET f1 = 2 WHERE f1 = 1; -SELECT COUNT(*) = 1 FROM t1 WHERE f1 = 2; -COUNT(*) = 1 -1 -SET GLOBAL binlog_rows_query_log_events = 0; -DROP TABLE t1; diff --git a/mysql-test/suite/galera/r/galera_flush.result b/mysql-test/suite/galera/r/galera_flush.result deleted file mode 100644 index 71226432eda..00000000000 --- a/mysql-test/suite/galera/r/galera_flush.result +++ /dev/null @@ -1,88 +0,0 @@ -DROP TABLE IF EXISTS t1, t2; -FLUSH DES_KEY_FILE; -wsrep_last_committed_diff -1 -FLUSH HOSTS; -wsrep_last_committed_diff -1 -SET GLOBAL wsrep_replicate_myisam = TRUE; -INSERT INTO mysql.user VALUES('localhost','user1',PASSWORD('pass1'), 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0,'mysql_native_password','','N','N','',0); -FLUSH PRIVILEGES; -DELETE FROM mysql.user WHERE user = 'user1'; -SET GLOBAL wsrep_replicate_myisam = FALSE; -FLUSH PRIVILEGES; -FLUSH QUERY CACHE; -wsrep_last_committed_diff -1 -FLUSH STATUS; -wsrep_last_committed_diff -1 -FLUSH USER_RESOURCES; -wsrep_last_committed_diff -1 -FLUSH TABLES; -wsrep_last_committed_diff -1 -CREATE TABLE t2 (f1 INTEGER); -FLUSH TABLES t2; -wsrep_last_committed_diff -1 -FLUSH ERROR LOGS; -wsrep_last_committed_diff -1 -FLUSH SLOW LOGS; -wsrep_last_committed_diff -1 -FLUSH GENERAL LOGS; -wsrep_last_committed_diff -1 -FLUSH ENGINE LOGS; -wsrep_last_committed_diff -1 -FLUSH RELAY LOGS; -wsrep_last_committed_diff -1 -SET @userstat_old= @@userstat; -SET GLOBAL userstat=ON; -FLUSH CLIENT_STATISTICS; -FLUSH INDEX_STATISTICS; -FLUSH TABLE_STATISTICS; -FLUSH USER_STATISTICS; -wsrep_last_committed_diff -1 -SET @old_thread_statistics= @@global.thread_statistics; -SET GLOBAL thread_statistics= ON; -FLUSH THREAD_STATISTICS; -wsrep_last_committed_diff -1 -FLUSH CHANGED_PAGE_BITMAPS; -wsrep_last_committed_diff -1 -CREATE TABLE t1 (f1 INTEGER); -FLUSH LOGS; -FLUSH TABLES WITH READ LOCK; -UNLOCK TABLES; -FLUSH TABLES t1 WITH READ LOCK; -UNLOCK TABLES; -FLUSH TABLES t1 FOR EXPORT; -UNLOCK TABLES; -wsrep_last_committed_diff -1 -LOCK TABLES t1 WRITE; -FLUSH TABLES t1; -UNLOCK TABLES; -wsrep_last_committed_diff -1 -LOCK TABLES t1 READ; -FLUSH TABLES t1; -ERROR HY000: Table 't1' was locked with a READ lock and can't be updated -UNLOCK TABLES; -wsrep_last_committed_diff -1 -FLUSH TABLES t1; -wsrep_last_committed_diff -1 -DROP TABLE t1; -DROP TABLE t2; -SET GLOBAL userstat= @userstat_old; -SET GLOBAL thread_statistics= @old_thread_statistics; diff --git a/mysql-test/suite/galera/r/galera_migrate.result b/mysql-test/suite/galera/r/galera_migrate.result deleted file mode 100644 index aab3ffbd6b6..00000000000 --- a/mysql-test/suite/galera/r/galera_migrate.result +++ /dev/null @@ -1,79 +0,0 @@ -CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t1 VALUES (1); -START SLAVE USER='root'; -Warnings: -Note 1759 Sending passwords in plain text without SSL/TLS is extremely insecure. -INSERT INTO t1 VALUES (2); -START SLAVE USER='root'; -Warnings: -Note 1759 Sending passwords in plain text without SSL/TLS is extremely insecure. -INSERT INTO t1 VALUES (3); -INSERT INTO t1 VALUES (4); -SET GLOBAL wsrep_cluster_address='gcomm://'; -INSERT INTO t1 VALUES (5); -SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; -VARIABLE_VALUE = 'Synced' -1 -SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; -VARIABLE_VALUE = 'Primary' -1 -SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; -VARIABLE_VALUE = 1 -1 -INSERT INTO t1 VALUES (6); -GRANT ALL PRIVILEGES ON *.* TO 'sst'; -SET GLOBAL wsrep_sst_auth = 'sst:'; -GRANT ALL PRIVILEGES ON *.* TO 'sst'; -SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; -VARIABLE_VALUE = 'Synced' -1 -SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; -VARIABLE_VALUE = 'Primary' -1 -SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; -VARIABLE_VALUE = 2 -1 -STOP SLAVE; -RESET SLAVE ALL; -STOP SLAVE; -RESET SLAVE ALL; -INSERT INTO t1 VALUES (7); -INSERT INTO t1 VALUES (8); -SELECT COUNT(*) = 8 FROM t1; -COUNT(*) = 8 -1 -SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; -VARIABLE_VALUE = 'Synced' -1 -SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; -VARIABLE_VALUE = 'Primary' -1 -SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; -VARIABLE_VALUE = 2 -1 -SELECT COUNT(*) = 8 FROM t1; -COUNT(*) = 8 -1 -SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; -VARIABLE_VALUE = 'Synced' -1 -SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; -VARIABLE_VALUE = 'Primary' -1 -SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; -VARIABLE_VALUE = 2 -1 -DROP TABLE t1; -DROP TABLE t1; -SET GLOBAL wsrep_provider = 'none'; -SET GLOBAL wsrep_sst_auth = ''; -SET GLOBAL wsrep_provider_options = ''; -DROP TABLE t1; -DROP USER sst; -SET GLOBAL wsrep_provider = 'none'; -SET GLOBAL wsrep_sst_method = 'rsync'; -SET GLOBAL wsrep_provider_options = ''; -SET GLOBAL wsrep_sst_receive_address = 'AUTO'; -DROP TABLE t1; -DROP USER sst; -CALL mtr.add_suppression("InnoDB: Error: Table \"mysql\"\\.\"innodb_index_stats\" not found"); diff --git a/mysql-test/suite/galera/t/MW-360.test b/mysql-test/suite/galera/t/MW-360.test deleted file mode 100644 index b776631cfff..00000000000 --- a/mysql-test/suite/galera/t/MW-360.test +++ /dev/null @@ -1,100 +0,0 @@ -# -# MW-360 DROP TABLE containing temporary tables results in binlog divergence -# - ---source include/galera_cluster.inc ---source include/have_binlog_format_row.inc - ---connection node_1 -SET GLOBAL wsrep_on=OFF; -RESET MASTER; -SET GLOBAL wsrep_on=ON; - ---connection node_2 -SET GLOBAL wsrep_on=OFF; -RESET MASTER; -SET GLOBAL wsrep_on=ON; - ---connection node_1 - -# -# Straightforward temporary table -# - -CREATE TEMPORARY TABLE t1 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t1 VALUES (1); -DROP TABLE t1; - ---let $local_uuid = `SELECT LEFT(@@global.gtid_executed, 36)` - -# -# A mix of normal and temporary tables -# - -# Temp table first, normal table second - -CREATE TEMPORARY TABLE t1 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t1 VALUES (1); - -CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t2 VALUES (2); - -DROP TABLE t1, t2; - -# Normal table first, temporary table second - -CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t1 VALUES (1); - -CREATE TEMPORARY TABLE t2 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t2 VALUES (2); - -DROP TABLE t1, t2; - -# Temporary table first, normal table second, temp table third - -CREATE TEMPORARY TABLE t1 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t1 VALUES (1); - -CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t2 VALUES (2); - -CREATE TEMPORARY TABLE t3 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t3 VALUES (3); - -DROP TABLE t1, t2, t3; - -# Normal table first, temporary table second, normal table third - -CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t1 VALUES (1); - -CREATE TEMPORARY TABLE t2 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t2 VALUES (2); - -CREATE TABLE t3 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t3 VALUES (3); - -DROP TABLE t1, t2, t3; - -# -# A temporary table masking a normal one -# - -CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t1 VALUES (1); - -CREATE TEMPORARY TABLE t1 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t1 VALUES (2); - -DROP TABLE t1; -DROP TABLE t1; - ---connection node_2 ---let $gtid_executed_node2 = `SELECT @@global.gtid_executed;` - ---connection node_1 ---disable_query_log -# Node 1 has extra GTID set generated by the temporary table drop ---eval SELECT GTID_SUBSET('$gtid_executed_node2', @@global.gtid_executed) AS gtid_executed_equal; ---enable_query_log diff --git a/mysql-test/suite/galera/t/galera_account_management.test b/mysql-test/suite/galera/t/galera_account_management.test deleted file mode 100644 index 6dea0fcfa9e..00000000000 --- a/mysql-test/suite/galera/t/galera_account_management.test +++ /dev/null @@ -1,99 +0,0 @@ -# -# Test the account management statements - GRANT, REVOKE, etc. -# - ---source include/galera_cluster.inc ---source include/have_innodb.inc - -# -# CREATE USER -# ---connection node_1 -CREATE USER user1, user2 IDENTIFIED BY 'password'; - ---connection node_2 -SELECT COUNT(*) = 2 FROM mysql.user WHERE user IN ('user1', 'user2'); - -# -# ALTER USER -# - ---connection node_1 -ALTER USER user1 PASSWORD EXPIRE; -SELECT password_expired = 'Y' FROM mysql.user WHERE user = 'user1'; - ---connection node_2 -SELECT password_expired = 'Y' FROM mysql.user WHERE user = 'user1'; - -# -# RENAME USER -# - ---connection node_1 -RENAME USER user2 TO user3; - ---connection node_2 -SELECT COUNT(*) = 0 FROM mysql.user WHERE user = 'user2'; -SELECT COUNT(*) = 1 FROM mysql.user WHERE user = 'user3'; - -# -# SET PASSWORD -# - ---connection node_1 -SET PASSWORD FOR user3 = PASSWORD('foo'); - ---connection node_1 -SELECT password != '' FROM mysql.user WHERE user = 'user3'; - -# -# DROP USER -# ---connection node_1 -DROP USER user1, user3; - ---connection node_2 -SELECT COUNT(*) = 0 FROM mysql.user WHERE user IN ('user1', 'user2'); - -# -# GRANT -# - ---connection node_1 -GRANT ALL ON *.* TO user4 IDENTIFIED BY 'password'; - ---connection node_2 -SELECT COUNT(*) = 1 FROM mysql.user WHERE user = 'user4'; -SELECT Select_priv = 'Y' FROM mysql.user WHERE user = 'user4'; - -# -# GRANT PROXY ON -# ---connection node_1 -CREATE USER user5; -GRANT PROXY ON user4 TO user5; - ---connection node_2 -SELECT COUNT(*) = 1 FROM mysql.proxies_priv WHERE user = 'user5'; - -# -# REVOKE -# - ---connection node_1 -REVOKE ALL PRIVILEGES ON *.* FROM user4; - ---connection node_2 -SELECT Select_priv = 'N' FROM mysql.user WHERE user = 'user4'; - -# -# REVOKE PROXY -# - ---connection node_1 -REVOKE PROXY ON user4 FROM user5; - ---connection node_2 -SELECT COUNT(*) = 0 FROM mysql.proxies_priv WHERE user = 'user5'; - -DROP USER user4, user5; diff --git a/mysql-test/suite/galera/t/galera_as_master_gtid.cnf b/mysql-test/suite/galera/t/galera_as_master_gtid.cnf deleted file mode 100644 index 75caba5420a..00000000000 --- a/mysql-test/suite/galera/t/galera_as_master_gtid.cnf +++ /dev/null @@ -1,6 +0,0 @@ -!include ../galera_2nodes_as_master.cnf - -[mysqld] -log-bin=mysqld-bin -log-slave-updates -binlog-format=ROW diff --git a/mysql-test/suite/galera/t/galera_as_master_gtid.test b/mysql-test/suite/galera/t/galera_as_master_gtid.test deleted file mode 100644 index 9be065e448b..00000000000 --- a/mysql-test/suite/galera/t/galera_as_master_gtid.test +++ /dev/null @@ -1,70 +0,0 @@ -# -# Test Galera as a master to a MySQL slave with GTID -# -# The galera/galera_2node_master.cnf describes the setup of the nodes -# -# We check that all transactions originating from within Galera use a UUID that is -# different from the server_uuid of either node -# -# - ---source include/have_innodb.inc ---source include/have_log_bin.inc ---source include/galera_cluster.inc - ---connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 ---disable_query_log ---eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$NODE_MYPORT_1; ---enable_query_log -START SLAVE USER='root'; - ---connection node_1 -CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; -INSERT INTO t1 VALUES(1); - ---let $effective_uuid = `SELECT LEFT(@@global.gtid_executed, 36)` ---disable_query_log ---eval SELECT '$effective_uuid' != @@global.server_uuid AS uuids_do_not_match; ---enable_query_log - ---connection node_2 -INSERT INTO t1 VALUES(2); - ---disable_query_log ---eval SELECT '$effective_uuid' != @@global.server_uuid AS uuids_do_not_match; ---eval SELECT '$effective_uuid' = LEFT(@@global.gtid_executed, 36) AS uuids_match; ---enable_query_log - ---connection node_3 ---let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; ---source include/wait_condition.inc - ---let $wait_condition = SELECT COUNT(*) = 2 FROM t1; ---source include/wait_condition.inc - ---disable_query_log ---eval SELECT '$effective_uuid' != @@global.server_uuid AS uuids_do_not_match; ---eval SELECT '$effective_uuid' = LEFT(@@global.gtid_executed, 36) AS uuids_match; ---enable_query_log - ---connection node_1 -DROP TABLE t1; - ---connection node_3 ---let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; ---source include/wait_condition.inc - ---connection node_1 ---let $gtid_executed_node1 = `SELECT @@global.gtid_executed;` - ---connection node_2 ---disable_query_log ---eval SELECT '$gtid_executed_node1' = @@global.gtid_executed AS gtid_executed_equal ---enable_query_log ---connection node_3 ---disable_query_log ---eval SELECT '$gtid_executed_node1' = @@global.gtid_executed AS gtid_executed_equal ---enable_query_log - -STOP SLAVE; -RESET SLAVE ALL; diff --git a/mysql-test/suite/galera/t/galera_as_master_gtid_change_master.cnf b/mysql-test/suite/galera/t/galera_as_master_gtid_change_master.cnf deleted file mode 100644 index 75caba5420a..00000000000 --- a/mysql-test/suite/galera/t/galera_as_master_gtid_change_master.cnf +++ /dev/null @@ -1,6 +0,0 @@ -!include ../galera_2nodes_as_master.cnf - -[mysqld] -log-bin=mysqld-bin -log-slave-updates -binlog-format=ROW diff --git a/mysql-test/suite/galera/t/galera_as_master_gtid_change_master.test b/mysql-test/suite/galera/t/galera_as_master_gtid_change_master.test deleted file mode 100644 index 61c7eed6543..00000000000 --- a/mysql-test/suite/galera/t/galera_as_master_gtid_change_master.test +++ /dev/null @@ -1,56 +0,0 @@ -# -# Test that a MySQL slave can use CHANGE MASTER MASTER_AUTO_POSITION to begin replicating -# from another Galera node -# -# The galera/galera_2node_master.cnf describes the setup of the nodes -# -# - ---source include/have_innodb.inc ---source include/have_log_bin.inc ---source include/galera_cluster.inc - ---connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 ---disable_query_log ---eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$NODE_MYPORT_1; ---enable_query_log -START SLAVE USER='root'; - ---connection node_1 -CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; -INSERT INTO t1 VALUES(1); - ---connection node_2 -INSERT INTO t1 VALUES(2); - ---connection node_3 ---let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; ---source include/wait_condition.inc -STOP SLAVE; ---disable_query_log ---eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$NODE_MYPORT_2, MASTER_AUTO_POSITION=1; ---enable_query_log -START SLAVE USER='root'; - ---connection node_1 -INSERT INTO t1 VALUES(3); - ---connection node_2 -INSERT INTO t1 VALUES(4); - ---connection node_3 ---let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; ---source include/wait_condition.inc - ---let $wait_condition = SELECT COUNT(*) = 4 FROM t1; ---source include/wait_condition.inc - ---connection node_1 -DROP TABLE t1; - ---connection node_3 ---let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; ---source include/wait_condition.inc - -STOP SLAVE; -RESET SLAVE ALL; diff --git a/mysql-test/suite/galera/t/galera_as_slave_gtid_replicate_do_db.cnf b/mysql-test/suite/galera/t/galera_as_slave_gtid_replicate_do_db.cnf deleted file mode 100644 index e0852c50c44..00000000000 --- a/mysql-test/suite/galera/t/galera_as_slave_gtid_replicate_do_db.cnf +++ /dev/null @@ -1,17 +0,0 @@ -!include ../galera_2nodes_as_slave.cnf - -[mysqld] -#gtid-mode=ON -log-bin=master-bin -log-bin-index=master-bin -log-slave-updates -#enforce-gtid-consistency -binlog-format=ROW - -[mysqld.2] -replicate-do-db=test1 -replicate-wild-do-table=test1.% - -[mysqld.3] -replicate-do-db=test1 -replicate-wild-do-table=test1.% diff --git a/mysql-test/suite/galera/t/galera_as_slave_gtid_replicate_do_db.test b/mysql-test/suite/galera/t/galera_as_slave_gtid_replicate_do_db.test deleted file mode 100644 index 81b6d446ba6..00000000000 --- a/mysql-test/suite/galera/t/galera_as_slave_gtid_replicate_do_db.test +++ /dev/null @@ -1,150 +0,0 @@ -# -# Test Galera as a slave to a MySQL master using GTIDs -# - ---source include/have_innodb.inc ---source include/galera_cluster.inc ---source include/have_log_bin.inc - -# As node #3 is not a Galera node, and galera_cluster.inc does not open connetion to it -# we open the node_3 connection here ---connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 - ---connection node_1 -SET global wsrep_on=OFF; -RESET MASTER; -SET global wsrep_on=ON; - ---connection node_3 -RESET MASTER; - ---connection node_2 -SET global wsrep_on=OFF; -RESET MASTER; -SET global wsrep_on=ON; ---disable_query_log ---eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$NODE_MYPORT_3, MASTER_USER='root'; ---enable_query_log -START SLAVE; - ---connection node_3 -CREATE SCHEMA test1; -CREATE SCHEMA test2; -USE test1; -CREATE TABLE t1 (f1 INTEGER PRIMARY KEY,f2 CHAR(5) DEFAULT 'abc') ENGINE=InnoDB; -USE test2; -CREATE TABLE t1 (f1 INTEGER PRIMARY KEY,f2 CHAR(5) DEFAULT 'abc') ENGINE=InnoDB; - -# -# First , some autocommit stuff -# - -# Simple inserts - -INSERT INTO test1.t1 (f1) VALUES (1); -INSERT INTO test2.t1 (f1) VALUES (1); - -INSERT INTO test1.t1 (f1) VALUES (2); -INSERT INTO test2.t1 (f1) VALUES (2); - -INSERT INTO test1.t1 (f1) VALUES (3); -INSERT INTO test2.t1 (f1) VALUES (3); - -# Update that only covers test2.t1 - -UPDATE test2.t1 SET test2.t1.f2 = 'cde'; - -# Multi-table UPDATE - -UPDATE test1.t1, test2.t1 SET test1.t1.f2 = 'klm', test2.t1.f2 = 'xyz'; - -# Multi-table DELETE - -DELETE test1.t1, test2.t1 FROM test1.t1 INNER JOIN test2.t1 WHERE test1.t1.f1 = test2.t1.f1 AND test1.t1.f1 = 3; - -# -# Multi-statement transactions -# - -# Transaction which is not replicated at all - -SET AUTOCOMMIT=OFF; -START TRANSACTION; -INSERT INTO test2.t1 (f1) VALUES (999); -INSERT INTO test2.t1 (f1) VALUES (9999); -COMMIT; - -# Transaction that is completely replicated -START TRANSACTION; -INSERT INTO test1.t1 (f1) VALUES (111); -INSERT INTO test1.t1 (f1) VALUES (222); -COMMIT; - -# Transaction that is partially replicated - -START TRANSACTION; -INSERT INTO test1.t1 (f1) VALUES (333); -INSERT INTO test2.t1 (f1) VALUES (99999); -COMMIT; - -# -# Make sure binary logs and gtid_executed strings are equal -# - ---sleep 2 ---connection node_2 ---let $effective_uuid = `SELECT LEFT(@@global.gtid_current_pos, 36)` ---let $gtid_executed_node2 = `SELECT @@global.gtid_current_pos;` - ---replace_result $effective_uuid ---replace_regex /xid=[0-9]+/xid=###/ /table_id: [0-9]+/table_id: ###/ -SHOW BINLOG EVENTS IN 'master-bin.000001' FROM 256; - ---connection node_1 - ---disable_query_log ---eval SELECT '$gtid_executed_node2' = @@global.gtid_current_pos AS gtid_executed_equal; ---enable_query_log - ---replace_result $effective_uuid ---replace_regex /xid=[0-9]+/xid=###/ /table_id: [0-9]+/table_id: ###/ -SHOW BINLOG EVENTS IN 'master-bin.000001' FROM 256; - -# -# Final consistency checks -# - ---let $diff_servers = 1 2 ---source include/diff_servers.inc - ---connection node_1 ---let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; ---source include/wait_condition.inc - -SELECT COUNT(*) = 2 FROM test1.t1 WHERE f1 IN (1,2); -SELECT COUNT(*) = 3 FROM test1.t1 WHERE f1 IN (111,222,333); -SELECT COUNT(*) = 2 FROM test1.t1 WHERE f2 = 'klm'; - ---error 1049 -USE test2; - -# -# Cleanup -# - ---connection node_3 -DROP SCHEMA test1; -DROP SCHEMA test2; - ---sleep 1 - ---connection node_1 ---let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; ---source include/wait_condition.inc - ---connection node_2 ---let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; ---source include/wait_condition.inc - -STOP SLAVE; -RESET SLAVE ALL; diff --git a/mysql-test/suite/galera/t/galera_as_slave_gtid_replicate_do_db_cc.test b/mysql-test/suite/galera/t/galera_as_slave_gtid_replicate_do_db_cc.test deleted file mode 100644 index 27698121c0d..00000000000 --- a/mysql-test/suite/galera/t/galera_as_slave_gtid_replicate_do_db_cc.test +++ /dev/null @@ -1,174 +0,0 @@ -# -# Test the case where a Galera slave to async replication goes non-prim while -# a stream of replication events including filtered events is arriving -# - ---source include/have_innodb.inc ---source include/have_log_bin.inc ---source include/big_test.inc - -# As node #1 is not a Galera node, we connect to node #2 in order to run include/galera_cluster.inc ---connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 ---source include/galera_cluster.inc - ---connection node_1 -SET GLOBAL wsrep_on=OFF; -RESET MASTER; -SET GLOBAL wsrep_on=ON; - ---connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 ---connection node_3 -RESET MASTER; - ---connection node_2 -SET global wsrep_on=OFF; -RESET MASTER; -SET global wsrep_on=ON; - ---connection node_2 ---disable_query_log ---eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$NODE_MYPORT_1; ---enable_query_log -START SLAVE USER='root'; - ---connection node_1 -CREATE SCHEMA test1; -CREATE SCHEMA test2; -USE test1; -CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; -USE test2; -CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; - -INSERT INTO test1.t1 (f1) VALUES (1); -INSERT INTO test2.t1 (f1) VALUES (1); - -INSERT INTO test1.t1 (f1) VALUES (2); -INSERT INTO test2.t1 (f1) VALUES (2); - ---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(*) = 2 FROM test1.t1; ---source include/wait_condition.inc - -SET GLOBAL wsrep_provider_options='gmcast.isolate=1'; - ---connection node_1 -INSERT INTO test1.t1 (f1) VALUES (3); -INSERT INTO test2.t1 (f1) VALUES (3); -INSERT INTO test1.t1 (f1) VALUES (3); -INSERT INTO test2.t1 (f1) VALUES (3); -INSERT INTO test1.t1 (f1) VALUES (3); -INSERT INTO test2.t1 (f1) VALUES (3); -INSERT INTO test1.t1 (f1) VALUES (3); -INSERT INTO test2.t1 (f1) VALUES (3); - ---connection node_2 -SET SESSION wsrep_on=OFF; ---let $wait_condition = SELECT VARIABLE_VALUE = 'non-Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE variable_name = 'wsrep_cluster_status'; ---source include/wait_condition.inc - ---let $slave_sql_errno = 1047 ---source include/wait_for_slave_sql_error.inc - ---connection node_1 -INSERT INTO test1.t1 (f1) VALUES (4); -INSERT INTO test2.t1 (f1) VALUES (4); -INSERT INTO test1.t1 (f1) VALUES (4); -INSERT INTO test2.t1 (f1) VALUES (4); -INSERT INTO test1.t1 (f1) VALUES (4); -INSERT INTO test2.t1 (f1) VALUES (4); -INSERT INTO test1.t1 (f1) VALUES (4); -INSERT INTO test2.t1 (f1) VALUES (4); -INSERT INTO test1.t1 (f1) VALUES (4); -INSERT INTO test2.t1 (f1) VALUES (4); - ---connection node_2 -SET GLOBAL wsrep_provider_options='gmcast.isolate=0'; - ---connection node_1 -INSERT INTO test1.t1 (f1) VALUES (5); -INSERT INTO test2.t1 (f1) VALUES (5); - ---connection node_2 ---let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE variable_name = 'wsrep_cluster_status'; ---source include/wait_condition.inc -SET SESSION wsrep_on=ON; ---let $wait_condition = SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE variable_name = 'wsrep_ready'; ---source include/wait_condition.inc - ---connection node_1 -INSERT INTO test1.t1 (f1) VALUES (6); -INSERT INTO test2.t1 (f1) VALUES (6); - ---connection node_2 -START SLAVE; - -# -# Consistency checks -# - ---sleep 2 ---connection node_2 ---let $wait_condition = SELECT COUNT(DISTINCT f1) = 6 FROM test1.t1; ---source include/wait_condition.inc - ---connection node_3 ---let $wait_condition = SELECT COUNT(DISTINCT f1) = 6 FROM test1.t1; ---source include/wait_condition.inc - ---connection node_2 ---let $gtid_executed_node2 = `SELECT @@global.gtid_executed;` - ---let $effective_uuid_1 = `SELECT SUBSTRING_INDEX(@@global.gtid_executed, ':', 1)` ---let $effective_uuid_2 = `SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(@@global.gtid_executed, '\n', -1), ':', 1)` - ---replace_result $effective_uuid_1 $effective_uuid_2 ---replace_regex /xid=[0-9]+/xid=###/ /table_id: [0-9]+/table_id: ###/ -SHOW BINLOG EVENTS IN 'mysqld-bin.000001' FROM 120; - ---error 1049 -USE test2; - ---connection node_3 - ---disable_query_log ---eval SELECT '$gtid_executed_node2' = @@global.gtid_executed AS gtid_executed_equal; ---enable_query_log - ---error 1049 -USE test2; - ---replace_result $effective_uuid_1 $effective_uuid_2 ---replace_regex /xid=[0-9]+/xid=###/ /table_id: [0-9]+/table_id: ###/ -SHOW BINLOG EVENTS IN 'mysqld-bin.000001' FROM 120; - -# -# Cleanup -# - ---connection node_1 -DROP SCHEMA test1; -DROP SCHEMA test2; - ---sleep 1 - ---connection node_3 ---let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; ---source include/wait_condition.inc - ---connection node_2 ---let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; ---source include/wait_condition.inc - ---connection node_2 -STOP SLAVE; -RESET SLAVE ALL; -CALL mtr.add_suppression("GTID replication failed"); -CALL mtr.add_suppression("Slave SQL: Error in Xid_log_event: Commit could not be completed"); -CALL mtr.add_suppression("Slave SQL: Node has dropped from cluster, Error_code: 1047"); -CALL mtr.add_suppression("TO isolation failed for"); -CALL mtr.add_suppression("Slave SQL: Error 'Deadlock found when trying to get lock; try restarting transaction' on query"); -CALL mtr.add_suppression("Slave SQL: Error 'WSREP has not yet prepared node for application use' on query"); -CALL mtr.add_suppression("Slave: WSREP has not yet prepared node for application use Error_code: 1047"); diff --git a/mysql-test/suite/galera/t/galera_as_slave_preordered.cnf b/mysql-test/suite/galera/t/galera_as_slave_preordered.cnf deleted file mode 100644 index d1a0fb15ff3..00000000000 --- a/mysql-test/suite/galera/t/galera_as_slave_preordered.cnf +++ /dev/null @@ -1,3 +0,0 @@ -!include ../galera_2nodes_as_slave.cnf -[mysqld] -wsrep-preordered=TRUE diff --git a/mysql-test/suite/galera/t/galera_as_slave_preordered.test b/mysql-test/suite/galera/t/galera_as_slave_preordered.test deleted file mode 100644 index 5b3c78b2cb1..00000000000 --- a/mysql-test/suite/galera/t/galera_as_slave_preordered.test +++ /dev/null @@ -1,87 +0,0 @@ -# -# Test Galera as a slave to a MySQL master with --wsrep-preordered=TRUE -# -# The galera/galera_2node_slave.cnf describes the setup of the nodes -# - ---source include/have_innodb.inc ---source include/have_log_bin.inc ---source include/galera_cluster.inc - -# As node #3 is not a Galera node, and galera_cluster.inc does not open connetion to it -# we open the node_3 connection here ---connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 - ---connection node_2 ---disable_query_log ---eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$NODE_MYPORT_3; ---enable_query_log -START SLAVE USER='root'; - -# -# Issue many large-ish transaction on the async master -# - ---connection node_3 -CREATE TABLE ten (f1 INTEGER); -INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); - -CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 INTEGER) ENGINE=InnoDB; - ---disable_query_log ---let $count = 100 -while ($count) -{ - --eval INSERT INTO t1 (f2) SELECT 1 FROM ten AS a1, ten AS a2; - --dec $count -} ---enable_query_log - -# -# While the async transactions are being applied, issue another set of transactions -# on the Galera node. -# - ---connection node_2 ---let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; ---source include/wait_condition.inc - ---let $count = 100 ---disable_query_log -while ($count) -{ - --eval INSERT INTO t1 (f2) SELECT 1 FROM ten AS a1, ten AS a2; - --dec $count -} ---enable_query_log - -# -# Confirm that all transactions successfully committed -# - ---let $wait_condition = SELECT COUNT(*) = 2 * 100 * 10 * 10 FROM t1; ---source include/wait_condition.inc - -SELECT COUNT(DISTINCT f1) = 2 * 100 * 10 * 10 FROM t1; - ---connection node_1 -SELECT COUNT(*) = 2 * 100 * 10 * 10 FROM t1; -SELECT COUNT(DISTINCT f1) = 2 * 100 * 10 * 10 FROM t1; - -# -# Cleanup -# - ---connection node_3 -DROP TABLE t1; -DROP TABLE ten; - ---connection node_2 ---let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; ---source include/wait_condition.inc - ---let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'ten'; ---source include/wait_condition.inc - -STOP SLAVE; -RESET SLAVE ALL; diff --git a/mysql-test/suite/galera/t/galera_binlog_rows_query_log_events.test b/mysql-test/suite/galera/t/galera_binlog_rows_query_log_events.test deleted file mode 100644 index 95bc85c4cab..00000000000 --- a/mysql-test/suite/galera/t/galera_binlog_rows_query_log_events.test +++ /dev/null @@ -1,28 +0,0 @@ -# -# Test that Galera continues to run even with binlog-rows-query-log-events=TRUE -# - ---source include/galera_cluster.inc ---source include/have_innodb.inc - ---let $binlog_rows_query_log_events_orig = `SELECT @@binlog_rows_query_log_events` - -SET GLOBAL binlog_rows_query_log_events=TRUE; - -CREATE TABLE t1 (f1 INT PRIMARY KEY) ENGINE=InnoDB; - -INSERT INTO t1 VALUES (1); - ---connection node_2 -SELECT COUNT(*) = 1 FROM t1; - ---connection node_1 -UPDATE t1 SET f1 = 2 WHERE f1 = 1; - ---connection node_2 -SELECT COUNT(*) = 1 FROM t1 WHERE f1 = 2; - ---connection node_1 ---eval SET GLOBAL binlog_rows_query_log_events = $binlog_rows_query_log_events_orig - -DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_flush.cnf b/mysql-test/suite/galera/t/galera_flush.cnf deleted file mode 100644 index e2d869ab364..00000000000 --- a/mysql-test/suite/galera/t/galera_flush.cnf +++ /dev/null @@ -1,10 +0,0 @@ -!include ../galera_2nodes.cnf - -[mysqld.1] -query_cache_type=1 -query_cache_size=1000000 - -[mysqld.2] -query_cache_type=1 -query_cache_size=1000000 - diff --git a/mysql-test/suite/galera/t/galera_flush.test b/mysql-test/suite/galera/t/galera_flush.test deleted file mode 100644 index 77e95f62fda..00000000000 --- a/mysql-test/suite/galera/t/galera_flush.test +++ /dev/null @@ -1,273 +0,0 @@ -# -# Test that various FLUSH commands are replicated. Whenever possible, check the slave for the effects. -# - ---source include/galera_cluster.inc ---source include/have_innodb.inc ---source include/have_perfschema.inc ---source include/have_query_cache.inc - ---disable_warnings -DROP TABLE IF EXISTS t1, t2; ---enable_warnings -# -# The following FLUSH statements should be replicated -# - ---connection node_2 ---let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---connection node_1 -FLUSH DES_KEY_FILE; ---connection node_2 ---let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---disable_query_log ---eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff; ---enable_query_log - - ---connection node_2 ---let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---connection node_1 -FLUSH HOSTS; ---connection node_2 ---let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---disable_query_log ---eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff; ---enable_query_log - ---connection node_1 -SET GLOBAL wsrep_replicate_myisam = TRUE; -INSERT INTO mysql.user VALUES('localhost','user1',PASSWORD('pass1'), 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0,'mysql_native_password','','N','N','',0); -FLUSH PRIVILEGES; ---connect node_2a, 127.0.0.1, user1, pass1, test, $NODE_MYPORT_2 ---connection node_1 -DELETE FROM mysql.user WHERE user = 'user1'; -SET GLOBAL wsrep_replicate_myisam = FALSE; -FLUSH PRIVILEGES; - - ---connection node_2 ---let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---connection node_1 -FLUSH QUERY CACHE; ---connection node_2 ---let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---disable_query_log ---eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff; ---enable_query_log - - ---connection node_2 ---let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---connection node_1 -FLUSH STATUS; - ---connection node_2 ---let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---disable_query_log ---eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff; ---enable_query_log - - ---connection node_2 ---let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---connection node_1 -FLUSH USER_RESOURCES; ---connection node_2 ---let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---disable_query_log ---eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff; ---enable_query_log - - ---connection node_2 ---let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---connection node_1 -FLUSH TABLES; ---connection node_2 ---let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---disable_query_log ---eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff; ---enable_query_log - ---connection node_1 -CREATE TABLE t2 (f1 INTEGER); - ---connection node_2 ---let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---connection node_1 -FLUSH TABLES t2; ---connection node_2 ---let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---disable_query_log ---eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff; ---enable_query_log - - ---connection node_2 ---let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---connection node_1 -FLUSH ERROR LOGS; ---connection node_2 ---let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---disable_query_log ---eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff; ---enable_query_log - - ---connection node_2 ---let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---connection node_1 -FLUSH SLOW LOGS; ---connection node_2 ---let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---disable_query_log ---eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff; ---enable_query_log - ---connection node_2 ---let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---connection node_1 -FLUSH GENERAL LOGS; ---connection node_2 ---let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---disable_query_log ---eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff; ---enable_query_log - ---connection node_2 ---let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---connection node_1 -FLUSH ENGINE LOGS; ---connection node_2 ---let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---disable_query_log ---eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff; ---enable_query_log - ---connection node_2 ---let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---connection node_1 -FLUSH RELAY LOGS; ---connection node_2 ---let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---disable_query_log ---eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff; ---enable_query_log - ---connection node_1 -SET @userstat_old= @@userstat; -SET GLOBAL userstat=ON; - ---connection node_2 ---let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---connection node_1 -FLUSH CLIENT_STATISTICS; -FLUSH INDEX_STATISTICS; -FLUSH TABLE_STATISTICS; -FLUSH USER_STATISTICS; ---connection node_2 ---let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---disable_query_log ---eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 4 AS wsrep_last_committed_diff; ---enable_query_log - - ---connection node_1 -SET @old_thread_statistics= @@global.thread_statistics; -SET GLOBAL thread_statistics= ON; - ---connection node_2 ---let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---connection node_1 -FLUSH THREAD_STATISTICS; ---connection node_2 ---let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---disable_query_log ---eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff; ---enable_query_log - - ---connection node_2 ---let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---connection node_1 -FLUSH CHANGED_PAGE_BITMAPS; ---connection node_2 ---let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---disable_query_log ---eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff; ---enable_query_log - - -# -# The following statements should not be replicated: FLUSH LOGS, FLUSH TABLES WITH LOCKS -# - - ---connection node_1 -CREATE TABLE t1 (f1 INTEGER); - ---connection node_2 ---let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` - ---connection node_1 -FLUSH LOGS; -FLUSH TABLES WITH READ LOCK; -UNLOCK TABLES; -FLUSH TABLES t1 WITH READ LOCK; -UNLOCK TABLES; -FLUSH TABLES t1 FOR EXPORT; -UNLOCK TABLES; - ---connection node_2 ---let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---disable_query_log ---eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before AS wsrep_last_committed_diff; ---enable_query_log - - -## Test LOCK TABLES with FLUSH TABLES -## LOCK TABLES t1 write followed by flush tables t1 should succeed due to MDL upgrade. -## LOCK tables t2 read followed by flush tables t2 should fail with ER_TABLE_NOT_LOCKED_FOR_WRITE - - ---connection node_2 ---let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---connection node_1 -LOCK TABLES t1 WRITE; -FLUSH TABLES t1; -UNLOCK TABLES; ---connection node_2 ---let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---disable_query_log ---eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff; ---enable_query_log - - ---connection node_2 ---let $wsrep_last_committed_before = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---connection node_1 -LOCK TABLES t1 READ; ---error ER_TABLE_NOT_LOCKED_FOR_WRITE -FLUSH TABLES t1; -UNLOCK TABLES; ---connection node_2 ---let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---disable_query_log ---eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before AS wsrep_last_committed_diff; ---enable_query_log ---connection node_1 -FLUSH TABLES t1; ---connection node_2 ---let $wsrep_last_committed_after = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'` ---disable_query_log ---eval SELECT $wsrep_last_committed_after = $wsrep_last_committed_before + 1 AS wsrep_last_committed_diff; ---enable_query_log - - - ---connection node_1 -DROP TABLE t1; -DROP TABLE t2; -SET GLOBAL userstat= @userstat_old; -SET GLOBAL thread_statistics= @old_thread_statistics; diff --git a/mysql-test/suite/galera/t/galera_migrate.cnf b/mysql-test/suite/galera/t/galera_migrate.cnf deleted file mode 100644 index 2e1e9f161a9..00000000000 --- a/mysql-test/suite/galera/t/galera_migrate.cnf +++ /dev/null @@ -1,61 +0,0 @@ -# -# This .cnf file starts 4 servers without enabling Galera. -# The galera_migrate.test will set wsrep_provider and the other settings as needed. -# - -!include include/default_mysqld.cnf - -[mysqld] -binlog-format=row -innodb_autoinc_lock_mode=2 -innodb_flush_log_at_trx_commit=2 -log-bin=mysqld-bin - -wsrep_node_address=127.0.0.1 -wsrep_causal_reads=ON -wsrep_sync_wait = 15 - -[mysqld.1] -#galera_port=@OPT.port -#ist_port=@OPT.port -#sst_port=@OPT.port - -[mysqld.2] -#galera_port=@OPT.port -#ist_port=@OPT.port -#sst_port=@OPT.port - -[mysqld.3] -#galera_port=@OPT.port -#ist_port=@OPT.port -#sst_port=@OPT.port -log-slave-updates - -[mysqld.4] -#galera_port=@OPT.port -#ist_port=@OPT.port -#sst_port=@OPT.port -log-slave-updates - -[ENV] -NODE_MYPORT_1= @mysqld.1.port -NODE_MYSOCK_1= @mysqld.1.socket - -NODE_MYPORT_2= @mysqld.2.port -NODE_MYSOCK_2= @mysqld.2.socket - -NODE_MYPORT_3= @mysqld.3.port -NODE_MYSOCK_3= @mysqld.3.socket - -NODE_MYPORT_4= @mysqld.4.port -NODE_MYSOCK_4= @mysqld.4.socket - -NODE_GALERAPORT_1= @mysqld.1.#galera_port -NODE_GALERAPORT_2= @mysqld.2.#galera_port -NODE_GALERAPORT_3= @mysqld.3.#galera_port -NODE_GALERAPORT_4= @mysqld.4.#galera_port - -NODE_SSTPORT_1= @mysqld.1.#sst_port -NODE_SSTPORT_2= @mysqld.2.#sst_port -NODE_SSTPORT_3= @mysqld.3.#sst_port -NODE_SSTPORT_4= @mysqld.4.#sst_port diff --git a/mysql-test/suite/galera/t/galera_migrate.test b/mysql-test/suite/galera/t/galera_migrate.test deleted file mode 100644 index 84897b66c6d..00000000000 --- a/mysql-test/suite/galera/t/galera_migrate.test +++ /dev/null @@ -1,204 +0,0 @@ -# -# Execute a migration from MariaDB replication to Galera replication. -# The test starts with 4 stand-alone servers defined by galera_migrate.cnf and then -# performs the following steps: -# -# 1. Begin with a single MySQL server -# 2. Establish traditional MySQL master-slave replication -# 3. Attach a new sever to serve as a MySQL replication slave -# 4. Enable Galera on the new slave and create a single-node Galera cluster -# 5. Attach a second Galera node -# 6. Turn off the traditional replication parts of the system -# 7. Continue replicating within Galera only -# - ---source include/big_test.inc ---source include/have_innodb.inc ---source include/have_log_bin.inc - -# -# Step #1 Begin with a single server -# - ---connect node_1, 127.0.0.1, root, , test, $NODE_MYPORT_1 - -CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; -INSERT INTO t1 VALUES (1); - -# -# Step #2. Establish traditional MySQL replication -# - ---connect node_2, 127.0.0.1, root, , test, $NODE_MYPORT_2 ---disable_query_log ---eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT = $NODE_MYPORT_1; ---enable_query_log -START SLAVE; - ---connection node_1 -INSERT INTO t1 VALUES (2); - ---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(*) = 2 FROM t1; ---source include/wait_condition.inc - -# -# Step #3. Attach a second slave, later to be converted to Galera -# - ---connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 ---disable_query_log ---eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT = $NODE_MYPORT_1; ---enable_query_log -START SLAVE USER='root'; - ---connection node_1 -INSERT INTO t1 VALUES (3); - ---connection node_3 ---let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; ---source include/wait_condition.inc - ---let $wait_condition = SELECT COUNT(*) = 3 FROM t1; ---source include/wait_condition.inc - -# -# Step #4. Convert this MySQL slave into a Galera node -# - ---connection node_1 -INSERT INTO t1 VALUES (4); - ---connection node_3 ---disable_query_log ---eval SET GLOBAL wsrep_provider='$WSREP_PROVIDER' ---eval SET GLOBAL wsrep_provider_options='base_port=$NODE_GALERAPORT_3' ---enable_query_log -SET GLOBAL wsrep_cluster_address='gcomm://'; - ---connection node_1 -INSERT INTO t1 VALUES (5); - ---connection node_3 ---let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; ---source include/wait_condition.inc ---let $wait_condition = SELECT COUNT(*) = 5 FROM t1; ---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 - -SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; -SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; -SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; - ---connection node_1 -INSERT INTO t1 VALUES (6); - -# -# Step #5. Attach a second Galera node using mysqldump SST -# - ---connection node_3 -# We need a user with a password for mysqldump SST -GRANT ALL PRIVILEGES ON *.* TO 'sst'; -SET GLOBAL wsrep_sst_auth = 'sst:'; - ---connect node_4, 127.0.0.1, root, , test, $NODE_MYPORT_4 -GRANT ALL PRIVILEGES ON *.* TO 'sst'; - ---disable_query_log ---eval SET GLOBAL wsrep_sst_method = 'mysqldump'; ---eval SET GLOBAL wsrep_provider='$WSREP_PROVIDER' ---eval SET GLOBAL wsrep_provider_options='base_port=$NODE_GALERAPORT_4' ---eval SET GLOBAL wsrep_sst_receive_address = '127.0.0.2:$NODE_MYPORT_4'; ---eval SET GLOBAL wsrep_cluster_address='gcomm://127.0.0.1:$NODE_GALERAPORT_3' ---enable_query_log - ---let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; ---source include/wait_condition.inc - ---let $wait_condition = SELECT COUNT(*) = 6 FROM t1; ---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 - -SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; -SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; -SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; - - -# -# Step #6. Turn off traditional replication -# - ---connection node_2 -STOP SLAVE; -RESET SLAVE ALL; - ---connection node_3 -STOP SLAVE; -RESET SLAVE ALL; - -# -# Step #7. Continue replicating within Galera only -# - -# We need fresh connections due to galera#191 - ---connect node_3a, 127.0.0.1, root, , test, $NODE_MYPORT_3 -INSERT INTO t1 VALUES (7); - ---connect node_4a, 127.0.0.1, root, , test, $NODE_MYPORT_4 -INSERT INTO t1 VALUES (8); - ---connection node_4a -SELECT COUNT(*) = 8 FROM t1; - ---let $wait_condition = SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready'; ---source include/wait_condition.inc - -SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; -SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; -SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; - ---connection node_3a -SELECT COUNT(*) = 8 FROM t1; - ---let $wait_condition = SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready'; ---source include/wait_condition.inc - -SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment'; -SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; -SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; - -# -# Teardown -# - ---connection node_1 -DROP TABLE t1; - ---connection node_2 -DROP TABLE t1; - ---connection node_3 -SET GLOBAL wsrep_provider = 'none'; -SET GLOBAL wsrep_sst_auth = ''; -SET GLOBAL wsrep_provider_options = ''; -DROP TABLE t1; -DROP USER sst; - ---connection node_4 -SET GLOBAL wsrep_provider = 'none'; -SET GLOBAL wsrep_sst_method = 'rsync'; -SET GLOBAL wsrep_provider_options = ''; -SET GLOBAL wsrep_sst_receive_address = 'AUTO'; -DROP TABLE t1; -DROP USER sst; - -CALL mtr.add_suppression("InnoDB: Error: Table \"mysql\"\\.\"innodb_index_stats\" not found"); diff --git a/mysql-test/suite/galera_sr/disabled.def b/mysql-test/suite/galera_sr/disabled.def index efc1b73d4e7..1d8b79a8fb5 100644 --- a/mysql-test/suite/galera_sr/disabled.def +++ b/mysql-test/suite/galera_sr/disabled.def @@ -10,9 +10,8 @@ # ############################################################################## +GCF-1018B : MDEV-21613 galera_sr.GCF-1018B MTR failed: Failed to open table mysql.wsrep_streaming_log for writing GCF-1043A : MDEV-21170 Galera test failure on galera_sr.GCF-1043A -GCF-437 : test relies on InnoDB redo log size limitation -GCF-561 : MDEV-21517 galera_sr.GCF-561 -GCF_1060 : MDEV-20848 galera_sr.GCF_1060 +GCF-1060 : MDEV-20848 galera_sr.GCF_1060 galera-features#56 : MDEV-18542 galera_sr.galera-features#56 -galera_sr_table_contents : missing file + diff --git a/mysql-test/suite/galera_sr/r/GCF-437.result b/mysql-test/suite/galera_sr/r/GCF-437.result deleted file mode 100644 index 1aa0c9c0768..00000000000 --- a/mysql-test/suite/galera_sr/r/GCF-437.result +++ /dev/null @@ -1,12 +0,0 @@ -CREATE TABLE ten (f1 INTEGER) ENGINE=MyISAM; -INSERT INTO ten VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); -CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 VARCHAR(512)) ENGINE=InnoDB; -SET SESSION wsrep_trx_fragment_size = 2 * 1024 * 1024; -INSERT INTO t1 (f2) SELECT REPEAT('x', 512) FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5; -ERROR HY000: Writing one row to the row-based binary log failed -CALL mtr.add_suppression("InnoDB: The total blob data length*"); -CALL mtr.add_suppression("WSREP: Error writing into mysql.wsrep_streaming_log: 139"); -CALL mtr.add_suppression("WSREP: Failed to write to frag table: 1"); -CALL mtr.add_suppression("WSREP: Failed to append frag to persistent storage"); -DROP TABLE t1; -DROP table ten; diff --git a/mysql-test/suite/galera_sr/r/galera_sr_table_contents.result b/mysql-test/suite/galera_sr/r/galera_sr_table_contents.result deleted file mode 100644 index 006a1a9da96..00000000000 --- a/mysql-test/suite/galera_sr/r/galera_sr_table_contents.result +++ /dev/null @@ -1,178 +0,0 @@ -connection node_2; -connection node_1; -CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; -INSERT INTO t1 VALUES (1),(2),(3); -CREATE TABLE t2 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; -INSERT INTO t2 VALUES (1),(2),(3); -SET SESSION wsrep_trx_fragment_size = 1; -SET AUTOCOMMIT=OFF; -START TRANSACTION; - -Start of Simple Insert -INSERT INTO t1 VALUES (4); -DELIMITER /*!*/; -# at 256 -# at 300 - server id 1 end_log_pos 85 CRC32 0x00000301 Table_map: `test`.`t1` mapped to number -# at 341 - server id 1 end_log_pos 119 CRC32 0x00000004 Write_rows: table id flags: STMT_END_F -# Number of rows: 1 -DELIMITER ; -# End of log file -ROLLBACK /* added by mysqlbinlog */; -/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; -End of Simple Insert - -ROLLBACK; -Start of Multi-row Update -UPDATE t1 SET f1 = f1 + 10; -DELIMITER /*!*/; -# at 256 -# at 301 - server id 1 end_log_pos 86 CRC32 0x00000301 Table_map: `test`.`t1` mapped to number -# at 342 - server id 1 end_log_pos 126 CRC32 0x0000000b Update_rows: table id flags: STMT_END_F -# Number of rows: 1 -DELIMITER ; -# End of log file -ROLLBACK /* added by mysqlbinlog */; -/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; -DELIMITER /*!*/; -# at 256 -# at 301 - server id 1 end_log_pos 212 CRC32 0x00000301 Table_map: `test`.`t1` mapped to number -# at 342 - server id 1 end_log_pos 252 CRC32 0x0000000c Update_rows: table id flags: STMT_END_F -# Number of rows: 1 -DELIMITER ; -# End of log file -ROLLBACK /* added by mysqlbinlog */; -/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; -DELIMITER /*!*/; -# at 256 -# at 301 - server id 1 end_log_pos 338 CRC32 0x00000301 Table_map: `test`.`t1` mapped to number -# at 342 - server id 1 end_log_pos 378 CRC32 0x0000000d Update_rows: table id flags: STMT_END_F -# Number of rows: 1 -DELIMITER ; -# End of log file -ROLLBACK /* added by mysqlbinlog */; -/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; -End of Multi-row Update - -ROLLBACK; -Start of Multi-table Update -UPDATE t1, t2 SET t1.f1 = t1.f1 + 100, t2.f1 = t2.f1 + 100; -DELIMITER /*!*/; -# at 256 -# at 333 - server id 1 end_log_pos 118 CRC32 0x00000301 Table_map: `test`.`t1` mapped to number -# at 374 - server id 1 end_log_pos 159 CRC32 0x00000301 Table_map: `test`.`t2` mapped to number -# at 415 - server id 1 end_log_pos 199 CRC32 0x00000065 Update_rows: table id flags: STMT_END_F -# Number of rows: 1 -DELIMITER ; -# End of log file -ROLLBACK /* added by mysqlbinlog */; -/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; -DELIMITER /*!*/; -# at 256 -# at 333 - server id 1 end_log_pos 317 CRC32 0x00000301 Table_map: `test`.`t1` mapped to number -# at 374 - server id 1 end_log_pos 358 CRC32 0x00000301 Table_map: `test`.`t2` mapped to number -# at 415 - server id 1 end_log_pos 398 CRC32 0x00000066 Update_rows: table id flags: STMT_END_F -# Number of rows: 1 -DELIMITER ; -# End of log file -ROLLBACK /* added by mysqlbinlog */; -/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; -DELIMITER /*!*/; -# at 256 -# at 333 - server id 1 end_log_pos 516 CRC32 0x00000301 Table_map: `test`.`t1` mapped to number -# at 374 - server id 1 end_log_pos 557 CRC32 0x00000301 Table_map: `test`.`t2` mapped to number -# at 415 - server id 1 end_log_pos 597 CRC32 0x00000067 Update_rows: table id flags: STMT_END_F -# Number of rows: 1 -DELIMITER ; -# End of log file -ROLLBACK /* added by mysqlbinlog */; -/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; -DELIMITER /*!*/; -# at 256 -# at 333 - server id 1 end_log_pos 715 CRC32 0x00000301 Table_map: `test`.`t1` mapped to number -# at 374 - server id 1 end_log_pos 756 CRC32 0x00000301 Table_map: `test`.`t2` mapped to number -# at 415 - server id 1 end_log_pos 796 CRC32 0x00000065 Update_rows: table id flags: STMT_END_F -# Number of rows: 1 -DELIMITER ; -# End of log file -ROLLBACK /* added by mysqlbinlog */; -/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; -DELIMITER /*!*/; -# at 256 -# at 333 - server id 1 end_log_pos 914 CRC32 0x00000301 Table_map: `test`.`t1` mapped to number -# at 374 - server id 1 end_log_pos 955 CRC32 0x00000301 Table_map: `test`.`t2` mapped to number -# at 415 - server id 1 end_log_pos 995 CRC32 0x00000066 Update_rows: table id flags: STMT_END_F -# Number of rows: 1 -DELIMITER ; -# End of log file -ROLLBACK /* added by mysqlbinlog */; -/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; -DELIMITER /*!*/; -# at 256 -# at 333 - server id 1 end_log_pos 1113 CRC32 0x00000301 Table_map: `test`.`t1` mapped to number -# at 374 - server id 1 end_log_pos 1154 CRC32 0x00000301 Table_map: `test`.`t2` mapped to number -# at 415 - server id 1 end_log_pos 1194 CRC32 0x00000067 Update_rows: table id flags: STMT_END_F -# Number of rows: 1 -DELIMITER ; -# End of log file -ROLLBACK /* added by mysqlbinlog */; -/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; -End of Multi-table Update - -ROLLBACK; -Start of Savepoint -INSERT INTO t1 VALUES (1000); -SAVEPOINT X; -INSERT INTO t1 VALUES (2000); -ROLLBACK TO SAVEPOINT X; -DELIMITER /*!*/; -# at 256 -# at 303 - server id 1 end_log_pos 88 CRC32 0x00000301 Table_map: `test`.`t1` mapped to number -# at 344 - server id 1 end_log_pos 122 CRC32 0x000003e8 Write_rows: table id flags: STMT_END_F -# Number of rows: 1 -DELIMITER ; -# End of log file -ROLLBACK /* added by mysqlbinlog */; -/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; -DELIMITER /*!*/; -# at 256 -# at 303 - server id 1 end_log_pos 210 CRC32 0x00000301 Table_map: `test`.`t1` mapped to number -# at 344 - server id 1 end_log_pos 244 CRC32 0x000007d0 Write_rows: table id flags: STMT_END_F -# Number of rows: 1 -DELIMITER ; -# End of log file -ROLLBACK /* added by mysqlbinlog */; -/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; -End of Savepoint - -ROLLBACK; -DROP TABLE t1, t2; diff --git a/mysql-test/suite/galera_sr/t/GCF-437.test b/mysql-test/suite/galera_sr/t/GCF-437.test deleted file mode 100644 index f71be65708e..00000000000 --- a/mysql-test/suite/galera_sr/t/GCF-437.test +++ /dev/null @@ -1,21 +0,0 @@ ---source include/galera_cluster.inc ---source include/have_innodb.inc ---source include/big_test.inc - -CREATE TABLE ten (f1 INTEGER) ENGINE=MyISAM; -INSERT INTO ten VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); - -CREATE TABLE t1 (f1 INTEGER PRIMARY KEY AUTO_INCREMENT, f2 VARCHAR(512)) ENGINE=InnoDB; - -SET SESSION wsrep_trx_fragment_size = 2 * 1024 * 1024; - ---error ER_BINLOG_ROW_LOGGING_FAILED -INSERT INTO t1 (f2) SELECT REPEAT('x', 512) FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5; - -CALL mtr.add_suppression("InnoDB: The total blob data length*"); -CALL mtr.add_suppression("WSREP: Error writing into mysql.wsrep_streaming_log: 139"); -CALL mtr.add_suppression("WSREP: Failed to write to frag table: 1"); -CALL mtr.add_suppression("WSREP: Failed to append frag to persistent storage"); - -DROP TABLE t1; -DROP table ten; diff --git a/mysql-test/suite/galera_sr/t/galera_sr_table_contents.test b/mysql-test/suite/galera_sr/t/galera_sr_table_contents.test deleted file mode 100644 index 92d29fe4ca2..00000000000 --- a/mysql-test/suite/galera_sr/t/galera_sr_table_contents.test +++ /dev/null @@ -1,49 +0,0 @@ -# -# This test dumps the contents of the SR table under various circumstances -# - ---source include/galera_cluster.inc - -CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; -INSERT INTO t1 VALUES (1),(2),(3); - -CREATE TABLE t2 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; -INSERT INTO t2 VALUES (1),(2),(3); - -SET SESSION wsrep_trx_fragment_size = 1; -SET AUTOCOMMIT=OFF; -START TRANSACTION; - ---echo ---echo Start of Simple Insert -INSERT INTO t1 VALUES (4); ---source suite/galera/include/galera_dump_sr_table.inc ---echo End of Simple Insert ---echo -ROLLBACK; - ---echo Start of Multi-row Update -UPDATE t1 SET f1 = f1 + 10; ---source suite/galera/include/galera_dump_sr_table.inc ---echo End of Multi-row Update ---echo -ROLLBACK; - ---echo Start of Multi-table Update -UPDATE t1, t2 SET t1.f1 = t1.f1 + 100, t2.f1 = t2.f1 + 100; ---source suite/galera/include/galera_dump_sr_table.inc ---echo End of Multi-table Update ---echo -ROLLBACK; - ---echo Start of Savepoint -INSERT INTO t1 VALUES (1000); -SAVEPOINT X; -INSERT INTO t1 VALUES (2000); -ROLLBACK TO SAVEPOINT X; ---source suite/galera/include/galera_dump_sr_table.inc ---echo End of Savepoint ---echo -ROLLBACK; - -DROP TABLE t1, t2; From a3f3d40b3312334fc96780f4e1740895d45a97c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Thu, 13 Feb 2020 08:32:59 +0200 Subject: [PATCH 15/66] MDEV-21421 : Galera test sporadic failure on galera.galera_as_slave_gtid_myisam: Result length mismatch In Galera 4 nodes 1 and 2 are galera nodes and node_3 should be non galera. --- mysql-test/suite/galera/disabled.def | 1 - .../suite/galera/galera_2nodes_as_slave.cnf | 66 +++++++++---------- .../r/galera_as_slave_gtid_myisam.result | 35 +++++----- .../galera/t/galera_as_slave_gtid_myisam.test | 40 ++++++----- 4 files changed, 71 insertions(+), 71 deletions(-) diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index 304ab745f54..9a35da65ac2 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -19,7 +19,6 @@ MW-328A : MDEV-21483 galera.MW-328A galera.MW-328B MW-328B : MDEV-21483 galera.MW-328A galera.MW-328B MW-329 : MDEV-19962 Galera test failure on MW-329 galera.galera_defaults : MDEV-21494 Galera test sporadic failure on galera.galera_defaults -galera_as_slave_gtid_myisam : MDEV-21421 galera.galera_as_slave_gtid_myisam galera_as_slave_replication_bundle : MDEV-15785 OPTION_GTID_BEGIN is set in Gtid_log_event::do_apply_event() galera_autoinc_sst_mariabackup : Known issue, may require porting MDEV-17458 from later versions galera_bf_abort_group_commit : MDEV-18282 Galera test failure on galera.galera_bf_abort_group_commit diff --git a/mysql-test/suite/galera/galera_2nodes_as_slave.cnf b/mysql-test/suite/galera/galera_2nodes_as_slave.cnf index 4c7763896d0..7daa501ca4a 100644 --- a/mysql-test/suite/galera/galera_2nodes_as_slave.cnf +++ b/mysql-test/suite/galera/galera_2nodes_as_slave.cnf @@ -9,18 +9,13 @@ binlog-format=row [mysqld.1] -log-bin -server-id=1 -wsrep-on=0 - -[mysqld.2] #galera_port=@OPT.port #ist_port=@OPT.port #sst_port=@OPT.port - wsrep-on=1 -log-bin +log-bin=master-bin +log-bin-index=master-bin log-slave-updates innodb-autoinc-lock-mode=2 @@ -28,6 +23,33 @@ default-storage-engine=innodb wsrep-provider=@ENV.WSREP_PROVIDER wsrep_node_address=127.0.0.1 wsrep-cluster-address=gcomm:// +wsrep_provider_options='base_port=@mysqld.1.#galera_port;gcache.size=10M' +wsrep_node_incoming_address=127.0.0.1:@mysqld.1.port +wsrep_sst_receive_address='127.0.0.1:@mysqld.1.#sst_port' + +# enforce read-committed characteristics across the cluster +wsrep-causal-reads=ON +wsrep-sync-wait=15 +server-id=1 +# lock schedule alg appears to be VATS by default, and it is not +# yet compatible with galera +innodb_lock_schedule_algorithm=FCFS + +[mysqld.2] +#galera_port=@OPT.port +#ist_port=@OPT.port +#sst_port=@OPT.port +wsrep-on=1 + +log-bin=master-bin +log-bin-index=master-bin +log-slave-updates + +innodb-autoinc-lock-mode=2 +default-storage-engine=innodb +wsrep-provider=@ENV.WSREP_PROVIDER +wsrep_node_address=127.0.0.1 +wsrep_cluster_address='gcomm://127.0.0.1:@mysqld.1.#galera_port' wsrep_provider_options='base_port=@mysqld.2.#galera_port;gcache.size=10M' wsrep_node_incoming_address=127.0.0.1:@mysqld.2.port wsrep_sst_receive_address='127.0.0.1:@mysqld.2.#sst_port' @@ -38,28 +60,10 @@ wsrep-sync-wait=15 server-id=2 [mysqld.3] -#galera_port=@OPT.port -#ist_port=@OPT.port -#sst_port=@OPT.port - -wsrep-on=1 - -log-bin -log-slave-updates - -innodb-autoinc-lock-mode=2 -default-storage-engine=innodb -wsrep-provider=@ENV.WSREP_PROVIDER -wsrep_node_address=127.0.0.1 -wsrep_cluster_address='gcomm://127.0.0.1:@mysqld.2.#galera_port' -wsrep_provider_options='base_port=@mysqld.3.#galera_port;gcache.size=10M' -wsrep_node_incoming_address=127.0.0.1:@mysqld.3.port -wsrep_sst_receive_address='127.0.0.1:@mysqld.3.#sst_port' - -# enforce read-committed characteristics across the cluster -wsrep-causal-reads=ON -wsrep-sync-wait=15 +log-bin=master-bin +log-bin-index=master-bin server-id=3 +wsrep-on=OFF [ENV] NODE_MYPORT_1= @mysqld.1.port @@ -70,9 +74,3 @@ NODE_MYSOCK_2= @mysqld.2.socket NODE_MYPORT_3= @mysqld.3.port NODE_MYSOCK_3= @mysqld.3.socket - -NODE_GALERAPORT_2= @mysqld.2.#galera_port -NODE_GALERAPORT_3= @mysqld.3.#galera_port - -NODE_SSTPORT_2= @mysqld.2.#sst_port -NODE_SSTPORT_3= @mysqld.3.#sst_port diff --git a/mysql-test/suite/galera/r/galera_as_slave_gtid_myisam.result b/mysql-test/suite/galera/r/galera_as_slave_gtid_myisam.result index 4516b171b60..6d808ce801e 100644 --- a/mysql-test/suite/galera/r/galera_as_slave_gtid_myisam.result +++ b/mysql-test/suite/galera/r/galera_as_slave_gtid_myisam.result @@ -1,33 +1,38 @@ -connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2; -connection node_2a; +connection node_2; +connection node_1; +connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3; +SELECT @@wsrep_on; +@@wsrep_on +0 +connection node_1; ALTER TABLE mysql.gtid_slave_pos engine = InnoDB; START SLAVE; -connection default; +connection node_3; CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=MyISAM; INSERT INTO t1 VALUES(1); SELECT LENGTH(@@global.gtid_binlog_state) > 1; LENGTH(@@global.gtid_binlog_state) > 1 1 -connection node_2a; +connection node_1; gtid_binlog_state_equal 0 -connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3; -SELECT COUNT(*) = 0 FROM t1; -COUNT(*) = 0 -1 +connection node_2; +SELECT COUNT(*) AS EXPECT_0 FROM t1; +EXPECT_0 +0 gtid_binlog_state_equal 0 #cleanup -connection default; +connection node_3; DROP TABLE t1; reset master; -connection node_2a; +connection node_1; STOP SLAVE; RESET SLAVE ALL; -set global wsrep_on=OFF; +SET GLOBAL WSREP_ON=OFF; reset master; -set global wsrep_on=ON; -connection node_3; -set global wsrep_on=OFF; +SET GLOBAL WSREP_ON=ON; +connection node_2; +SET GLOBAL WSREP_ON=OFF; reset master; -set global wsrep_on=ON; +SET GLOBAL WSREP_ON=ON; diff --git a/mysql-test/suite/galera/t/galera_as_slave_gtid_myisam.test b/mysql-test/suite/galera/t/galera_as_slave_gtid_myisam.test index 2bbf6dfce12..40f8bd7ad49 100644 --- a/mysql-test/suite/galera/t/galera_as_slave_gtid_myisam.test +++ b/mysql-test/suite/galera/t/galera_as_slave_gtid_myisam.test @@ -12,27 +12,31 @@ # --source include/have_innodb.inc +--source include/have_log_bin.inc +--source include/galera_cluster.inc -# As node #1 is not a Galera node, we connect to node #2 in order to run include/galera_cluster.inc ---connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 +# As node #3 is not a Galera node, and galera_cluster.inc does not open connetion to it +# we open the node_3 connection here +--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 +SELECT @@wsrep_on; ---connection node_2a +--connection node_1 # make sure gtid_slave_pos is of innodb engine, mtr does not currently provide that ALTER TABLE mysql.gtid_slave_pos engine = InnoDB; --disable_query_log ---eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_USER='root', MASTER_PORT=$NODE_MYPORT_1; +--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_USER='root', MASTER_PORT=$NODE_MYPORT_3; --enable_query_log START SLAVE; ---connection default +--connection node_3 CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=MyISAM; INSERT INTO t1 VALUES(1); SELECT LENGTH(@@global.gtid_binlog_state) > 1; --let $gtid_binlog_state_node1 = `SELECT @@global.gtid_binlog_state;` ---connection node_2a +--connection node_1 --let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; --source include/wait_condition.inc @@ -43,32 +47,26 @@ SELECT LENGTH(@@global.gtid_binlog_state) > 1; --eval SELECT '$gtid_binlog_state_node1' = @@global.gtid_binlog_state AS gtid_binlog_state_equal; --enable_query_log ---connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 -SELECT COUNT(*) = 0 FROM t1; +--connection node_2 +SELECT COUNT(*) AS EXPECT_0 FROM t1; --disable_query_log --eval SELECT '$gtid_binlog_state_node1' = @@global.gtid_binlog_state AS gtid_binlog_state_equal; --enable_query_log --echo #cleanup ---connection default +--connection node_3 DROP TABLE t1; reset master; ---connection node_2a ---let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; ---source include/wait_condition.inc +--connection node_1 STOP SLAVE; RESET SLAVE ALL; -set global wsrep_on=OFF; +SET GLOBAL WSREP_ON=OFF; reset master; -set global wsrep_on=ON; +SET GLOBAL WSREP_ON=ON; ---connection node_3 ---let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; ---source include/wait_condition.inc - -set global wsrep_on=OFF; +--connection node_2 +SET GLOBAL WSREP_ON=OFF; reset master; -set global wsrep_on=ON; - +SET GLOBAL WSREP_ON=ON; From 7002948bc50d50782b27d9b9d3bfbfd9dfe4ca0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Wed, 12 Feb 2020 11:29:37 +0200 Subject: [PATCH 16/66] MDEV-21517 : Galera test galera_sr.GCF-561 failure: Result length mismatch Add wait conditions. --- mysql-test/suite/galera_sr/r/GCF-561.result | 6 +++--- mysql-test/suite/galera_sr/t/GCF-561.test | 9 +++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/mysql-test/suite/galera_sr/r/GCF-561.result b/mysql-test/suite/galera_sr/r/GCF-561.result index 9d595973f57..ec5ec786628 100644 --- a/mysql-test/suite/galera_sr/r/GCF-561.result +++ b/mysql-test/suite/galera_sr/r/GCF-561.result @@ -12,9 +12,9 @@ INSERT INTO t1 VALUES (4, 4); INSERT INTO t1 VALUES (5, 5); connection node_2; SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; -SELECT COUNT(*) > 0 FROM mysql.wsrep_streaming_log; -COUNT(*) > 0 -1 +SELECT COUNT(*) AS EXPECT_5 FROM mysql.wsrep_streaming_log; +EXPECT_5 +5 ALTER TABLE t1 DROP COLUMN f2; SELECT COUNT(*) AS EXPECT_0 FROM t1; EXPECT_0 diff --git a/mysql-test/suite/galera_sr/t/GCF-561.test b/mysql-test/suite/galera_sr/t/GCF-561.test index b58e337e72c..eadf0263ada 100644 --- a/mysql-test/suite/galera_sr/t/GCF-561.test +++ b/mysql-test/suite/galera_sr/t/GCF-561.test @@ -20,9 +20,12 @@ INSERT INTO t1 VALUES (5, 5); --connection node_2 SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; ---let $wait_condition = SELECT COUNT(*) > 0 FROM t1; +--let $wait_condition = SELECT COUNT(*) = 5 FROM t1; --source include/wait_condition.inc -SELECT COUNT(*) > 0 FROM mysql.wsrep_streaming_log; + +--let $wait_condition = SELECT COUNT(*) = 5 FROM mysql.wsrep_streaming_log; +--source include/wait_condition.inc +SELECT COUNT(*) AS EXPECT_5 FROM mysql.wsrep_streaming_log; ALTER TABLE t1 DROP COLUMN f2; @@ -35,6 +38,8 @@ SELECT COUNT(*) AS EXPECT_0 FROM mysql.wsrep_streaming_log; --error ER_LOCK_DEADLOCK INSERT INTO t1 VALUES (6, 6); +--let $wait_condition = SELECT COUNT(*) = 0 FROM mysql.wsrep_streaming_log; +--source include/wait_condition.inc SELECT COUNT(*) AS EXPECT_0 FROM mysql.wsrep_streaming_log; # DDL is now in effect From ba3e9d0adbe6ab6de896b295b83afe46f62078b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Thu, 13 Feb 2020 12:38:15 +0200 Subject: [PATCH 17/66] MDEV-18180 : Galera test failure on galera.galera_concurrent_ctas Test changes only. --- mysql-test/suite/galera/disabled.def | 1 - .../galera/t/galera_concurrent_ctas.test | 36 +++++++++---------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index 9a35da65ac2..a1f28bd634b 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -23,7 +23,6 @@ galera_as_slave_replication_bundle : MDEV-15785 OPTION_GTID_BEGIN is set in Gtid galera_autoinc_sst_mariabackup : Known issue, may require porting MDEV-17458 from later versions galera_bf_abort_group_commit : MDEV-18282 Galera test failure on galera.galera_bf_abort_group_commit galera_binlog_stmt_autoinc : MDEV-19959 Galera test failure on galera_binlog_stmt_autoinc -galera_concurrent_ctas : MDEV-18180 Galera test failure on galera.galera_concurrent_ctas galera_encrypt_tmp_files : Get error failed to enable encryption of temporary files galera_ftwrl : MDEV-21525 galera.galera_ftwrl galera_gcache_recover_manytrx : MDEV-18834 Galera test failure diff --git a/mysql-test/suite/galera/t/galera_concurrent_ctas.test b/mysql-test/suite/galera/t/galera_concurrent_ctas.test index 6c4e8be68a7..61038664b21 100644 --- a/mysql-test/suite/galera/t/galera_concurrent_ctas.test +++ b/mysql-test/suite/galera/t/galera_concurrent_ctas.test @@ -1,32 +1,32 @@ --source include/galera_cluster.inc ---source include/have_innodb.inc +--source include/big_test.inc --write_file $MYSQLTEST_VARDIR/tmp/galera_concurrent.sql -CREATE table t1 as SELECT SLEEP(0); +CREATE table t1 as SELECT SLEEP(0.1); DROP table t1; -CREATE table t1 as SELECT SLEEP(0); +CREATE table t1 as SELECT SLEEP(0.1); DROP table t1; -CREATE table t1 as SELECT SLEEP(0); +CREATE table t1 as SELECT SLEEP(0.1); DROP table t1; -CREATE table t1 as SELECT SLEEP(0); +CREATE table t1 as SELECT SLEEP(0.1); DROP table t1; -CREATE table t1 as SELECT SLEEP(0); +CREATE table t1 as SELECT SLEEP(0.1); DROP table t1; -CREATE table t1 as SELECT SLEEP(0); +CREATE table t1 as SELECT SLEEP(0.1); DROP table t1; -CREATE table t1 as SELECT SLEEP(0); +CREATE table t1 as SELECT SLEEP(0.1); DROP table t1; -CREATE table t1 as SELECT SLEEP(0); +CREATE table t1 as SELECT SLEEP(0.1); DROP table t1; -CREATE table t1 as SELECT SLEEP(0); -CREATE table t2 as SELECT SLEEP(0); -CREATE table t3 as SELECT SLEEP(0); -CREATE table t4 as SELECT SLEEP(0); -CREATE table t5 as SELECT SLEEP(0); -CREATE table t6 as SELECT SLEEP(0); -CREATE table t7 as SELECT SLEEP(0); -CREATE table t8 as SELECT SLEEP(0); -CREATE table t9 as SELECT SLEEP(0); +CREATE table t1 as SELECT SLEEP(0.2); +CREATE table t2 as SELECT SLEEP(0.2); +CREATE table t3 as SELECT SLEEP(0.2); +CREATE table t4 as SELECT SLEEP(0.2); +CREATE table t5 as SELECT SLEEP(0.2); +CREATE table t6 as SELECT SLEEP(0.2); +CREATE table t7 as SELECT SLEEP(0.2); +CREATE table t8 as SELECT SLEEP(0.2); +CREATE table t9 as SELECT SLEEP(0.2); DROP table t1; DROP table t2; DROP table t3; From 2cff5428920a05bc8918d55ba3e221f065313c86 Mon Sep 17 00:00:00 2001 From: "Alexander E. Patrakov" Date: Thu, 28 Nov 2019 17:37:57 +0500 Subject: [PATCH 18/66] MDEV-21140 Make galera_recovery.sh work with fs.protected_regular = 1 (#1417) The log file is opened as root since commit bb7a70c, so there is no need to chown it. --- scripts/galera_recovery.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/galera_recovery.sh b/scripts/galera_recovery.sh index 709c4b0eed5..8df2abc3fd5 100644 --- a/scripts/galera_recovery.sh +++ b/scripts/galera_recovery.sh @@ -101,8 +101,7 @@ wsrep_recover_position() { # Safety checks if [ -n "$log_file" -a -f "$log_file" ]; then - [ "$euid" = "0" ] && chown $user $log_file - chmod 600 $log_file + chmod 600 $log_file else log "WSREP: mktemp failed" fi From 38414b2bd0099b54da32453e2f9a80a568e1acc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Thu, 13 Feb 2020 14:13:12 +0200 Subject: [PATCH 19/66] MDEV-21514 : Galera test failure on galera.galera_wan_restart_sst on Azure Remove sleeps and unnecessary waits. --- mysql-test/suite/galera/disabled.def | 1 - .../galera/r/galera_wan_restart_sst.result | 26 ++++++++++--------- .../galera/t/galera_wan_restart_sst.test | 22 +++++----------- 3 files changed, 20 insertions(+), 29 deletions(-) diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index a1f28bd634b..1ae1bf7b267 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -48,7 +48,6 @@ galera_var_notify_cmd : MDEV-21488,MDEV-20600 galera_var_reject_queries : assertion in inline_mysql_socket_send galera_var_retry_autocommit: MDEV-18181 Galera test failure on galera.galera_var_retry_autocommit galera_wan : MDEV-17259 Test failure on galera.galera_wan -galera_wan_restart_sst : MDEV-21514 galera.galera_wan_restart_sst galera_wsrep_new_cluster : MDEV-21515 galera.galera_wsrep_new_cluster mysql-wsrep#198 : MDEV-18935 Galera test mysql-wsrep#198 sporaric assertion transaction.cpp:362: int wsrep::transaction::before_commit(): Assertion `state() == s_executing || state() == s_committing || state() == s_must_abort || state() == s_replaying' failed. mysql-wsrep#33 : MDEV-21420 galera.mysql-wsrep#33 diff --git a/mysql-test/suite/galera/r/galera_wan_restart_sst.result b/mysql-test/suite/galera/r/galera_wan_restart_sst.result index 1296744a9c1..05390338160 100644 --- a/mysql-test/suite/galera/r/galera_wan_restart_sst.result +++ b/mysql-test/suite/galera/r/galera_wan_restart_sst.result @@ -48,38 +48,40 @@ INSERT INTO t1 VALUES (33); connection node_4; INSERT INTO t1 VALUES (341); connection node_1; -SELECT COUNT(*) = 19 FROM t1; -COUNT(*) = 19 -1 +SELECT COUNT(*) AS EXPECT_19 FROM t1; +EXPECT_19 +19 connection node_2; SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; VARIABLE_VALUE = 4 1 -SELECT COUNT(*) = 19 FROM t1; -COUNT(*) = 19 -1 +SELECT COUNT(*) AS EXPECT_19 FROM t1; +EXPECT_19 +19 connection node_3; SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; VARIABLE_VALUE = 4 1 -SELECT COUNT(*) = 19 FROM t1; -COUNT(*) = 19 -1 +SELECT COUNT(*) AS EXPECT_19 FROM t1; +EXPECT_19 +19 connection node_4; SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; VARIABLE_VALUE = 4 1 -SELECT COUNT(*) = 19 FROM t1; -COUNT(*) = 19 -1 +SELECT COUNT(*) AS EXPECT_19 FROM t1; +EXPECT_19 +19 connection node_1; DROP TABLE t1; CALL mtr.add_suppression("There are no nodes in the same segment that will ever be able to become donors, yet there is a suitable donor outside"); CALL mtr.add_suppression("WSREP: gcs_caused\\(\\) returned -1 \\(Operation not permitted\\)"); connection node_2; +CALL mtr.add_suppression("There are no nodes in the same segment that will ever be able to become donors, yet there is a suitable donor outside"); CALL mtr.add_suppression("Action message in non-primary configuration from member 0"); connection node_3; CALL mtr.add_suppression("There are no nodes in the same segment that will ever be able to become donors, yet there is a suitable donor outside"); CALL mtr.add_suppression("Action message in non-primary configuration from member 0"); connection node_4; +CALL mtr.add_suppression("There are no nodes in the same segment that will ever be able to become donors, yet there is a suitable donor outside"); CALL mtr.add_suppression("Action message in non-primary configuration from member 0"); diff --git a/mysql-test/suite/galera/t/galera_wan_restart_sst.test b/mysql-test/suite/galera/t/galera_wan_restart_sst.test index 9b12eeed1ac..24620458570 100644 --- a/mysql-test/suite/galera/t/galera_wan_restart_sst.test +++ b/mysql-test/suite/galera/t/galera_wan_restart_sst.test @@ -37,10 +37,8 @@ INSERT INTO t1 VALUES (4); INSERT INTO t1 VALUES (13); --source include/kill_galera.inc ---sleep 5 --connection node_1 ---source include/wait_until_connected_again.inc INSERT INTO t1 VALUES (11); --connection node_2 @@ -51,8 +49,6 @@ INSERT INTO t1 VALUES (14); --connection node_3 --source include/start_mysqld.inc ---sleep 5 ---source include/wait_until_connected_again.inc INSERT INTO t1 VALUES (131); @@ -64,10 +60,8 @@ INSERT INTO t1 VALUES (131); INSERT INTO t1 VALUES (22); --source include/kill_galera.inc ---sleep 5 --connection node_1 ---source include/wait_until_connected_again.inc INSERT INTO t1 VALUES (21); --connection node_3 @@ -78,8 +72,6 @@ INSERT INTO t1 VALUES (24); --connection node_2 --source include/start_mysqld.inc ---sleep 5 ---source include/wait_until_connected_again.inc INSERT INTO t1 VALUES (221); @@ -91,10 +83,8 @@ INSERT INTO t1 VALUES (221); INSERT INTO t1 VALUES (34); --source include/kill_galera.inc ---sleep 5 --connection node_1 ---source include/wait_until_connected_again.inc INSERT INTO t1 VALUES (31); --connection node_2 @@ -105,8 +95,6 @@ INSERT INTO t1 VALUES (33); --connection node_4 --source include/start_mysqld.inc ---sleep 5 ---source include/wait_until_connected_again.inc INSERT INTO t1 VALUES (341); @@ -119,19 +107,19 @@ INSERT INTO t1 VALUES (341); --let $wait_condition = SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; --source include/wait_condition.inc -SELECT COUNT(*) = 19 FROM t1; +SELECT COUNT(*) AS EXPECT_19 FROM t1; --connection node_2 SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; -SELECT COUNT(*) = 19 FROM t1; +SELECT COUNT(*) AS EXPECT_19 FROM t1; --connection node_3 SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; -SELECT COUNT(*) = 19 FROM t1; +SELECT COUNT(*) AS EXPECT_19 FROM t1; --connection node_4 SELECT VARIABLE_VALUE = 4 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; -SELECT COUNT(*) = 19 FROM t1; +SELECT COUNT(*) AS EXPECT_19 FROM t1; --connection node_1 DROP TABLE t1; @@ -139,6 +127,7 @@ CALL mtr.add_suppression("There are no nodes in the same segment that will ever CALL mtr.add_suppression("WSREP: gcs_caused\\(\\) returned -1 \\(Operation not permitted\\)"); --connection node_2 +CALL mtr.add_suppression("There are no nodes in the same segment that will ever be able to become donors, yet there is a suitable donor outside"); CALL mtr.add_suppression("Action message in non-primary configuration from member 0"); --connection node_3 @@ -146,4 +135,5 @@ CALL mtr.add_suppression("There are no nodes in the same segment that will ever CALL mtr.add_suppression("Action message in non-primary configuration from member 0"); --connection node_4 +CALL mtr.add_suppression("There are no nodes in the same segment that will ever be able to become donors, yet there is a suitable donor outside"); CALL mtr.add_suppression("Action message in non-primary configuration from member 0"); From 9ab171edd6d5e6a13be50ffcb908ef0169f41da2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Thu, 13 Feb 2020 17:06:02 +0200 Subject: [PATCH 20/66] MDEV-21420 : Galera test failure on galera.mysql-wsrep#33 Add more tests and move SST restore to correct place. --- mysql-test/suite/galera/disabled.def | 1 - .../suite/galera/r/mysql-wsrep#33,debug.rdiff | 117 +++++++ .../suite/galera/r/mysql-wsrep#33.result | 291 +++++++++++++++++- mysql-test/suite/galera/t/mysql-wsrep#33.test | 16 +- 4 files changed, 418 insertions(+), 7 deletions(-) create mode 100644 mysql-test/suite/galera/r/mysql-wsrep#33,debug.rdiff diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index 1ae1bf7b267..b1c28a0e594 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -50,7 +50,6 @@ galera_var_retry_autocommit: MDEV-18181 Galera test failure on galera.galera_var galera_wan : MDEV-17259 Test failure on galera.galera_wan galera_wsrep_new_cluster : MDEV-21515 galera.galera_wsrep_new_cluster mysql-wsrep#198 : MDEV-18935 Galera test mysql-wsrep#198 sporaric assertion transaction.cpp:362: int wsrep::transaction::before_commit(): Assertion `state() == s_executing || state() == s_committing || state() == s_must_abort || state() == s_replaying' failed. -mysql-wsrep#33 : MDEV-21420 galera.mysql-wsrep#33 partition : MDEV-19958 Galera test failure on galera.partition query_cache: MDEV-15805 Test failure on galera.query_cache sql_log_bin : MDEV-21491 galera.sql_log_bin diff --git a/mysql-test/suite/galera/r/mysql-wsrep#33,debug.rdiff b/mysql-test/suite/galera/r/mysql-wsrep#33,debug.rdiff new file mode 100644 index 00000000000..d8fed3897fd --- /dev/null +++ b/mysql-test/suite/galera/r/mysql-wsrep#33,debug.rdiff @@ -0,0 +1,117 @@ +--- r/mysql-wsrep#33.result 2020-02-13 15:14:31.871914684 +0200 ++++ r/mysql-wsrep#33.reject 2020-02-13 17:01:22.559450367 +0200 +@@ -395,6 +395,114 @@ + DROP TABLE t1; + COMMIT; + SET AUTOCOMMIT=ON; ++Performing State Transfer on a server that has been killed and restarted ++while a DDL was in progress on it ++connection node_1; ++CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB; ++SET AUTOCOMMIT=OFF; ++START TRANSACTION; ++INSERT INTO t1 VALUES ('node1_committed_before'); ++INSERT INTO t1 VALUES ('node1_committed_before'); ++INSERT INTO t1 VALUES ('node1_committed_before'); ++INSERT INTO t1 VALUES ('node1_committed_before'); ++INSERT INTO t1 VALUES ('node1_committed_before'); ++connection node_2; ++START TRANSACTION; ++INSERT INTO t1 VALUES ('node2_committed_before'); ++INSERT INTO t1 VALUES ('node2_committed_before'); ++INSERT INTO t1 VALUES ('node2_committed_before'); ++INSERT INTO t1 VALUES ('node2_committed_before'); ++INSERT INTO t1 VALUES ('node2_committed_before'); ++COMMIT; ++SET GLOBAL debug_dbug = 'd,sync.alter_opened_table'; ++connection node_1; ++ALTER TABLE t1 ADD COLUMN f2 INTEGER; ++connection node_2; ++SET wsrep_sync_wait = 0; ++Killing server ... ++connection node_1; ++SET AUTOCOMMIT=OFF; ++START TRANSACTION; ++INSERT INTO t1 (f1) VALUES ('node1_committed_during'); ++INSERT INTO t1 (f1) VALUES ('node1_committed_during'); ++INSERT INTO t1 (f1) VALUES ('node1_committed_during'); ++INSERT INTO t1 (f1) VALUES ('node1_committed_during'); ++INSERT INTO t1 (f1) VALUES ('node1_committed_during'); ++COMMIT; ++START TRANSACTION; ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++connect node_1a_galera_st_kill_slave_ddl, 127.0.0.1, root, , test, $NODE_MYPORT_1; ++SET AUTOCOMMIT=OFF; ++START TRANSACTION; ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++connection node_2; ++Performing --wsrep-recover ... ++connection node_2; ++Starting server ... ++Using --wsrep-start-position when starting mysqld ... ++SET AUTOCOMMIT=OFF; ++START TRANSACTION; ++INSERT INTO t1 (f1) VALUES ('node2_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node2_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node2_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node2_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node2_committed_after'); ++COMMIT; ++connection node_1; ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_committed_after'); ++COMMIT; ++SET AUTOCOMMIT=OFF; ++START TRANSACTION; ++INSERT INTO t1 (f1) VALUES ('node1_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_committed_after'); ++INSERT INTO t1 (f1) VALUES ('node1_committed_after'); ++COMMIT; ++connection node_1a_galera_st_kill_slave_ddl; ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++INSERT INTO t1 (f1) VALUES ('node1_to_be_rollbacked_after'); ++ROLLBACK; ++SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; ++COUNT(*) = 2 ++1 ++SELECT COUNT(*) = 35 FROM t1; ++COUNT(*) = 35 ++1 ++SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; ++COUNT(*) = 0 ++1 ++COMMIT; ++SET AUTOCOMMIT=ON; ++connection node_1; ++SELECT COUNT(*) = 2 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't1'; ++COUNT(*) = 2 ++1 ++SELECT COUNT(*) = 35 FROM t1; ++COUNT(*) = 35 ++1 ++SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; ++COUNT(*) = 0 ++1 ++DROP TABLE t1; ++COMMIT; ++SET AUTOCOMMIT=ON; ++SET GLOBAL debug_dbug = $debug_orig; + connection node_2; + connection node_1; + CALL mtr.add_suppression("Slave SQL: Error 'The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement' on query"); diff --git a/mysql-test/suite/galera/r/mysql-wsrep#33.result b/mysql-test/suite/galera/r/mysql-wsrep#33.result index 5589faad8b1..fb0b593cc96 100644 --- a/mysql-test/suite/galera/r/mysql-wsrep#33.result +++ b/mysql-test/suite/galera/r/mysql-wsrep#33.result @@ -109,6 +109,293 @@ COUNT(*) = 0 DROP TABLE t1; COMMIT; SET AUTOCOMMIT=ON; +Performing State Transfer on a server that has been shut down cleanly and restarted +connection node_1; +CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_committed_before'); +INSERT INTO t1 VALUES ('node1_committed_before'); +INSERT INTO t1 VALUES ('node1_committed_before'); +INSERT INTO t1 VALUES ('node1_committed_before'); +INSERT INTO t1 VALUES ('node1_committed_before'); +COMMIT; +connection node_2; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before'); +COMMIT; +Shutting down server ... +connection node_1; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_committed_during'); +INSERT INTO t1 VALUES ('node1_committed_during'); +INSERT INTO t1 VALUES ('node1_committed_during'); +INSERT INTO t1 VALUES ('node1_committed_during'); +INSERT INTO t1 VALUES ('node1_committed_during'); +COMMIT; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +connect node_1a_galera_st_shutdown_slave, 127.0.0.1, root, , test, $NODE_MYPORT_1; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +connection node_2; +Starting server ... +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node2_committed_after'); +INSERT INTO t1 VALUES ('node2_committed_after'); +INSERT INTO t1 VALUES ('node2_committed_after'); +INSERT INTO t1 VALUES ('node2_committed_after'); +INSERT INTO t1 VALUES ('node2_committed_after'); +COMMIT; +connection node_1; +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +COMMIT; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_committed_after'); +INSERT INTO t1 VALUES ('node1_committed_after'); +INSERT INTO t1 VALUES ('node1_committed_after'); +INSERT INTO t1 VALUES ('node1_committed_after'); +INSERT INTO t1 VALUES ('node1_committed_after'); +COMMIT; +connection node_1a_galera_st_shutdown_slave; +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +ROLLBACK; +SELECT COUNT(*) = 35 FROM t1; +COUNT(*) = 35 +1 +SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; +COUNT(*) = 0 +1 +COMMIT; +SET AUTOCOMMIT=ON; +connection node_1; +SELECT COUNT(*) = 35 FROM t1; +COUNT(*) = 35 +1 +SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; +COUNT(*) = 0 +1 +DROP TABLE t1; +COMMIT; +SET AUTOCOMMIT=ON; +Performing State Transfer on a server that starts from a clean var directory +This is accomplished by shutting down node #2 and removing its var directory before restarting it +connection node_1; +CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_committed_before'); +INSERT INTO t1 VALUES ('node1_committed_before'); +INSERT INTO t1 VALUES ('node1_committed_before'); +INSERT INTO t1 VALUES ('node1_committed_before'); +INSERT INTO t1 VALUES ('node1_committed_before'); +COMMIT; +connection node_2; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before'); +COMMIT; +Shutting down server ... +connection node_1; +Cleaning var directory ... +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_committed_during'); +INSERT INTO t1 VALUES ('node1_committed_during'); +INSERT INTO t1 VALUES ('node1_committed_during'); +INSERT INTO t1 VALUES ('node1_committed_during'); +INSERT INTO t1 VALUES ('node1_committed_during'); +COMMIT; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +connect node_1a_galera_st_clean_slave, 127.0.0.1, root, , test, $NODE_MYPORT_1; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +connection node_2; +Starting server ... +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node2_committed_after'); +INSERT INTO t1 VALUES ('node2_committed_after'); +INSERT INTO t1 VALUES ('node2_committed_after'); +INSERT INTO t1 VALUES ('node2_committed_after'); +INSERT INTO t1 VALUES ('node2_committed_after'); +COMMIT; +connection node_1; +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +COMMIT; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_committed_after'); +INSERT INTO t1 VALUES ('node1_committed_after'); +INSERT INTO t1 VALUES ('node1_committed_after'); +INSERT INTO t1 VALUES ('node1_committed_after'); +INSERT INTO t1 VALUES ('node1_committed_after'); +COMMIT; +connection node_1a_galera_st_clean_slave; +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +ROLLBACK; +SELECT COUNT(*) = 35 FROM t1; +COUNT(*) = 35 +1 +SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; +COUNT(*) = 0 +1 +COMMIT; +SET AUTOCOMMIT=ON; +connection node_1; +SELECT COUNT(*) = 35 FROM t1; +COUNT(*) = 35 +1 +SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; +COUNT(*) = 0 +1 +DROP TABLE t1; +COMMIT; +SET AUTOCOMMIT=ON; +Performing State Transfer on a server that has been killed and restarted +connection node_1; +CREATE TABLE t1 (f1 CHAR(255)) ENGINE=InnoDB; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_committed_before'); +INSERT INTO t1 VALUES ('node1_committed_before'); +INSERT INTO t1 VALUES ('node1_committed_before'); +INSERT INTO t1 VALUES ('node1_committed_before'); +INSERT INTO t1 VALUES ('node1_committed_before'); +COMMIT; +connection node_2; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before'); +INSERT INTO t1 VALUES ('node2_committed_before'); +COMMIT; +Killing server ... +connection node_1; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_committed_during'); +INSERT INTO t1 VALUES ('node1_committed_during'); +INSERT INTO t1 VALUES ('node1_committed_during'); +INSERT INTO t1 VALUES ('node1_committed_during'); +INSERT INTO t1 VALUES ('node1_committed_during'); +COMMIT; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +connect node_1a_galera_st_kill_slave, 127.0.0.1, root, , test, $NODE_MYPORT_1; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +connection node_2; +Performing --wsrep-recover ... +Starting server ... +Using --wsrep-start-position when starting mysqld ... +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node2_committed_after'); +INSERT INTO t1 VALUES ('node2_committed_after'); +INSERT INTO t1 VALUES ('node2_committed_after'); +INSERT INTO t1 VALUES ('node2_committed_after'); +INSERT INTO t1 VALUES ('node2_committed_after'); +COMMIT; +connection node_1; +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +INSERT INTO t1 VALUES ('node1_to_be_committed_after'); +COMMIT; +SET AUTOCOMMIT=OFF; +START TRANSACTION; +INSERT INTO t1 VALUES ('node1_committed_after'); +INSERT INTO t1 VALUES ('node1_committed_after'); +INSERT INTO t1 VALUES ('node1_committed_after'); +INSERT INTO t1 VALUES ('node1_committed_after'); +INSERT INTO t1 VALUES ('node1_committed_after'); +COMMIT; +connection node_1a_galera_st_kill_slave; +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +INSERT INTO t1 VALUES ('node1_to_be_rollbacked_after'); +ROLLBACK; +SELECT COUNT(*) = 35 FROM t1; +COUNT(*) = 35 +1 +SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; +COUNT(*) = 0 +1 +COMMIT; +SET AUTOCOMMIT=ON; +connection node_1; +SELECT COUNT(*) = 35 FROM t1; +COUNT(*) = 35 +1 +SELECT COUNT(*) = 0 FROM (SELECT COUNT(*) AS c, f1 FROM t1 GROUP BY f1 HAVING c NOT IN (5, 10)) AS a1; +COUNT(*) = 0 +1 +DROP TABLE t1; +COMMIT; +SET AUTOCOMMIT=ON; +connection node_2; connection node_1; CALL mtr.add_suppression("Slave SQL: Error 'The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement' on query"); DROP USER sst; @@ -120,5 +407,5 @@ CALL mtr.add_suppression("Can't open and lock privilege tables"); CALL mtr.add_suppression("Info table is not ready to be used"); CALL mtr.add_suppression("Native table .* has the wrong structure"); CALL mtr.add_suppression("Table \'mysql.gtid_slave_pos\' doesn\'t exist"); -connection node_2; -Restarting server ... +SET GLOBAL general_log = ON; +SET GLOBAL slow_query_log = ON; diff --git a/mysql-test/suite/galera/t/mysql-wsrep#33.test b/mysql-test/suite/galera/t/mysql-wsrep#33.test index 351e457f165..a67336cc67e 100644 --- a/mysql-test/suite/galera/t/mysql-wsrep#33.test +++ b/mysql-test/suite/galera/t/mysql-wsrep#33.test @@ -6,15 +6,23 @@ --let $node_1=node_1 --let $node_2=node_2 --source suite/galera/include/auto_increment_offset_save.inc + --source suite/galera/include/galera_sst_set_mysqldump.inc --source suite/galera/include/galera_st_disconnect_slave.inc ---source suite/galera/include/galera_sst_restore.inc +--source suite/galera/include/galera_st_shutdown_slave.inc +--source suite/galera/include/galera_st_clean_slave.inc +--source suite/galera/include/galera_st_kill_slave.inc +--source suite/galera/include/galera_st_kill_slave_ddl.inc --connection node_2 ---echo Restarting server ... ---source include/restart_mysqld.inc - --source suite/galera/include/auto_increment_offset_restore.inc +--source suite/galera/include/galera_sst_restore.inc + +# We have to manually restore global_log and slow_query_log due to mysql-wsrep#108 +# Otherwise MTR's check_testcases complains + +SET GLOBAL general_log = ON; +SET GLOBAL slow_query_log = ON; From 4eb4d0785629242669a31c0e437a695d40ec93af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Fri, 14 Feb 2020 08:20:52 +0200 Subject: [PATCH 21/66] Fix Galera test galera_as_slave_ctas. --- .../galera/r/galera_as_slave_ctas.result | 26 ++++++------ .../suite/galera/t/galera_as_slave_ctas.test | 40 +++++++++---------- 2 files changed, 34 insertions(+), 32 deletions(-) diff --git a/mysql-test/suite/galera/r/galera_as_slave_ctas.result b/mysql-test/suite/galera/r/galera_as_slave_ctas.result index 16df71b744f..a3d28ce42aa 100644 --- a/mysql-test/suite/galera/r/galera_as_slave_ctas.result +++ b/mysql-test/suite/galera/r/galera_as_slave_ctas.result @@ -1,29 +1,31 @@ -connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2; +connection node_2; +connection node_1; connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3; -connection node_2a; +SELECT @@wsrep_on; +@@wsrep_on +0 +connection node_1; START SLAVE; -connection default; +connection node_3; SHOW VARIABLES LIKE 'binlog_format'; Variable_name Value binlog_format ROW -connection default; CREATE TABLE source (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; CREATE TABLE target AS SELECT * FROM source; -connection node_2a; +connection node_1; +connection node_2; connection node_3; -connection default; DROP TABLE target; INSERT INTO source VALUES(1); CREATE TABLE target AS SELECT * FROM source; -connection node_2a; +connection node_1; +connection node_2; connection node_3; -connection default; DROP TABLE source; DROP TABLE target; -connection node_3; -connection node_2a; +connection node_2; +connection node_1; STOP SLAVE; RESET SLAVE ALL; -connection default; +connection node_3; RESET MASTER; -disconnect node_2a; diff --git a/mysql-test/suite/galera/t/galera_as_slave_ctas.test b/mysql-test/suite/galera/t/galera_as_slave_ctas.test index b146b1ce3dc..eced636c600 100644 --- a/mysql-test/suite/galera/t/galera_as_slave_ctas.test +++ b/mysql-test/suite/galera/t/galera_as_slave_ctas.test @@ -6,69 +6,69 @@ # --source include/have_innodb.inc +--source include/have_log_bin.inc +--source include/galera_cluster.inc -# As node #1 is not a Galera node, we connect to node #2 in order to run include/galera_cluster.inc ---connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 +# As node #3 is not a Galera node, and galera_cluster.inc does not open connetion to it +# we open the node_3 connection here --connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 +SELECT @@wsrep_on; ---connection node_2a +--connection node_1 --disable_query_log ---eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_USER='root', MASTER_PORT=$NODE_MYPORT_1; +--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_USER='root', MASTER_PORT=$NODE_MYPORT_3; --enable_query_log START SLAVE; - # make sure master server has binlog_format=ROW ---connection default +--connection node_3 SHOW VARIABLES LIKE 'binlog_format'; # # test phase one, issue CTAS with empty source table # ---connection default + CREATE TABLE source (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; CREATE TABLE target AS SELECT * FROM source; ---connection node_2a +--connection node_1 --let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'target'; --source include/wait_condition.inc ---connection node_3 +--connection node_2 --let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'target'; --source include/wait_condition.inc # # test phase two, issue CTAS with populated source table # ---connection default +--connection node_3 DROP TABLE target; INSERT INTO source VALUES(1); CREATE TABLE target AS SELECT * FROM source; ---connection node_2a +--connection node_1 +--let $wait_condition = SELECT COUNT(*) = 1 FROM target; +--source include/wait_condition.inc + +--connection node_2 --let $wait_condition = SELECT COUNT(*) = 1 FROM target; --source include/wait_condition.inc --connection node_3 ---let $wait_condition = SELECT COUNT(*) = 1 FROM target; ---source include/wait_condition.inc - ---connection default DROP TABLE source; DROP TABLE target; ---connection node_3 +--connection node_2 --let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'target'; --source include/wait_condition.inc - ---connection node_2a +--connection node_1 STOP SLAVE; RESET SLAVE ALL; ---connection default +--connection node_3 RESET MASTER; ---disconnect node_2a From 1a73b995fc03cc2fecd5b9288bd657db962bf67b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Fri, 31 Jan 2020 08:05:41 +0200 Subject: [PATCH 22/66] MDEV-21601 : Cleanup Galera disabled tests * Remove those tests that will not be supported on that release. * Make sure that correct tests are disabled and have MDEVs * Sort test names This should not be merged upwards. --- .../galera_as_slave_replication_bundle.result | 15 ------ .../galera/r/galera_v1_row_events.result | 15 ------ .../suite/galera/t/galera_as_slave_gtid.cnf | 6 --- .../galera/t/galera_as_slave_gtid_myisam.cnf | 6 --- .../t/galera_as_slave_replication_bundle.cnf | 4 -- .../t/galera_as_slave_replication_bundle.test | 49 ------------------- .../suite/galera/t/galera_flush_local.cnf | 12 ----- .../galera_sr/t/galera_sr_v1_row_events.test | 27 ---------- 8 files changed, 134 deletions(-) delete mode 100644 mysql-test/suite/galera/r/galera_as_slave_replication_bundle.result delete mode 100644 mysql-test/suite/galera/r/galera_v1_row_events.result delete mode 100644 mysql-test/suite/galera/t/galera_as_slave_gtid.cnf delete mode 100644 mysql-test/suite/galera/t/galera_as_slave_gtid_myisam.cnf delete mode 100644 mysql-test/suite/galera/t/galera_as_slave_replication_bundle.cnf delete mode 100644 mysql-test/suite/galera/t/galera_as_slave_replication_bundle.test delete mode 100644 mysql-test/suite/galera/t/galera_flush_local.cnf delete mode 100644 mysql-test/suite/galera_sr/t/galera_sr_v1_row_events.test diff --git a/mysql-test/suite/galera/r/galera_as_slave_replication_bundle.result b/mysql-test/suite/galera/r/galera_as_slave_replication_bundle.result deleted file mode 100644 index a86bfd20e2f..00000000000 --- a/mysql-test/suite/galera/r/galera_as_slave_replication_bundle.result +++ /dev/null @@ -1,15 +0,0 @@ -START SLAVE USER='root'; -Warnings: -Note 1759 Sending passwords in plain text without SSL/TLS is extremely insecure. -CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; -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); -SELECT COUNT(*) = 4 FROM t1; -COUNT(*) = 4 -1 -DROP TABLE t1; -STOP SLAVE; -RESET SLAVE ALL; diff --git a/mysql-test/suite/galera/r/galera_v1_row_events.result b/mysql-test/suite/galera/r/galera_v1_row_events.result deleted file mode 100644 index 80fe2fb6d8d..00000000000 --- a/mysql-test/suite/galera/r/galera_v1_row_events.result +++ /dev/null @@ -1,15 +0,0 @@ -connection node_2; -connection node_1; -CREATE TABLE t1 (f1 INT PRIMARY KEY) ENGINE=InnoDB; -INSERT INTO t1 VALUES (1); -connection node_2; -SELECT COUNT(*) = 1 FROM t1; -COUNT(*) = 1 -1 -connection node_1; -UPDATE t1 SET f1 = 2 WHERE f1 = 1; -connection node_2; -SELECT COUNT(*) = 1 FROM t1 WHERE f1 = 2; -COUNT(*) = 1 -1 -DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/galera_as_slave_gtid.cnf b/mysql-test/suite/galera/t/galera_as_slave_gtid.cnf deleted file mode 100644 index 01d2eb12630..00000000000 --- a/mysql-test/suite/galera/t/galera_as_slave_gtid.cnf +++ /dev/null @@ -1,6 +0,0 @@ -!include ../galera_2nodes_as_slave.cnf - -[mysqld] -log-bin=mysqld-bin -log-slave-updates -binlog-format=ROW diff --git a/mysql-test/suite/galera/t/galera_as_slave_gtid_myisam.cnf b/mysql-test/suite/galera/t/galera_as_slave_gtid_myisam.cnf deleted file mode 100644 index 01d2eb12630..00000000000 --- a/mysql-test/suite/galera/t/galera_as_slave_gtid_myisam.cnf +++ /dev/null @@ -1,6 +0,0 @@ -!include ../galera_2nodes_as_slave.cnf - -[mysqld] -log-bin=mysqld-bin -log-slave-updates -binlog-format=ROW diff --git a/mysql-test/suite/galera/t/galera_as_slave_replication_bundle.cnf b/mysql-test/suite/galera/t/galera_as_slave_replication_bundle.cnf deleted file mode 100644 index d092d88bfaf..00000000000 --- a/mysql-test/suite/galera/t/galera_as_slave_replication_bundle.cnf +++ /dev/null @@ -1,4 +0,0 @@ -!include ../galera_2nodes_as_slave.cnf - -[mysqld] -wsrep-mysql-replication-bundle=2 diff --git a/mysql-test/suite/galera/t/galera_as_slave_replication_bundle.test b/mysql-test/suite/galera/t/galera_as_slave_replication_bundle.test deleted file mode 100644 index fa5f3f9c7c6..00000000000 --- a/mysql-test/suite/galera/t/galera_as_slave_replication_bundle.test +++ /dev/null @@ -1,49 +0,0 @@ -# -# Test the wsrep_replication_bundle variable. We expect that multiple async replication events -# will be grouped together and thus a smaller number of wsrep_last_committed transactions will -# be reported. -# - ---source include/have_innodb.inc ---source include/galera_cluster.inc - -# As node #3 is not a Galera node, and galera_cluster.inc does not open connetion to it -# we open the node_3 connection here ---connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 - ---connection node_2 ---disable_query_log ---eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_USER='root', MASTER_PORT=$NODE_MYPORT_3; ---enable_query_log -START SLAVE; - ---connection node_3 -CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; -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); - ---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(*) = 4 FROM t1; ---source include/wait_condition.inc - -# With wsrep_mysql_replication_bundle = 2, the last insert is not delivered -# because there are not enough events remaining to complete an entire bundle -SELECT COUNT(*) = 4 FROM t1; - -# Bundle is now complete, the last INSERT and the DROP are delivered ---connection node_3 -DROP TABLE t1; - ---connection node_2 ---sleep 1 ---let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; ---source include/wait_condition.inc - -STOP SLAVE; -RESET SLAVE ALL; diff --git a/mysql-test/suite/galera/t/galera_flush_local.cnf b/mysql-test/suite/galera/t/galera_flush_local.cnf deleted file mode 100644 index c92cb58f484..00000000000 --- a/mysql-test/suite/galera/t/galera_flush_local.cnf +++ /dev/null @@ -1,12 +0,0 @@ -!include ../galera_2nodes.cnf - -[mysqld.1] -query_cache_type=1 -query_cache_size=1000000 -wsrep_replicate_myisam=ON - -[mysqld.2] -query_cache_type=1 -query_cache_size=1000000 -wsrep_replicate_myisam=ON - diff --git a/mysql-test/suite/galera_sr/t/galera_sr_v1_row_events.test b/mysql-test/suite/galera_sr/t/galera_sr_v1_row_events.test deleted file mode 100644 index d3d4d2d0c14..00000000000 --- a/mysql-test/suite/galera_sr/t/galera_sr_v1_row_events.test +++ /dev/null @@ -1,27 +0,0 @@ -# -# Test that Galera SR continues to run even with --log-bin-use-v1-row-events=1 -# - ---source include/galera_cluster.inc ---source include/have_innodb.inc - -CREATE TABLE t1 (f1 INT PRIMARY KEY) ENGINE=InnoDB; - -SET AUTOCOMMIT=OFF; -START TRANSACTION; -INSERT INTO t1 VALUES (1); - ---connection node_2 -SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; -SELECT COUNT(*) = 1 FROM t1; - ---connection node_1 -COMMIT; - -SET AUTOCOMMIT=ON; -UPDATE t1 SET f1 = 2 WHERE f1 = 1; - ---connection node_2 -SELECT COUNT(*) = 1 FROM t1 WHERE f1 = 2; - -DROP TABLE t1; From 5a42a114fdc9cacb6e64b5c61097e7759036b11c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Mon, 17 Feb 2020 13:56:41 +0200 Subject: [PATCH 23/66] Add missing files. --- mysql-test/suite/galera/t/galera_as_slave_gtid.cnf | 6 ++++++ mysql-test/suite/galera/t/galera_as_slave_gtid_myisam.cnf | 6 ++++++ 2 files changed, 12 insertions(+) create mode 100644 mysql-test/suite/galera/t/galera_as_slave_gtid.cnf create mode 100644 mysql-test/suite/galera/t/galera_as_slave_gtid_myisam.cnf diff --git a/mysql-test/suite/galera/t/galera_as_slave_gtid.cnf b/mysql-test/suite/galera/t/galera_as_slave_gtid.cnf new file mode 100644 index 00000000000..01d2eb12630 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_as_slave_gtid.cnf @@ -0,0 +1,6 @@ +!include ../galera_2nodes_as_slave.cnf + +[mysqld] +log-bin=mysqld-bin +log-slave-updates +binlog-format=ROW diff --git a/mysql-test/suite/galera/t/galera_as_slave_gtid_myisam.cnf b/mysql-test/suite/galera/t/galera_as_slave_gtid_myisam.cnf new file mode 100644 index 00000000000..01d2eb12630 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_as_slave_gtid_myisam.cnf @@ -0,0 +1,6 @@ +!include ../galera_2nodes_as_slave.cnf + +[mysqld] +log-bin=mysqld-bin +log-slave-updates +binlog-format=ROW From 959fc0c0ccaac0c0946a9c07bceb9b82116c8b47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Mon, 17 Feb 2020 14:01:16 +0200 Subject: [PATCH 24/66] MDEV-21591 : galera.galera_rsu_add_pk MTR failed: Result content mismatch Add missing wait condition before we check the end database state. --- .../suite/galera/r/galera_rsu_add_pk.result | 24 +++++++++---------- .../suite/galera/t/galera_rsu_add_pk.test | 14 +++++++---- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/mysql-test/suite/galera/r/galera_rsu_add_pk.result b/mysql-test/suite/galera/r/galera_rsu_add_pk.result index 4c79da154e2..2df08c3e4ff 100644 --- a/mysql-test/suite/galera/r/galera_rsu_add_pk.result +++ b/mysql-test/suite/galera/r/galera_rsu_add_pk.result @@ -9,19 +9,19 @@ SET SESSION wsrep_OSU_method = "RSU"; ALTER TABLE t1 ADD PRIMARY KEY (f1); SET SESSION wsrep_OSU_method = "TOI"; INSERT INTO t1 (f1) SELECT 200000 + (10000 * a1.f1) + (1000 * a2.f1) + (100 * a3.f1) + (10 * a4.f1) + a5.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5; -SELECT COUNT(*) = 300000 FROM t1; -COUNT(*) = 300000 -1 -SELECT MAX(f1) = 299999 FROM t1; -MAX(f1) = 299999 -1 +SELECT COUNT(*) AS EXPECT_300000 FROM t1; +EXPECT_300000 +300000 +SELECT MAX(f1) AS EXPECT_299999 FROM t1; +EXPECT_299999 +299999 connection node_1; -SELECT COUNT(*) = 300000 FROM t1; -COUNT(*) = 300000 -1 -SELECT MAX(f1) = 299999 FROM t1; -MAX(f1) = 299999 -1 +SELECT COUNT(*) AS EXPECT_300000 FROM t1; +EXPECT_300000 +300000 +SELECT MAX(f1) AS EXPECT_299999 FROM t1; +EXPECT_299999 +299999 SET SESSION wsrep_OSU_method = "RSU"; ALTER TABLE t1 ADD PRIMARY KEY (f1); SET SESSION wsrep_OSU_method = "TOI"; diff --git a/mysql-test/suite/galera/t/galera_rsu_add_pk.test b/mysql-test/suite/galera/t/galera_rsu_add_pk.test index 7db990d7be1..094048f6caa 100644 --- a/mysql-test/suite/galera/t/galera_rsu_add_pk.test +++ b/mysql-test/suite/galera/t/galera_rsu_add_pk.test @@ -26,14 +26,20 @@ SET SESSION wsrep_OSU_method = "TOI"; # Insert values after the ALTER INSERT INTO t1 (f1) SELECT 200000 + (10000 * a1.f1) + (1000 * a2.f1) + (100 * a3.f1) + (10 * a4.f1) + a5.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5; +--let $wait_condition = SELECT COUNT(*) = 300000 FROM t1; +--source include/wait_condition.inc -SELECT COUNT(*) = 300000 FROM t1; -SELECT MAX(f1) = 299999 FROM t1; +SELECT COUNT(*) AS EXPECT_300000 FROM t1; +SELECT MAX(f1) AS EXPECT_299999 FROM t1; --connection node_1 --reap -SELECT COUNT(*) = 300000 FROM t1; -SELECT MAX(f1) = 299999 FROM t1; + +--let $wait_condition = SELECT COUNT(*) = 300000 FROM t1; +--source include/wait_condition.inc + +SELECT COUNT(*) AS EXPECT_300000 FROM t1; +SELECT MAX(f1) AS EXPECT_299999 FROM t1; SET SESSION wsrep_OSU_method = "RSU"; ALTER TABLE t1 ADD PRIMARY KEY (f1); From 7ccc1710a0dc4dd397905f9488e3c55d91d5ac7b Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Mon, 14 Oct 2019 16:20:16 +0300 Subject: [PATCH 25/66] cleanup: key parts comparison Engine specific code moved to engine. --- sql/handler.cc | 14 +++ sql/handler.h | 14 +++ sql/sql_table.cc | 120 ++++++++++++-------------- storage/innobase/handler/ha_innodb.cc | 32 +++++++ storage/innobase/handler/ha_innodb.h | 5 ++ 5 files changed, 121 insertions(+), 64 deletions(-) diff --git a/sql/handler.cc b/sql/handler.cc index aa3815b2de3..77b7f490590 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -6953,6 +6953,20 @@ void handler::set_lock_type(enum thr_lock_type lock) table->reginfo.lock_type= lock; } +Compare_keys handler::compare_key_parts(const Field &old_field, + const Column_definition &new_field, + const KEY_PART_INFO &old_part, + const KEY_PART_INFO &new_part) const +{ + if (!old_field.is_equal(new_field)) + return Compare_keys::NotEqual; + + if (old_part.length != new_part.length) + return Compare_keys::NotEqual; + + return Compare_keys::Equal; +} + #ifdef WITH_WSREP /** @details diff --git a/sql/handler.h b/sql/handler.h index 6d675683ada..421941c0b35 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -2936,6 +2936,13 @@ public: virtual ~Handler_share() {} }; +enum class Compare_keys : uint32_t +{ + Equal, + EqualButKeyPartLength, + EqualButComment, + NotEqual +}; /** The handler class is the interface for dynamically loadable @@ -4877,6 +4884,13 @@ public: return false; } + /* Used for ALTER TABLE. + Some engines can handle some differences in indexes by themself. */ + virtual Compare_keys compare_key_parts(const Field &old_field, + const Column_definition &new_field, + const KEY_PART_INFO &old_part, + const KEY_PART_INFO &new_part) const; + protected: Handler_share *get_ha_share_ptr(); void set_ha_share_ptr(Handler_share *arg_ha_share); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 851a63bf05a..619c3fe2654 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -6579,38 +6579,68 @@ static int compare_uint(const uint *s, const uint *t) return (*s < *t) ? -1 : ((*s > *t) ? 1 : 0); } -enum class Compare_keys : uint32_t -{ - Equal, - EqualButKeyPartLength, - EqualButComment, - NotEqual -}; +static Compare_keys merge(Compare_keys current, Compare_keys add) { + if (current == Compare_keys::Equal) + return add; + + if (add == Compare_keys::Equal) + return current; + + if (current == add) + return current; + + if (current == Compare_keys::EqualButComment) { + return Compare_keys::NotEqual; + } + + if (current == Compare_keys::EqualButKeyPartLength) { + if (add == Compare_keys::EqualButComment) + return Compare_keys::NotEqual; + DBUG_ASSERT(add == Compare_keys::NotEqual); + return Compare_keys::NotEqual; + } + + DBUG_ASSERT(current == Compare_keys::NotEqual); + return current; +} Compare_keys compare_keys_but_name(const KEY *table_key, const KEY *new_key, Alter_info *alter_info, const TABLE *table, const KEY *const new_pk, const KEY *const old_pk) { - Compare_keys result= Compare_keys::Equal; + if (table_key->algorithm != new_key->algorithm) + return Compare_keys::NotEqual; - if ((table_key->algorithm != new_key->algorithm) || - ((table_key->flags & HA_KEYFLAG_MASK) != - (new_key->flags & HA_KEYFLAG_MASK)) || - (table_key->user_defined_key_parts != new_key->user_defined_key_parts)) + if ((table_key->flags & HA_KEYFLAG_MASK) != + (new_key->flags & HA_KEYFLAG_MASK)) + return Compare_keys::NotEqual; + + if (table_key->user_defined_key_parts != new_key->user_defined_key_parts) return Compare_keys::NotEqual; if (table_key->block_size != new_key->block_size) return Compare_keys::NotEqual; + /* + Rebuild the index if following condition get satisfied: + + (i) Old table doesn't have primary key, new table has it and vice-versa + (ii) Primary key changed to another existing index + */ + if ((new_key == new_pk) != (table_key == old_pk)) + return Compare_keys::NotEqual; + if (engine_options_differ(table_key->option_struct, new_key->option_struct, table->file->ht->index_options)) return Compare_keys::NotEqual; - const KEY_PART_INFO *end= - table_key->key_part + table_key->user_defined_key_parts; - for (const KEY_PART_INFO *key_part= table_key->key_part, - *new_part= new_key->key_part; + Compare_keys result= Compare_keys::Equal; + + for (const KEY_PART_INFO * + key_part= table_key->key_part, + *new_part= new_key->key_part, + *end= table_key->key_part + table_key->user_defined_key_parts; key_part < end; key_part++, new_part++) { /* @@ -6618,61 +6648,23 @@ Compare_keys compare_keys_but_name(const KEY *table_key, const KEY *new_key, object with adjusted length. So below we have to check field indexes instead of simply comparing pointers to Field objects. */ - Create_field *new_field= alter_info->create_list.elem(new_part->fieldnr); - if (!new_field->field || - new_field->field->field_index != key_part->fieldnr - 1) + const Create_field &new_field= + *alter_info->create_list.elem(new_part->fieldnr); + + if (!new_field.field || + new_field.field->field_index != key_part->fieldnr - 1) + { return Compare_keys::NotEqual; - - /* - If there is a change in index length due to column expansion - like varchar(X) changed to varchar(X + N) and has a compatible - packed data representation, we mark it for fast/INPLACE change - in index definition. InnoDB supports INPLACE for this cases - - Key definition has changed if we are using a different field or - if the user key part length is different. - */ - const Field *old_field= table->field[key_part->fieldnr - 1]; - - bool is_equal= old_field->is_equal(*new_field); - /* TODO: below is an InnoDB specific code which should be moved to InnoDB */ - if (!is_equal) - { - if (!key_part->field->can_be_converted_by_engine(*new_field)) - return Compare_keys::NotEqual; - - if (!Charset(old_field->charset()) - .eq_collation_specific_names(new_field->charset)) - return Compare_keys::NotEqual; } - if (key_part->length != new_part->length) - { - if (key_part->length != old_field->field_length || - key_part->length >= new_part->length || is_equal) - { - return Compare_keys::NotEqual; - } - result= Compare_keys::EqualButKeyPartLength; - } + auto compare= table->file->compare_key_parts( + *table->field[key_part->fieldnr - 1], new_field, *key_part, *new_part); + result= merge(result, compare); } - /* - Rebuild the index if following condition get satisfied: - - (i) Old table doesn't have primary key, new table has it and vice-versa - (ii) Primary key changed to another existing index -*/ - if ((new_key == new_pk) != (table_key == old_pk)) - return Compare_keys::NotEqual; - /* Check that key comment is not changed. */ if (cmp(table_key->comment, new_key->comment) != 0) - { - if (result != Compare_keys::Equal) - return Compare_keys::NotEqual; - result= Compare_keys::EqualButComment; - } + result= merge(result, Compare_keys::EqualButComment); return result; } diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 0c60348a9ed..7fe707ac1e2 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -21138,6 +21138,38 @@ ha_innobase::can_convert_blob(const Field_blob* field, return true; } +Compare_keys ha_innobase::compare_key_parts( + const Field &old_field, const Column_definition &new_field, + const KEY_PART_INFO &old_part, const KEY_PART_INFO &new_part) const +{ + const bool is_equal= old_field.is_equal(new_field); + + if (!is_equal) + { + if (!old_field.can_be_converted_by_engine(new_field)) + return Compare_keys::NotEqual; + + if (!Charset(old_field.charset()) + .eq_collation_specific_names(new_field.charset)) + { + return Compare_keys::NotEqual; + } + } + + if (old_part.length != new_part.length) + { + if (old_part.length != old_field.field_length || + old_part.length >= new_part.length || is_equal) + { + return Compare_keys::NotEqual; + } + + return Compare_keys::EqualButKeyPartLength; + } + + return Compare_keys::Equal; +} + /******************************************************************//** Use this when the args are passed to the format string from errmsg-utf8.txt directly as is. diff --git a/storage/innobase/handler/ha_innodb.h b/storage/innobase/handler/ha_innodb.h index 79e3bdb3d13..3e3dffbc7a9 100644 --- a/storage/innobase/handler/ha_innodb.h +++ b/storage/innobase/handler/ha_innodb.h @@ -445,6 +445,11 @@ public: /** @return whether innodb_strict_mode is active */ bool is_innodb_strict_mode() { return is_innodb_strict_mode(m_user_thd); } + Compare_keys + compare_key_parts(const Field& old_field, + const Column_definition& new_field, + const KEY_PART_INFO& old_part, + const KEY_PART_INFO& new_part) const override; protected: dberr_t innobase_get_autoinc(ulonglong* value); From df07e00a810890f6f6eb1334c76ee22133750777 Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Mon, 14 Oct 2019 18:13:02 +0300 Subject: [PATCH 26/66] MDEV-20726 InnoDB: Assertion failure in file data0type.cc line 67 Do not rebuild index when it's key part converted from utf8mb3 to utf8mb4 but key part stays the same. dict_index_add_to_cache(): assert that prefix_len is divided by mbmaxlen ha_innobase::compare_key_parts(): compare key part lenght in symbols instead of bytes. --- .../suite/innodb/r/instant_alter_charset.result | 11 +++++++++++ .../suite/innodb/t/instant_alter_charset.test | 15 +++++++++++++++ storage/innobase/dict/dict0dict.cc | 1 + storage/innobase/handler/ha_innodb.cc | 17 ++++++++--------- 4 files changed, 35 insertions(+), 9 deletions(-) diff --git a/mysql-test/suite/innodb/r/instant_alter_charset.result b/mysql-test/suite/innodb/r/instant_alter_charset.result index f8c21978327..cbb49819bfe 100644 --- a/mysql-test/suite/innodb/r/instant_alter_charset.result +++ b/mysql-test/suite/innodb/r/instant_alter_charset.result @@ -1918,3 +1918,14 @@ check table t; Table Op Msg_type Msg_text test.t check status OK drop table t; +# +# MDEV-20726: InnoDB: Assertion failure in file data0type.cc line 67 +# +CREATE TABLE t ( +id int(10) unsigned NOT NULL PRIMARY KEY, +a text CHARSET utf8mb3, +KEY a_idx(a(1)) +) ENGINE=InnoDB; +INSERT INTO t VALUES (1, 'something in the air'); +ALTER TABLE t MODIFY a text CHARSET utf8mb4; +DROP TABLE t; diff --git a/mysql-test/suite/innodb/t/instant_alter_charset.test b/mysql-test/suite/innodb/t/instant_alter_charset.test index 82ae1040f57..270db2d6462 100644 --- a/mysql-test/suite/innodb/t/instant_alter_charset.test +++ b/mysql-test/suite/innodb/t/instant_alter_charset.test @@ -715,3 +715,18 @@ alter table t modify c varchar(10) collate latin1_general_cs, algorithm=instant; check table t; drop table t; + +--echo # +--echo # MDEV-20726: InnoDB: Assertion failure in file data0type.cc line 67 +--echo # + +CREATE TABLE t ( + id int(10) unsigned NOT NULL PRIMARY KEY, + a text CHARSET utf8mb3, + KEY a_idx(a(1)) +) ENGINE=InnoDB; + +INSERT INTO t VALUES (1, 'something in the air'); +ALTER TABLE t MODIFY a text CHARSET utf8mb4; + +DROP TABLE t; diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index af6e45e3ad3..b1ea5788222 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -1839,6 +1839,7 @@ dict_index_add_to_cache( > field->col->max_prefix) { /* Set the max_prefix value based on the prefix_len. */ + ut_ad(field->prefix_len % field->col->mbmaxlen == 0); field->col->max_prefix = field->prefix_len; } ut_ad(field->col->ord_part == 1); diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 7fe707ac1e2..ba02f71058e 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -21143,26 +21143,25 @@ Compare_keys ha_innobase::compare_key_parts( const KEY_PART_INFO &old_part, const KEY_PART_INFO &new_part) const { const bool is_equal= old_field.is_equal(new_field); + const CHARSET_INFO *old_cs= old_field.charset(); + const CHARSET_INFO *new_cs= new_field.charset; if (!is_equal) { if (!old_field.can_be_converted_by_engine(new_field)) return Compare_keys::NotEqual; - if (!Charset(old_field.charset()) - .eq_collation_specific_names(new_field.charset)) - { + if (!Charset(old_cs).eq_collation_specific_names(new_cs)) return Compare_keys::NotEqual; - } } - if (old_part.length != new_part.length) + if (old_part.length / old_cs->mbmaxlen != new_part.length / new_cs->mbmaxlen) { - if (old_part.length != old_field.field_length || - old_part.length >= new_part.length || is_equal) - { + if (old_part.length != old_field.field_length) + return Compare_keys::NotEqual; + + if (old_part.length >= new_part.length) return Compare_keys::NotEqual; - } return Compare_keys::EqualButKeyPartLength; } From 2fb881df1d89b27521ac50a6f6f5c1426536e70b Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Tue, 18 Feb 2020 22:49:42 -0800 Subject: [PATCH 27/66] MDEV-21610 Different query results from 10.4.11 to 10.4.12 This patch fixes the following defects/bugs. 1. If BKA[H] algorithm was used to join a table for which the optimizer had decided to employ a rowid filter the filter actually was not built. 2. The patch for the bug MDEV-21356 that added the code canceling pushing rowid filter into an engine for the table joined with employment of BKA[H] and MRR was not quite correct for Innodb engine because this cancellation was done after InnoDB code had already bound the the pushed filter to internal InnoDB structures. --- mysql-test/main/rowid_filter_innodb.result | 333 +++++++++++++++++++++ mysql-test/main/rowid_filter_innodb.test | 153 ++++++++++ sql/multi_range_read.cc | 41 +-- sql/multi_range_read.h | 5 +- sql/opt_range.cc | 3 +- sql/sql_join_cache.cc | 2 + 6 files changed, 516 insertions(+), 21 deletions(-) diff --git a/mysql-test/main/rowid_filter_innodb.result b/mysql-test/main/rowid_filter_innodb.result index c59b95bf877..9423fb18fd9 100644 --- a/mysql-test/main/rowid_filter_innodb.result +++ b/mysql-test/main/rowid_filter_innodb.result @@ -2522,3 +2522,336 @@ id select_type table type possible_keys key key_len ref rows r_rows filtered r_f 1 SIMPLE t1 index a,b PRIMARY 4 NULL 3008 3008.00 1.36 0.00 Using where DROP TABLE t1; SET global innodb_stats_persistent= @stats.save; +# +# MDEV-21610: Using rowid filter with BKA+MRR +# +set @stats.save= @@innodb_stats_persistent; +set global innodb_stats_persistent=on; +CREATE TABLE acli ( +id bigint(20) NOT NULL, +rid varchar(255) NOT NULL, +tp smallint(6) NOT NULL DEFAULT 0, +PRIMARY KEY (id), +KEY acli_rid (rid), +KEY acli_tp (tp) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +insert into acli(id,rid,tp) values +(184929059698905997,'ABABABABABABABABAB',103), +(184929059698905998,'ABABABABABABABABAB',121), +(283586039035985921,'00000000000000000000000000000000',103), +(2216474704108064678,'020BED6D07B741CE9B10AB2200FEF1DF',103), +(2216474704108064679,'020BED6D07B741CE9B10AB2200FEF1DF',121), +(3080602882609775593,'B5FCC8C7111E4E3CBC21AAF5012F59C2',103), +(3080602882609775594,'B5FCC8C7111E4E3CBC21AAF5012F59C2',121), +(3080602882609776594,'B5FCC8C7111E4E3CBC21AAF5012F59C2',121), +(3080602882609777595,'B5FCC8C7111E4E3CBC21AAF5012F59C2',121), +(4269412446747236214,'SCSCSCSCSCSCSCSC',103), +(4269412446747236215,'SCSCSCSCSCSCSCSC',121), +(6341490487802728356,'6072D47E513F4A4794BBAB2200FDB67D',103), +(6341490487802728357,'6072D47E513F4A4794BBAB2200FDB67D',121); +CREATE TABLE acei ( +id bigint(20) NOT NULL, +aclid bigint(20) NOT NULL DEFAULT 0, +atp smallint(6) NOT NULL DEFAULT 0, +clus smallint(6) NOT NULL DEFAULT 0, +PRIMARY KEY (id), +KEY acei_aclid (aclid), +KEY acei_clus (clus) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +insert into acei(id,aclid,atp,clus) values +(184929059698905999,184929059698905997,0,1), +(184929059698906000,184929059698905997,0,1), +(184929059698906001,184929059698905997,1,1), +(184929059698906002,184929059698905998,1,1), +(283586039035985922,283586039035985921,1,1), +(2216474704108064684,2216474704108064678,0,1), +(2216474704108064685,2216474704108064678,0,1), +(2216474704108064686,2216474704108064678,1,1), +(2216474704108064687,2216474704108064679,1,1), +(3080602882609775595,3080602882609775593,0,1), +(3080602882609775596,3080602882609775593,0,1), +(3080602882609775597,3080602882609775593,1,1), +(3080602882609775598,3080602882609775594,1,1), +(3080602882609776595,3080602882609776594,1,1), +(3080602882609777596,3080602882609777595,1,1), +(4269412446747236216,4269412446747236214,0,1), +(4269412446747236217,4269412446747236214,0,1), +(4269412446747236218,4269412446747236214,1,1), +(4269412446747236219,4269412446747236215,1,1), +(6341490487802728358,6341490487802728356,0,1), +(6341490487802728359,6341490487802728356,0,1), +(6341490487802728360,6341490487802728356,1,1), +(6341490487802728361,6341490487802728357,1,1); +CREATE TABLE filt ( +id bigint(20) NOT NULL, +aceid bigint(20) NOT NULL DEFAULT 0, +clid smallint(6) NOT NULL DEFAULT 0, +fh bigint(20) NOT NULL DEFAULT 0, +PRIMARY KEY (id), +KEY filt_aceid (aceid), +KEY filt_clid (clid), +KEY filt_fh (fh) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +insert into filt(id,aceid,clid,fh) values +(184929059698905999,184929059698905999,1,8948400944397203540), +(184929059698906000,184929059698906000,1,-3516039679025944536), +(184929059698906001,184929059698906001,1,-3516039679025944536), +(184929059698906002,184929059698906001,1,2965370193075218252), +(184929059698906003,184929059698906001,1,8948400944397203540), +(184929059698906004,184929059698906002,1,2478709353550777738), +(283586039035985922,283586039035985922,1,5902600816362013271), +(2216474704108064686,2216474704108064684,1,8948400944397203540), +(2216474704108064687,2216474704108064685,1,-7244708939311117030), +(2216474704108064688,2216474704108064686,1,-7244708939311117030), +(2216474704108064689,2216474704108064686,1,7489060986210282479), +(2216474704108064690,2216474704108064686,1,8948400944397203540), +(2216474704108064691,2216474704108064687,1,-3575268945274980038), +(3080602882609775595,3080602882609775595,1,8948400944397203540), +(3080602882609775596,3080602882609775596,1,-5420422472375069774), +(3080602882609775597,3080602882609775597,1,-5420422472375069774), +(3080602882609775598,3080602882609775597,1,8518228073041491534), +(3080602882609775599,3080602882609775597,1,8948400944397203540), +(3080602882609775600,3080602882609775598,1,6311439873746261694), +(3080602882609775601,3080602882609775598,1,6311439873746261694), +(3080602882609776595,3080602882609776595,1,-661101805245999843), +(3080602882609777596,3080602882609777596,1,-661101805245999843), +(3080602882609777597,3080602882609777596,1,2216865386202464067), +(4269412446747236216,4269412446747236216,1,8948400944397203540), +(4269412446747236217,4269412446747236217,1,-1143096194892676000), +(4269412446747236218,4269412446747236218,1,-1143096194892676000), +(4269412446747236219,4269412446747236218,1,5313391811364818290), +(4269412446747236220,4269412446747236218,1,8948400944397203540), +(4269412446747236221,4269412446747236219,1,7624499822621753835), +(6341490487802728358,6341490487802728358,1,8948400944397203540), +(6341490487802728359,6341490487802728359,1,8141092449587136068), +(6341490487802728360,6341490487802728360,1,8141092449587136068), +(6341490487802728361,6341490487802728360,1,1291319099896431785), +(6341490487802728362,6341490487802728360,1,8948400944397203540), +(6341490487802728363,6341490487802728361,1,6701841652906431497); +analyze table filt, acei, acli; +Table Op Msg_type Msg_text +test.filt analyze status Engine-independent statistics collected +test.filt analyze status OK +test.acei analyze status Engine-independent statistics collected +test.acei analyze status OK +test.acli analyze status Engine-independent statistics collected +test.acli analyze status OK +set @save_optimizer_switch=@@optimizer_switch; +set @save_join_cache_level=@@join_cache_level; +set optimizer_switch='mrr=off'; +set join_cache_level=2; +set statement optimizer_switch='rowid_filter=off' for explain extended select t.id, fi.* +from (acli t inner join acei a on a.aclid = t.id) +inner join filt fi on a.id = fi.aceid +where +t.rid = 'B5FCC8C7111E4E3CBC21AAF5012F59C2' and +t.tp = 121 and +a.atp = 1 and +fi.fh in (6311439873746261694,-397087483897438286, +8518228073041491534,-5420422472375069774); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t index_merge PRIMARY,acli_rid,acli_tp acli_tp,acli_rid 2,767 NULL 2 100.00 Using intersect(acli_tp,acli_rid); Using where; Using index +1 SIMPLE a ref PRIMARY,acei_aclid acei_aclid 8 test.t.id 1 100.00 Using where +1 SIMPLE fi ref filt_aceid,filt_fh filt_aceid 8 test.a.id 1 17.14 Using where +Warnings: +Note 1003 select `test`.`t`.`id` AS `id`,`test`.`fi`.`id` AS `id`,`test`.`fi`.`aceid` AS `aceid`,`test`.`fi`.`clid` AS `clid`,`test`.`fi`.`fh` AS `fh` from `test`.`acli` `t` join `test`.`acei` `a` join `test`.`filt` `fi` where `test`.`t`.`tp` = 121 and `test`.`a`.`atp` = 1 and `test`.`fi`.`aceid` = `test`.`a`.`id` and `test`.`a`.`aclid` = `test`.`t`.`id` and `test`.`t`.`rid` = 'B5FCC8C7111E4E3CBC21AAF5012F59C2' and `test`.`fi`.`fh` in (6311439873746261694,-397087483897438286,8518228073041491534,-5420422472375069774) +set statement optimizer_switch='rowid_filter=off' for select t.id, fi.* +from (acli t inner join acei a on a.aclid = t.id) +inner join filt fi on a.id = fi.aceid +where +t.rid = 'B5FCC8C7111E4E3CBC21AAF5012F59C2' and +t.tp = 121 and +a.atp = 1 and +fi.fh in (6311439873746261694,-397087483897438286, +8518228073041491534,-5420422472375069774); +id id aceid clid fh +3080602882609775594 3080602882609775600 3080602882609775598 1 6311439873746261694 +3080602882609775594 3080602882609775601 3080602882609775598 1 6311439873746261694 +set statement optimizer_switch='rowid_filter=on' for explain extended select t.id, fi.* +from (acli t inner join acei a on a.aclid = t.id) +inner join filt fi on a.id = fi.aceid +where +t.rid = 'B5FCC8C7111E4E3CBC21AAF5012F59C2' and +t.tp = 121 and +a.atp = 1 and +fi.fh in (6311439873746261694,-397087483897438286, +8518228073041491534,-5420422472375069774); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t index_merge PRIMARY,acli_rid,acli_tp acli_tp,acli_rid 2,767 NULL 2 100.00 Using intersect(acli_tp,acli_rid); Using where; Using index +1 SIMPLE a ref PRIMARY,acei_aclid acei_aclid 8 test.t.id 1 100.00 Using where +1 SIMPLE fi ref|filter filt_aceid,filt_fh filt_aceid|filt_fh 8|8 test.a.id 1 (17%) 17.14 Using where; Using rowid filter +Warnings: +Note 1003 select `test`.`t`.`id` AS `id`,`test`.`fi`.`id` AS `id`,`test`.`fi`.`aceid` AS `aceid`,`test`.`fi`.`clid` AS `clid`,`test`.`fi`.`fh` AS `fh` from `test`.`acli` `t` join `test`.`acei` `a` join `test`.`filt` `fi` where `test`.`t`.`tp` = 121 and `test`.`a`.`atp` = 1 and `test`.`fi`.`aceid` = `test`.`a`.`id` and `test`.`a`.`aclid` = `test`.`t`.`id` and `test`.`t`.`rid` = 'B5FCC8C7111E4E3CBC21AAF5012F59C2' and `test`.`fi`.`fh` in (6311439873746261694,-397087483897438286,8518228073041491534,-5420422472375069774) +set statement optimizer_switch='rowid_filter=on' for select t.id, fi.* +from (acli t inner join acei a on a.aclid = t.id) +inner join filt fi on a.id = fi.aceid +where +t.rid = 'B5FCC8C7111E4E3CBC21AAF5012F59C2' and +t.tp = 121 and +a.atp = 1 and +fi.fh in (6311439873746261694,-397087483897438286, +8518228073041491534,-5420422472375069774); +id id aceid clid fh +3080602882609775594 3080602882609775600 3080602882609775598 1 6311439873746261694 +3080602882609775594 3080602882609775601 3080602882609775598 1 6311439873746261694 +set optimizer_switch='mrr=on'; +set join_cache_level=6; +set statement optimizer_switch='rowid_filter=off' for explain extended select t.id, fi.* +from (acli t inner join acei a on a.aclid = t.id) +inner join filt fi on a.id = fi.aceid +where +t.rid = 'B5FCC8C7111E4E3CBC21AAF5012F59C2' and +t.tp = 121 and +a.atp = 1 and +fi.fh in (6311439873746261694,-397087483897438286, +8518228073041491534,-5420422472375069774); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t index_merge PRIMARY,acli_rid,acli_tp acli_tp,acli_rid 2,767 NULL 2 100.00 Using intersect(acli_tp,acli_rid); Using where; Using index +1 SIMPLE a ref PRIMARY,acei_aclid acei_aclid 8 test.t.id 1 100.00 Using where; Using join buffer (flat, BKA join); Rowid-ordered scan +1 SIMPLE fi ref filt_aceid,filt_fh filt_aceid 8 test.a.id 1 17.14 Using where; Using join buffer (incremental, BKA join); Rowid-ordered scan +Warnings: +Note 1003 select `test`.`t`.`id` AS `id`,`test`.`fi`.`id` AS `id`,`test`.`fi`.`aceid` AS `aceid`,`test`.`fi`.`clid` AS `clid`,`test`.`fi`.`fh` AS `fh` from `test`.`acli` `t` join `test`.`acei` `a` join `test`.`filt` `fi` where `test`.`t`.`tp` = 121 and `test`.`a`.`atp` = 1 and `test`.`fi`.`aceid` = `test`.`a`.`id` and `test`.`a`.`aclid` = `test`.`t`.`id` and `test`.`t`.`rid` = 'B5FCC8C7111E4E3CBC21AAF5012F59C2' and `test`.`fi`.`fh` in (6311439873746261694,-397087483897438286,8518228073041491534,-5420422472375069774) +set statement optimizer_switch='rowid_filter=off' for select t.id, fi.* +from (acli t inner join acei a on a.aclid = t.id) +inner join filt fi on a.id = fi.aceid +where +t.rid = 'B5FCC8C7111E4E3CBC21AAF5012F59C2' and +t.tp = 121 and +a.atp = 1 and +fi.fh in (6311439873746261694,-397087483897438286, +8518228073041491534,-5420422472375069774); +id id aceid clid fh +3080602882609775594 3080602882609775600 3080602882609775598 1 6311439873746261694 +3080602882609775594 3080602882609775601 3080602882609775598 1 6311439873746261694 +set statement optimizer_switch='rowid_filter=on' for explain extended select t.id, fi.* +from (acli t inner join acei a on a.aclid = t.id) +inner join filt fi on a.id = fi.aceid +where +t.rid = 'B5FCC8C7111E4E3CBC21AAF5012F59C2' and +t.tp = 121 and +a.atp = 1 and +fi.fh in (6311439873746261694,-397087483897438286, +8518228073041491534,-5420422472375069774); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t index_merge PRIMARY,acli_rid,acli_tp acli_tp,acli_rid 2,767 NULL 2 100.00 Using intersect(acli_tp,acli_rid); Using where; Using index +1 SIMPLE a ref PRIMARY,acei_aclid acei_aclid 8 test.t.id 1 100.00 Using where; Using join buffer (flat, BKA join); Rowid-ordered scan +1 SIMPLE fi ref|filter filt_aceid,filt_fh filt_aceid|filt_fh 8|8 test.a.id 1 (17%) 17.14 Using where; Using join buffer (incremental, BKA join); Rowid-ordered scan; Using rowid filter +Warnings: +Note 1003 select `test`.`t`.`id` AS `id`,`test`.`fi`.`id` AS `id`,`test`.`fi`.`aceid` AS `aceid`,`test`.`fi`.`clid` AS `clid`,`test`.`fi`.`fh` AS `fh` from `test`.`acli` `t` join `test`.`acei` `a` join `test`.`filt` `fi` where `test`.`t`.`tp` = 121 and `test`.`a`.`atp` = 1 and `test`.`fi`.`aceid` = `test`.`a`.`id` and `test`.`a`.`aclid` = `test`.`t`.`id` and `test`.`t`.`rid` = 'B5FCC8C7111E4E3CBC21AAF5012F59C2' and `test`.`fi`.`fh` in (6311439873746261694,-397087483897438286,8518228073041491534,-5420422472375069774) +set statement optimizer_switch='rowid_filter=on' for select t.id, fi.* +from (acli t inner join acei a on a.aclid = t.id) +inner join filt fi on a.id = fi.aceid +where +t.rid = 'B5FCC8C7111E4E3CBC21AAF5012F59C2' and +t.tp = 121 and +a.atp = 1 and +fi.fh in (6311439873746261694,-397087483897438286, +8518228073041491534,-5420422472375069774); +id id aceid clid fh +3080602882609775594 3080602882609775600 3080602882609775598 1 6311439873746261694 +3080602882609775594 3080602882609775601 3080602882609775598 1 6311439873746261694 +set statement optimizer_switch='rowid_filter=on' for analyze format=json select t.id, fi.* +from (acli t inner join acei a on a.aclid = t.id) +inner join filt fi on a.id = fi.aceid +where +t.rid = 'B5FCC8C7111E4E3CBC21AAF5012F59C2' and +t.tp = 121 and +a.atp = 1 and +fi.fh in (6311439873746261694,-397087483897438286, +8518228073041491534,-5420422472375069774); +ANALYZE +{ + "query_block": { + "select_id": 1, + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "table": { + "table_name": "t", + "access_type": "index_merge", + "possible_keys": ["PRIMARY", "acli_rid", "acli_tp"], + "key_length": "2,767", + "index_merge": { + "intersect": { + "range": { + "key": "acli_tp", + "used_key_parts": ["tp"] + }, + "range": { + "key": "acli_rid", + "used_key_parts": ["rid"] + } + } + }, + "r_loops": 1, + "rows": 2, + "r_rows": 3, + "r_total_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "attached_condition": "t.tp = 121 and t.rid = 'B5FCC8C7111E4E3CBC21AAF5012F59C2'", + "using_index": true + }, + "block-nl-join": { + "table": { + "table_name": "a", + "access_type": "ref", + "possible_keys": ["PRIMARY", "acei_aclid"], + "key": "acei_aclid", + "key_length": "8", + "used_key_parts": ["aclid"], + "ref": ["test.t.id"], + "r_loops": 1, + "rows": 1, + "r_rows": 3, + "r_total_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "8Kb", + "join_type": "BKA", + "mrr_type": "Rowid-ordered scan", + "attached_condition": "a.atp = 1", + "r_filtered": 100 + }, + "block-nl-join": { + "table": { + "table_name": "fi", + "access_type": "ref", + "possible_keys": ["filt_aceid", "filt_fh"], + "key": "filt_aceid", + "key_length": "8", + "used_key_parts": ["aceid"], + "ref": ["test.a.id"], + "rowid_filter": { + "range": { + "key": "filt_fh", + "used_key_parts": ["fh"] + }, + "rows": 6, + "selectivity_pct": 17.143, + "r_rows": 5, + "r_selectivity_pct": 40, + "r_buffer_size": "REPLACED", + "r_filling_time_ms": "REPLACED" + }, + "r_loops": 1, + "rows": 1, + "r_rows": 2, + "r_total_time_ms": "REPLACED", + "filtered": 17.143, + "r_filtered": 100 + }, + "buffer_type": "incremental", + "buffer_size": "603", + "join_type": "BKA", + "mrr_type": "Rowid-ordered scan", + "attached_condition": "fi.fh in (6311439873746261694,-397087483897438286,8518228073041491534,-5420422472375069774)", + "r_filtered": 100 + } + } +} +set optimizer_switch=@save_optimizer_switch; +set join_cache_level=@save_join_cache_level; +drop table filt, acei, acli; +set global innodb_stats_persistent= @stats.save; diff --git a/mysql-test/main/rowid_filter_innodb.test b/mysql-test/main/rowid_filter_innodb.test index 30e0edeb75a..74349b8c6bb 100644 --- a/mysql-test/main/rowid_filter_innodb.test +++ b/mysql-test/main/rowid_filter_innodb.test @@ -381,3 +381,156 @@ ORDER BY pk LIMIT 1; DROP TABLE t1; SET global innodb_stats_persistent= @stats.save; + +--echo # +--echo # MDEV-21610: Using rowid filter with BKA+MRR +--echo # + +set @stats.save= @@innodb_stats_persistent; +set global innodb_stats_persistent=on; + +CREATE TABLE acli ( + id bigint(20) NOT NULL, + rid varchar(255) NOT NULL, + tp smallint(6) NOT NULL DEFAULT 0, + PRIMARY KEY (id), + KEY acli_rid (rid), + KEY acli_tp (tp) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +insert into acli(id,rid,tp) values +(184929059698905997,'ABABABABABABABABAB',103), +(184929059698905998,'ABABABABABABABABAB',121), +(283586039035985921,'00000000000000000000000000000000',103), +(2216474704108064678,'020BED6D07B741CE9B10AB2200FEF1DF',103), +(2216474704108064679,'020BED6D07B741CE9B10AB2200FEF1DF',121), +(3080602882609775593,'B5FCC8C7111E4E3CBC21AAF5012F59C2',103), +(3080602882609775594,'B5FCC8C7111E4E3CBC21AAF5012F59C2',121), +(3080602882609776594,'B5FCC8C7111E4E3CBC21AAF5012F59C2',121), +(3080602882609777595,'B5FCC8C7111E4E3CBC21AAF5012F59C2',121), +(4269412446747236214,'SCSCSCSCSCSCSCSC',103), +(4269412446747236215,'SCSCSCSCSCSCSCSC',121), +(6341490487802728356,'6072D47E513F4A4794BBAB2200FDB67D',103), +(6341490487802728357,'6072D47E513F4A4794BBAB2200FDB67D',121); + +CREATE TABLE acei ( + id bigint(20) NOT NULL, + aclid bigint(20) NOT NULL DEFAULT 0, + atp smallint(6) NOT NULL DEFAULT 0, + clus smallint(6) NOT NULL DEFAULT 0, + PRIMARY KEY (id), + KEY acei_aclid (aclid), + KEY acei_clus (clus) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +insert into acei(id,aclid,atp,clus) values +(184929059698905999,184929059698905997,0,1), +(184929059698906000,184929059698905997,0,1), +(184929059698906001,184929059698905997,1,1), +(184929059698906002,184929059698905998,1,1), +(283586039035985922,283586039035985921,1,1), +(2216474704108064684,2216474704108064678,0,1), +(2216474704108064685,2216474704108064678,0,1), +(2216474704108064686,2216474704108064678,1,1), +(2216474704108064687,2216474704108064679,1,1), +(3080602882609775595,3080602882609775593,0,1), +(3080602882609775596,3080602882609775593,0,1), +(3080602882609775597,3080602882609775593,1,1), +(3080602882609775598,3080602882609775594,1,1), +(3080602882609776595,3080602882609776594,1,1), +(3080602882609777596,3080602882609777595,1,1), +(4269412446747236216,4269412446747236214,0,1), +(4269412446747236217,4269412446747236214,0,1), +(4269412446747236218,4269412446747236214,1,1), +(4269412446747236219,4269412446747236215,1,1), +(6341490487802728358,6341490487802728356,0,1), +(6341490487802728359,6341490487802728356,0,1), +(6341490487802728360,6341490487802728356,1,1), +(6341490487802728361,6341490487802728357,1,1); + +CREATE TABLE filt ( + id bigint(20) NOT NULL, + aceid bigint(20) NOT NULL DEFAULT 0, + clid smallint(6) NOT NULL DEFAULT 0, + fh bigint(20) NOT NULL DEFAULT 0, + PRIMARY KEY (id), + KEY filt_aceid (aceid), + KEY filt_clid (clid), + KEY filt_fh (fh) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +insert into filt(id,aceid,clid,fh) values +(184929059698905999,184929059698905999,1,8948400944397203540), +(184929059698906000,184929059698906000,1,-3516039679025944536), +(184929059698906001,184929059698906001,1,-3516039679025944536), +(184929059698906002,184929059698906001,1,2965370193075218252), +(184929059698906003,184929059698906001,1,8948400944397203540), +(184929059698906004,184929059698906002,1,2478709353550777738), +(283586039035985922,283586039035985922,1,5902600816362013271), +(2216474704108064686,2216474704108064684,1,8948400944397203540), +(2216474704108064687,2216474704108064685,1,-7244708939311117030), +(2216474704108064688,2216474704108064686,1,-7244708939311117030), +(2216474704108064689,2216474704108064686,1,7489060986210282479), +(2216474704108064690,2216474704108064686,1,8948400944397203540), +(2216474704108064691,2216474704108064687,1,-3575268945274980038), +(3080602882609775595,3080602882609775595,1,8948400944397203540), +(3080602882609775596,3080602882609775596,1,-5420422472375069774), +(3080602882609775597,3080602882609775597,1,-5420422472375069774), +(3080602882609775598,3080602882609775597,1,8518228073041491534), +(3080602882609775599,3080602882609775597,1,8948400944397203540), +(3080602882609775600,3080602882609775598,1,6311439873746261694), +(3080602882609775601,3080602882609775598,1,6311439873746261694), +(3080602882609776595,3080602882609776595,1,-661101805245999843), +(3080602882609777596,3080602882609777596,1,-661101805245999843), +(3080602882609777597,3080602882609777596,1,2216865386202464067), +(4269412446747236216,4269412446747236216,1,8948400944397203540), +(4269412446747236217,4269412446747236217,1,-1143096194892676000), +(4269412446747236218,4269412446747236218,1,-1143096194892676000), +(4269412446747236219,4269412446747236218,1,5313391811364818290), +(4269412446747236220,4269412446747236218,1,8948400944397203540), +(4269412446747236221,4269412446747236219,1,7624499822621753835), +(6341490487802728358,6341490487802728358,1,8948400944397203540), +(6341490487802728359,6341490487802728359,1,8141092449587136068), +(6341490487802728360,6341490487802728360,1,8141092449587136068), +(6341490487802728361,6341490487802728360,1,1291319099896431785), +(6341490487802728362,6341490487802728360,1,8948400944397203540), +(6341490487802728363,6341490487802728361,1,6701841652906431497); + +analyze table filt, acei, acli; + +let $q= +select t.id, fi.* +from (acli t inner join acei a on a.aclid = t.id) + inner join filt fi on a.id = fi.aceid + where + t.rid = 'B5FCC8C7111E4E3CBC21AAF5012F59C2' and + t.tp = 121 and + a.atp = 1 and + fi.fh in (6311439873746261694,-397087483897438286, + 8518228073041491534,-5420422472375069774); + +set @save_optimizer_switch=@@optimizer_switch; +set @save_join_cache_level=@@join_cache_level; + +set optimizer_switch='mrr=off'; +set join_cache_level=2; +eval $without_filter explain extended $q; +eval $without_filter $q; +eval $with_filter explain extended $q; +eval $with_filter $q; + +set optimizer_switch='mrr=on'; +set join_cache_level=6; +eval $without_filter explain extended $q; +eval $without_filter $q; +eval $with_filter explain extended $q; +eval $with_filter $q; +--source include/analyze-format.inc +eval $with_filter analyze format=json $q; + +set optimizer_switch=@save_optimizer_switch; +set join_cache_level=@save_join_cache_level; + +drop table filt, acei, acli; + +set global innodb_stats_persistent= @stats.save; diff --git a/sql/multi_range_read.cc b/sql/multi_range_read.cc index 7e4c2ed1f53..51c3dc7a205 100644 --- a/sql/multi_range_read.cc +++ b/sql/multi_range_read.cc @@ -702,7 +702,8 @@ static int rowid_cmp_reverse(void *file, uchar *a, uchar *b) int Mrr_ordered_rndpos_reader::init(handler *h_arg, Mrr_index_reader *index_reader_arg, uint mode, - Lifo_buffer *buf) + Lifo_buffer *buf, + Rowid_filter *filter) { file= h_arg; index_reader= index_reader_arg; @@ -710,19 +711,7 @@ int Mrr_ordered_rndpos_reader::init(handler *h_arg, is_mrr_assoc= !MY_TEST(mode & HA_MRR_NO_ASSOCIATION); index_reader_exhausted= FALSE; index_reader_needs_refill= TRUE; - - /* - Currently usage of a rowid filter within InnoDB engine is not supported - if the table is accessed by the primary key. - With optimizer switches ''mrr' and 'mrr_sort_keys' are both enabled - any access by a secondary index is converted to the rndpos access. In - InnoDB the rndpos access is always uses the primary key. - Do not use pushed rowid filter if the table is accessed actually by the - primary key. Use the rowid filter outside the engine code (see - Mrr_ordered_rndpos_reader::refill_from_index_reader). - */ - if (file->pushed_rowid_filter && file->primary_key_is_clustered()) - file->cancel_pushed_rowid_filter(); + rowid_filter= filter; return 0; } @@ -817,10 +806,8 @@ int Mrr_ordered_rndpos_reader::refill_from_index_reader() index_reader->position(); /* - If the built rowid filter cannot be used at the engine level use it here. + If the built rowid filter cannot be used at the engine level, use it here. */ - Rowid_filter *rowid_filter= - file->get_table()->reginfo.join_tab->rowid_filter; if (rowid_filter && !file->pushed_rowid_filter && !rowid_filter->check((char *)index_rowid)) continue; @@ -960,7 +947,8 @@ int DsMrr_impl::dsmrr_init(handler *h_arg, RANGE_SEQ_IF *seq_funcs, void *seq_init_param, uint n_ranges, uint mode, HANDLER_BUFFER *buf) { - THD *thd= h_arg->get_table()->in_use; + TABLE *table= h_arg->get_table(); + THD *thd= table->in_use; int res; Key_parameters keypar; uint UNINIT_VAR(key_buff_elem_size); /* set/used when do_sort_keys==TRUE */ @@ -1015,6 +1003,20 @@ int DsMrr_impl::dsmrr_init(handler *h_arg, RANGE_SEQ_IF *seq_funcs, if (!(keyno == table->s->primary_key && h_idx->primary_key_is_clustered())) { strategy= disk_strategy= &reader_factory.ordered_rndpos_reader; + if (h_arg->pushed_rowid_filter) + { + /* + Currently usage of a rowid filter within InnoDB engine is not supported + if the table is accessed by the primary key. + With optimizer switches ''mrr' and 'mrr_sort_keys' are both enabled + any access by a secondary index is converted to the rndpos access. In + InnoDB the rndpos access is always uses the primary key. + Do not use pushed rowid filter if the table is accessed actually by the + primary key. Use the rowid filter outside the engine code (see + Mrr_ordered_rndpos_reader::refill_from_index_reader). + */ + h_arg->cancel_pushed_rowid_filter(); + } } full_buf= buf->buffer; @@ -1101,7 +1103,8 @@ int DsMrr_impl::dsmrr_init(handler *h_arg, RANGE_SEQ_IF *seq_funcs, n_ranges, mode, &keypar, key_buffer, &buf_manager)) || (res= disk_strategy->init(primary_file, index_strategy, mode, - &rowid_buffer))) + &rowid_buffer, + table->reginfo.join_tab->rowid_filter))) { goto error; } diff --git a/sql/multi_range_read.h b/sql/multi_range_read.h index 0473fef04ae..6be95371bb2 100644 --- a/sql/multi_range_read.h +++ b/sql/multi_range_read.h @@ -364,7 +364,7 @@ class Mrr_ordered_rndpos_reader : public Mrr_reader { public: int init(handler *file, Mrr_index_reader *index_reader, uint mode, - Lifo_buffer *buf); + Lifo_buffer *buf, Rowid_filter *filter); int get_next(range_id_t *range_info); int refill_buffer(bool initial); private: @@ -399,6 +399,9 @@ private: /* Buffer to store (rowid, range_id) pairs */ Lifo_buffer *rowid_buffer; + /* Rowid filter to be checked against (if any) */ + Rowid_filter *rowid_filter; + int refill_from_index_reader(); }; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index c3b82827291..bff770fdc00 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -2902,7 +2902,8 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, remove_nonrange_trees(¶m, tree); /* Get best 'range' plan and prepare data for making other plans */ - if ((range_trp= get_key_scans_params(¶m, tree, FALSE, TRUE, + if ((range_trp= get_key_scans_params(¶m, tree, + only_single_index_range_scan, TRUE, best_read_time))) { best_trp= range_trp; diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc index 3a509b3d750..e9ad53850dd 100644 --- a/sql/sql_join_cache.cc +++ b/sql/sql_join_cache.cc @@ -2248,6 +2248,8 @@ enum_nested_loop_state JOIN_CACHE::join_matching_records(bool skip_last) if ((rc= join_tab_execution_startup(join_tab)) < 0) goto finish2; + join_tab->build_range_rowid_filter_if_needed(); + /* Prepare to retrieve all records of the joined table */ if (unlikely((error= join_tab_scan->open()))) { From adcfea710ff0dcd8d223d41440225ebf6e64f796 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Wed, 19 Feb 2020 14:57:47 +0300 Subject: [PATCH 28/66] Fix compile failure, compare_key_parts in handler shadowed by MyRocks The two functions have different signature. Use "using ..." to prevent shadowing --- storage/rocksdb/ha_rocksdb.h | 1 + 1 file changed, 1 insertion(+) diff --git a/storage/rocksdb/ha_rocksdb.h b/storage/rocksdb/ha_rocksdb.h index 1abdc345527..448900c5a91 100644 --- a/storage/rocksdb/ha_rocksdb.h +++ b/storage/rocksdb/ha_rocksdb.h @@ -739,6 +739,7 @@ public: const TABLE *old_table_arg, const Rdb_tbl_def *old_tbl_def_arg) const MY_ATTRIBUTE((__nonnull__)); + using handler::compare_key_parts; int compare_key_parts(const KEY *const old_key, const KEY *const new_key) const MY_ATTRIBUTE((__nonnull__, __warn_unused_result__)); From affe7fabc7baa36083e7632eb6c3611578d74b48 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Wed, 19 Feb 2020 21:27:38 +0300 Subject: [PATCH 29/66] MDEV-21628: Index condition pushdown condition ... not used with BKA (Backport to 10.3) Partitioning storage now supports MRR but doesn't support Index Condition Pushdown (aka ICP). This causes counter-intuitive query plans for queries that use BKA and conditions that depend on index fields: - If the condition refers to other tables, BKA's variant of ICP is used to handle it. - If the condition depends on this table only, the optimizer will try to use regular ICP for it, which will fail because the storage engine doesn't support ICP. Make the optimizer be smarter in the second case: if we were not able to use regular ICP, use BKA's variant of ICP.. --- mysql-test/main/partition_mrr_myisam.result | 59 +++++++++++++++++++++ mysql-test/main/partition_mrr_myisam.test | 59 +++++++++++++++++++++ sql/opt_index_cond_pushdown.cc | 15 ++++++ 3 files changed, 133 insertions(+) diff --git a/mysql-test/main/partition_mrr_myisam.result b/mysql-test/main/partition_mrr_myisam.result index 1f1cea8e9d6..d989536324c 100644 --- a/mysql-test/main/partition_mrr_myisam.result +++ b/mysql-test/main/partition_mrr_myisam.result @@ -77,3 +77,62 @@ ID part_id key_col col2 28 8 2 123456 29 9 2 123456 drop table t1,t3; +# +# MDEV-21628: Index condition pushdown for a simple condition over +# index fields is not used for ref access of partitioned tables when employing BKA +# +create table t0 ( +tp int, a int, b int, c varchar(12), index idx (a,b) +); +insert into t0 values +(1,3,30,'yyzy'), (1,3,30,'yxxyy'), (1,3,30,'yyxy'), (1,3,30,'xxyy'), +(1,3,30,'yyxz'), (1,3,30,'yyzz'), (1,3,30,'xxyzy'), (1,3,30,'yyyy'), +(1,3,30,'yzzy'), (1,93,30,'zzzy'), +(2,3,40,'yxx'), (2,4,40,'xx'), (2,3,10,'zxz'), +(2,3,40,'yyx'), (2,4,40,'xxx'), (2,3,10,'zyyz'), +(2,3,40,'xzzzz'), (2,4,40,'yyyxx'), (2,3,10,'zyz'), +(2,3,40,'xxx'), (2,4,40,'xx'), (2,3,10,'zzz'), +(2,3,40,'yyxzx'), (2,4,40,'xyx'), (2,3,10,'xzz'), +(2,3,40,'xxxzz'), (2,4,40,'xxz'), (2,3,10,'zzzy'), +(2,3,40,'zzxxx'), (2,4,40,'zxx'), (2,3,10,'yzzz'), +(2,3,40,'xyyxx'), (2,4,40,'xzzzx'), (2,3,10,'zzxxz'), +(2,3,40,'yzxxx'), (2,4,40,'xxzy'), (2,3,10,'zzzyx'), +(2,93,40,'xzx'), (2,94,40,'xz'), (2,93,10,'zyyyz'), +(3,4,30,'yx'), (3,4,30,'yyxxx'), (3,4,30,'zzyy'), (3,4,30,'zxyy'), +(3,4,30,'xxyy'), (3,4,30,'yyzx'), (3,4,30,'zyyy'), (3,4,30,'yzy'), +(3,4,30,'zzzyy'), (3,94,30,'yyz'); +create table t1 ( +tp int, a int, b int, c varchar(12), index idx (a,b) +) engine=myisam +partition by list (tp) +( partition p1 values in (1), +partition p2 values in (2), +partition p3 values in (3)); +insert into t1 select * from t0; +create table t2 (a int, index idx(a)) engine=myisam; +insert into t2 values (1), (2), (3), (4), (5); +insert into t2 select a+10 from t2; +insert into t2 select a+20 from t2; +analyze table t0,t1,t2; +Table Op Msg_type Msg_text +test.t0 analyze status Engine-independent statistics collected +test.t0 analyze status OK +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +test.t2 analyze status Engine-independent statistics collected +test.t2 analyze status OK +set @tmp1=@@join_cache_level, @tmp2=@@optimizer_switch; +set join_cache_level=6, optimizer_switch='mrr=on'; +explain +select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = 4; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range idx idx 5 NULL 2 Using where; Using index +1 SIMPLE t0 ref idx idx 5 test.t2.a 12 Using index condition; Using join buffer (flat, BKA join); Rowid-ordered scan +# This will use "Using index condition(BKA)" +explain +select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = 4; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range idx idx 5 NULL 2 Using where; Using index +1 SIMPLE t1 ref idx idx 5 test.t2.a 12 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan +set join_cache_level=@tmp1, optimizer_switch=@tmp2; +drop table t0,t1,t2; diff --git a/mysql-test/main/partition_mrr_myisam.test b/mysql-test/main/partition_mrr_myisam.test index d67a37ab3d2..eb30319d81f 100644 --- a/mysql-test/main/partition_mrr_myisam.test +++ b/mysql-test/main/partition_mrr_myisam.test @@ -1,3 +1,62 @@ let $engine_type= myisam; --source include/partition_mrr.inc + +--echo # +--echo # MDEV-21628: Index condition pushdown for a simple condition over +--echo # index fields is not used for ref access of partitioned tables when employing BKA +--echo # + +create table t0 ( +tp int, a int, b int, c varchar(12), index idx (a,b) +); + +insert into t0 values +(1,3,30,'yyzy'), (1,3,30,'yxxyy'), (1,3,30,'yyxy'), (1,3,30,'xxyy'), +(1,3,30,'yyxz'), (1,3,30,'yyzz'), (1,3,30,'xxyzy'), (1,3,30,'yyyy'), +(1,3,30,'yzzy'), (1,93,30,'zzzy'), +(2,3,40,'yxx'), (2,4,40,'xx'), (2,3,10,'zxz'), +(2,3,40,'yyx'), (2,4,40,'xxx'), (2,3,10,'zyyz'), +(2,3,40,'xzzzz'), (2,4,40,'yyyxx'), (2,3,10,'zyz'), +(2,3,40,'xxx'), (2,4,40,'xx'), (2,3,10,'zzz'), +(2,3,40,'yyxzx'), (2,4,40,'xyx'), (2,3,10,'xzz'), +(2,3,40,'xxxzz'), (2,4,40,'xxz'), (2,3,10,'zzzy'), +(2,3,40,'zzxxx'), (2,4,40,'zxx'), (2,3,10,'yzzz'), +(2,3,40,'xyyxx'), (2,4,40,'xzzzx'), (2,3,10,'zzxxz'), +(2,3,40,'yzxxx'), (2,4,40,'xxzy'), (2,3,10,'zzzyx'), +(2,93,40,'xzx'), (2,94,40,'xz'), (2,93,10,'zyyyz'), +(3,4,30,'yx'), (3,4,30,'yyxxx'), (3,4,30,'zzyy'), (3,4,30,'zxyy'), +(3,4,30,'xxyy'), (3,4,30,'yyzx'), (3,4,30,'zyyy'), (3,4,30,'yzy'), +(3,4,30,'zzzyy'), (3,94,30,'yyz'); + +create table t1 ( +tp int, a int, b int, c varchar(12), index idx (a,b) +) engine=myisam +partition by list (tp) +( partition p1 values in (1), + partition p2 values in (2), + partition p3 values in (3)); +insert into t1 select * from t0; + +create table t2 (a int, index idx(a)) engine=myisam; +insert into t2 values (1), (2), (3), (4), (5); +insert into t2 select a+10 from t2; +insert into t2 select a+20 from t2; + +analyze table t0,t1,t2; + +set @tmp1=@@join_cache_level, @tmp2=@@optimizer_switch; +set join_cache_level=6, optimizer_switch='mrr=on'; + +explain +select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = 4; + +--echo # This will use "Using index condition(BKA)" +explain +select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = 4; + +set join_cache_level=@tmp1, optimizer_switch=@tmp2; + +drop table t0,t1,t2; + + diff --git a/sql/opt_index_cond_pushdown.cc b/sql/opt_index_cond_pushdown.cc index 8f3f9cdac72..af6a75cdef2 100644 --- a/sql/opt_index_cond_pushdown.cc +++ b/sql/opt_index_cond_pushdown.cc @@ -393,8 +393,23 @@ void push_index_cond(JOIN_TAB *tab, uint keyno) ~(tab->table->map | tab->join->const_table_map))) tab->cache_idx_cond= idx_cond; else + { idx_remainder_cond= tab->table->file->idx_cond_push(keyno, idx_cond); + /* + If (1) there is an index condition that we couldn't push using ICP, + (2) we are using Join Buffering + (3) and we are using BKA + then use BKA's Index Condition Pushdown mechanism to check it. + */ + if (idx_remainder_cond && tab->use_join_cache && // (1) && (2) + tab->icp_other_tables_ok) // (3) + { + tab->cache_idx_cond= idx_remainder_cond; + idx_remainder_cond= NULL; + } + } + /* Disable eq_ref's "lookup cache" if we've pushed down an index condition. From fb01cc3766be9131402b82730adfa0e45e6e3511 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Fri, 9 Nov 2018 14:38:22 +1100 Subject: [PATCH 30/66] my_getncpus based on threads available Detecting the cpus based on sysconf of the online CPUs can significantly over estimate the number of cpus available. Wheither via numactl, cgroups, taskset, systemd constraints, docker containers and probably other mechanisms, the number of threads mysqld can be run on can be quite less. As such we use the pthread_getaffinity_np function on Linux and FreeBSD (identical API) to get the number of CPUs. The number of CPUs is the default for the thread_pool_size and a too high default will resulting in large memory usage and high context switching overhead. Closes PR #922 --- cmake/os/WindowsCache.cmake | 2 ++ config.h.cmake | 3 +++ configure.cmake | 2 ++ mysys/my_getncpus.c | 31 ++++++++++++++++++++++++++++++- 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/cmake/os/WindowsCache.cmake b/cmake/os/WindowsCache.cmake index 1cb6c81b627..1dbedfc24f2 100644 --- a/cmake/os/WindowsCache.cmake +++ b/cmake/os/WindowsCache.cmake @@ -127,6 +127,8 @@ SET(HAVE_PTHREAD_ATTR_GETSTACKSIZE CACHE INTERNAL "") SET(HAVE_PTHREAD_ATTR_SETSCOPE CACHE INTERNAL "") SET(HAVE_PTHREAD_ATTR_SETSTACKSIZE CACHE INTERNAL "") SET(HAVE_PTHREAD_CONDATTR_CREATE CACHE INTERNAL "") +SET(HAVE_PTHREAD_CONDATTR_SETCLOCK CACHE INTERNAL "") +SET(HAVE_PTHREAD_GETAFFINITY_NP CACHE INTERNAL "") SET(HAVE_PTHREAD_INIT CACHE INTERNAL "") SET(HAVE_PTHREAD_KEY_DELETE CACHE INTERNAL "") SET(HAVE_PTHREAD_RWLOCK_RDLOCK CACHE INTERNAL "") diff --git a/config.h.cmake b/config.h.cmake index 6e4af65c40e..fdaba640ad6 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -200,6 +200,9 @@ #cmakedefine HAVE_PTHREAD_ATTR_SETSCOPE 1 #cmakedefine HAVE_PTHREAD_ATTR_SETSTACKSIZE 1 #cmakedefine HAVE_PTHREAD_CONDATTR_CREATE 1 +#cmakedefine HAVE_PTHREAD_CONDATTR_SETCLOCK 1 +#cmakedefine HAVE_PTHREAD_GETAFFINITY_NP 1 +#cmakedefine HAVE_PTHREAD_KEY_DELETE 1 #cmakedefine HAVE_PTHREAD_KEY_DELETE 1 #cmakedefine HAVE_PTHREAD_KILL 1 #cmakedefine HAVE_PTHREAD_RWLOCK_RDLOCK 1 diff --git a/configure.cmake b/configure.cmake index f94fb3642a5..a85652a8345 100644 --- a/configure.cmake +++ b/configure.cmake @@ -375,6 +375,8 @@ CHECK_FUNCTION_EXISTS (pthread_attr_setscope HAVE_PTHREAD_ATTR_SETSCOPE) CHECK_FUNCTION_EXISTS (pthread_attr_getguardsize HAVE_PTHREAD_ATTR_GETGUARDSIZE) CHECK_FUNCTION_EXISTS (pthread_attr_setstacksize HAVE_PTHREAD_ATTR_SETSTACKSIZE) CHECK_FUNCTION_EXISTS (pthread_condattr_create HAVE_PTHREAD_CONDATTR_CREATE) +CHECK_FUNCTION_EXISTS (pthread_condattr_setclock HAVE_PTHREAD_CONDATTR_SETCLOCK) +CHECK_FUNCTION_EXISTS (pthread_getaffinity_np HAVE_PTHREAD_GETAFFINITY_NP) CHECK_FUNCTION_EXISTS (pthread_key_delete HAVE_PTHREAD_KEY_DELETE) CHECK_FUNCTION_EXISTS (pthread_rwlock_rdlock HAVE_PTHREAD_RWLOCK_RDLOCK) CHECK_FUNCTION_EXISTS (pthread_sigmask HAVE_PTHREAD_SIGMASK) diff --git a/mysys/my_getncpus.c b/mysys/my_getncpus.c index 38585161c22..0ee03631da8 100644 --- a/mysys/my_getncpus.c +++ b/mysys/my_getncpus.c @@ -21,10 +21,36 @@ #include #endif +#if defined(__FreeBSD__) && defined(HAVE_PTHREAD_GETAFFINITY_NP) +#include +#include +#endif + static int ncpus=0; -int my_getncpus() +int my_getncpus(void) { +#if (defined(__linux__) || defined(__FreeBSD__)) && defined(HAVE_PTHREAD_GETAFFINITY_NP) + cpu_set_t set; + + if (!ncpus) + { + if (pthread_getaffinity_np(pthread_self(), sizeof(set), &set) == 0) + { + ncpus= CPU_COUNT(&set); + } + else + { +#ifdef _SC_NPROCESSORS_ONLN + ncpus= sysconf(_SC_NPROCESSORS_ONLN); +#else + ncpus= 2; +#endif + } + } + +#else /* __linux__ || FreeBSD && HAVE_PTHREAD_GETAFFINITY_NP */ + if (!ncpus) { #ifdef _SC_NPROCESSORS_ONLN @@ -46,5 +72,8 @@ int my_getncpus() ncpus= 2; #endif } + +#endif /* __linux__ || FreeBSD && HAVE_PTHREAD_GETAFFINITY_NP */ + return ncpus; } From 0d1dd2e79d4411ef8aaac9e789569253061caec9 Mon Sep 17 00:00:00 2001 From: Anel Husakovic Date: Thu, 20 Feb 2020 09:25:05 +0100 Subject: [PATCH 31/66] Clean wrong cherry-pick from previous commit - Delete variable HAVE_PTHREAD_CONDATTR_SETCLOCK and check - Delete second HAVE_PTHREAD_KEY_DELETE --- cmake/os/WindowsCache.cmake | 1 - config.h.cmake | 2 -- configure.cmake | 1 - 3 files changed, 4 deletions(-) diff --git a/cmake/os/WindowsCache.cmake b/cmake/os/WindowsCache.cmake index 1dbedfc24f2..a18f7cc7fe2 100644 --- a/cmake/os/WindowsCache.cmake +++ b/cmake/os/WindowsCache.cmake @@ -127,7 +127,6 @@ SET(HAVE_PTHREAD_ATTR_GETSTACKSIZE CACHE INTERNAL "") SET(HAVE_PTHREAD_ATTR_SETSCOPE CACHE INTERNAL "") SET(HAVE_PTHREAD_ATTR_SETSTACKSIZE CACHE INTERNAL "") SET(HAVE_PTHREAD_CONDATTR_CREATE CACHE INTERNAL "") -SET(HAVE_PTHREAD_CONDATTR_SETCLOCK CACHE INTERNAL "") SET(HAVE_PTHREAD_GETAFFINITY_NP CACHE INTERNAL "") SET(HAVE_PTHREAD_INIT CACHE INTERNAL "") SET(HAVE_PTHREAD_KEY_DELETE CACHE INTERNAL "") diff --git a/config.h.cmake b/config.h.cmake index fdaba640ad6..170bb80b691 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -200,10 +200,8 @@ #cmakedefine HAVE_PTHREAD_ATTR_SETSCOPE 1 #cmakedefine HAVE_PTHREAD_ATTR_SETSTACKSIZE 1 #cmakedefine HAVE_PTHREAD_CONDATTR_CREATE 1 -#cmakedefine HAVE_PTHREAD_CONDATTR_SETCLOCK 1 #cmakedefine HAVE_PTHREAD_GETAFFINITY_NP 1 #cmakedefine HAVE_PTHREAD_KEY_DELETE 1 -#cmakedefine HAVE_PTHREAD_KEY_DELETE 1 #cmakedefine HAVE_PTHREAD_KILL 1 #cmakedefine HAVE_PTHREAD_RWLOCK_RDLOCK 1 #cmakedefine HAVE_PTHREAD_SIGMASK 1 diff --git a/configure.cmake b/configure.cmake index a85652a8345..dec28f47d72 100644 --- a/configure.cmake +++ b/configure.cmake @@ -375,7 +375,6 @@ CHECK_FUNCTION_EXISTS (pthread_attr_setscope HAVE_PTHREAD_ATTR_SETSCOPE) CHECK_FUNCTION_EXISTS (pthread_attr_getguardsize HAVE_PTHREAD_ATTR_GETGUARDSIZE) CHECK_FUNCTION_EXISTS (pthread_attr_setstacksize HAVE_PTHREAD_ATTR_SETSTACKSIZE) CHECK_FUNCTION_EXISTS (pthread_condattr_create HAVE_PTHREAD_CONDATTR_CREATE) -CHECK_FUNCTION_EXISTS (pthread_condattr_setclock HAVE_PTHREAD_CONDATTR_SETCLOCK) CHECK_FUNCTION_EXISTS (pthread_getaffinity_np HAVE_PTHREAD_GETAFFINITY_NP) CHECK_FUNCTION_EXISTS (pthread_key_delete HAVE_PTHREAD_KEY_DELETE) CHECK_FUNCTION_EXISTS (pthread_rwlock_rdlock HAVE_PTHREAD_RWLOCK_RDLOCK) From 3ce49a0a5225eb7d185361e1ece65d03813ec550 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Thu, 20 Feb 2020 14:04:09 +0530 Subject: [PATCH 32/66] MDEV-21563 FTS thread aborts during shutdown - Add warning suppression in misc_debug2 test. --- mysql-test/suite/innodb_fts/r/misc_debug2.result | 1 + mysql-test/suite/innodb_fts/t/misc_debug2.test | 1 + 2 files changed, 2 insertions(+) diff --git a/mysql-test/suite/innodb_fts/r/misc_debug2.result b/mysql-test/suite/innodb_fts/r/misc_debug2.result index e9daa2d6b30..b3bc12f92cc 100644 --- a/mysql-test/suite/innodb_fts/r/misc_debug2.result +++ b/mysql-test/suite/innodb_fts/r/misc_debug2.result @@ -1,4 +1,5 @@ call mtr.add_suppression("InnoDB: Table '.*' tablespace is set as discarded."); +call mtr.add_suppression("InnoDB: Tablespace for table .* is set as discarded."); CREATE TABLE mdev21563(f1 VARCHAR(100), FULLTEXT idx(f1))ENGINE=InnoDB; set debug_dbug="+d,fts_instrument_sync_request"; INSERT INTO mdev21563 VALUES('This is a test'); diff --git a/mysql-test/suite/innodb_fts/t/misc_debug2.test b/mysql-test/suite/innodb_fts/t/misc_debug2.test index 31c026e3db9..0a9e137dd80 100644 --- a/mysql-test/suite/innodb_fts/t/misc_debug2.test +++ b/mysql-test/suite/innodb_fts/t/misc_debug2.test @@ -2,6 +2,7 @@ --source include/have_debug.inc --source include/not_embedded.inc call mtr.add_suppression("InnoDB: Table '.*' tablespace is set as discarded."); +call mtr.add_suppression("InnoDB: Tablespace for table .* is set as discarded."); CREATE TABLE mdev21563(f1 VARCHAR(100), FULLTEXT idx(f1))ENGINE=InnoDB; set debug_dbug="+d,fts_instrument_sync_request"; From e637355156cb28388a291b0e3a5e9ee863b2854d Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Thu, 20 Feb 2020 13:35:19 +0300 Subject: [PATCH 33/66] MDEV-21610 Different query results from 10.4.11 to 10.4.12 Part#2: cleanup: In the part 1 of the fix, DS-MRR implementation would peek into the JOIN_TAB to get the rowid filter from table->reginfo.join_tab->rowid_filter This doesn't look good from code isolation standpoint (why should a storage engine assume it is used through a JOIN_TAB?). Fixed this by storing the 'un-pushed' rowid_filter in the DsMrr_impl structure. The filter survives across multi_range_read_init() calls. It is discarded when somebody calls index_end() or rnd_end() and cleans up the DsMrr_impl. --- sql/multi_range_read.cc | 9 +++++++-- sql/multi_range_read.h | 11 +++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/sql/multi_range_read.cc b/sql/multi_range_read.cc index 51c3dc7a205..c000187626f 100644 --- a/sql/multi_range_read.cc +++ b/sql/multi_range_read.cc @@ -1015,6 +1015,7 @@ int DsMrr_impl::dsmrr_init(handler *h_arg, RANGE_SEQ_IF *seq_funcs, primary key. Use the rowid filter outside the engine code (see Mrr_ordered_rndpos_reader::refill_from_index_reader). */ + rowid_filter= h_arg->pushed_rowid_filter; h_arg->cancel_pushed_rowid_filter(); } } @@ -1096,15 +1097,18 @@ int DsMrr_impl::dsmrr_init(handler *h_arg, RANGE_SEQ_IF *seq_funcs, goto use_default_impl; } + // setup_two_handlers() will call dsmrr_close() will clears the filter. + // Save its value and restore afterwards. + Rowid_filter *tmp = rowid_filter; if ((res= setup_two_handlers())) goto error; + rowid_filter= tmp; if ((res= index_strategy->init(secondary_file, seq_funcs, seq_init_param, n_ranges, mode, &keypar, key_buffer, &buf_manager)) || (res= disk_strategy->init(primary_file, index_strategy, mode, - &rowid_buffer, - table->reginfo.join_tab->rowid_filter))) + &rowid_buffer, rowid_filter))) { goto error; } @@ -1286,6 +1290,7 @@ void DsMrr_impl::close_second_handler() void DsMrr_impl::dsmrr_close() { DBUG_ENTER("DsMrr_impl::dsmrr_close"); + rowid_filter= NULL; close_second_handler(); strategy= NULL; DBUG_VOID_RETURN; diff --git a/sql/multi_range_read.h b/sql/multi_range_read.h index 6be95371bb2..37a00e3086f 100644 --- a/sql/multi_range_read.h +++ b/sql/multi_range_read.h @@ -557,7 +557,8 @@ public: typedef void (handler::*range_check_toggle_func_t)(bool on); DsMrr_impl() - : secondary_file(NULL) {}; + : secondary_file(NULL), + rowid_filter(NULL) {}; void init(handler *h_arg, TABLE *table_arg) { @@ -594,7 +595,13 @@ private: to run both index scan and rnd_pos() scan at the same time) */ handler *secondary_file; - + + /* + The rowid filter that DS-MRR has "unpushed" from the storage engine. + If it's present, DS-MRR will use it. + */ + Rowid_filter *rowid_filter; + uint keyno; /* index we're running the scan on */ /* TRUE <=> need range association, buffers hold {rowid, range_id} pairs */ bool is_mrr_assoc; From b9689712e00bec64fa5dfad7ed65e6a82df8be23 Mon Sep 17 00:00:00 2001 From: Anel Husakovic Date: Tue, 31 Dec 2019 18:02:54 +0100 Subject: [PATCH 34/66] MDEV-21374: When "--help --verbose" prints out configuration file paths, the --defaults-file option is not considered * `--defaults-file` option is showed only in `--help --verbose` if applied * `--default-extra-file` is showing correctly now in `--help --verbose`, previously it was treated as a directory with appended `my.cnf` --- mysql-test/r/mysqld--defaults-file.result | 12 ++++++++++++ mysql-test/t/mysqld--defaults-file.test | 16 ++++++++++++++++ mysys/my_default.c | 10 ++++++++++ 3 files changed, 38 insertions(+) diff --git a/mysql-test/r/mysqld--defaults-file.result b/mysql-test/r/mysqld--defaults-file.result index 5fd5ca8d95a..be62580c47e 100644 --- a/mysql-test/r/mysqld--defaults-file.result +++ b/mysql-test/r/mysqld--defaults-file.result @@ -10,3 +10,15 @@ Could not open required defaults file: MYSQL_TEST_DIR/with.ext Fatal error in defaults handling. Program aborted Could not open required defaults file: MYSQL_TEST_DIR/no_extension Fatal error in defaults handling. Program aborted +# +# MDEV-21374: When "--help --verbose" prints out configuration file paths, +# the --defaults-file option is not considered +# +# Test on `defaults-file` +Default options are read from the following files in the given order: +MYSQLTEST_VARDIR/my.cnf +The following groups are read: mysqld server mysqld-10.1 mariadb mariadb-10.1 client-server galera +# Test on `defaults-extra-file` +Default options are read from the following files in the given order: + MYSQLTEST_VARDIR/my_test.cnf ~/.my.cnf +The following groups are read: mysqld server mysqld-10.1 mariadb mariadb-10.1 client-server galera diff --git a/mysql-test/t/mysqld--defaults-file.test b/mysql-test/t/mysqld--defaults-file.test index 3bfe0aa891f..acc1cea5b8c 100644 --- a/mysql-test/t/mysqld--defaults-file.test +++ b/mysql-test/t/mysqld--defaults-file.test @@ -29,3 +29,19 @@ exec $MYSQLD --defaults-file=with.ext --print-defaults 2>&1; --error 1 exec $MYSQLD --defaults-file=no_extension --print-defaults 2>&1; +--echo # +--echo # MDEV-21374: When "--help --verbose" prints out configuration file paths, +--echo # the --defaults-file option is not considered +--echo # + +--echo # Test on `defaults-file` +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +exec $MYSQLD --defaults-file=$MYSQLTEST_VARDIR/my.cnf --help --verbose | grep -A 2 'Default options are read'; + +--echo # Test on `defaults-extra-file` +# = `/etc/my.cnf /etc/mysql/my.cnf` +# Using sysconfdir configuration, we don't always have `/etc/mysql/my.cnf`, so replace them with a regex as well. +copy_file $MYSQLTEST_VARDIR/my.cnf $MYSQLTEST_VARDIR/my_test.cnf; +--replace_regex /.*my_test.cnf/ MYSQLTEST_VARDIR\/my_test.cnf/ +exec $MYSQLD --defaults-extra-file=$MYSQLTEST_VARDIR/my_test.cnf --help --verbose | grep -A 2 'Default options are read'; +remove_file $MYSQLTEST_VARDIR/my_test.cnf; diff --git a/mysys/my_default.c b/mysys/my_default.c index 32faf2045f9..6f080bb35fe 100644 --- a/mysys/my_default.c +++ b/mysys/my_default.c @@ -1035,6 +1035,11 @@ void my_print_default_files(const char *conf_file) char name[FN_REFLEN], **ext; puts("\nDefault options are read from the following files in the given order:"); + if (my_defaults_file) + { + puts(my_defaults_file); + return; + } if (dirname_length(conf_file)) fputs(conf_file,stdout); @@ -1059,7 +1064,12 @@ void my_print_default_files(const char *conf_file) if (**dirs) pos= *dirs; else if (my_defaults_extra_file) + { pos= my_defaults_extra_file; + fputs(pos, stdout); + fputs(" ", stdout); + continue; + } else continue; end= convert_dirname(name, pos, NullS); From 4618c974e4b467624d38bb256c2993afb4ac93b1 Mon Sep 17 00:00:00 2001 From: seppo Date: Sun, 23 Feb 2020 10:29:42 +0200 Subject: [PATCH 35/66] MDEV-21723 Async slave thread BF abort and replaying fixes (#1448) If async replication slave thread conflicts with cluster replication, then the async slave transaction should be BF aborted, and depending on the state of async slave transaction execution, potentially also replayed. There were problems in such BF abort implementation and the replaying was not started. This pull request contains fixes which make sure that if async slave thread is marked to abort and replay, it will complete carry out the rollback and release all locks and resources before starting the replaying. After replaying, async slave transactions is treated as successful, so the slave thread will continue as usual, handling next replication event. There is also new mtr test: galera.galera_slave_replay, which stresses both a certification failure for async slave thread and a successful BF abort followed by replaying. --- .../suite/galera/r/galera_slave_replay.result | 95 +++++++++ .../suite/galera/t/galera_slave_replay.cnf | 1 + .../suite/galera/t/galera_slave_replay.test | 198 ++++++++++++++++++ sql/log_event.cc | 8 + sql/slave.cc | 24 ++- sql/wsrep_thd.cc | 8 +- 6 files changed, 329 insertions(+), 5 deletions(-) create mode 100644 mysql-test/suite/galera/r/galera_slave_replay.result create mode 100644 mysql-test/suite/galera/t/galera_slave_replay.cnf create mode 100644 mysql-test/suite/galera/t/galera_slave_replay.test diff --git a/mysql-test/suite/galera/r/galera_slave_replay.result b/mysql-test/suite/galera/r/galera_slave_replay.result new file mode 100644 index 00000000000..760617be5f7 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_slave_replay.result @@ -0,0 +1,95 @@ +connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2; +connection node_2a; +connection node_1; +RESET MASTER; +connection node_2a; +START SLAVE; +connection node_1; +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1)) engine=innodb; +INSERT INTO t1 VALUES (1, 'a'); +INSERT INTO t1 VALUES (3, 'a'); +set binlog_format=STATEMENT; +SET AUTOCOMMIT=ON; +START TRANSACTION; +SELECT * FROM t1 FOR UPDATE; +f1 f2 +1 a +3 a +UPDATE t1 SET f2 = 'c' WHERE f1 > 1; +connection node_2a; +SET SESSION wsrep_sync_wait = 0; +connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3; +connection node_3; +SET SESSION wsrep_sync_wait = 0; +connection node_2a; +SET GLOBAL wsrep_provider_options = 'dbug=d,commit_monitor_enter_sync'; +SET GLOBAL debug_dbug = "d,sync.wsrep_apply_cb"; +connection node_3; +INSERT INTO test.t1 VALUES (2, 'b'); +connection node_1; +COMMIT; +connection node_2a; +SET SESSION wsrep_on = 0; +SET SESSION wsrep_on = 1; +SET GLOBAL debug_dbug = ""; +SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; +connection node_2a; +SET GLOBAL wsrep_provider_options = 'dbug='; +SET GLOBAL wsrep_provider_options = 'signal=commit_monitor_enter_sync'; +connection node_1; +SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'a'; +COUNT(*) = 1 +1 +SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'c'; +COUNT(*) = 1 +1 +SELECT * FROM t1; +f1 f2 +1 a +3 c +connection node_2a; +set session wsrep_sync_wait=15; +set session wsrep_sync_wait=0; +wsrep_local_replays +1 +SELECT * FROM t1; +f1 f2 +1 a +2 b +3 c +SET DEBUG_SYNC = "RESET"; +# +# test phase with real abort +# +connection node_1; +set binlog_format=ROW; +insert into t1 values (4, 'd'); +SET AUTOCOMMIT=ON; +START TRANSACTION; +UPDATE t1 SET f2 = 'd' WHERE f1 = 3; +connection node_2a; +SET GLOBAL wsrep_provider_options = 'dbug=d,commit_monitor_enter_sync'; +SET GLOBAL debug_dbug = "d,sync.wsrep_apply_cb"; +connection node_3; +UPDATE test.t1 SET f2 = 'e' WHERE f1 = 3; +connection node_1; +COMMIT; +connection node_2a; +SET GLOBAL debug_dbug = ""; +SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; +connection node_2a; +SET GLOBAL wsrep_provider_options = 'dbug='; +SET GLOBAL wsrep_provider_options = 'signal=commit_monitor_enter_sync'; +SET DEBUG_SYNC = "RESET"; +connection node_2a; +set session wsrep_sync_wait=15; +SELECT COUNT(*) = 1 FROM test.t1 WHERE f2 = 'e'; +COUNT(*) = 1 +1 +set session wsrep_sync_wait=0; +STOP SLAVE; +RESET SLAVE; +DROP TABLE t1; +connection node_1; +DROP TABLE t1; +RESET MASTER; diff --git a/mysql-test/suite/galera/t/galera_slave_replay.cnf b/mysql-test/suite/galera/t/galera_slave_replay.cnf new file mode 100644 index 00000000000..9449ec9cf40 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_slave_replay.cnf @@ -0,0 +1 @@ +!include ../galera_2nodes_as_slave.cnf diff --git a/mysql-test/suite/galera/t/galera_slave_replay.test b/mysql-test/suite/galera/t/galera_slave_replay.test new file mode 100644 index 00000000000..1d133e90e88 --- /dev/null +++ b/mysql-test/suite/galera/t/galera_slave_replay.test @@ -0,0 +1,198 @@ +# +# This test tests the operation of transaction replay for async replication slave. +# If a potentially conflicting galera transaction arrives at +# just the right time during the commit and has lock conflict with async replication transaction +# applied by slave SQL thread, then the async replication transaction should either abort +# or rollback and replay (depending on the nature of lock conflict). +# + +--source include/have_innodb.inc +--source include/have_debug_sync.inc + +--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 + +--connection node_2a +--source include/galera_cluster.inc +#--source suite/galera/include/galera_have_debug_sync.inc + +# +# node 1 is native MariaDB server operating as async replication master +# +--connection node_1 +RESET MASTER; + +--connection node_2a +# +# count the number of wsrep replay's done in the node +# +--let $wsrep_local_replays_old = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays'` + + +# +# nodes 2 and 3 form a galera cluster, node 2 operates as slave for native MariaDB naster in node 1 +# +--disable_query_log +--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_USER='root', MASTER_PORT=$NODE_MYPORT_1; +--enable_query_log +START SLAVE; + +--connection node_1 +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1)) engine=innodb; +INSERT INTO t1 VALUES (1, 'a'); +INSERT INTO t1 VALUES (3, 'a'); + +# +# use statement format replication to cause a false positive conflict with async replication transaction +# and galera replication. The conflict will be on GAP lock, and slave SQL thread should rollback +# and replay +# +set binlog_format=STATEMENT; + +SET AUTOCOMMIT=ON; +START TRANSACTION; + +SELECT * FROM t1 FOR UPDATE; +UPDATE t1 SET f2 = 'c' WHERE f1 > 1; + +--connection node_2a +# wait for create table and inserts to be replicated from master +SET SESSION wsrep_sync_wait = 0; +--let $wait_condition = SELECT COUNT(*) = 2 FROM test.t1; +--source include/wait_condition.inc + +# wait for create table and inserts to be replicated in cluster +--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 +--connection node_3 +SET SESSION wsrep_sync_wait = 0; +--let $wait_condition = SELECT COUNT(*) = 2 FROM test.t1; +--source include/wait_condition.inc + +--connection node_2a +# Block the future commit of async replication +--let $galera_sync_point = commit_monitor_enter_sync +--source include/galera_set_sync_point.inc + +# block also the applier before applying begins +SET GLOBAL debug_dbug = "d,sync.wsrep_apply_cb"; + +# +# now inject a conflicting insert from node 3, it will replicate with +# earlier seqno (than async transaction) and pause before applying in node 2 +# +--connection node_3 +INSERT INTO test.t1 VALUES (2, 'b'); + +# +# send the update from master, this will succeed here, beceuase of async replication. +# async replication will apply this in node 2 and pause before commit phase, +--connection node_1 +--error 0 +COMMIT; + +# Wait until async slave commit is blocked in node_2 +--connection node_2a +--source include/galera_wait_sync_point.inc + +# +# release the applier +# note: have to clear wsrep_apply_cb sync point first, as async replication will go for replay +# and as this sync point, after BF applier is released to progress +# +SET GLOBAL debug_dbug = ""; +SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; + +# Unblock the async slave commit +--connection node_2a +--source include/galera_clear_sync_point.inc +--source include/galera_signal_sync_point.inc + +--connection node_1 + +SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'a'; +SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'c'; +SELECT * FROM t1; + +--connection node_2a + +# wsrep_local_replays has increased by 1 +set session wsrep_sync_wait=15; +--let $wsrep_local_replays_new = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_replays'` +set session wsrep_sync_wait=0; + +--disable_query_log +--eval SELECT $wsrep_local_replays_new - $wsrep_local_replays_old = 1 AS wsrep_local_replays; +--enable_query_log + +# +# replaying of async transaction should be effective, and row 3 having 'c' in f2 +# +SELECT * FROM t1; +SET DEBUG_SYNC = "RESET"; + +#******************************************************************************** +# test phase 2 +#******************************************************************************** + +--echo # +--echo # test phase with real abort +--echo # + +--connection node_1 + +set binlog_format=ROW; + +insert into t1 values (4, 'd'); + +SET AUTOCOMMIT=ON; +START TRANSACTION; + +UPDATE t1 SET f2 = 'd' WHERE f1 = 3; + +--connection node_2a +# wait for the last insert to be replicated from master +--let $wait_condition = SELECT COUNT(*) = 4 FROM test.t1; +--source include/wait_condition.inc + +# Block the commit +--let $galera_sync_point = commit_monitor_enter_sync +--source include/galera_set_sync_point.inc + +# block applier +SET GLOBAL debug_dbug = "d,sync.wsrep_apply_cb"; + +# Inject a conflicting update from node 3 +--connection node_3 +UPDATE test.t1 SET f2 = 'e' WHERE f1 = 3; + +# send the update from master +--connection node_1 +--error 0 +COMMIT; + +--connection node_2a + +# release the applier +SET GLOBAL debug_dbug = ""; +SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; + + +# Unblock the async slave commit +--connection node_2a +--source include/galera_clear_sync_point.inc +--source include/galera_signal_sync_point.inc +SET DEBUG_SYNC = "RESET"; + +--connection node_2a + +set session wsrep_sync_wait=15; +SELECT COUNT(*) = 1 FROM test.t1 WHERE f2 = 'e'; +set session wsrep_sync_wait=0; + +STOP SLAVE; +RESET SLAVE; + +DROP TABLE t1; + +--connection node_1 +DROP TABLE t1; +RESET MASTER; diff --git a/sql/log_event.cc b/sql/log_event.cc index d5066fdabdf..29cb4d6d7d7 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -8567,8 +8567,16 @@ int Xid_log_event::do_apply_event(rpl_group_info *rgi) res= trans_commit(thd); /* Automatically rolls back on error. */ thd->mdl_context.release_transactional_locks(); +#ifdef WITH_WSREP + if (WSREP(thd)) mysql_mutex_lock(&thd->LOCK_thd_data); + if ((!res || (WSREP(thd) && thd->wsrep_conflict_state == MUST_REPLAY)) && sub_id) +#else if (!res && sub_id) +#endif /* WITH_WSREP */ rpl_global_gtid_slave_state->update_state_hash(sub_id, >id, rgi); +#ifdef WITH_WSREP + if (WSREP(thd)) mysql_mutex_unlock(&thd->LOCK_thd_data); +#endif /* WITH_WSREP */ /* Increment the global status commit count variable diff --git a/sql/slave.cc b/sql/slave.cc index 01a86979648..3f8c1ce546b 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -3567,14 +3567,34 @@ apply_event_and_update_pos_apply(Log_event* ev, THD* thd, rpl_group_info *rgi, exec_res= ev->apply_event(rgi); #ifdef WITH_WSREP - if (exec_res && thd->wsrep_conflict_state != NO_CONFLICT) - { + if (exec_res) + { + switch (thd->wsrep_conflict_state) { + case NO_CONFLICT: break; + case MUST_REPLAY: + WSREP_DEBUG("SQL apply failed for MUST_REPLAY, res %d", exec_res); + mysql_mutex_lock(&thd->LOCK_thd_data); + wsrep_replay_transaction(thd); + switch (thd->wsrep_conflict_state) { + case NO_CONFLICT: + exec_res = 0; /* replaying succeeded, and slave may continue */ + break; + case ABORTED: break; /* replaying has failed, trx is rolled back */ + default: + WSREP_WARN("unexpected result of slave transaction replaying: %lld, %d", + thd->thread_id, thd->wsrep_conflict_state); + } + mysql_mutex_unlock(&thd->LOCK_thd_data); + break; + default: WSREP_DEBUG("SQL apply failed, res %d conflict state: %d", exec_res, thd->wsrep_conflict_state); rli->abort_slave= 1; rli->report(ERROR_LEVEL, ER_UNKNOWN_COM_ERROR, rgi->gtid_info(), "Node has dropped from cluster"); + break; } + } #endif #ifndef DBUG_OFF diff --git a/sql/wsrep_thd.cc b/sql/wsrep_thd.cc index de2ad6d1a1f..a7b6e8ff1b1 100644 --- a/sql/wsrep_thd.cc +++ b/sql/wsrep_thd.cc @@ -153,8 +153,9 @@ static void wsrep_prepare_bf_thd(THD *thd, struct wsrep_thd_shadow* shadow) if (!thd->wsrep_rgi) thd->wsrep_rgi= wsrep_relay_group_init("wsrep_relay"); /* thd->system_thread_info.rpl_sql_info isn't initialized. */ - thd->system_thread_info.rpl_sql_info= - new rpl_sql_thread_info(thd->wsrep_rgi->rli->mi->rpl_filter); + if (!thd->slave_thread) + thd->system_thread_info.rpl_sql_info= + new rpl_sql_thread_info(thd->wsrep_rgi->rli->mi->rpl_filter); thd->wsrep_exec_mode= REPL_RECV; thd->net.vio= 0; @@ -181,7 +182,8 @@ static void wsrep_return_from_bf_mode(THD *thd, struct wsrep_thd_shadow* shadow) thd->user_time = shadow->user_time; thd->reset_db(shadow->db, shadow->db_length); - delete thd->system_thread_info.rpl_sql_info; + if (!thd->slave_thread) + delete thd->system_thread_info.rpl_sql_info; delete thd->wsrep_rgi->rli->mi; delete thd->wsrep_rgi->rli; From cd5d864fef7945bff1e4a0e8431f728fcf38dad7 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Tue, 25 Feb 2020 15:58:42 +1100 Subject: [PATCH 36/66] mariadb{,@}.service comment typo open-file-limit -> open-files-limit --- support-files/mariadb.service.in | 2 +- support-files/mariadb@.service.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/support-files/mariadb.service.in b/support-files/mariadb.service.in index ede97c04112..38f55cb7e8f 100644 --- a/support-files/mariadb.service.in +++ b/support-files/mariadb.service.in @@ -133,7 +133,7 @@ TimeoutStopSec=900 ## isn't executed. ## -# Number of files limit. previously [mysqld_safe] open-file-limit +# Number of files limit. previously [mysqld_safe] open-files-limit LimitNOFILE=16364 # Maximium core size. previously [mysqld_safe] core-file-size diff --git a/support-files/mariadb@.service.in b/support-files/mariadb@.service.in index 1f84b582e4e..475f3830a78 100644 --- a/support-files/mariadb@.service.in +++ b/support-files/mariadb@.service.in @@ -154,7 +154,7 @@ TimeoutStopSec=900 ## isn't executed. ## -# Number of files limit. previously [mysqld_safe] open-file-limit +# Number of files limit. previously [mysqld_safe] open-files-limit LimitNOFILE=16364 # Maximium core size. previously [mysqld_safe] core-file-size From c749eb2b41545377166a94e25b3ab84991729bab Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Tue, 15 Oct 2019 14:35:46 +1100 Subject: [PATCH 37/66] MDEV-16662: cmake: CMP0026 compatible for dtrace cmake enabling -DENABLE_DTRACE=ON is particularlly noisy with CMP0026 errors. Fixed in the same way as 6b53f9d781cc19cbec96c3eb048e6407021685a2 --- cmake/dtrace.cmake | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cmake/dtrace.cmake b/cmake/dtrace.cmake index 4e0f7501045..1e29ba685e0 100644 --- a/cmake/dtrace.cmake +++ b/cmake/dtrace.cmake @@ -147,11 +147,10 @@ FUNCTION(DTRACE_INSTRUMENT target) # Note: DTrace probes in static libraries are unusable currently # (see explanation for DTRACE_INSTRUMENT_STATIC_LIBS below) # but maybe one day this will be fixed. - GET_TARGET_PROPERTY(target_location ${target} LOCATION) ADD_CUSTOM_COMMAND( TARGET ${target} POST_BUILD - COMMAND ${CMAKE_AR} r ${target_location} ${outfile} - COMMAND ${CMAKE_RANLIB} ${target_location} + COMMAND ${CMAKE_AR} r $ ${outfile} + COMMAND ${CMAKE_RANLIB} $ ) # Used in DTRACE_INSTRUMENT_WITH_STATIC_LIBS SET(TARGET_OBJECT_DIRECTORY_${target} ${objdir} CACHE INTERNAL "") From f6b9a29820d5f30d4e607c8a334f8ffea861e940 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Tue, 15 Oct 2019 15:03:53 +1100 Subject: [PATCH 38/66] MDEV-16662: cmake remove empty INSTALL_DEBUG_TARGET No adverse effects since this was made a null function in 6b53f9d781cc19cbec96c3eb048e6407021685a2. This function had the last remaining cmake CMP0026 violation. --- cmake/install_macros.cmake | 87 --------------------------- cmake/plugin.cmake | 1 - mysys/CMakeLists.txt | 4 -- plugin/win_auth_client/CMakeLists.txt | 3 - 4 files changed, 95 deletions(-) diff --git a/cmake/install_macros.cmake b/cmake/install_macros.cmake index f28720e97bc..c40c196c3d0 100644 --- a/cmake/install_macros.cmake +++ b/cmake/install_macros.cmake @@ -262,93 +262,6 @@ GET_FILENAME_COMPONENT(BINARY_PARENTDIR ${CMAKE_BINARY_DIR} PATH) SET(DEBUGBUILDDIR "${BINARY_PARENTDIR}/debug" CACHE INTERNAL "Directory of debug build") -FUNCTION(INSTALL_DEBUG_TARGET target) - RETURN() # XXX unused? - CMAKE_PARSE_ARGUMENTS(ARG - "" - "DESTINATION;RENAME;PDB_DESTINATION;COMPONENT" - "" - ${ARGN} - ) - GET_TARGET_PROPERTY(target_type ${target} TYPE) - IF(ARG_RENAME) - SET(RENAME_PARAM RENAME ${ARG_RENAME}${CMAKE_${target_type}_SUFFIX}) - ELSE() - SET(RENAME_PARAM) - ENDIF() - IF(NOT ARG_DESTINATION) - MESSAGE(FATAL_ERROR "Need DESTINATION parameter for INSTALL_DEBUG_TARGET") - ENDIF() - GET_TARGET_PROPERTY(target_location ${target} LOCATION) - IF(CMAKE_GENERATOR MATCHES "Makefiles|Ninja") - STRING(REPLACE "${CMAKE_BINARY_DIR}" "${DEBUGBUILDDIR}" debug_target_location "${target_location}") - ELSE() - STRING(REPLACE "${CMAKE_CFG_INTDIR}" "Debug" debug_target_location "${target_location}" ) - ENDIF() - IF(NOT ARG_COMPONENT) - SET(ARG_COMPONENT DebugBinaries) - ENDIF() - - # Define permissions - # For executable files - SET(PERMISSIONS_EXECUTABLE - PERMISSIONS - OWNER_READ OWNER_WRITE OWNER_EXECUTE - GROUP_READ GROUP_EXECUTE - WORLD_READ WORLD_EXECUTE) - - # Permissions for shared library (honors CMAKE_INSTALL_NO_EXE which is - # typically set on Debian) - IF(CMAKE_INSTALL_SO_NO_EXE) - SET(PERMISSIONS_SHARED_LIBRARY - PERMISSIONS - OWNER_READ OWNER_WRITE - GROUP_READ - WORLD_READ) - ELSE() - SET(PERMISSIONS_SHARED_LIBRARY ${PERMISSIONS_EXECUTABLE}) - ENDIF() - - # Shared modules get the same permissions as shared libraries - SET(PERMISSIONS_MODULE_LIBRARY ${PERMISSIONS_SHARED_LIBRARY}) - - # Define permissions for static library - SET(PERMISSIONS_STATIC_LIBRARY - PERMISSIONS - OWNER_READ OWNER_WRITE - GROUP_READ - WORLD_READ) - - INSTALL(FILES ${debug_target_location} - DESTINATION ${ARG_DESTINATION} - ${RENAME_PARAM} - ${PERMISSIONS_${target_type}} - CONFIGURATIONS Release RelWithDebInfo - COMPONENT ${ARG_COMPONENT} - OPTIONAL) - - IF(MSVC) - GET_FILENAME_COMPONENT(ext ${debug_target_location} EXT) - STRING(REPLACE "${ext}" ".pdb" debug_pdb_target_location "${debug_target_location}" ) - IF (RENAME_PARAM) - IF(NOT ARG_PDB_DESTINATION) - STRING(REPLACE "${ext}" ".pdb" "${ARG_RENAME}" pdb_rename) - SET(PDB_RENAME_PARAM RENAME "${pdb_rename}") - ENDIF() - ENDIF() - IF(NOT ARG_PDB_DESTINATION) - SET(ARG_PDB_DESTINATION "${ARG_DESTINATION}") - ENDIF() - INSTALL(FILES ${debug_pdb_target_location} - DESTINATION ${ARG_PDB_DESTINATION} - ${PDB_RENAME_PARAM} - CONFIGURATIONS Release RelWithDebInfo - COMPONENT ${ARG_COMPONENT} - OPTIONAL) - ENDIF() -ENDFUNCTION() - - FUNCTION(INSTALL_MYSQL_TEST from to) IF(INSTALL_MYSQLTESTDIR) INSTALL( diff --git a/cmake/plugin.cmake b/cmake/plugin.cmake index 5a1e8f81f0a..486f5b00590 100644 --- a/cmake/plugin.cmake +++ b/cmake/plugin.cmake @@ -249,7 +249,6 @@ MACRO(MYSQL_ADD_PLUGIN) SET(ARG_COMPONENT Server) ENDIF() MYSQL_INSTALL_TARGETS(${target} DESTINATION ${INSTALL_PLUGINDIR} COMPONENT ${ARG_COMPONENT}) - #INSTALL_DEBUG_TARGET(${target} DESTINATION ${INSTALL_PLUGINDIR}/debug COMPONENT ${ARG_COMPONENT}) ENDIF() GET_FILENAME_COMPONENT(subpath ${CMAKE_CURRENT_SOURCE_DIR} NAME) diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt index 438d6b428e0..0a61c856506 100644 --- a/mysys/CMakeLists.txt +++ b/mysys/CMakeLists.txt @@ -102,7 +102,3 @@ SET_TARGET_PROPERTIES(thr_timer PROPERTIES COMPILE_FLAGS "-DMAIN") ADD_EXECUTABLE(test_hash hash.c) TARGET_LINK_LIBRARIES(test_hash mysys) SET_TARGET_PROPERTIES(test_hash PROPERTIES COMPILE_FLAGS "-DMAIN") - -IF(MSVC) - INSTALL_DEBUG_TARGET(mysys DESTINATION ${INSTALL_LIBDIR}/debug) -ENDIF() diff --git a/plugin/win_auth_client/CMakeLists.txt b/plugin/win_auth_client/CMakeLists.txt index 435c5b8966a..8c7696347aa 100644 --- a/plugin/win_auth_client/CMakeLists.txt +++ b/plugin/win_auth_client/CMakeLists.txt @@ -31,7 +31,4 @@ IF(WIN32) LINK_LIBRARIES Secur32 MODULE_ONLY COMPONENT ClientPlugins) - #IF(MSVC) - # INSTALL_DEBUG_TARGET(auth_win_client DESTINATION ${INSTALL_LIBDIR}/debug) - #ENDIF() ENDIF(WIN32) From cfa0506f8a7bc9855cbc8869c9cfbb4e9faf21eb Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Tue, 25 Feb 2020 00:47:03 -0800 Subject: [PATCH 39/66] MDEV-21554 Crash in JOIN_CACHE_BKAH::skip_index_tuple when mrr=on and join_cache_level=6+ The patch fixes two similar bugs in the commit 8eeb689e9fc57afe19a8dbff354b5f9f167867a9 that added multi_range_read support to partitions. The commit opened a possibility to join a partition table using BKA+MRR. However in some cases it could lead to wrong results or even crashes. This could happened when - index condition pushdown was used to join the table or - the joined table was an inner table of an outer join and 'not exist' optimization was applied or - the join table was the inner table of a semi-join and the first match optimization was applied The bugs were in the code of the call-back functions - partition_multi_range_key_skip_record() and - partition_multi_range_key_skip_index_tuple(). Each of this function consist only of an invocation of another function. Yet a wrong parameter was passed at this invocation. The fix was suggested by Sergey Petrunia and it is apparently in line with original design. The corresponding comprehensive test cases demonstrating the problems caused by the bugs were constructed by me. --- mysql-test/include/partition_mrr.inc | 92 +++++++++++ mysql-test/main/partition_mrr_aria.result | 157 +++++++++++++++++++ mysql-test/main/partition_mrr_innodb.result | 157 +++++++++++++++++++ mysql-test/main/partition_mrr_myisam.result | 164 +++++++++++++++++++- sql/ha_partition.cc | 6 +- 5 files changed, 569 insertions(+), 7 deletions(-) diff --git a/mysql-test/include/partition_mrr.inc b/mysql-test/include/partition_mrr.inc index 4c285791ec7..f372cccfdd2 100644 --- a/mysql-test/include/partition_mrr.inc +++ b/mysql-test/include/partition_mrr.inc @@ -36,11 +36,103 @@ insert into t3 select 123456 from t1 A, t1 B; +set @save_optimizer_switch=@@optimizer_switch; + set optimizer_switch='mrr=on'; --replace_column 9 # explain select * from t3 force index (key_col) where key_col < 3; select * from t3 force index (key_col) where key_col < 3; +set optimizer_switch=@save_optimizer_switch; + drop table t1,t3; +--echo # +--echo # MDEV-21544: partitioned table is joined with BKA+MRR +--echo # + +set @save_join_cache_level=@@join_cache_level; +set @save_optimizer_switch=@@optimizer_switch; + +create table t0 ( + tp int, a int, b int not null, c varchar(12), index idx (a,b) +); +insert into t0 values +(1,3,30,'yyzy'), (1,3,30,'yxxyy'), (1,3,30,'yyxy'), (1,3,30,'xxyy'), +(1,3,30,'yyxz'), (1,3,30,'yyzz'), (1,3,30,'xxyzy'), (1,3,30,'yyyy'), +(1,3,30,'yzzy'), (1,93,30,'zzzy'), +(2,3,40,'yxx'), (2,4,40,'xx'), (2,3,10,'zxz'), +(2,3,40,'yyx'), (2,4,40,'xxx'), (2,3,10,'zyyz'), +(2,3,40,'xzzzz'), (2,4,40,'yyyxx'), (2,3,10,'zyz'), +(2,3,40,'xxx'), (2,4,40,'xx'), (2,3,10,'zzz'), +(2,3,40,'yyxzx'), (2,4,40,'xyx'), (2,3,10,'xzz'), +(2,3,40,'xxxzz'), (2,4,40,'xxz'), (2,3,10,'zzzy'), +(2,3,40,'zzxxx'), (2,4,40,'zxx'), (2,3,10,'yzzz'), +(2,3,40,'xyyxx'), (2,4,40,'xzzzx'), (2,3,10,'zzxxz'), +(2,3,40,'yzxxx'), (2,4,40,'xxzy'), (2,3,10,'zzzyx'), +(2,93,40,'xzx'), (2,94,40,'xz'), (2,93,10,'zyyyz'), +(3,4,30,'yx'), (3,4,30,'yyxxx'), (3,4,30,'zzyy'), (3,4,30,'zxyy'), +(3,4,30,'xxyy'), (3,4,30,'yyzx'), (3,4,30,'zyyy'), (3,4,30,'yzy'), +(3,4,30,'zzzyy'), (3,94,30,'yyz'); + +create table t1 ( + tp int, a int, b int not null, c varchar(12), index idx (a,b) +) +partition by list (tp) +( partition p1 values in (1), + partition p2 values in (2), + partition p3 values in (3)); +insert into t1 select * from t0; + +# tables t0 and t1 contain the same set of records. + +create table t2 (a int, index idx(a)); +insert into t2 values +(1), (2), (3), (4), (5); +insert into t2 select a+10 from t2; +insert into t2 select a+20 from t2; + +analyze table t0,t1,t2; + +set join_cache_level=6; +set optimizer_switch='mrr=on'; + +let $q1= +select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = t2.a-1; +eval explain extended $q1; +eval $q1; + +let $q2= +select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = t2.a-1; +eval explain extended $q2; +eval $q2; + +let $q1= +select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = 4; +eval explain extended $q1; +eval $q1; + +let $q2= +select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = 4; +eval explain extended $q2; +eval $q2; + +insert into t2 values +(3), (4), (5); +analyze table t2; + +let $q1= +select * from t2 left join t0 on t2.a=t0.a where t2.a in (3,4) and t0.b is null; +eval explain extended $q1; +eval $q1; + +let $q2= +select * from t2 left join t1 on t2.a=t1.a where t2.a in (3,4) and t1.b is null; +eval explain extended $q2; +eval $q2; + +set join_cache_level=@save_join_cache_level; +set optimizer_switch=@save_optimizer_switch; + +drop table t0,t1,t2; diff --git a/mysql-test/main/partition_mrr_aria.result b/mysql-test/main/partition_mrr_aria.result index 7a0c35a309e..c2be6ee4703 100644 --- a/mysql-test/main/partition_mrr_aria.result +++ b/mysql-test/main/partition_mrr_aria.result @@ -39,6 +39,7 @@ A.a, B.a, 123456 from t1 A, t1 B; +set @save_optimizer_switch=@@optimizer_switch; set optimizer_switch='mrr=on'; explain select * from t3 force index (key_col) where key_col < 3; @@ -76,4 +77,160 @@ ID part_id key_col col2 27 7 2 123456 28 8 2 123456 29 9 2 123456 +set optimizer_switch=@save_optimizer_switch; drop table t1,t3; +# +# MDEV-21544: partitioned table is joined with BKA+MRR +# +set @save_join_cache_level=@@join_cache_level; +set @save_optimizer_switch=@@optimizer_switch; +create table t0 ( +tp int, a int, b int not null, c varchar(12), index idx (a,b) +); +insert into t0 values +(1,3,30,'yyzy'), (1,3,30,'yxxyy'), (1,3,30,'yyxy'), (1,3,30,'xxyy'), +(1,3,30,'yyxz'), (1,3,30,'yyzz'), (1,3,30,'xxyzy'), (1,3,30,'yyyy'), +(1,3,30,'yzzy'), (1,93,30,'zzzy'), +(2,3,40,'yxx'), (2,4,40,'xx'), (2,3,10,'zxz'), +(2,3,40,'yyx'), (2,4,40,'xxx'), (2,3,10,'zyyz'), +(2,3,40,'xzzzz'), (2,4,40,'yyyxx'), (2,3,10,'zyz'), +(2,3,40,'xxx'), (2,4,40,'xx'), (2,3,10,'zzz'), +(2,3,40,'yyxzx'), (2,4,40,'xyx'), (2,3,10,'xzz'), +(2,3,40,'xxxzz'), (2,4,40,'xxz'), (2,3,10,'zzzy'), +(2,3,40,'zzxxx'), (2,4,40,'zxx'), (2,3,10,'yzzz'), +(2,3,40,'xyyxx'), (2,4,40,'xzzzx'), (2,3,10,'zzxxz'), +(2,3,40,'yzxxx'), (2,4,40,'xxzy'), (2,3,10,'zzzyx'), +(2,93,40,'xzx'), (2,94,40,'xz'), (2,93,10,'zyyyz'), +(3,4,30,'yx'), (3,4,30,'yyxxx'), (3,4,30,'zzyy'), (3,4,30,'zxyy'), +(3,4,30,'xxyy'), (3,4,30,'yyzx'), (3,4,30,'zyyy'), (3,4,30,'yzy'), +(3,4,30,'zzzyy'), (3,94,30,'yyz'); +create table t1 ( +tp int, a int, b int not null, c varchar(12), index idx (a,b) +) +partition by list (tp) +( partition p1 values in (1), +partition p2 values in (2), +partition p3 values in (3)); +insert into t1 select * from t0; +create table t2 (a int, index idx(a)); +insert into t2 values +(1), (2), (3), (4), (5); +insert into t2 select a+10 from t2; +insert into t2 select a+20 from t2; +analyze table t0,t1,t2; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +set join_cache_level=6; +set optimizer_switch='mrr=on'; +explain extended select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = t2.a-1; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index +1 SIMPLE t0 ref idx idx 5 test.t2.a 13 100.00 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan +Warnings: +Note 1003 select `test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t0` join `test`.`t2` where `test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` / 10 = `test`.`t2`.`a` - 1 +select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = t2.a-1; +tp a b c a +3 4 30 yx 4 +3 4 30 yyxxx 4 +3 4 30 zzyy 4 +3 4 30 zxyy 4 +3 4 30 xxyy 4 +3 4 30 yyzx 4 +3 4 30 zyyy 4 +3 4 30 yzy 4 +3 4 30 zzzyy 4 +explain extended select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = t2.a-1; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index +1 SIMPLE t1 ref idx idx 5 test.t2.a 8 100.00 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan +Warnings: +Note 1003 select `test`.`t1`.`tp` AS `tp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t1`.`b` / 10 = `test`.`t2`.`a` - 1 +select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = t2.a-1; +tp a b c a +3 4 30 yx 4 +3 4 30 yyxxx 4 +3 4 30 zzyy 4 +3 4 30 zxyy 4 +3 4 30 xxyy 4 +3 4 30 yyzx 4 +3 4 30 zyyy 4 +3 4 30 yzy 4 +3 4 30 zzzyy 4 +explain extended select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = 4; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index +1 SIMPLE t0 ref idx idx 5 test.t2.a 13 100.00 Using index condition; Using join buffer (flat, BKA join); Rowid-ordered scan +Warnings: +Note 1003 select `test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t0` join `test`.`t2` where `test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` / 10 = 4 +select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = 4; +tp a b c a +2 3 40 yxx 3 +2 4 40 xx 4 +2 3 40 yyx 3 +2 4 40 xxx 4 +2 3 40 xzzzz 3 +2 4 40 yyyxx 4 +2 3 40 xxx 3 +2 4 40 xx 4 +2 3 40 yyxzx 3 +2 4 40 xyx 4 +2 3 40 xxxzz 3 +2 4 40 xxz 4 +2 3 40 zzxxx 3 +2 4 40 zxx 4 +2 3 40 xyyxx 3 +2 4 40 xzzzx 4 +2 3 40 yzxxx 3 +2 4 40 xxzy 4 +explain extended select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = 4; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index +1 SIMPLE t1 ref idx idx 5 test.t2.a 5 100.00 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan +Warnings: +Note 1003 select `test`.`t1`.`tp` AS `tp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t1`.`b` / 10 = 4 +select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = 4; +tp a b c a +2 3 40 yxx 3 +2 4 40 xx 4 +2 3 40 yyx 3 +2 4 40 xxx 4 +2 3 40 xzzzz 3 +2 4 40 yyyxx 4 +2 3 40 xxx 3 +2 4 40 xx 4 +2 3 40 yyxzx 3 +2 4 40 xyx 4 +2 3 40 xxxzz 3 +2 4 40 xxz 4 +2 3 40 zzxxx 3 +2 4 40 zxx 4 +2 3 40 xyyxx 3 +2 4 40 xzzzx 4 +2 3 40 yzxxx 3 +2 4 40 xxzy 4 +insert into t2 values +(3), (4), (5); +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +explain extended select * from t2 left join t0 on t2.a=t0.a where t2.a in (3,4) and t0.b is null; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 range idx idx 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t0 ref idx idx 5 test.t2.a 13 100.00 Using where; Not exists; Using join buffer (flat, BKA join); Rowid-ordered scan +Warnings: +Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c` from `test`.`t2` left join `test`.`t0` on(`test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` is not null) where `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` is null +select * from t2 left join t0 on t2.a=t0.a where t2.a in (3,4) and t0.b is null; +a tp a b c +explain extended select * from t2 left join t1 on t2.a=t1.a where t2.a in (3,4) and t1.b is null; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 range idx idx 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 ref idx idx 5 test.t2.a 5 100.00 Using where; Not exists; Using join buffer (flat, BKA join); Rowid-ordered scan +Warnings: +Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t1`.`tp` AS `tp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t2` left join `test`.`t1` on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` is not null) where `test`.`t2`.`a` in (3,4) and `test`.`t1`.`b` is null +select * from t2 left join t1 on t2.a=t1.a where t2.a in (3,4) and t1.b is null; +a tp a b c +set join_cache_level=@save_join_cache_level; +set optimizer_switch=@save_optimizer_switch; +drop table t0,t1,t2; diff --git a/mysql-test/main/partition_mrr_innodb.result b/mysql-test/main/partition_mrr_innodb.result index c188f7e9929..ecef67817a3 100644 --- a/mysql-test/main/partition_mrr_innodb.result +++ b/mysql-test/main/partition_mrr_innodb.result @@ -39,6 +39,7 @@ A.a, B.a, 123456 from t1 A, t1 B; +set @save_optimizer_switch=@@optimizer_switch; set optimizer_switch='mrr=on'; explain select * from t3 force index (key_col) where key_col < 3; @@ -76,4 +77,160 @@ ID part_id key_col col2 27 7 2 123456 28 8 2 123456 29 9 2 123456 +set optimizer_switch=@save_optimizer_switch; drop table t1,t3; +# +# MDEV-21544: partitioned table is joined with BKA+MRR +# +set @save_join_cache_level=@@join_cache_level; +set @save_optimizer_switch=@@optimizer_switch; +create table t0 ( +tp int, a int, b int not null, c varchar(12), index idx (a,b) +); +insert into t0 values +(1,3,30,'yyzy'), (1,3,30,'yxxyy'), (1,3,30,'yyxy'), (1,3,30,'xxyy'), +(1,3,30,'yyxz'), (1,3,30,'yyzz'), (1,3,30,'xxyzy'), (1,3,30,'yyyy'), +(1,3,30,'yzzy'), (1,93,30,'zzzy'), +(2,3,40,'yxx'), (2,4,40,'xx'), (2,3,10,'zxz'), +(2,3,40,'yyx'), (2,4,40,'xxx'), (2,3,10,'zyyz'), +(2,3,40,'xzzzz'), (2,4,40,'yyyxx'), (2,3,10,'zyz'), +(2,3,40,'xxx'), (2,4,40,'xx'), (2,3,10,'zzz'), +(2,3,40,'yyxzx'), (2,4,40,'xyx'), (2,3,10,'xzz'), +(2,3,40,'xxxzz'), (2,4,40,'xxz'), (2,3,10,'zzzy'), +(2,3,40,'zzxxx'), (2,4,40,'zxx'), (2,3,10,'yzzz'), +(2,3,40,'xyyxx'), (2,4,40,'xzzzx'), (2,3,10,'zzxxz'), +(2,3,40,'yzxxx'), (2,4,40,'xxzy'), (2,3,10,'zzzyx'), +(2,93,40,'xzx'), (2,94,40,'xz'), (2,93,10,'zyyyz'), +(3,4,30,'yx'), (3,4,30,'yyxxx'), (3,4,30,'zzyy'), (3,4,30,'zxyy'), +(3,4,30,'xxyy'), (3,4,30,'yyzx'), (3,4,30,'zyyy'), (3,4,30,'yzy'), +(3,4,30,'zzzyy'), (3,94,30,'yyz'); +create table t1 ( +tp int, a int, b int not null, c varchar(12), index idx (a,b) +) +partition by list (tp) +( partition p1 values in (1), +partition p2 values in (2), +partition p3 values in (3)); +insert into t1 select * from t0; +create table t2 (a int, index idx(a)); +insert into t2 values +(1), (2), (3), (4), (5); +insert into t2 select a+10 from t2; +insert into t2 select a+20 from t2; +analyze table t0,t1,t2; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +set join_cache_level=6; +set optimizer_switch='mrr=on'; +explain extended select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = t2.a-1; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index +1 SIMPLE t0 ref idx idx 5 test.t2.a 13 100.00 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan +Warnings: +Note 1003 select `test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t0` join `test`.`t2` where `test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` / 10 = `test`.`t2`.`a` - 1 +select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = t2.a-1; +tp a b c a +3 4 30 yx 4 +3 4 30 yyxxx 4 +3 4 30 zzyy 4 +3 4 30 zxyy 4 +3 4 30 xxyy 4 +3 4 30 yyzx 4 +3 4 30 zyyy 4 +3 4 30 yzy 4 +3 4 30 zzzyy 4 +explain extended select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = t2.a-1; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index +1 SIMPLE t1 ref idx idx 5 test.t2.a 8 100.00 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan +Warnings: +Note 1003 select `test`.`t1`.`tp` AS `tp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t1`.`b` / 10 = `test`.`t2`.`a` - 1 +select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = t2.a-1; +tp a b c a +3 4 30 yx 4 +3 4 30 yyxxx 4 +3 4 30 zzyy 4 +3 4 30 zxyy 4 +3 4 30 xxyy 4 +3 4 30 yyzx 4 +3 4 30 zyyy 4 +3 4 30 yzy 4 +3 4 30 zzzyy 4 +explain extended select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = 4; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index +1 SIMPLE t0 ref idx idx 5 test.t2.a 13 100.00 Using index condition; Using join buffer (flat, BKA join); Rowid-ordered scan +Warnings: +Note 1003 select `test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t0` join `test`.`t2` where `test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` / 10 = 4 +select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = 4; +tp a b c a +2 3 40 yxx 3 +2 4 40 xx 4 +2 3 40 yyx 3 +2 4 40 xxx 4 +2 3 40 xzzzz 3 +2 4 40 yyyxx 4 +2 3 40 xxx 3 +2 4 40 xx 4 +2 3 40 yyxzx 3 +2 4 40 xyx 4 +2 3 40 xxxzz 3 +2 4 40 xxz 4 +2 3 40 zzxxx 3 +2 4 40 zxx 4 +2 3 40 xyyxx 3 +2 4 40 xzzzx 4 +2 3 40 yzxxx 3 +2 4 40 xxzy 4 +explain extended select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = 4; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index +1 SIMPLE t1 ref idx idx 5 test.t2.a 5 100.00 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan +Warnings: +Note 1003 select `test`.`t1`.`tp` AS `tp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t1`.`b` / 10 = 4 +select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = 4; +tp a b c a +2 3 40 yxx 3 +2 4 40 xx 4 +2 3 40 yyx 3 +2 4 40 xxx 4 +2 3 40 xzzzz 3 +2 4 40 yyyxx 4 +2 3 40 xxx 3 +2 4 40 xx 4 +2 3 40 yyxzx 3 +2 4 40 xyx 4 +2 3 40 xxxzz 3 +2 4 40 xxz 4 +2 3 40 zzxxx 3 +2 4 40 zxx 4 +2 3 40 xyyxx 3 +2 4 40 xzzzx 4 +2 3 40 yzxxx 3 +2 4 40 xxzy 4 +insert into t2 values +(3), (4), (5); +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +explain extended select * from t2 left join t0 on t2.a=t0.a where t2.a in (3,4) and t0.b is null; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 range idx idx 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t0 ref idx idx 5 test.t2.a 13 100.00 Using where; Not exists; Using join buffer (flat, BKA join); Rowid-ordered scan +Warnings: +Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c` from `test`.`t2` left join `test`.`t0` on(`test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` is not null) where `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` is null +select * from t2 left join t0 on t2.a=t0.a where t2.a in (3,4) and t0.b is null; +a tp a b c +explain extended select * from t2 left join t1 on t2.a=t1.a where t2.a in (3,4) and t1.b is null; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 range idx idx 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 ref idx idx 5 test.t2.a 5 100.00 Using where; Not exists; Using join buffer (flat, BKA join); Rowid-ordered scan +Warnings: +Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t1`.`tp` AS `tp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t2` left join `test`.`t1` on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` is not null) where `test`.`t2`.`a` in (3,4) and `test`.`t1`.`b` is null +select * from t2 left join t1 on t2.a=t1.a where t2.a in (3,4) and t1.b is null; +a tp a b c +set join_cache_level=@save_join_cache_level; +set optimizer_switch=@save_optimizer_switch; +drop table t0,t1,t2; diff --git a/mysql-test/main/partition_mrr_myisam.result b/mysql-test/main/partition_mrr_myisam.result index d989536324c..ff23982ff1a 100644 --- a/mysql-test/main/partition_mrr_myisam.result +++ b/mysql-test/main/partition_mrr_myisam.result @@ -39,6 +39,7 @@ A.a, B.a, 123456 from t1 A, t1 B; +set @save_optimizer_switch=@@optimizer_switch; set optimizer_switch='mrr=on'; explain select * from t3 force index (key_col) where key_col < 3; @@ -76,8 +77,164 @@ ID part_id key_col col2 27 7 2 123456 28 8 2 123456 29 9 2 123456 +set optimizer_switch=@save_optimizer_switch; drop table t1,t3; # +# MDEV-21544: partitioned table is joined with BKA+MRR +# +set @save_join_cache_level=@@join_cache_level; +set @save_optimizer_switch=@@optimizer_switch; +create table t0 ( +tp int, a int, b int not null, c varchar(12), index idx (a,b) +); +insert into t0 values +(1,3,30,'yyzy'), (1,3,30,'yxxyy'), (1,3,30,'yyxy'), (1,3,30,'xxyy'), +(1,3,30,'yyxz'), (1,3,30,'yyzz'), (1,3,30,'xxyzy'), (1,3,30,'yyyy'), +(1,3,30,'yzzy'), (1,93,30,'zzzy'), +(2,3,40,'yxx'), (2,4,40,'xx'), (2,3,10,'zxz'), +(2,3,40,'yyx'), (2,4,40,'xxx'), (2,3,10,'zyyz'), +(2,3,40,'xzzzz'), (2,4,40,'yyyxx'), (2,3,10,'zyz'), +(2,3,40,'xxx'), (2,4,40,'xx'), (2,3,10,'zzz'), +(2,3,40,'yyxzx'), (2,4,40,'xyx'), (2,3,10,'xzz'), +(2,3,40,'xxxzz'), (2,4,40,'xxz'), (2,3,10,'zzzy'), +(2,3,40,'zzxxx'), (2,4,40,'zxx'), (2,3,10,'yzzz'), +(2,3,40,'xyyxx'), (2,4,40,'xzzzx'), (2,3,10,'zzxxz'), +(2,3,40,'yzxxx'), (2,4,40,'xxzy'), (2,3,10,'zzzyx'), +(2,93,40,'xzx'), (2,94,40,'xz'), (2,93,10,'zyyyz'), +(3,4,30,'yx'), (3,4,30,'yyxxx'), (3,4,30,'zzyy'), (3,4,30,'zxyy'), +(3,4,30,'xxyy'), (3,4,30,'yyzx'), (3,4,30,'zyyy'), (3,4,30,'yzy'), +(3,4,30,'zzzyy'), (3,94,30,'yyz'); +create table t1 ( +tp int, a int, b int not null, c varchar(12), index idx (a,b) +) +partition by list (tp) +( partition p1 values in (1), +partition p2 values in (2), +partition p3 values in (3)); +insert into t1 select * from t0; +create table t2 (a int, index idx(a)); +insert into t2 values +(1), (2), (3), (4), (5); +insert into t2 select a+10 from t2; +insert into t2 select a+20 from t2; +analyze table t0,t1,t2; +Table Op Msg_type Msg_text +test.t0 analyze status OK +test.t1 analyze status OK +test.t2 analyze status OK +set join_cache_level=6; +set optimizer_switch='mrr=on'; +explain extended select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = t2.a-1; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index +1 SIMPLE t0 ref idx idx 5 test.t2.a 13 100.00 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan +Warnings: +Note 1003 select `test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t0` join `test`.`t2` where `test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` / 10 = `test`.`t2`.`a` - 1 +select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = t2.a-1; +tp a b c a +3 4 30 yx 4 +3 4 30 yyxxx 4 +3 4 30 zzyy 4 +3 4 30 zxyy 4 +3 4 30 xxyy 4 +3 4 30 yyzx 4 +3 4 30 zyyy 4 +3 4 30 yzy 4 +3 4 30 zzzyy 4 +explain extended select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = t2.a-1; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index +1 SIMPLE t1 ref idx idx 5 test.t2.a 8 100.00 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan +Warnings: +Note 1003 select `test`.`t1`.`tp` AS `tp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t1`.`b` / 10 = `test`.`t2`.`a` - 1 +select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = t2.a-1; +tp a b c a +3 4 30 yx 4 +3 4 30 yyxxx 4 +3 4 30 zzyy 4 +3 4 30 zxyy 4 +3 4 30 xxyy 4 +3 4 30 yyzx 4 +3 4 30 zyyy 4 +3 4 30 yzy 4 +3 4 30 zzzyy 4 +explain extended select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = 4; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index +1 SIMPLE t0 ref idx idx 5 test.t2.a 13 100.00 Using index condition; Using join buffer (flat, BKA join); Rowid-ordered scan +Warnings: +Note 1003 select `test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t0` join `test`.`t2` where `test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` / 10 = 4 +select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = 4; +tp a b c a +2 3 40 yxx 3 +2 4 40 xx 4 +2 3 40 yyx 3 +2 4 40 xxx 4 +2 3 40 xzzzz 3 +2 4 40 yyyxx 4 +2 3 40 xxx 3 +2 4 40 xx 4 +2 3 40 yyxzx 3 +2 4 40 xyx 4 +2 3 40 xxxzz 3 +2 4 40 xxz 4 +2 3 40 zzxxx 3 +2 4 40 zxx 4 +2 3 40 xyyxx 3 +2 4 40 xzzzx 4 +2 3 40 yzxxx 3 +2 4 40 xxzy 4 +explain extended select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = 4; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 range idx idx 5 NULL 2 100.00 Using where; Using index +1 SIMPLE t1 ref idx idx 5 test.t2.a 5 100.00 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan +Warnings: +Note 1003 select `test`.`t1`.`tp` AS `tp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c`,`test`.`t2`.`a` AS `a` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` in (3,4) and `test`.`t1`.`b` / 10 = 4 +select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = 4; +tp a b c a +2 3 40 yxx 3 +2 4 40 xx 4 +2 3 40 yyx 3 +2 4 40 xxx 4 +2 3 40 xzzzz 3 +2 4 40 yyyxx 4 +2 3 40 xxx 3 +2 4 40 xx 4 +2 3 40 yyxzx 3 +2 4 40 xyx 4 +2 3 40 xxxzz 3 +2 4 40 xxz 4 +2 3 40 zzxxx 3 +2 4 40 zxx 4 +2 3 40 xyyxx 3 +2 4 40 xzzzx 4 +2 3 40 yzxxx 3 +2 4 40 xxzy 4 +insert into t2 values +(3), (4), (5); +analyze table t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +explain extended select * from t2 left join t0 on t2.a=t0.a where t2.a in (3,4) and t0.b is null; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 range idx idx 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t0 ref idx idx 5 test.t2.a 13 100.00 Using where; Not exists; Using join buffer (flat, BKA join); Rowid-ordered scan +Warnings: +Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t0`.`tp` AS `tp`,`test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t0`.`c` AS `c` from `test`.`t2` left join `test`.`t0` on(`test`.`t0`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` is not null) where `test`.`t2`.`a` in (3,4) and `test`.`t0`.`b` is null +select * from t2 left join t0 on t2.a=t0.a where t2.a in (3,4) and t0.b is null; +a tp a b c +explain extended select * from t2 left join t1 on t2.a=t1.a where t2.a in (3,4) and t1.b is null; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 range idx idx 5 NULL 4 100.00 Using where; Using index +1 SIMPLE t1 ref idx idx 5 test.t2.a 5 100.00 Using where; Not exists; Using join buffer (flat, BKA join); Rowid-ordered scan +Warnings: +Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t1`.`tp` AS `tp`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t2` left join `test`.`t1` on(`test`.`t1`.`a` = `test`.`t2`.`a` and `test`.`t2`.`a` is not null) where `test`.`t2`.`a` in (3,4) and `test`.`t1`.`b` is null +select * from t2 left join t1 on t2.a=t1.a where t2.a in (3,4) and t1.b is null; +a tp a b c +set join_cache_level=@save_join_cache_level; +set optimizer_switch=@save_optimizer_switch; +drop table t0,t1,t2; +# # MDEV-21628: Index condition pushdown for a simple condition over # index fields is not used for ref access of partitioned tables when employing BKA # @@ -115,11 +272,8 @@ insert into t2 select a+10 from t2; insert into t2 select a+20 from t2; analyze table t0,t1,t2; Table Op Msg_type Msg_text -test.t0 analyze status Engine-independent statistics collected test.t0 analyze status OK -test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK -test.t2 analyze status Engine-independent statistics collected test.t2 analyze status OK set @tmp1=@@join_cache_level, @tmp2=@@optimizer_switch; set join_cache_level=6, optimizer_switch='mrr=on'; @@ -127,12 +281,12 @@ explain select * from t0,t2 where t2.a in (3,4) and t0.a=t2.a and (t0.b / 10) = 4; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 range idx idx 5 NULL 2 Using where; Using index -1 SIMPLE t0 ref idx idx 5 test.t2.a 12 Using index condition; Using join buffer (flat, BKA join); Rowid-ordered scan +1 SIMPLE t0 ref idx idx 5 test.t2.a 13 Using index condition; Using join buffer (flat, BKA join); Rowid-ordered scan # This will use "Using index condition(BKA)" explain select * from t1,t2 where t2.a in (3,4) and t1.a=t2.a and (t1.b / 10) = 4; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 range idx idx 5 NULL 2 Using where; Using index -1 SIMPLE t1 ref idx idx 5 test.t2.a 12 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan +1 SIMPLE t1 ref idx idx 5 test.t2.a 8 Using index condition(BKA); Using join buffer (flat, BKA join); Rowid-ordered scan set join_cache_level=@tmp1, optimizer_switch=@tmp2; drop table t0,t1,t2; diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 130c7f7e4d5..48610cabd4f 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -6264,9 +6264,10 @@ static bool partition_multi_range_key_skip_record(range_seq_t seq, { PARTITION_PART_KEY_MULTI_RANGE_HLD *hld= (PARTITION_PART_KEY_MULTI_RANGE_HLD *)seq; + PARTITION_KEY_MULTI_RANGE *pkmr= (PARTITION_KEY_MULTI_RANGE *)range_info; DBUG_ENTER("partition_multi_range_key_skip_record"); DBUG_RETURN(hld->partition->m_seq_if->skip_record(hld->partition->m_seq, - range_info, rowid)); + pkmr->ptr, rowid)); } @@ -6275,9 +6276,10 @@ static bool partition_multi_range_key_skip_index_tuple(range_seq_t seq, { PARTITION_PART_KEY_MULTI_RANGE_HLD *hld= (PARTITION_PART_KEY_MULTI_RANGE_HLD *)seq; + PARTITION_KEY_MULTI_RANGE *pkmr= (PARTITION_KEY_MULTI_RANGE *)range_info; DBUG_ENTER("partition_multi_range_key_skip_index_tuple"); DBUG_RETURN(hld->partition->m_seq_if->skip_index_tuple(hld->partition->m_seq, - range_info)); + pkmr->ptr)); } ha_rows ha_partition::multi_range_read_info_const(uint keyno, From a662cb9b4329abc6f3895fed97c80434e8f78b20 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Tue, 25 Feb 2020 14:55:15 +0300 Subject: [PATCH 40/66] Better comments --- sql/ha_partition.h | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/sql/ha_partition.h b/sql/ha_partition.h index fc6c8c4d570..6bc067af3e7 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -224,7 +224,7 @@ typedef struct st_partition_key_multi_range /* - List of ranges to be scanned in a certain [sub]partition. + List of ranges to be scanned in a certain [sub]partition The idea is that there's a list of ranges to be scanned in the table (formed by PARTITION_KEY_MULTI_RANGE structures), @@ -260,10 +260,10 @@ typedef struct st_partition_part_key_multi_range_hld /* Owner object */ ha_partition *partition; - // id of the the partition this structure is for + /* id of the the partition this structure is for */ uint32 part_id; - // Current range we're iterating through. + /* Current range we're iterating through */ PARTITION_PART_KEY_MULTI_RANGE *partition_part_key_multi_range; } PARTITION_PART_KEY_MULTI_RANGE_HLD; @@ -867,28 +867,31 @@ public: uint m_mrr_new_full_buffer_size; MY_BITMAP m_mrr_used_partitions; uint *m_stock_range_seq; - // not used: uint m_current_range_seq; + /* not used: uint m_current_range_seq; */ - // Value of mrr_mode passed to ha_partition::multi_range_read_init + /* Value of mrr_mode passed to ha_partition::multi_range_read_init */ uint m_mrr_mode; - // Value of n_ranges passed to ha_partition::multi_range_read_init + /* Value of n_ranges passed to ha_partition::multi_range_read_init */ uint m_mrr_n_ranges; /* Ordered MRR mode: m_range_info[N] has the range_id of the last record that - we've got from partition N. + we've got from partition N */ range_id_t *m_range_info; - // TRUE <=> This ha_partition::multi_range_read_next() call is the first one + /* + TRUE <=> This ha_partition::multi_range_read_next() call is the first one + */ bool m_multi_range_read_first; - // not used: uint m_mrr_range_init_flags; + + /* not used: uint m_mrr_range_init_flags; */ /* Number of elements in the list pointed by m_mrr_range_first. Not used */ uint m_mrr_range_length; - // Linked list of ranges to scan + /* Linked list of ranges to scan */ PARTITION_KEY_MULTI_RANGE *m_mrr_range_first; PARTITION_KEY_MULTI_RANGE *m_mrr_range_current; @@ -897,21 +900,19 @@ public: */ uint *m_part_mrr_range_length; - /* - For each partition: List of ranges to scan in this partition. - */ + /* For each partition: List of ranges to scan in this partition */ PARTITION_PART_KEY_MULTI_RANGE **m_part_mrr_range_first; PARTITION_PART_KEY_MULTI_RANGE **m_part_mrr_range_current; PARTITION_PART_KEY_MULTI_RANGE_HLD *m_partition_part_key_multi_range_hld; /* - Sequence of ranges to be scanned (TODO: why not stores this in + Sequence of ranges to be scanned (TODO: why not store this in handler::mrr_{iter,funcs}?) */ range_seq_t m_seq; RANGE_SEQ_IF *m_seq_if; - // Range iterator structure to be supplied to partitions + /* Range iterator structure to be supplied to partitions */ RANGE_SEQ_IF m_part_seq_if; virtual int multi_range_key_create_key( From 42b29d41335d2f6991b8c9f110fe1e1476764ace Mon Sep 17 00:00:00 2001 From: Alexey Bychko Date: Tue, 25 Feb 2020 17:59:49 +0700 Subject: [PATCH 41/66] MENT-645 Undefined symbols for architecture x86_64: _pam_syslog added cmake checks for pam_ext.h and pam_appl.h headers added check for pam_syslog() added pam_syslog() if doesn't exist all cmake checks performed from inside the plugin --- plugin/auth_pam/CMakeLists.txt | 14 +++++++++++++ plugin/auth_pam/mapper/pam_user_map.c | 30 +++++++++++++++++++++------ 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/plugin/auth_pam/CMakeLists.txt b/plugin/auth_pam/CMakeLists.txt index 0efb0b07feb..c826b422240 100644 --- a/plugin/auth_pam/CMakeLists.txt +++ b/plugin/auth_pam/CMakeLists.txt @@ -1,10 +1,24 @@ INCLUDE (CheckIncludeFiles) INCLUDE (CheckFunctionExists) +CHECK_INCLUDE_FILES (security/pam_ext.h HAVE_PAM_EXT_H) CHECK_INCLUDE_FILES (security/pam_appl.h HAVE_PAM_APPL_H) CHECK_FUNCTION_EXISTS (strndup HAVE_STRNDUP) +SET(CMAKE_REQUIRED_LIBRARIES pam) +CHECK_FUNCTION_EXISTS(pam_syslog HAVE_PAM_SYSLOG) +SET(CMAKE_REQUIRED_LIBRARIES) + +IF(HAVE_PAM_SYSLOG) + ADD_DEFINITIONS(-DHAVE_PAM_SYSLOG) +ENDIF() + +IF(HAVE_PAM_EXT_H) + ADD_DEFINITIONS(-DHAVE_PAM_EXT_H) +ENDIF() + IF(HAVE_PAM_APPL_H) + ADD_DEFINITIONS(-DHAVE_PAM_APPL_H) IF(HAVE_STRNDUP) ADD_DEFINITIONS(-DHAVE_STRNDUP) ENDIF(HAVE_STRNDUP) diff --git a/plugin/auth_pam/mapper/pam_user_map.c b/plugin/auth_pam/mapper/pam_user_map.c index e1d11acabb9..9d7ed53f8b1 100644 --- a/plugin/auth_pam/mapper/pam_user_map.c +++ b/plugin/auth_pam/mapper/pam_user_map.c @@ -2,7 +2,7 @@ Pam module to change user names arbitrarily in the pam stack. Compile as - + gcc pam_user_map.c -shared -lpam -fPIC -o pam_user_map.so Install as appropriate (for example, in /lib/security/). @@ -39,14 +39,36 @@ and usually end up in /var/log/secure file. #include #include +#ifdef HAVE_PAM_EXT_H #include +#endif + +#ifdef HAVE_PAM_APPL_H +#include +#include +#endif + #include +#ifndef HAVE_PAM_SYSLOG +#include +static void +pam_syslog (const pam_handle_t *pamh, int priority, + const char *fmt, ...) +{ + va_list args; + va_start (args, fmt); + vsyslog (priority, fmt, args); + va_end (args); +} +#endif + #define FILENAME "/etc/security/user_map.conf" #define skip(what) while (*s && (what)) s++ +#define SYSLOG_DEBUG if (mode_debug) pam_syslog #define GROUP_BUFFER_SIZE 100 - +static const char debug_keyword[]= "debug"; static int populate_user_groups(const char *user, gid_t **groups) { @@ -128,10 +150,6 @@ static void print_groups(pam_handle_t *pamh, const gid_t *user_groups, int ng) ng, (ng == 1) ? "group" : "groups", buf+1); } - -static const char debug_keyword[]= "debug"; -#define SYSLOG_DEBUG if (mode_debug) pam_syslog - int pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc, const char *argv[]) { From 8382f106916b8369b8e903d24dbd7233b48ceb80 Mon Sep 17 00:00:00 2001 From: Alexey Bychko Date: Wed, 26 Feb 2020 13:01:18 +0700 Subject: [PATCH 42/66] MENT-606 Error while setting value 'aes_ctr' to 'file-key-management-encryption-algorithm' cmake cannot detect openssl headers on Mac during checks. the solution is to add path to openssl includes to CMAKE_REQUIRED_INCLUDES before checks. --- cmake/ssl.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/ssl.cmake b/cmake/ssl.cmake index b00250cf367..d87d2c8fbd0 100644 --- a/cmake/ssl.cmake +++ b/cmake/ssl.cmake @@ -147,6 +147,7 @@ MACRO (MYSQL_CHECK_SSL) SET(SSL_DEFINES "-DHAVE_OPENSSL") SET(CMAKE_REQUIRED_LIBRARIES ${SSL_LIBRARIES}) + SET(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) CHECK_SYMBOL_EXISTS(ERR_remove_thread_state "openssl/err.h" HAVE_ERR_remove_thread_state) CHECK_SYMBOL_EXISTS(EVP_aes_128_ctr "openssl/evp.h" From f21592c675e198ba6298748b40e5d695a17f4e5f Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 1 Nov 2018 13:16:11 -0400 Subject: [PATCH 43/66] mariadb.pc: remove unnecessary include directory When installing, no headers are installed into the parent directory of `${includedir}`. --- support-files/mariadb.pc.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support-files/mariadb.pc.in b/support-files/mariadb.pc.in index bc84a5c5c4c..7d321f28491 100644 --- a/support-files/mariadb.pc.in +++ b/support-files/mariadb.pc.in @@ -20,4 +20,4 @@ Description: @CPACK_PACKAGE_DESCRIPTION_SUMMARY@ URL: @CPACK_PACKAGE_URL@ Version: @VERSION@ Libs: -L${libdir} @LIBS_FOR_CLIENTS@ -Cflags: -I${includedir} -I${includedir}/.. @CFLAGS_FOR_CLIENTS@ +Cflags: -I${includedir} @CFLAGS_FOR_CLIENTS@ From a17a327f116302612a889af7c448ef1cd8243f28 Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Wed, 26 Feb 2020 13:58:08 +0100 Subject: [PATCH 44/66] MDEV-21684: mysqld crash with signal 11 when renaming table+max_statement_time Main select should be pushed first in case of SET STATEMENT. --- mysql-test/main/parser.result | 36 +++++++++++++++++++++++++++++++ mysql-test/main/parser.test | 33 +++++++++++++++++++++++++++++ sql/sql_yacc.yy | 34 +++++++++++++++++++++++------ sql/sql_yacc_ora.yy | 40 +++++++++++++++++++++++++++++------ 4 files changed, 129 insertions(+), 14 deletions(-) diff --git a/mysql-test/main/parser.result b/mysql-test/main/parser.result index 868e3458368..d9f98ac3611 100644 --- a/mysql-test/main/parser.result +++ b/mysql-test/main/parser.result @@ -1807,4 +1807,40 @@ Field Type Null Key Default Extra a int(11) YES NULL drop table t1; SET STATEMENT max_statement_time=0 FOR do 1; +set @save_sql_mode=@@SQL_MODE; +set SQL_MODE=ORACLE; +create table t1 (a int); +SET STATEMENT max_statement_time=0 FOR desc t1; +Field Type Null Key Default Extra +a int(11) YES NULL +drop table t1; +SET STATEMENT max_statement_time=0 FOR do 1; +set SQL_MODE=@save_sql_mode; +# +# MDEV-21684: mysqld crash with signal 11 when renaming +# table+max_statement_time +# +SET STATEMENT max_statement_time=180 FOR RENAME TABLE bleh TO blah; +ERROR 42S02: Table 'test.bleh' doesn't exist +SET STATEMENT max_statement_time=180 FOR load index into cache t1_base; +Table Op Msg_type Msg_text +test.t1_base preload_keys Error Table 'test.t1_base' doesn't exist +test.t1_base preload_keys status Operation failed +SET STATEMENT max_statement_time=180 FOR DROP INDEX i1 ON t1; +ERROR 42S02: Table 'test.t1' doesn't exist +SET STATEMENT max_statement_time=180 FOR BACKUP LOCK test.t1; +SET STATEMENT max_statement_time=180 FOR BACKUP UNLOCK; +set @save_sql_mode=@@SQL_MODE; +set SQL_MODE=ORACLE; +SET STATEMENT max_statement_time=180 FOR RENAME TABLE bleh TO blah; +ERROR 42S02: Table 'test.bleh' doesn't exist +SET STATEMENT max_statement_time=180 FOR load index into cache t1_base; +Table Op Msg_type Msg_text +test.t1_base preload_keys Error Table 'test.t1_base' doesn't exist +test.t1_base preload_keys status Operation failed +SET STATEMENT max_statement_time=180 FOR DROP INDEX i1 ON t1; +ERROR 42S02: Table 'test.t1' doesn't exist +SET STATEMENT max_statement_time=180 FOR BACKUP LOCK test.t1; +SET STATEMENT max_statement_time=180 FOR BACKUP UNLOCK; +set SQL_MODE=@save_sql_mode; # End of 10.4 tests diff --git a/mysql-test/main/parser.test b/mysql-test/main/parser.test index 54048d0de1d..dba155f1b7c 100644 --- a/mysql-test/main/parser.test +++ b/mysql-test/main/parser.test @@ -1575,4 +1575,37 @@ SET STATEMENT max_statement_time=0 FOR desc t1; drop table t1; SET STATEMENT max_statement_time=0 FOR do 1; +set @save_sql_mode=@@SQL_MODE; +set SQL_MODE=ORACLE; +create table t1 (a int); +SET STATEMENT max_statement_time=0 FOR desc t1; +drop table t1; +SET STATEMENT max_statement_time=0 FOR do 1; +set SQL_MODE=@save_sql_mode; + + +--echo # +--echo # MDEV-21684: mysqld crash with signal 11 when renaming +--echo # table+max_statement_time +--echo # + +--error ER_NO_SUCH_TABLE +SET STATEMENT max_statement_time=180 FOR RENAME TABLE bleh TO blah; +SET STATEMENT max_statement_time=180 FOR load index into cache t1_base; +--error ER_NO_SUCH_TABLE +SET STATEMENT max_statement_time=180 FOR DROP INDEX i1 ON t1; +SET STATEMENT max_statement_time=180 FOR BACKUP LOCK test.t1; +SET STATEMENT max_statement_time=180 FOR BACKUP UNLOCK; + +set @save_sql_mode=@@SQL_MODE; +set SQL_MODE=ORACLE; +--error ER_NO_SUCH_TABLE +SET STATEMENT max_statement_time=180 FOR RENAME TABLE bleh TO blah; +SET STATEMENT max_statement_time=180 FOR load index into cache t1_base; +--error ER_NO_SUCH_TABLE +SET STATEMENT max_statement_time=180 FOR DROP INDEX i1 ON t1; +SET STATEMENT max_statement_time=180 FOR BACKUP LOCK test.t1; +SET STATEMENT max_statement_time=180 FOR BACKUP UNLOCK; +set SQL_MODE=@save_sql_mode; + --echo # End of 10.4 tests diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index ed04d2a0584..f557d9cce92 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -8996,9 +8996,13 @@ rename: RENAME table_or_tables { Lex->sql_command= SQLCOM_RENAME_TABLE; + if (Lex->main_select_push()) + MYSQL_YYABORT; } table_to_table_list - {} + { + Lex->pop_select(); //main select + } | RENAME USER_SYM clear_privileges rename_list { Lex->sql_command = SQLCOM_RENAME_USER; @@ -9096,9 +9100,13 @@ preload: LEX *lex=Lex; lex->sql_command=SQLCOM_PRELOAD_KEYS; lex->alter_info.reset(); + if (lex->main_select_push()) + MYSQL_YYABORT; } preload_list_or_parts - {} + { + Lex->pop_select(); //main select + } ; preload_list_or_parts: @@ -13278,11 +13286,16 @@ drop: } table_list opt_lock_wait_timeout opt_restrict {} - | DROP INDEX_SYM opt_if_exists_table_element ident ON table_ident opt_lock_wait_timeout + | DROP INDEX_SYM + { + if (Lex->main_select_push()) + MYSQL_YYABORT; + } + opt_if_exists_table_element ident ON table_ident opt_lock_wait_timeout { LEX *lex=Lex; Alter_drop *ad= (new (thd->mem_root) - Alter_drop(Alter_drop::KEY, $4.str, $3)); + Alter_drop(Alter_drop::KEY, $5.str, $4)); if (unlikely(ad == NULL)) MYSQL_YYABORT; lex->sql_command= SQLCOM_DROP_INDEX; @@ -13290,10 +13303,11 @@ drop: lex->alter_info.flags= ALTER_DROP_INDEX; lex->alter_info.drop_list.push_back(ad, thd->mem_root); if (unlikely(!lex->current_select-> - add_table_to_list(thd, $6, NULL, TL_OPTION_UPDATING, + add_table_to_list(thd, $7, NULL, TL_OPTION_UPDATING, TL_READ_NO_INSERT, MDL_SHARED_UPGRADABLE))) MYSQL_YYABORT; + Lex->pop_select(); //main select } | DROP DATABASE opt_if_exists ident { @@ -14789,12 +14803,18 @@ backup_statements: Lex->backup_stage= (backup_stages) (type-1); break; } - | LOCK_SYM table_ident + | LOCK_SYM { - if (unlikely(!Select->add_table_to_list(thd, $2, NULL, 0, + if (Lex->main_select_push()) + MYSQL_YYABORT; + } + table_ident + { + if (unlikely(!Select->add_table_to_list(thd, $3, NULL, 0, TL_READ, MDL_SHARED_HIGH_PRIO))) MYSQL_YYABORT; Lex->sql_command= SQLCOM_BACKUP_LOCK; + Lex->pop_select(); //main select } | UNLOCK_SYM { diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy index aebbb145f96..a72b4a7594b 100644 --- a/sql/sql_yacc_ora.yy +++ b/sql/sql_yacc_ora.yy @@ -9097,9 +9097,13 @@ rename: RENAME table_or_tables { Lex->sql_command= SQLCOM_RENAME_TABLE; + if (Lex->main_select_push()) + MYSQL_YYABORT; } table_to_table_list - {} + { + Lex->pop_select(); //main select + } | RENAME USER_SYM clear_privileges rename_list { Lex->sql_command = SQLCOM_RENAME_USER; @@ -9197,9 +9201,13 @@ preload: LEX *lex=Lex; lex->sql_command=SQLCOM_PRELOAD_KEYS; lex->alter_info.reset(); + if (lex->main_select_push()) + MYSQL_YYABORT; } preload_list_or_parts - {} + { + Lex->pop_select(); //main select + } ; preload_list_or_parts: @@ -13363,11 +13371,14 @@ do: { LEX *lex=Lex; lex->sql_command = SQLCOM_DO; + if (lex->main_select_push()) + MYSQL_YYABORT; mysql_init_select(lex); } expr_list { Lex->insert_list= $3; + Lex->pop_select(); //main select } ; @@ -13385,11 +13396,16 @@ drop: } table_list opt_lock_wait_timeout opt_restrict {} - | DROP INDEX_SYM opt_if_exists_table_element ident ON table_ident opt_lock_wait_timeout + | DROP INDEX_SYM + { + if (Lex->main_select_push()) + MYSQL_YYABORT; + } + opt_if_exists_table_element ident ON table_ident opt_lock_wait_timeout { LEX *lex=Lex; Alter_drop *ad= (new (thd->mem_root) - Alter_drop(Alter_drop::KEY, $4.str, $3)); + Alter_drop(Alter_drop::KEY, $5.str, $4)); if (unlikely(ad == NULL)) MYSQL_YYABORT; lex->sql_command= SQLCOM_DROP_INDEX; @@ -13397,10 +13413,11 @@ drop: lex->alter_info.flags= ALTER_DROP_INDEX; lex->alter_info.drop_list.push_back(ad, thd->mem_root); if (unlikely(!lex->current_select-> - add_table_to_list(thd, $6, NULL, TL_OPTION_UPDATING, + add_table_to_list(thd, $7, NULL, TL_OPTION_UPDATING, TL_READ_NO_INSERT, MDL_SHARED_UPGRADABLE))) MYSQL_YYABORT; + Lex->pop_select(); //main select } | DROP DATABASE opt_if_exists ident { @@ -14685,6 +14702,8 @@ describe: describe_command table_ident { LEX *lex= Lex; + if (lex->main_select_push()) + MYSQL_YYABORT; mysql_init_select(lex); lex->current_select->parsing_place= SELECT_LIST; lex->sql_command= SQLCOM_SHOW_FIELDS; @@ -14696,6 +14715,7 @@ describe: opt_describe_column { Select->parsing_place= NO_MATTER; + Lex->pop_select(); //main select } | describe_command opt_extended_describe { Lex->describe|= DESCRIBE_NORMAL; } @@ -14916,12 +14936,18 @@ backup_statements: Lex->backup_stage= (backup_stages) (type-1); break; } - | LOCK_SYM table_ident + | LOCK_SYM { - if (unlikely(!Select->add_table_to_list(thd, $2, NULL, 0, + if (Lex->main_select_push()) + MYSQL_YYABORT; + } + table_ident + { + if (unlikely(!Select->add_table_to_list(thd, $3, NULL, 0, TL_READ, MDL_SHARED_HIGH_PRIO))) MYSQL_YYABORT; Lex->sql_command= SQLCOM_BACKUP_LOCK; + Lex->pop_select(); //main select } | UNLOCK_SYM { From f56dd0a12dc7d7c3020625e76a532ee77386b2ca Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Fri, 28 Feb 2020 14:29:05 +0530 Subject: [PATCH 45/66] MDEV-21693 ALGORITHM=INSTANT does not work for partitioned tables - Flag ALTER_STORED_COLUMN_TYPE set while doing varchar extension for partition table. Basically all partition supports can_be_converted_by_engine() then it should be set to ALTER_COLUMN_TYPE_CHANGE_BY_ENGINE. --- .../parts/r/partition_special_innodb.result | 8 +++++ .../parts/t/partition_special_innodb.test | 10 ++++++ sql/ha_partition.cc | 36 ++++++++++++++++++- sql/ha_partition.h | 11 ++++++ 4 files changed, 64 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/parts/r/partition_special_innodb.result b/mysql-test/suite/parts/r/partition_special_innodb.result index c375c2d2232..01c6e1f9e64 100644 --- a/mysql-test/suite/parts/r/partition_special_innodb.result +++ b/mysql-test/suite/parts/r/partition_special_innodb.result @@ -327,3 +327,11 @@ disconnect con3; disconnect con2; disconnect con1; connection default; +CREATE TABLE t1( +f1 INT, f2 VARCHAR(10) CHARSET ascii, +f3 CHAR(150) CHARSET ascii, +f4 TEXT CHARSET ascii)ENGINE=InnoDB +PARTITION BY RANGE(f1) (PARTITION p1 VALUES LESS THAN(10), +PARTITION p2 VALUES LESS THAN (100)); +ALTER TABLE t1 convert to charset ascii collate ascii_bin, ALGORITHM=INSTANT; +DROP TABLE t1; diff --git a/mysql-test/suite/parts/t/partition_special_innodb.test b/mysql-test/suite/parts/t/partition_special_innodb.test index 1fc9ac7fafc..ef7cf4bd4cf 100644 --- a/mysql-test/suite/parts/t/partition_special_innodb.test +++ b/mysql-test/suite/parts/t/partition_special_innodb.test @@ -205,3 +205,13 @@ DROP TABLE t4; --disconnect con1 --connection default # End of Test #3 + +# MDEV-21693 ALGORITHM=INSTANT does not work for partitioned tables +CREATE TABLE t1( + f1 INT, f2 VARCHAR(10) CHARSET ascii, + f3 CHAR(150) CHARSET ascii, + f4 TEXT CHARSET ascii)ENGINE=InnoDB + PARTITION BY RANGE(f1) (PARTITION p1 VALUES LESS THAN(10), + PARTITION p2 VALUES LESS THAN (100)); +ALTER TABLE t1 convert to charset ascii collate ascii_bin, ALGORITHM=INSTANT; +DROP TABLE t1; diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index bcd419562b1..53bcd4df5c5 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2005, 2019, Oracle and/or its affiliates. - Copyright (c) 2009, 2019, MariaDB + Copyright (c) 2009, 2020, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -11799,6 +11799,40 @@ void ha_partition::clear_top_table_fields() DBUG_VOID_RETURN; } +bool +ha_partition::can_convert_string(const Field_string* field, + const Column_definition& new_type) const +{ + for (uint index= 0; index < m_tot_parts; index++) + { + if (!m_file[index]->can_convert_string(field, new_type)) + return false; + } + return true; +} + +bool +ha_partition::can_convert_varstring(const Field_varstring* field, + const Column_definition& new_type) const{ + for (uint index= 0; index < m_tot_parts; index++) + { + if (!m_file[index]->can_convert_varstring(field, new_type)) + return false; + } + return true; +} + +bool +ha_partition::can_convert_blob(const Field_blob* field, + const Column_definition& new_type) const +{ + for (uint index= 0; index < m_tot_parts; index++) + { + if (!m_file[index]->can_convert_blob(field, new_type)) + return false; + } + return true; +} struct st_mysql_storage_engine partition_storage_engine= { MYSQL_HANDLERTON_INTERFACE_VERSION }; diff --git a/sql/ha_partition.h b/sql/ha_partition.h index 5b8718cd3ae..78561d0ec27 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -1640,5 +1640,16 @@ public: friend int cmp_key_rowid_part_id(void *ptr, uchar *ref1, uchar *ref2); friend int cmp_key_part_id(void *key_p, uchar *ref1, uchar *ref2); + bool can_convert_string( + const Field_string* field, + const Column_definition& new_field) const override; + + bool can_convert_varstring( + const Field_varstring* field, + const Column_definition& new_field) const override; + + bool can_convert_blob( + const Field_blob* field, + const Column_definition& new_field) const override; }; #endif /* HA_PARTITION_INCLUDED */ From e837a358b660ab259cdf2c12712a925ece98a40d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 28 Feb 2020 14:01:27 +0200 Subject: [PATCH 46/66] MDEV-21693: Fix clang -Winconsistent-missing-override ha_partition: Remove redundant 'virtual' keywords and add missing 'override'. FIXME: handler::table_type() is not declared virtual, yet ha_partition and ha_sequence are seemingly trying to override it. --- sql/ha_partition.h | 386 ++++++++++++++++++++++----------------------- 1 file changed, 193 insertions(+), 193 deletions(-) diff --git a/sql/ha_partition.h b/sql/ha_partition.h index 78561d0ec27..420fdb50109 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -3,7 +3,7 @@ /* Copyright (c) 2005, 2012, Oracle and/or its affiliates. - Copyright (c) 2009, 2013, Monty Program Ab & SkySQL Ab. + Copyright (c) 2009, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -431,18 +431,18 @@ private: /** Stores shared auto_increment etc. */ Partition_share *part_share; /** Fix spurious -Werror=overloaded-virtual in GCC 9 */ - virtual void restore_auto_increment(ulonglong prev_insert_id) + virtual void restore_auto_increment(ulonglong prev_insert_id) override { handler::restore_auto_increment(prev_insert_id); } /** Store and restore next_auto_inc_val over duplicate key errors. */ - virtual void store_auto_increment() + void store_auto_increment() override { DBUG_ASSERT(part_share); part_share->prev_auto_inc_val= part_share->next_auto_inc_val; handler::store_auto_increment(); } - virtual void restore_auto_increment() + void restore_auto_increment() override { DBUG_ASSERT(part_share); part_share->next_auto_inc_val= part_share->prev_auto_inc_val; @@ -450,7 +450,7 @@ private: } void sum_copy_info(handler *file); void sum_copy_infos(); - void reset_copy_info(); + void reset_copy_info() override; /** Temporary storage for new partitions Handler_shares during ALTER */ List m_new_partitions_share_refs; /** Sorted array of partition ids in descending order of number of rows. */ @@ -483,16 +483,16 @@ public: return NO_CURRENT_PART_ID; } Partition_share *get_part_share() { return part_share; } - handler *clone(const char *name, MEM_ROOT *mem_root); - virtual void set_part_info(partition_info *part_info) + handler *clone(const char *name, MEM_ROOT *mem_root) override; + virtual void set_part_info(partition_info *part_info) override { m_part_info= part_info; m_is_sub_partitioned= part_info->is_sub_partitioned(); } - virtual void return_record_by_parent(); + void return_record_by_parent() override; - virtual bool vers_can_native(THD *thd) + bool vers_can_native(THD *thd) override { if (thd->lex->part_info) { @@ -551,31 +551,30 @@ public: object needed in opening the object in openfrm ------------------------------------------------------------------------- */ - virtual int delete_table(const char *from); - virtual int rename_table(const char *from, const char *to); - virtual int create(const char *name, TABLE *form, - HA_CREATE_INFO *create_info); - virtual int create_partitioning_metadata(const char *name, - const char *old_name, int action_flag); - virtual void update_create_info(HA_CREATE_INFO *create_info); - virtual char *update_table_comment(const char *comment); - virtual int change_partitions(HA_CREATE_INFO *create_info, - const char *path, - ulonglong * const copied, - ulonglong * const deleted, - const uchar *pack_frm_data, - size_t pack_frm_len); - virtual int drop_partitions(const char *path); - virtual int rename_partitions(const char *path); - bool get_no_parts(const char *name, uint *num_parts) + int delete_table(const char *from) override; + int rename_table(const char *from, const char *to) override; + int create(const char *name, TABLE *form, + HA_CREATE_INFO *create_info) override; + int create_partitioning_metadata(const char *name, + const char *old_name, int action_flag) + override; + void update_create_info(HA_CREATE_INFO *create_info) override; + char *update_table_comment(const char *comment) override; + int change_partitions(HA_CREATE_INFO *create_info, const char *path, + ulonglong * const copied, ulonglong * const deleted, + const uchar *pack_frm_data, size_t pack_frm_len) + override; + int drop_partitions(const char *path) override; + int rename_partitions(const char *path) override; + bool get_no_parts(const char *, uint *num_parts) override { DBUG_ENTER("ha_partition::get_no_parts"); *num_parts= m_tot_parts; DBUG_RETURN(0); } - virtual void change_table_ptr(TABLE *table_arg, TABLE_SHARE *share); - virtual bool check_if_incompatible_data(HA_CREATE_INFO *create_info, - uint table_changes); + void change_table_ptr(TABLE *table_arg, TABLE_SHARE *share) override; + bool check_if_incompatible_data(HA_CREATE_INFO *create_info, + uint table_changes) override; void update_part_create_info(HA_CREATE_INFO *create_info, uint part_id) { m_file[part_id]->update_create_info(create_info); @@ -614,7 +613,7 @@ private: bool is_subpart); bool populate_partition_name_hash(); Partition_share *get_share(); - bool set_ha_share_ref(Handler_share **ha_share); + bool set_ha_share_ref(Handler_share **ha_share) override; void fix_data_dir(char* path); bool init_partition_bitmaps(); void free_partition_bitmaps(); @@ -634,8 +633,8 @@ public: being used for normal queries (not before meta-data changes always. If the object was opened it will also be closed before being deleted. */ - virtual int open(const char *name, int mode, uint test_if_locked); - virtual int close(void); + int open(const char *name, int mode, uint test_if_locked) override; + int close() override; /* ------------------------------------------------------------------------- @@ -650,31 +649,31 @@ public: and these go directly to the handlers supporting transactions ------------------------------------------------------------------------- */ - virtual THR_LOCK_DATA **store_lock(THD * thd, THR_LOCK_DATA ** to, - enum thr_lock_type lock_type); - virtual int external_lock(THD * thd, int lock_type); - LEX_CSTRING *engine_name() { return hton_name(partition_ht()); } + THR_LOCK_DATA **store_lock(THD * thd, THR_LOCK_DATA ** to, + enum thr_lock_type lock_type) override; + int external_lock(THD * thd, int lock_type) override; + LEX_CSTRING *engine_name() override { return hton_name(partition_ht()); } /* When table is locked a statement is started by calling start_stmt instead of external_lock */ - virtual int start_stmt(THD * thd, thr_lock_type lock_type); + int start_stmt(THD * thd, thr_lock_type lock_type) override; /* Lock count is number of locked underlying handlers (I assume) */ - virtual uint lock_count(void) const; + uint lock_count() const override; /* Call to unlock rows not to be updated in transaction */ - virtual void unlock_row(); + void unlock_row() override; /* Check if semi consistent read */ - virtual bool was_semi_consistent_read(); + bool was_semi_consistent_read() override; /* Call to hint about semi consistent read */ - virtual void try_semi_consistent_read(bool); + void try_semi_consistent_read(bool) override; /* NOTE: due to performance and resource issues with many partitions, @@ -708,28 +707,28 @@ public: start_bulk_insert and end_bulk_insert is called before and after a number of calls to write_row. */ - virtual int write_row(const uchar * buf); - virtual bool start_bulk_update(); - virtual int exec_bulk_update(ha_rows *dup_key_found); - virtual int end_bulk_update(); - virtual int bulk_update_row(const uchar *old_data, const uchar *new_data, - ha_rows *dup_key_found); - virtual int update_row(const uchar * old_data, const uchar * new_data); - virtual int direct_update_rows_init(List *update_fields); - virtual int pre_direct_update_rows_init(List *update_fields); - virtual int direct_update_rows(ha_rows *update_rows, ha_rows *found_rows); - virtual int pre_direct_update_rows(); - virtual bool start_bulk_delete(); - virtual int end_bulk_delete(); - virtual int delete_row(const uchar * buf); - virtual int direct_delete_rows_init(); - virtual int pre_direct_delete_rows_init(); - virtual int direct_delete_rows(ha_rows *delete_rows); - virtual int pre_direct_delete_rows(); - virtual int delete_all_rows(void); - virtual int truncate(); - virtual void start_bulk_insert(ha_rows rows, uint flags); - virtual int end_bulk_insert(); + int write_row(const uchar * buf) override; + bool start_bulk_update() override; + int exec_bulk_update(ha_rows *dup_key_found) override; + int end_bulk_update() override; + int bulk_update_row(const uchar *old_data, const uchar *new_data, + ha_rows *dup_key_found) override; + int update_row(const uchar * old_data, const uchar * new_data) override; + int direct_update_rows_init(List *update_fields) override; + int pre_direct_update_rows_init(List *update_fields) override; + int direct_update_rows(ha_rows *update_rows, ha_rows *found_rows) override; + int pre_direct_update_rows() override; + bool start_bulk_delete() override; + int end_bulk_delete() override; + int delete_row(const uchar * buf) override; + int direct_delete_rows_init() override; + int pre_direct_delete_rows_init() override; + int direct_delete_rows(ha_rows *delete_rows) override; + int pre_direct_delete_rows() override; + int delete_all_rows() override; + int truncate() override; + void start_bulk_insert(ha_rows rows, uint flags) override; + int end_bulk_insert() override; private: ha_rows guess_bulk_insert_rows(); void start_part_bulk_insert(THD *thd, uint part_id); @@ -745,7 +744,7 @@ public: */ int truncate_partition(Alter_info *, bool *binlog_stmt); - virtual bool is_fatal_error(int error, uint flags) + bool is_fatal_error(int error, uint flags) override { if (!handler::is_fatal_error(error, flags) || error == HA_ERR_NO_PARTITION_FOUND || @@ -780,12 +779,12 @@ public: position it to the start of the table, no need to deallocate and allocate it again */ - virtual int rnd_init(bool scan); - virtual int rnd_end(); - virtual int rnd_next(uchar * buf); - virtual int rnd_pos(uchar * buf, uchar * pos); - virtual int rnd_pos_by_record(uchar *record); - virtual void position(const uchar * record); + int rnd_init(bool scan) override; + int rnd_end() override; + int rnd_next(uchar * buf) override; + int rnd_pos(uchar * buf, uchar * pos) override; + int rnd_pos_by_record(uchar *record) override; + void position(const uchar * record) override; /* ------------------------------------------------------------------------- @@ -819,11 +818,11 @@ public: index_init initializes an index before using it and index_end does any end processing needed. */ - virtual int index_read_map(uchar * buf, const uchar * key, - key_part_map keypart_map, - enum ha_rkey_function find_flag); - virtual int index_init(uint idx, bool sorted); - virtual int index_end(); + int index_read_map(uchar * buf, const uchar * key, + key_part_map keypart_map, + enum ha_rkey_function find_flag) override; + int index_init(uint idx, bool sorted) override; + int index_end() override; /** @breif @@ -831,36 +830,36 @@ public: row if available. If the key value is null, begin at first key of the index. */ - virtual int index_read_idx_map(uchar *buf, uint index, const uchar *key, - key_part_map keypart_map, - enum ha_rkey_function find_flag); + int index_read_idx_map(uchar *buf, uint index, const uchar *key, + key_part_map keypart_map, + enum ha_rkey_function find_flag) override; /* These methods are used to jump to next or previous entry in the index scan. There are also methods to jump to first and last entry. */ - virtual int index_next(uchar * buf); - virtual int index_prev(uchar * buf); - virtual int index_first(uchar * buf); - virtual int index_last(uchar * buf); - virtual int index_next_same(uchar * buf, const uchar * key, uint keylen); + int index_next(uchar * buf) override; + int index_prev(uchar * buf) override; + int index_first(uchar * buf) override; + int index_last(uchar * buf) override; + int index_next_same(uchar * buf, const uchar * key, uint keylen) override; int index_read_last_map(uchar *buf, const uchar *key, - key_part_map keypart_map); + key_part_map keypart_map) override; /* read_first_row is virtual method but is only implemented by handler.cc, no storage engine has implemented it so neither will the partition handler. - virtual int read_first_row(uchar *buf, uint primary_key); + int read_first_row(uchar *buf, uint primary_key) override; */ - virtual int read_range_first(const key_range * start_key, - const key_range * end_key, - bool eq_range, bool sorted); - virtual int read_range_next(); + int read_range_first(const key_range * start_key, + const key_range * end_key, + bool eq_range, bool sorted) override; + int read_range_next() override; HANDLER_BUFFER *m_mrr_buffer; @@ -921,20 +920,20 @@ public: RANGE_SEQ_IF *seq, range_seq_t seq_it ); - virtual ha_rows multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq, - void *seq_init_param, - uint n_ranges, uint *bufsz, - uint *mrr_mode, - Cost_estimate *cost); - virtual ha_rows multi_range_read_info(uint keyno, uint n_ranges, uint keys, - uint key_parts, uint *bufsz, - uint *mrr_mode, Cost_estimate *cost); - virtual int multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param, - uint n_ranges, uint mrr_mode, - HANDLER_BUFFER *buf); - virtual int multi_range_read_next(range_id_t *range_info); - virtual int multi_range_read_explain_info(uint mrr_mode, char *str, - size_t size); + ha_rows multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq, + void *seq_init_param, + uint n_ranges, uint *bufsz, + uint *mrr_mode, + Cost_estimate *cost) override; + ha_rows multi_range_read_info(uint keyno, uint n_ranges, uint keys, + uint key_parts, uint *bufsz, + uint *mrr_mode, Cost_estimate *cost) override; + int multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param, + uint n_ranges, uint mrr_mode, + HANDLER_BUFFER *buf) override; + int multi_range_read_next(range_id_t *range_info) override; + int multi_range_read_explain_info(uint mrr_mode, char *str, size_t size) + override; uint last_part() { return m_last_part; } private: @@ -962,21 +961,20 @@ public: purposes. ------------------------------------------------------------------------- */ - virtual int info(uint); - void get_dynamic_partition_info(PARTITION_STATS *stat_info, - uint part_id); - void set_partitions_to_open(List *partition_names); - int change_partitions_to_open(List *partition_names); + int info(uint) override; + void get_dynamic_partition_info(PARTITION_STATS *stat_info, uint part_id) + override; + void set_partitions_to_open(List *partition_names) override; + int change_partitions_to_open(List *partition_names) override; int open_read_partitions(char *name_buff, size_t name_buff_size); - virtual int extra(enum ha_extra_function operation); - virtual int extra_opt(enum ha_extra_function operation, ulong arg); - virtual int reset(void); - virtual uint count_query_cache_dependant_tables(uint8 *tables_type); - virtual my_bool - register_query_cache_dependant_tables(THD *thd, - Query_cache *cache, - Query_cache_block_table **block, - uint *n); + int extra(enum ha_extra_function operation) override; + int extra_opt(enum ha_extra_function operation, ulong arg) override; + int reset() override; + uint count_query_cache_dependant_tables(uint8 *tables_type) override; + my_bool register_query_cache_dependant_tables(THD *thd, + Query_cache *cache, + Query_cache_block_table **block, + uint *n) override; private: typedef int handler_callback(handler *, void *); @@ -1031,40 +1029,40 @@ public: index-only scanning when performing an ORDER BY query. Only called from one place in sql_select.cc */ - virtual const key_map *keys_to_use_for_scanning(); + const key_map *keys_to_use_for_scanning() override; /* Called in test_quick_select to determine if indexes should be used. */ - virtual double scan_time(); + double scan_time() override; - virtual double key_scan_time(uint inx); + double key_scan_time(uint inx) override; - virtual double keyread_time(uint inx, uint ranges, ha_rows rows); + double keyread_time(uint inx, uint ranges, ha_rows rows) override; /* The next method will never be called if you do not implement indexes. */ - virtual double read_time(uint index, uint ranges, ha_rows rows); + double read_time(uint index, uint ranges, ha_rows rows) override; /* For the given range how many records are estimated to be in this range. Used by optimiser to calculate cost of using a particular index. */ - virtual ha_rows records_in_range(uint inx, key_range * min_key, - key_range * max_key); + ha_rows records_in_range(uint inx, key_range * min_key, key_range * max_key) + override; /* Upper bound of number records returned in scan is sum of all underlying handlers. */ - virtual ha_rows estimate_rows_upper_bound(); + ha_rows estimate_rows_upper_bound() override; /* table_cache_type is implemented by the underlying handler but all underlying handlers must have the same implementation for it to work. */ - virtual uint8 table_cache_type(); - virtual ha_rows records(); + uint8 table_cache_type() override; + ha_rows records() override; /* Calculate hash value for PARTITION BY KEY tables. */ static uint32 calculate_key_hash_value(Field **field_array); @@ -1082,19 +1080,19 @@ public: Here we must ensure that all handlers use the same index type for each index created. */ - virtual const char *index_type(uint inx); + const char *index_type(uint inx) override; /* The name of the table type that will be used for display purposes */ - virtual const char *table_type() const; + const char *table_type() const; /* The name of the row type used for the underlying tables. */ - virtual enum row_type get_row_type() const; + enum row_type get_row_type() const override; /* Handler specific error messages */ - virtual void print_error(int error, myf errflag); - virtual bool get_error_message(int error, String * buf); + void print_error(int error, myf errflag) override; + bool get_error_message(int error, String * buf) override; /* ------------------------------------------------------------------------- MODULE handler characteristics @@ -1248,7 +1246,7 @@ public: HA_CAN_INSERT_DELAYED, HA_PRIMARY_KEY_REQUIRED_FOR_POSITION is disabled until further investigated. */ - virtual Table_flags table_flags() const; + Table_flags table_flags() const override; /* This is a bitmap of flags that says how the storage engine @@ -1306,7 +1304,7 @@ public: must be updated in the row. (InnoDB, MyISAM) */ - virtual ulong index_flags(uint inx, uint part, bool all_parts) const + ulong index_flags(uint inx, uint part, bool all_parts) const override { /* The following code is not safe if you are using different @@ -1319,7 +1317,8 @@ public: wrapper function for handlerton alter_table_flags, since the ha_partition_hton cannot know all its capabilities */ - virtual alter_table_operations alter_table_flags(alter_table_operations flags); + alter_table_operations alter_table_flags(alter_table_operations flags) + override; /* unireg.cc will call the following to make sure that the storage engine can handle the data it is about to send. @@ -1327,19 +1326,18 @@ public: The maximum supported values is the minimum of all handlers in the table */ uint min_of_the_max_uint(uint (handler::*operator_func)(void) const) const; - virtual uint max_supported_record_length() const; - virtual uint max_supported_keys() const; - virtual uint max_supported_key_parts() const; - virtual uint max_supported_key_length() const; - virtual uint max_supported_key_part_length() const; - virtual uint min_record_length(uint options) const; + uint max_supported_record_length() const override; + uint max_supported_keys() const override; + uint max_supported_key_parts() const override; + uint max_supported_key_length() const override; + uint max_supported_key_part_length() const override; + uint min_record_length(uint options) const override; /* Primary key is clustered can only be true if all underlying handlers have this feature. */ - virtual bool primary_key_is_clustered() - { return m_pkey_is_clustered; } + bool primary_key_is_clustered() override { return m_pkey_is_clustered; } /* ------------------------------------------------------------------------- @@ -1357,7 +1355,7 @@ public: to check whether the rest of the reference part is also the same. ------------------------------------------------------------------------- */ - virtual int cmp_ref(const uchar * ref1, const uchar * ref2); + int cmp_ref(const uchar * ref1, const uchar * ref2) override; /* ------------------------------------------------------------------------- MODULE auto increment @@ -1371,15 +1369,15 @@ public: auto_increment_column_changed ------------------------------------------------------------------------- */ - virtual bool need_info_for_auto_inc(); - virtual bool can_use_for_auto_inc_init(); - virtual void get_auto_increment(ulonglong offset, ulonglong increment, - ulonglong nb_desired_values, - ulonglong *first_value, - ulonglong *nb_reserved_values); - virtual void release_auto_increment(); + bool need_info_for_auto_inc() override; + bool can_use_for_auto_inc_init() override; + void get_auto_increment(ulonglong offset, ulonglong increment, + ulonglong nb_desired_values, + ulonglong *first_value, + ulonglong *nb_reserved_values) override; + void release_auto_increment() override; private: - virtual int reset_auto_increment(ulonglong value); + int reset_auto_increment(ulonglong value) override; void update_next_auto_inc_val(); virtual void lock_auto_increment() { @@ -1441,7 +1439,7 @@ public: This method is a special InnoDB method called before a HANDLER query. ------------------------------------------------------------------------- */ - virtual void init_table_handle_for_HANDLER(); + void init_table_handle_for_HANDLER() override; /* The remainder of this file defines the handler methods not implemented @@ -1469,20 +1467,20 @@ public: List *f_key_list) virtual uint referenced_by_foreign_key() */ - virtual bool can_switch_engines(); + bool can_switch_engines() override; /* ------------------------------------------------------------------------- MODULE fulltext index ------------------------------------------------------------------------- */ void ft_close_search(FT_INFO *handler); - virtual int ft_init(); - virtual int pre_ft_init(); - virtual void ft_end(); - virtual int pre_ft_end(); - virtual FT_INFO *ft_init_ext(uint flags, uint inx, String *key); - virtual int ft_read(uchar *buf); - virtual int pre_ft_read(bool use_parallel); + int ft_init() override; + int pre_ft_init() override; + void ft_end() override; + int pre_ft_end() override; + FT_INFO *ft_init_ext(uint flags, uint inx, String *key) override; + int ft_read(uchar *buf) override; + int pre_ft_read(bool use_parallel) override; /* ------------------------------------------------------------------------- @@ -1490,7 +1488,7 @@ public: ------------------------------------------------------------------------- The following method is only used by MyISAM when used as temporary tables in a join. - virtual int restart_rnd_next(uchar *buf, uchar *pos); + int restart_rnd_next(uchar *buf, uchar *pos) override; */ /* @@ -1501,17 +1499,19 @@ public: They are used for in-place alter table: ------------------------------------------------------------------------- */ - virtual enum_alter_inplace_result + enum_alter_inplace_result check_if_supported_inplace_alter(TABLE *altered_table, - Alter_inplace_info *ha_alter_info); - virtual bool prepare_inplace_alter_table(TABLE *altered_table, - Alter_inplace_info *ha_alter_info); - virtual bool inplace_alter_table(TABLE *altered_table, - Alter_inplace_info *ha_alter_info); - virtual bool commit_inplace_alter_table(TABLE *altered_table, - Alter_inplace_info *ha_alter_info, - bool commit); - virtual void notify_table_changed(); + Alter_inplace_info *ha_alter_info) + override; + bool prepare_inplace_alter_table(TABLE *altered_table, + Alter_inplace_info *ha_alter_info) + override; + bool inplace_alter_table(TABLE *altered_table, + Alter_inplace_info *ha_alter_info) override; + bool commit_inplace_alter_table(TABLE *altered_table, + Alter_inplace_info *ha_alter_info, + bool commit) override; + void notify_table_changed() override; /* ------------------------------------------------------------------------- @@ -1535,24 +1535,24 @@ public: all partitions. ------------------------------------------------------------------------- */ - virtual int optimize(THD* thd, HA_CHECK_OPT *check_opt); - virtual int analyze(THD* thd, HA_CHECK_OPT *check_opt); - virtual int check(THD* thd, HA_CHECK_OPT *check_opt); - virtual int repair(THD* thd, HA_CHECK_OPT *check_opt); - virtual bool check_and_repair(THD *thd); - virtual bool auto_repair(int error) const; - virtual bool is_crashed() const; - virtual int check_for_upgrade(HA_CHECK_OPT *check_opt); + int optimize(THD* thd, HA_CHECK_OPT *check_opt) override; + int analyze(THD* thd, HA_CHECK_OPT *check_opt) override; + int check(THD* thd, HA_CHECK_OPT *check_opt) override; + int repair(THD* thd, HA_CHECK_OPT *check_opt) override; + bool check_and_repair(THD *thd) override; + bool auto_repair(int error) const override; + bool is_crashed() const override; + int check_for_upgrade(HA_CHECK_OPT *check_opt) override; /* ------------------------------------------------------------------------- MODULE condition pushdown ------------------------------------------------------------------------- */ - virtual const COND *cond_push(const COND *cond); - virtual void cond_pop(); - virtual void clear_top_table_fields(); - virtual int info_push(uint info_type, void *info); + const COND *cond_push(const COND *cond) override; + void cond_pop() override; + void clear_top_table_fields() override; + int info_push(uint info_type, void *info) override; private: int handle_opt_partitions(THD *thd, HA_CHECK_OPT *check_opt, uint flags); @@ -1566,13 +1566,13 @@ public: void append_row_to_str(String &str); public: - virtual int pre_calculate_checksum(); - virtual int calculate_checksum(); + int pre_calculate_checksum() override; + int calculate_checksum() override; /* Enabled keycache for performance reasons, WL#4571 */ - virtual int assign_to_keycache(THD* thd, HA_CHECK_OPT *check_opt); - virtual int preload_keys(THD* thd, HA_CHECK_OPT* check_opt); - virtual TABLE_LIST *get_next_global_for_child(); + int assign_to_keycache(THD* thd, HA_CHECK_OPT *check_opt) override; + int preload_keys(THD* thd, HA_CHECK_OPT* check_opt) override; + TABLE_LIST *get_next_global_for_child() override; /* ------------------------------------------------------------------------- @@ -1581,9 +1581,9 @@ public: Enable/Disable Indexes are only supported by HEAP and MyISAM. ------------------------------------------------------------------------- */ - virtual int disable_indexes(uint mode); - virtual int enable_indexes(uint mode); - virtual int indexes_are_disabled(void); + int disable_indexes(uint mode) override; + int enable_indexes(uint mode) override; + int indexes_are_disabled() override; /* ------------------------------------------------------------------------- @@ -1611,7 +1611,7 @@ public: this can also be done before partition will support a mix of engines, but preferably together with other incompatible API changes. */ - virtual handlerton *partition_ht() const + handlerton *partition_ht() const override { handlerton *h= m_file[0]->ht; for (uint i=1; i < m_tot_parts; i++) From 395f23a10d44a63732dd69f79fb7372bc5834443 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Fri, 28 Feb 2020 19:54:08 +0200 Subject: [PATCH 47/66] Remove unneded extra context line from test file to make it version independent --- mysql-test/r/mysqld--defaults-file.result | 2 -- mysql-test/t/mysqld--defaults-file.test | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/mysqld--defaults-file.result b/mysql-test/r/mysqld--defaults-file.result index be62580c47e..ccad1d119fc 100644 --- a/mysql-test/r/mysqld--defaults-file.result +++ b/mysql-test/r/mysqld--defaults-file.result @@ -17,8 +17,6 @@ Fatal error in defaults handling. Program aborted # Test on `defaults-file` Default options are read from the following files in the given order: MYSQLTEST_VARDIR/my.cnf -The following groups are read: mysqld server mysqld-10.1 mariadb mariadb-10.1 client-server galera # Test on `defaults-extra-file` Default options are read from the following files in the given order: MYSQLTEST_VARDIR/my_test.cnf ~/.my.cnf -The following groups are read: mysqld server mysqld-10.1 mariadb mariadb-10.1 client-server galera diff --git a/mysql-test/t/mysqld--defaults-file.test b/mysql-test/t/mysqld--defaults-file.test index acc1cea5b8c..91d30eb1617 100644 --- a/mysql-test/t/mysqld--defaults-file.test +++ b/mysql-test/t/mysqld--defaults-file.test @@ -36,12 +36,12 @@ exec $MYSQLD --defaults-file=no_extension --print-defaults 2>&1; --echo # Test on `defaults-file` --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR -exec $MYSQLD --defaults-file=$MYSQLTEST_VARDIR/my.cnf --help --verbose | grep -A 2 'Default options are read'; +exec $MYSQLD --defaults-file=$MYSQLTEST_VARDIR/my.cnf --help --verbose | grep -A 1 'Default options are read'; --echo # Test on `defaults-extra-file` # = `/etc/my.cnf /etc/mysql/my.cnf` # Using sysconfdir configuration, we don't always have `/etc/mysql/my.cnf`, so replace them with a regex as well. copy_file $MYSQLTEST_VARDIR/my.cnf $MYSQLTEST_VARDIR/my_test.cnf; --replace_regex /.*my_test.cnf/ MYSQLTEST_VARDIR\/my_test.cnf/ -exec $MYSQLD --defaults-extra-file=$MYSQLTEST_VARDIR/my_test.cnf --help --verbose | grep -A 2 'Default options are read'; +exec $MYSQLD --defaults-extra-file=$MYSQLTEST_VARDIR/my_test.cnf --help --verbose | grep -A 1 'Default options are read'; remove_file $MYSQLTEST_VARDIR/my_test.cnf; From 1ad8693a6f6b44121651a0c7ccf80ae1f099744d Mon Sep 17 00:00:00 2001 From: Roman Nozdrin Date: Fri, 28 Feb 2020 15:44:56 +0000 Subject: [PATCH 48/66] MDEV-21841 CONV() function doesn't truncate its output to 21 when uses default charset. --- mysql-test/main/func_str.result | 15 +++++++++++++++ mysql-test/main/func_str.test | 11 +++++++++++ sql/item_strfunc.h | 2 +- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/func_str.result b/mysql-test/main/func_str.result index b4e3f27eda6..4a01935785c 100644 --- a/mysql-test/main/func_str.result +++ b/mysql-test/main/func_str.result @@ -5159,6 +5159,21 @@ DROP TABLE t1, t2; # Start of 10.4 tests # # +# MDEV-21841 CONV() function truncates the result type to 21 symbol. +# +CREATE TABLE t1(i BIGINT); +INSERT INTO t1 VALUES (-1); +CREATE TABLE t2 AS SELECT conv(i,16,2) from t1; +SELECT * FROM t2; +conv(i,16,2) +1111111111111111111111111111111111111111111111111111111111111111 +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `conv(i,16,2)` varchar(64) CHARACTER SET utf8 DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1,t2; +# # MDEV-18205 Assertion `str_length < len' failed in Binary_string::realloc_raw # SELECT GROUP_CONCAT( UpdateXML( 'new year', '/a', '2019-01-01 00:00:00' ), ENCODE('text','pass') ) AS f; diff --git a/mysql-test/main/func_str.test b/mysql-test/main/func_str.test index a01b3942209..ba5b671ca4f 100644 --- a/mysql-test/main/func_str.test +++ b/mysql-test/main/func_str.test @@ -2099,6 +2099,17 @@ DROP TABLE t1, t2; --echo # Start of 10.4 tests --echo # +--echo # +--echo # MDEV-21841 CONV() function truncates the result type to 21 symbol. +--echo # + +CREATE TABLE t1(i BIGINT); +INSERT INTO t1 VALUES (-1); +CREATE TABLE t2 AS SELECT conv(i,16,2) from t1; +SELECT * FROM t2; +SHOW CREATE TABLE t2; +DROP TABLE t1,t2; + --echo # --echo # MDEV-18205 Assertion `str_length < len' failed in Binary_string::realloc_raw --echo # diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 42b5b4f2aeb..ae0afeabeae 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -1205,7 +1205,7 @@ public: bool fix_length_and_dec() { collation.set(default_charset()); - max_length=64; + fix_char_length(64); maybe_null= 1; return FALSE; } From f0d2542a37ccd0509ab37ebaa7661604f00db80d Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Mon, 2 Mar 2020 16:35:57 +0100 Subject: [PATCH 49/66] MDEV-21857 - Fix sporadic failure of mdev375 status threads_connected can temporarily be bigger than max_connections+1 If SHOW STATUS LIKE "Threads_connected" comes after ER_CON_COUNT_ERROR is sent to the client, but before the counter is decremented, Threads_connected can differ from the expected value. --- mysql-test/t/mdev375.test | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mysql-test/t/mdev375.test b/mysql-test/t/mdev375.test index 9e35190b927..6fdb35016ca 100644 --- a/mysql-test/t/mdev375.test +++ b/mysql-test/t/mdev375.test @@ -27,6 +27,8 @@ SELECT 2; --connection default SELECT 0; +let $count_sessions=11; +--source include/wait_until_count_sessions.inc show status like "Threads_connected"; SET GLOBAL log_warnings=@save_log_warnings; From f8ab5ca374243977f331cdf6e569386230a7fddb Mon Sep 17 00:00:00 2001 From: Anel Husakovic Date: Fri, 28 Feb 2020 14:40:00 +0100 Subject: [PATCH 50/66] MDEV-20382: SHOW PRIVILEGES displays "Delete versioning rows" rather than "Delete History" --- mysql-test/main/grant.result | 2 +- sql/sql_show.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/main/grant.result b/mysql-test/main/grant.result index d89afbc320c..56d2eb8e6b1 100644 --- a/mysql-test/main/grant.result +++ b/mysql-test/main/grant.result @@ -612,7 +612,7 @@ Create temporary tables Databases To use CREATE TEMPORARY TABLE Create view Tables To create new views Create user Server Admin To create new users Delete Tables To delete existing rows -Delete versioning rows Tables To delete versioning table historical rows +Delete history Tables To delete versioning table historical rows Drop Databases,Tables To drop databases, tables, and views Event Server Admin To create, alter, drop and execute events Execute Functions,Procedures To execute stored routines diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 0b35789b869..7240cb3264c 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -592,7 +592,7 @@ static struct show_privileges_st sys_privileges[]= {"Create view", "Tables", "To create new views"}, {"Create user", "Server Admin", "To create new users"}, {"Delete", "Tables", "To delete existing rows"}, - {"Delete versioning rows", "Tables", "To delete versioning table historical rows"}, + {"Delete history", "Tables", "To delete versioning table historical rows"}, {"Drop", "Databases,Tables", "To drop databases, tables, and views"}, #ifdef HAVE_EVENT_SCHEDULER {"Event","Server Admin","To create, alter, drop and execute events"}, From c5c1027c6eb0db9738c231731b664f9736970d98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Wed, 26 Feb 2020 13:46:27 +0200 Subject: [PATCH 51/66] MDEV-19208 mariadb.pc: install into libdir The .pc file installed by mariadb mentions archful directories and therefore must be archful itself. This fixes MDEV-14340. --- debian/libmariadb-dev.install | 2 +- support-files/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/libmariadb-dev.install b/debian/libmariadb-dev.install index e62aad1b43f..856cdacfd95 100644 --- a/debian/libmariadb-dev.install +++ b/debian/libmariadb-dev.install @@ -5,5 +5,5 @@ usr/lib/*/libmysqlclient.so usr/lib/*/libmariadbclient.so usr/lib/*/libmariadbclient.a usr/lib/*/libmysqlservices.a +usr/lib/*/pkgconfig/mariadb.pc usr/share/aclocal/mysql.m4 -usr/share/pkgconfig/mariadb.pc diff --git a/support-files/CMakeLists.txt b/support-files/CMakeLists.txt index 92a46b7b12a..038e7163901 100644 --- a/support-files/CMakeLists.txt +++ b/support-files/CMakeLists.txt @@ -100,7 +100,7 @@ IF(UNIX) ENDIF() CONFIGURE_FILE(mariadb.pc.in ${CMAKE_CURRENT_BINARY_DIR}/mariadb.pc @ONLY) - INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mariadb.pc DESTINATION ${INSTALL_SHAREDIR}/pkgconfig COMPONENT Development) + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mariadb.pc DESTINATION ${INSTALL_LIBDIR}/pkgconfig COMPONENT Development) INSTALL(FILES mysql.m4 DESTINATION ${INSTALL_SHAREDIR}/aclocal COMPONENT Development) From 91aae18cc44e4ae7931b380077920124c3e42179 Mon Sep 17 00:00:00 2001 From: Stepan Patryshev Date: Fri, 6 Mar 2020 13:46:19 +0200 Subject: [PATCH 52/66] Enable galera.galera_ist_mariabackup and galera.mysql-wsrep#33. --- mysql-test/suite/galera/disabled.def | 2 -- 1 file changed, 2 deletions(-) diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index bd505bfc490..27691c8f4b5 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -19,7 +19,6 @@ galera_as_slave_replication_bundle : MDEV-15785 OPTION_GTID_BEGIN is set in Gtid galera_autoinc_sst_mariabackup : Known issue, may require porting MDEV-17458 from later versions galera_binlog_stmt_autoinc : MDEV-19959 Galera test failure on galera_binlog_stmt_autoinc galera_gcache_recover_manytrx : MDEV-18834 Galera test failure -galera_ist_mariabackup : MDEV-18829 test leaves port open galera_ist_progress : MDEV-15236 fails when trying to read transfer status galera_load_data : MDEV-19968 galera.galera_load_data galera_parallel_autoinc_largetrx : MDEV-20916 galera.galera_parallel_autoinc_largetrx @@ -31,7 +30,6 @@ galera_sst_mariabackup_table_options: MDEV-19741 Galera test failure on galera.g galera_var_innodb_disallow_writes : MDEV-20928 galera.galera_var_innodb_disallow_writes galera_var_node_address : MDEV-20485 Galera test failure galera_wan : MDEV-17259 Test failure on galera.galera_wan -mysql-wsrep#33 : MDEV-21420 galera.mysql-wsrep#33 partition : MDEV-19958 Galera test failure on galera.partition query_cache: MDEV-15805 Test failure on galera.query_cache sql_log_bin : MDEV-21491 galera.sql_log_bin From 6610532170dbbf1b313561d9165976be9901bb12 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Sat, 7 Mar 2020 14:46:40 +0200 Subject: [PATCH 53/66] Update install layout to account for multi-arch setup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cleanup install_layout to account for multi-arch setup and remove redundant defines in debian rules. Signed-off-by: VicenÈ›iu Ciorbaru --- CMakeLists.txt | 2 +- cmake/install_layout.cmake | 10 +++------- debian/rules | 3 --- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0dcc2a75587..9bb12f89751 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA -CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3) +CMAKE_MINIMUM_REQUIRED(VERSION 2.8.5) # explicitly set the policy to OLD # (cannot use NEW, not everyone is on cmake-2.8.12 yet) diff --git a/cmake/install_layout.cmake b/cmake/install_layout.cmake index c326a0fd340..e9413390172 100644 --- a/cmake/install_layout.cmake +++ b/cmake/install_layout.cmake @@ -174,7 +174,7 @@ SET(INSTALL_SCRIPTDIR_DEB "bin") SET(INSTALL_SYSCONFDIR_DEB "/etc") SET(INSTALL_SYSCONF2DIR_DEB "/etc/mysql/conf.d") # -SET(INSTALL_LIBDIR_DEB "lib") +SET(INSTALL_LIBDIR_DEB "lib/${CMAKE_CXX_LIBRARY_ARCHITECTURE}") SET(INSTALL_PLUGINDIR_DEB "lib/mysql/plugin") # SET(INSTALL_INCLUDEDIR_DEB "include/mysql") @@ -186,7 +186,7 @@ SET(INSTALL_INFODIR_DEB "share/info") # SET(INSTALL_SHAREDIR_DEB "share") SET(INSTALL_MYSQLSHAREDIR_DEB "share/mysql") -SET(INSTALL_MYSQLTESTDIR_DEB "mysql-test") +SET(INSTALL_MYSQLTESTDIR_DEB "share/mysql/mysql-test") SET(INSTALL_SQLBENCHDIR_DEB ".") SET(INSTALL_SUPPORTFILESDIR_DEB "share/mysql") # @@ -196,11 +196,7 @@ SET(INSTALL_UNIX_ADDRDIR_DEB "/var/run/mysqld/mysqld.sock") SET(INSTALL_SYSTEMD_UNITDIR_DEB "/lib/systemd/system") SET(INSTALL_SYSTEMD_SYSUSERSDIR_DEB "/usr/lib/sysusers.d") SET(INSTALL_SYSTEMD_TMPFILESDIR_DEB "/usr/lib/tmpfiles.d") -IF(CMAKE_SIZEOF_VOID_P EQUAL 8) - SET(INSTALL_PAMDIR_DEB "/lib/x86_64-linux-gnu/security") -ELSE() - SET(INSTALL_PAMDIR_DEB "/lib/i386-linux-gnu/security") -ENDIF() +SET(INSTALL_PAMDIR_DEB "/lib/${CMAKE_CXX_LIBRARY_ARCHITECTURE}/security") # # SVR4 layout diff --git a/debian/rules b/debian/rules index 3b1952ad2b9..647c73e43e0 100755 --- a/debian/rules +++ b/debian/rules @@ -86,9 +86,6 @@ endif $${MYSQL_COMPILER_LAUNCHER:+-DCMAKE_C_COMPILER_LAUNCHER=${MYSQL_COMPILER_LAUNCHER}} \ -DCMAKE_SYSTEM_PROCESSOR=$(DEB_BUILD_ARCH) \ -DBUILD_CONFIG=mysql_release \ - -DINSTALL_LIBDIR=lib/$(DEB_HOST_MULTIARCH) \ - -DINSTALL_PLUGINDIR=lib/mysql/plugin \ - -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test \ -DDEB=$(DISTRIBUTION) ..' touch $@ From d7f74150e5ab3c25c6ae9638bf21787c86c0f656 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Sat, 7 Mar 2020 19:21:40 +0200 Subject: [PATCH 54/66] Check for CPU_COUNT macro within my_getncpus * Small refactor of my_getncpus function to compile for very old glibc < 2.6. * Cleanup code to eliminate duplication. --- mysys/my_getncpus.c | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/mysys/my_getncpus.c b/mysys/my_getncpus.c index 0ee03631da8..6890de4f827 100644 --- a/mysys/my_getncpus.c +++ b/mysys/my_getncpus.c @@ -30,50 +30,52 @@ static int ncpus=0; int my_getncpus(void) { -#if (defined(__linux__) || defined(__FreeBSD__)) && defined(HAVE_PTHREAD_GETAFFINITY_NP) - cpu_set_t set; - if (!ncpus) { + /* + First attempt to get the total number of available cores. sysconf is + the fallback, but it can return a larger number. It will return the + total number of cores, not the ones available to the process - as + configured via core affinity. + */ +#if (defined(__linux__) || defined(__FreeBSD__)) && defined(HAVE_PTHREAD_GETAFFINITY_NP) + cpu_set_t set; if (pthread_getaffinity_np(pthread_self(), sizeof(set), &set) == 0) { +#ifdef CPU_COUNT + /* CPU_COUNT was introduced with glibc 2.6. */ ncpus= CPU_COUNT(&set); - } - else - { -#ifdef _SC_NPROCESSORS_ONLN - ncpus= sysconf(_SC_NPROCESSORS_ONLN); #else - ncpus= 2; + /* Implementation for platforms with glibc < 2.6 */ + size_t i; + + for (i= 0; i < CPU_SETSIZE; i++) + if (CPU_ISSET(i, &set)) + ncpus++; #endif + return ncpus; } - } +#endif /* (__linux__ || __FreeBSD__) && HAVE_PTHREAD_GETAFFINITY_NP */ -#else /* __linux__ || FreeBSD && HAVE_PTHREAD_GETAFFINITY_NP */ - - if (!ncpus) - { #ifdef _SC_NPROCESSORS_ONLN ncpus= sysconf(_SC_NPROCESSORS_ONLN); #elif defined(__WIN__) SYSTEM_INFO sysinfo; /* - * We are not calling GetNativeSystemInfo here because (1) we - * don't believe that they return different values for number - * of processors and (2) if WOW64 limits processors for Win32 - * then we don't want to try to override that. + We are not calling GetNativeSystemInfo here because (1) we + don't believe that they return different values for number + of processors and (2) if WOW64 limits processors for Win32 + then we don't want to try to override that. */ GetSystemInfo(&sysinfo); ncpus= sysinfo.dwNumberOfProcessors; #else - /* unknown so play safe: assume SMP and forbid uniprocessor build */ + /* Unknown so play safe: assume SMP and forbid uniprocessor build */ ncpus= 2; #endif } -#endif /* __linux__ || FreeBSD && HAVE_PTHREAD_GETAFFINITY_NP */ - return ncpus; } From fd2dc9c3fdfb73fa450db9fecd72044bb0554040 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vicen=C8=9Biu=20Ciorbaru?= Date: Sun, 8 Mar 2020 16:19:43 +0200 Subject: [PATCH 55/66] Correctly link mysqlclient.pc to mariadb.pc under multi-arch support --- debian/control | 1 + debian/libmariadb-dev-compat.links | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/debian/control b/debian/control index 18fea70f073..64034c831c9 100644 --- a/debian/control +++ b/debian/control @@ -7,6 +7,7 @@ Build-Depends: bison, cmake (>= 2.7), debhelper (>= 9), dh-apparmor, + dh-exec, dh-systemd, gdb, libaio-dev [linux-any], diff --git a/debian/libmariadb-dev-compat.links b/debian/libmariadb-dev-compat.links index 11e0dbce225..e02260c0129 100644 --- a/debian/libmariadb-dev-compat.links +++ b/debian/libmariadb-dev-compat.links @@ -1,3 +1,4 @@ +#!/usr/bin/dh-exec usr/bin/mariadb_config usr/bin/mysql_config usr/include/mariadb usr/include/mysql -usr/share/pkgconfig/mariadb.pc usr/share/pkgconfig/mysqlclient.pc +usr/lib/${DEB_HOST_MULTIARCH}/pkgconfig/mariadb.pc usr/lib/${DEB_HOST_MULTIARCH}/pkgconfig/mysqlclient.pc From 2bf4e574ad732d934016fe93e7297c017385ff68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Mon, 9 Mar 2020 09:00:14 +0200 Subject: [PATCH 56/66] MDEV-21758 : Events switched randomly to SLAVESIDE_DISABLED Change events only on Galera environment where idea is that event is enabled only on one node of the cluster and nodes are identified by server_id. --- mysql-test/r/events_restart.result | 27 ++++++++++++++++++++++++++ mysql-test/t/events_restart.test | 31 ++++++++++++++++++++++++++++++ sql/events.cc | 8 ++++---- 3 files changed, 62 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/events_restart.result b/mysql-test/r/events_restart.result index e22cfa011f2..ab90f7ff2f7 100644 --- a/mysql-test/r/events_restart.result +++ b/mysql-test/r/events_restart.result @@ -110,3 +110,30 @@ Db Name Definer Time zone Type Execute at Interval value Interval field Starts E test e1 root@localhost SYSTEM RECURRING # 1 SECOND # # DISABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci DROP EVENT e1; # end test for bug#11748899 +# +# Test for MDEV-21758 Events switched randomly to SLAVESIDE_DISABLED +# +create event ev on schedule every 1 minute do set @a= 1; +select name, originator, status from mysql.event; +name originator status +ev 1 ENABLED +# +# Restarting server with server_id=100 +# +select @@global.server_id; +@@global.server_id +100 +select name, originator, status from mysql.event; +name originator status +ev 1 ENABLED +set global server_id= 1; +# +# Restarting server with the original server_id=1 +# +select @@global.server_id; +@@global.server_id +1 +select name, originator, status from mysql.event; +name originator status +ev 1 ENABLED +drop event ev; diff --git a/mysql-test/t/events_restart.test b/mysql-test/t/events_restart.test index ca674170e96..f56bd32b71d 100644 --- a/mysql-test/t/events_restart.test +++ b/mysql-test/t/events_restart.test @@ -141,3 +141,34 @@ SHOW EVENTS; DROP EVENT e1; --echo # end test for bug#11748899 + +--echo # +--echo # Test for MDEV-21758 Events switched randomly to SLAVESIDE_DISABLED +--echo # + +create event ev on schedule every 1 minute do set @a= 1; +select name, originator, status from mysql.event; + +--let $server_id= `SELECT @@global.server_id` + +--echo # +--echo # Restarting server with server_id=100 +--echo # +--let $restart_parameters= --server-id=100 +--source include/restart_mysqld.inc + +select @@global.server_id; +select name, originator, status from mysql.event; +--eval set global server_id= $server_id + +--echo # +--echo # Restarting server with the original server_id=$server_id +--echo # +--let $restart_parameters= +--source include/restart_mysqld.inc + +select @@global.server_id; +select name, originator, status from mysql.event; + +# Cleanup +drop event ev; diff --git a/sql/events.cc b/sql/events.cc index c189354d5eb..c5dc51ab83d 100644 --- a/sql/events.cc +++ b/sql/events.cc @@ -1201,9 +1201,9 @@ Events::load_events_from_db(THD *thd) #ifdef WITH_WSREP /** - IF SST is done from a galera node that is also acting as MASTER - newly synced node in galera eco-system will also copy-over the event state - enabling duplicate event in galera eco-system. + If SST is done from a galera node that is also acting as MASTER + newly synced node in galera eco-system will also copy-over the + event state enabling duplicate event in galera eco-system. DISABLE such events if the current node is not event orginator. (Also, make sure you skip disabling it if is already disabled to avoid creation of redundant action) @@ -1213,7 +1213,7 @@ Events::load_events_from_db(THD *thd) Infact, based on galera use-case it seems like it recommends to have each node with different server-id. */ - if (et->originator != thd->variables.server_id) + if (WSREP(thd) && et->originator != thd->variables.server_id) { if (et->status == Event_parse_data::SLAVESIDE_DISABLED) continue; From 7a52b6fd25e69e3f74731c6ef38531c612d6ca60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 9 Mar 2020 12:04:02 +0200 Subject: [PATCH 57/66] Minor cleanup of main.partition_innodb Stop masking the Data_free values, because innodb_file_per_table=1 is the default. Also, do mask Update_time after updating tables, even though for some reason it does appear to matter. --- mysql-test/r/partition_innodb.result | 12 ++++++------ mysql-test/t/partition_innodb.test | 28 ++++++---------------------- 2 files changed, 12 insertions(+), 28 deletions(-) diff --git a/mysql-test/r/partition_innodb.result b/mysql-test/r/partition_innodb.result index 8c0950e3643..6770b64552f 100644 --- a/mysql-test/r/partition_innodb.result +++ b/mysql-test/r/partition_innodb.result @@ -386,33 +386,33 @@ DROP TABLE t1; create table t1 (a int) engine=innodb partition by hash(a) ; show table status like 't1'; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 InnoDB 10 Dynamic 2 8192 16384 0 0 # NULL # NULL NULL latin1_swedish_ci NULL partitioned +t1 InnoDB 10 Dynamic 2 8192 16384 0 0 0 NULL # NULL NULL latin1_swedish_ci NULL partitioned drop table t1; create table t1 (a int) engine = innodb partition by key (a); show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 InnoDB 10 Dynamic 2 8192 16384 0 0 # NULL # NULL NULL latin1_swedish_ci NULL partitioned +t1 InnoDB 10 Dynamic 2 8192 16384 0 0 0 NULL Create_time NULL NULL latin1_swedish_ci NULL partitioned insert into t1 values (0), (1), (2), (3); show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 InnoDB 10 Dynamic 4 4096 16384 0 0 # NULL # NULL NULL latin1_swedish_ci NULL partitioned +t1 InnoDB 10 Dynamic 4 4096 16384 0 0 0 NULL Create_time Update_time NULL latin1_swedish_ci NULL partitioned drop table t1; create table t1 (a int auto_increment primary key) engine = innodb partition by key (a); show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 InnoDB 10 Dynamic 2 8192 16384 0 0 # 1 # NULL NULL latin1_swedish_ci NULL partitioned +t1 InnoDB 10 Dynamic 2 8192 16384 0 0 0 1 Create_time NULL NULL latin1_swedish_ci NULL partitioned insert into t1 values (NULL), (NULL), (NULL), (NULL); show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 InnoDB 10 Dynamic 4 4096 16384 0 0 # 5 # NULL NULL latin1_swedish_ci NULL partitioned +t1 InnoDB 10 Dynamic 4 4096 16384 0 0 0 5 Create_time Update_time NULL latin1_swedish_ci NULL partitioned insert into t1 values (NULL), (NULL), (NULL), (NULL); show table status; Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment -t1 InnoDB 10 Dynamic 8 2048 16384 0 0 # 9 # NULL NULL latin1_swedish_ci NULL partitioned +t1 InnoDB 10 Dynamic 8 2048 16384 0 0 0 9 Create_time Update_time NULL latin1_swedish_ci NULL partitioned drop table t1; create table t1 (a int) partition by key (a) diff --git a/mysql-test/t/partition_innodb.test b/mysql-test/t/partition_innodb.test index b682162f7ea..518ef187d54 100644 --- a/mysql-test/t/partition_innodb.test +++ b/mysql-test/t/partition_innodb.test @@ -1,7 +1,3 @@ -if (`select plugin_auth_version < "5.6.25" from information_schema.plugins where plugin_name='innodb'`) -{ - --skip Not fixed in InnoDB as of 5.6.24 or earlier -} --source include/not_embedded.inc --source include/have_partition.inc --source include/have_innodb.inc @@ -405,9 +401,7 @@ DROP TABLE t1; # Bug #14673: Wrong InnoDB default row format # create table t1 (a int) engine=innodb partition by hash(a) ; -# Data_free for InnoDB tablespace varies depending on which -# tests have been run before this one ---replace_column 10 # 12 # +--replace_column 12 # show table status like 't1'; drop table t1; @@ -417,33 +411,23 @@ drop table t1; create table t1 (a int) engine = innodb partition by key (a); -# Data_free for InnoDB tablespace varies depending on which -# tests have been run before this one ---replace_column 10 # 12 # +--replace_column 12 Create_time show table status; insert into t1 values (0), (1), (2), (3); -# Data_free for InnoDB tablespace varies depending on which -# tests have been run before this one ---replace_column 10 # 12 # +--replace_column 12 Create_time 13 Update_time show table status; drop table t1; create table t1 (a int auto_increment primary key) engine = innodb partition by key (a); -# Data_free for InnoDB tablespace varies depending on which -# tests have been run before this one ---replace_column 10 # 12 # +--replace_column 12 Create_time show table status; insert into t1 values (NULL), (NULL), (NULL), (NULL); -# Data_free for InnoDB tablespace varies depending on which -# tests have been run before this one ---replace_column 10 # 12 # +--replace_column 12 Create_time 13 Update_time show table status; insert into t1 values (NULL), (NULL), (NULL), (NULL); -# Data_free for InnoDB tablespace varies depending on which -# tests have been run before this one ---replace_column 10 # 12 # +--replace_column 12 Create_time 13 Update_time show table status; drop table t1; From 940fcbe73bc0aad18bb77a45428126ff987b96c4 Mon Sep 17 00:00:00 2001 From: Monty Date: Fri, 6 Mar 2020 10:33:11 +0200 Subject: [PATCH 58/66] Improved speed of optimizer trace - Added unlikely() to optimize for not having optimizer trace enabled - Made THD::trace_started() inline - Added 'if (trace_enabled())' around some potentially expensive code (not many found) - Added ASSERT's to ensure we don't call expensive optimizer trace calls if optimizer trace is not enabled - Added length to Json_writer functions to speed up buffer writes when optimizer trace is enabled. - Changed LEX_CSTRING argument handling to not send full struct to writer function on_add_str() functions now trusts length arguments --- sql/my_json_writer.cc | 89 +++++++++++++++++++++++++++++-------------- sql/my_json_writer.h | 52 ++++++++++++++----------- sql/opt_range.cc | 15 +++++++- sql/opt_subselect.cc | 30 ++++++++------- sql/opt_trace.cc | 33 +++++++++------- sql/sql_class.cc | 5 --- sql/sql_class.h | 6 ++- sql/sql_select.cc | 43 +++++++++++++-------- sql/sql_test.cc | 5 ++- 9 files changed, 176 insertions(+), 102 deletions(-) diff --git a/sql/my_json_writer.cc b/sql/my_json_writer.cc index 4200769b1dc..0c059d18a23 100644 --- a/sql/my_json_writer.cc +++ b/sql/my_json_writer.cc @@ -79,7 +79,8 @@ void Json_writer::end_array() Json_writer& Json_writer::add_member(const char *name) { - if (fmt_helper.on_add_member(name)) + size_t len= strlen(name); + if (fmt_helper.on_add_member(name, len)) return *this; // handled // assert that we are in an object @@ -87,7 +88,22 @@ Json_writer& Json_writer::add_member(const char *name) start_element(); output.append('"'); - output.append(name); + output.append(name, len); + output.append("\": ", 3); + return *this; +} + +Json_writer& Json_writer::add_member(const char *name, size_t len) +{ + if (fmt_helper.on_add_member(name, len)) + return *this; // handled + + // assert that we are in an object + DBUG_ASSERT(!element_started); + start_element(); + + output.append('"'); + output.append(name, len); output.append("\": "); return *this; } @@ -141,28 +157,31 @@ void Json_writer::add_ull(ulonglong val) void Json_writer::add_size(longlong val) { char buf[64]; + size_t len; if (val < 1024) - my_snprintf(buf, sizeof(buf), "%lld", val); + len= my_snprintf(buf, sizeof(buf), "%lld", val); else if (val < 1024*1024*16) { /* Values less than 16MB are specified in KB for precision */ - size_t len= my_snprintf(buf, sizeof(buf), "%lld", val/1024); + len= my_snprintf(buf, sizeof(buf), "%lld", val/1024); strcpy(buf + len, "Kb"); + len+= 2; } else { - size_t len= my_snprintf(buf, sizeof(buf), "%lld", val/(1024*1024)); + len= my_snprintf(buf, sizeof(buf), "%lld", val/(1024*1024)); strcpy(buf + len, "Mb"); + len+= 2; } - add_str(buf); + add_str(buf, len); } void Json_writer::add_double(double val) { char buf[64]; - my_snprintf(buf, sizeof(buf), "%lg", val); - add_unquoted_str(buf); + size_t len= my_snprintf(buf, sizeof(buf), "%lg", val); + add_unquoted_str(buf, len); } @@ -174,32 +193,46 @@ void Json_writer::add_bool(bool val) void Json_writer::add_null() { - add_unquoted_str("null"); + add_unquoted_str("null", (size_t) 4); } void Json_writer::add_unquoted_str(const char* str) { - if (fmt_helper.on_add_str(str, 0)) + size_t len= strlen(str); + if (fmt_helper.on_add_str(str, len)) return; if (!element_started) start_element(); - output.append(str); + output.append(str, len); + element_started= false; +} + +void Json_writer::add_unquoted_str(const char* str, size_t len) +{ + if (fmt_helper.on_add_str(str, len)) + return; + + if (!element_started) + start_element(); + + output.append(str, len); element_started= false; } void Json_writer::add_str(const char *str) { - if (fmt_helper.on_add_str(str, 0)) + size_t len= strlen(str); + if (fmt_helper.on_add_str(str, len)) return; if (!element_started) start_element(); output.append('"'); - output.append(str); + output.append(str, len); output.append('"'); element_started= false; } @@ -230,20 +263,20 @@ void Json_writer::add_str(const String &str) Json_writer_object::Json_writer_object(THD *thd) : Json_writer_struct(thd) { - if (my_writer) + if (unlikely(my_writer)) my_writer->start_object(); } Json_writer_object::Json_writer_object(THD* thd, const char *str) : Json_writer_struct(thd) { - if (my_writer) + if (unlikely(my_writer)) my_writer->add_member(str).start_object(); } Json_writer_object::~Json_writer_object() { - if (!closed && my_writer) + if (my_writer && !closed) my_writer->end_object(); closed= TRUE; } @@ -251,20 +284,20 @@ Json_writer_object::~Json_writer_object() Json_writer_array::Json_writer_array(THD *thd) : Json_writer_struct(thd) { - if (my_writer) + if (unlikely(my_writer)) my_writer->start_array(); } Json_writer_array::Json_writer_array(THD *thd, const char *str) : Json_writer_struct(thd) { - if (my_writer) + if (unlikely(my_writer)) my_writer->add_member(str).start_array(); } Json_writer_array::~Json_writer_array() { - if (!closed && my_writer) + if (unlikely(my_writer && !closed)) { my_writer->end_array(); closed= TRUE; @@ -281,7 +314,8 @@ Json_writer_temp_disable::~Json_writer_temp_disable() thd->opt_trace.enable_tracing_if_required(); } -bool Single_line_formatting_helper::on_add_member(const char *name) +bool Single_line_formatting_helper::on_add_member(const char *name, + size_t len) { DBUG_ASSERT(state== INACTIVE || state == DISABLED); if (state != DISABLED) @@ -290,7 +324,6 @@ bool Single_line_formatting_helper::on_add_member(const char *name) buf_ptr= buffer; //append member name to the array - size_t len= strlen(name); if (len < MAX_LINE_LEN) { memcpy(buf_ptr, name, len); @@ -344,12 +377,10 @@ void Single_line_formatting_helper::on_start_object() bool Single_line_formatting_helper::on_add_str(const char *str, - size_t num_bytes) + size_t len) { if (state == IN_ARRAY) { - size_t len= num_bytes ? num_bytes : strlen(str); - // New length will be: // "$string", // quote + quote + comma + space = 4 @@ -425,9 +456,11 @@ void Single_line_formatting_helper::disable_and_flush() while (ptr < buf_ptr) { char *str= ptr; + size_t len= strlen(str); + if (nr == 0) { - owner->add_member(str); + owner->add_member(str, len); if (start_array) owner->start_array(); } @@ -435,13 +468,11 @@ void Single_line_formatting_helper::disable_and_flush() { //if (nr == 1) // owner->start_array(); - owner->add_str(str); + owner->add_str(str, len); } nr++; - while (*ptr!=0) - ptr++; - ptr++; + ptr+= len+1; } buf_ptr= buffer; state= INACTIVE; diff --git a/sql/my_json_writer.h b/sql/my_json_writer.h index f1f1be70bb0..f7ae58d9bc8 100644 --- a/sql/my_json_writer.h +++ b/sql/my_json_writer.h @@ -86,7 +86,7 @@ public: void init(Json_writer *owner_arg) { owner= owner_arg; } - bool on_add_member(const char *name); + bool on_add_member(const char *name, size_t len); bool on_start_array(); bool on_end_array(); @@ -184,6 +184,7 @@ class Json_writer public: /* Add a member. We must be in an object. */ Json_writer& add_member(const char *name); + Json_writer& add_member(const char *name, size_t len); /* Add atomic values */ void add_str(const char* val); @@ -202,6 +203,7 @@ public: private: void add_unquoted_str(const char* val); + void add_unquoted_str(const char* val, size_t len); public: /* Start a child object */ void start_object(); @@ -254,63 +256,63 @@ public: void init(Json_writer *my_writer) { writer= my_writer; } void add_str(const char* val) { - if (writer) + if (unlikely(writer)) writer->add_str(val); } void add_str(const char* val, size_t length) { - if (writer) + if (unlikely(writer)) writer->add_str(val, length); } void add_str(const String &str) { - if (writer) - writer->add_str(str); + if (unlikely(writer)) + writer->add_str(str.ptr(), str.length()); } - void add_str(LEX_CSTRING str) + void add_str(const LEX_CSTRING &str) { - if (writer) - writer->add_str(str.str); + if (unlikely(writer)) + writer->add_str(str.str, str.length); } void add_str(Item *item) { - if (writer) + if (unlikely(writer)) writer->add_str(item); } void add_ll(longlong val) { - if (writer) + if (unlikely(writer)) writer->add_ll(val); } void add_size(longlong val) { - if (writer) + if (unlikely(writer)) writer->add_size(val); } void add_double(double val) { - if (writer) + if (unlikely(writer)) writer->add_double(val); } void add_bool(bool val) { - if (writer) + if (unlikely(writer)) writer->add_bool(val); } void add_null() { - if (writer) + if (unlikely(writer)) writer->add_null(); } void add_table_name(const JOIN_TAB *tab) { - if (writer) + if (unlikely(writer)) writer->add_table_name(tab); } void add_table_name(const TABLE* table) { - if (writer) + if (unlikely(writer)) writer->add_table_name(table); } }; @@ -333,6 +335,10 @@ public: context.init(my_writer); closed= false; } + bool trace_started() + { + return my_writer != 0; + } }; @@ -349,7 +355,7 @@ class Json_writer_object : public Json_writer_struct private: void add_member(const char *name) { - if (my_writer) + if (unlikely(my_writer)) my_writer->add_member(name); } public: @@ -406,11 +412,11 @@ public: context.add_str(value, num_bytes); return *this; } - Json_writer_object& add(const char *name, LEX_CSTRING value) + Json_writer_object& add(const char *name, const LEX_CSTRING &value) { DBUG_ASSERT(!closed); add_member(name); - context.add_str(value.str); + context.add_str(value.str, value.length); return *this; } Json_writer_object& add(const char *name, Item *value) @@ -454,7 +460,7 @@ public: void end() { DBUG_ASSERT(!closed); - if (my_writer) + if (unlikely(my_writer)) my_writer->end_object(); closed= TRUE; } @@ -478,7 +484,7 @@ public: void end() { DBUG_ASSERT(!closed); - if (my_writer) + if (unlikely(my_writer)) my_writer->end_array(); closed= TRUE; } @@ -527,10 +533,10 @@ public: context.add_str(value, num_bytes); return *this; } - Json_writer_array& add(LEX_CSTRING value) + Json_writer_array& add(const LEX_CSTRING &value) { DBUG_ASSERT(!closed); - context.add_str(value.str); + context.add_str(value.str, value.length); return *this; } Json_writer_array& add(Item *value) diff --git a/sql/opt_range.cc b/sql/opt_range.cc index bff770fdc00..a1982e246a7 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -2258,6 +2258,7 @@ public: void TRP_RANGE::trace_basic_info(PARAM *param, Json_writer_object *trace_object) const { + DBUG_ASSERT(trace_object->trace_started()); DBUG_ASSERT(param->using_real_indexes); const uint keynr_in_table= param->real_keynr[key_idx]; @@ -2322,6 +2323,7 @@ void TRP_ROR_UNION::trace_basic_info(PARAM *param, Json_writer_object *trace_object) const { THD *thd= param->thd; + DBUG_ASSERT(trace_object->trace_started()); trace_object->add("type", "index_roworder_union"); Json_writer_array smth_trace(thd, "union_of"); for (TABLE_READ_PLAN **current= first_ror; current != last_ror; current++) @@ -2357,6 +2359,7 @@ void TRP_INDEX_INTERSECT::trace_basic_info(PARAM *param, Json_writer_object *trace_object) const { THD *thd= param->thd; + DBUG_ASSERT(trace_object->trace_started()); trace_object->add("type", "index_sort_intersect"); Json_writer_array smth_trace(thd, "index_sort_intersect_of"); for (TRP_RANGE **current= range_scans; current != range_scans_end; @@ -2390,6 +2393,7 @@ void TRP_INDEX_MERGE::trace_basic_info(PARAM *param, Json_writer_object *trace_object) const { THD *thd= param->thd; + DBUG_ASSERT(trace_object->trace_started()); trace_object->add("type", "index_merge"); Json_writer_array smth_trace(thd, "index_merge_of"); for (TRP_RANGE **current= range_scans; current != range_scans_end; current++) @@ -2458,6 +2462,8 @@ void TRP_GROUP_MIN_MAX::trace_basic_info(PARAM *param, Json_writer_object *trace_object) const { THD *thd= param->thd; + DBUG_ASSERT(trace_object->trace_started()); + trace_object->add("type", "index_group").add("index", index_info->name); if (min_max_arg_part) @@ -2833,7 +2839,7 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, { { Json_writer_array trace_range_summary(thd, - "setup_range_conditions"); + "setup_range_conditions"); tree= cond->get_mm_tree(¶m, &cond); } if (tree) @@ -5596,6 +5602,8 @@ ha_rows get_table_cardinality_for_index_intersect(TABLE *table) static void print_keyparts(THD *thd, KEY *key, uint key_parts) { + DBUG_ASSERT(thd->trace_started()); + KEY_PART_INFO *part= key->key_part; Json_writer_array keyparts= Json_writer_array(thd, "keyparts"); for(uint i= 0; i < key_parts; i++, part++) @@ -6385,6 +6393,8 @@ void TRP_ROR_INTERSECT::trace_basic_info(PARAM *param, Json_writer_object *trace_object) const { THD *thd= param->thd; + DBUG_ASSERT(trace_object->trace_started()); + trace_object->add("type", "index_roworder_intersect"); trace_object->add("rows", records); trace_object->add("cost", read_cost); @@ -7424,10 +7434,12 @@ static TRP_RANGE *get_key_scans_params(PARAM *param, SEL_TREE *tree, { trace_idx.add("chosen", false); if (found_records == HA_POS_ERROR) + { if (key->type == SEL_ARG::Type::MAYBE_KEY) trace_idx.add("cause", "depends on unread values"); else trace_idx.add("cause", "unknown"); + } else trace_idx.add("cause", "cost"); } @@ -15829,6 +15841,7 @@ static void trace_ranges(Json_writer_array *range_trace, sel_arg_range_seq_next, 0, 0}; KEY *keyinfo= param->table->key_info + param->real_keynr[idx]; uint n_key_parts= param->table->actual_n_key_parts(keyinfo); + DBUG_ASSERT(range_trace->trace_started()); seq.keyno= idx; seq.real_keyno= param->real_keynr[idx]; seq.param= param; diff --git a/sql/opt_subselect.cc b/sql/opt_subselect.cc index 23767bfbc16..dbb71264777 100644 --- a/sql/opt_subselect.cc +++ b/sql/opt_subselect.cc @@ -3050,12 +3050,13 @@ bool Sj_materialization_picker::check_qep(JOIN *join, } else { - Json_writer_object trace(join->thd); - trace.add("strategy", "SJ-Materialization"); /* This is SJ-Materialization with lookups */ Cost_estimate prefix_cost; signed int first_tab= (int)idx - mat_info->tables; double prefix_rec_count; + Json_writer_object trace(join->thd); + trace.add("strategy", "SJ-Materialization"); + if (first_tab < (int)join->const_tables) { prefix_cost.reset(); @@ -3084,7 +3085,7 @@ bool Sj_materialization_picker::check_qep(JOIN *join, *record_count= prefix_rec_count; *handled_fanout= new_join_tab->emb_sj_nest->sj_inner_tables; *strategy= SJ_OPT_MATERIALIZE; - if (unlikely(join->thd->trace_started())) + if (unlikely(trace.trace_started())) { trace.add("records", *record_count); trace.add("read_time", *read_time); @@ -3166,7 +3167,7 @@ bool Sj_materialization_picker::check_qep(JOIN *join, */ *record_count= prefix_rec_count; *handled_fanout= mat_nest->sj_inner_tables; - if (unlikely(join->thd->trace_started())) + if (unlikely(trace.trace_started())) { trace.add("records", *record_count); trace.add("read_time", *read_time); @@ -3266,7 +3267,7 @@ bool LooseScan_picker::check_qep(JOIN *join, */ *strategy= SJ_OPT_LOOSE_SCAN; *handled_fanout= first->table->emb_sj_nest->sj_inner_tables; - if (unlikely(join->thd->trace_started())) + if (unlikely(trace.trace_started())) { trace.add("records", *record_count); trace.add("read_time", *read_time); @@ -3384,7 +3385,7 @@ bool Firstmatch_picker::check_qep(JOIN *join, *handled_fanout= firstmatch_need_tables; /* *record_count and *read_time were set by the above call */ *strategy= SJ_OPT_FIRST_MATCH; - if (unlikely(join->thd->trace_started())) + if (unlikely(trace.trace_started())) { trace.add("records", *record_count); trace.add("read_time", *read_time); @@ -3469,6 +3470,7 @@ bool Duplicate_weedout_picker::check_qep(JOIN *join, uint temptable_rec_size; Json_writer_object trace(join->thd); trace.add("strategy", "DuplicateWeedout"); + if (first_tab == join->const_tables) { prefix_rec_count= 1.0; @@ -3529,7 +3531,7 @@ bool Duplicate_weedout_picker::check_qep(JOIN *join, *record_count= prefix_rec_count * sj_outer_fanout; *handled_fanout= dups_removed_fanout; *strategy= SJ_OPT_DUPS_WEEDOUT; - if (unlikely(join->thd->trace_started())) + if (unlikely(trace.trace_started())) { trace.add("records", *record_count); trace.add("read_time", *read_time); @@ -3727,18 +3729,20 @@ static void recalculate_prefix_record_count(JOIN *join, uint start, uint end) void fix_semijoin_strategies_for_picked_join_order(JOIN *join) { + join->sjm_lookup_tables= 0; + join->sjm_scan_tables= 0; + if (!join->select_lex->sj_nests.elements) + return; + + THD *thd= join->thd; uint table_count=join->table_count; uint tablenr; table_map remaining_tables= 0; table_map handled_tabs= 0; - join->sjm_lookup_tables= 0; - join->sjm_scan_tables= 0; - THD *thd= join->thd; - if (!join->select_lex->sj_nests.elements) - return; Json_writer_object trace_wrapper(thd); Json_writer_array trace_semijoin_strategies(thd, - "fix_semijoin_strategies_for_picked_join_order"); + "fix_semijoin_strategies_for_picked_join_order"); + for (tablenr= table_count - 1 ; tablenr != join->const_tables - 1; tablenr--) { POSITION *pos= join->best_positions + tablenr; diff --git a/sql/opt_trace.cc b/sql/opt_trace.cc index 7c82ba829bc..50274f06fbc 100644 --- a/sql/opt_trace.cc +++ b/sql/opt_trace.cc @@ -105,8 +105,8 @@ void opt_trace_print_expanded_query(THD *thd, SELECT_LEX *select_lex, Json_writer_object *writer) { - if (!thd->trace_started()) - return; + DBUG_ASSERT(thd->trace_started()); + StringBuffer<1024> str(system_charset_info); ulonglong save_option_bits= thd->variables.option_bits; thd->variables.option_bits &= ~OPTION_QUOTE_SHOW_CREATE; @@ -195,12 +195,11 @@ void opt_trace_disable_if_no_stored_proc_func_access(THD *thd, sp_head *sp) { if (likely(!(thd->variables.optimizer_trace & Opt_trace_context::FLAG_ENABLED)) || - thd->system_thread) + thd->system_thread || + !thd->trace_started()) return; Opt_trace_context *const trace= &thd->opt_trace; - if (!thd->trace_started()) - return; bool full_access; Security_context *const backup_thd_sctx= thd->security_context(); thd->set_security_context(&thd->main_security_ctx); @@ -229,13 +228,12 @@ void opt_trace_disable_if_no_stored_proc_func_access(THD *thd, sp_head *sp) void opt_trace_disable_if_no_tables_access(THD *thd, TABLE_LIST *tbl) { if (likely(!(thd->variables.optimizer_trace & - Opt_trace_context::FLAG_ENABLED)) || thd->system_thread) + Opt_trace_context::FLAG_ENABLED)) || + thd->system_thread || + !thd->trace_started()) return; + Opt_trace_context *const trace= &thd->opt_trace; - - if (!thd->trace_started()) - return; - Security_context *const backup_thd_sctx= thd->security_context(); thd->set_security_context(&thd->main_security_ctx); const TABLE_LIST *const first_not_own_table= thd->lex->first_not_own_table(); @@ -290,12 +288,11 @@ void opt_trace_disable_if_no_view_access(THD *thd, TABLE_LIST *view, if (likely(!(thd->variables.optimizer_trace & Opt_trace_context::FLAG_ENABLED)) || - thd->system_thread) - return; - Opt_trace_context *const trace= &thd->opt_trace; - if (!thd->trace_started()) + thd->system_thread || + !thd->trace_started()) return; + Opt_trace_context *const trace= &thd->opt_trace; Security_context *const backup_table_sctx= view->security_ctx; Security_context *const backup_thd_sctx= thd->security_context(); const GRANT_INFO backup_grant_info= view->grant; @@ -592,6 +589,7 @@ void Opt_trace_stmt::set_allowed_mem_size(size_t mem_size) void Json_writer::add_table_name(const JOIN_TAB *tab) { + DBUG_ASSERT(tab->join->thd->trace_started()); if (tab != NULL) { char table_name_buffer[SAFE_NAME_LEN]; @@ -630,6 +628,7 @@ void Json_writer::add_table_name(const TABLE *table) void add_table_scan_values_to_trace(THD *thd, JOIN_TAB *tab) { + DBUG_ASSERT(thd->trace_started()); Json_writer_object table_records(thd); table_records.add_table_name(tab); Json_writer_object table_rec(thd, "table_scan"); @@ -655,6 +654,8 @@ void add_table_scan_values_to_trace(THD *thd, JOIN_TAB *tab) void trace_plan_prefix(JOIN *join, uint idx, table_map join_tables) { THD *const thd= join->thd; + DBUG_ASSERT(thd->trace_started()); + Json_writer_array plan_prefix(thd, "plan_prefix"); for (uint i= 0; i < idx; i++) { @@ -679,6 +680,8 @@ void trace_plan_prefix(JOIN *join, uint idx, table_map join_tables) void print_final_join_order(JOIN *join) { + DBUG_ASSERT(join->thd->trace_started()); + Json_writer_object join_order(join->thd); Json_writer_array best_order(join->thd, "best_join_order"); JOIN_TAB *j; @@ -692,6 +695,8 @@ void print_final_join_order(JOIN *join) void print_best_access_for_table(THD *thd, POSITION *pos, enum join_type type) { + DBUG_ASSERT(thd->trace_started()); + Json_writer_object trace_best_access(thd, "chosen_access_method"); trace_best_access.add("type", type == JT_ALL ? "scan" : join_type_str[type]); diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 84e18e71a80..ca33a2a8f12 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -2205,11 +2205,6 @@ void THD::reset_globals() net.thd= 0; } -bool THD::trace_started() -{ - return opt_trace.is_started(); -} - /* Cleanup after query. diff --git a/sql/sql_class.h b/sql/sql_class.h index 36cb42c6314..2c7e911f808 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -3274,7 +3274,10 @@ public: void reset_for_reuse(); bool store_globals(); void reset_globals(); - bool trace_started(); + bool trace_started() + { + return opt_trace.is_started(); + } #ifdef SIGNAL_WITH_VIO_CLOSE inline void set_active_vio(Vio* vio) { @@ -5003,6 +5006,7 @@ public: Item *sp_fix_func_item(Item **it_addr); Item *sp_prepare_func_item(Item **it_addr, uint cols= 1); bool sp_eval_expr(Field *result_field, Item **expr_item_ptr); + }; /** A short cut for thd->get_stmt_da()->set_ok_status(). */ diff --git a/sql/sql_select.cc b/sql/sql_select.cc index decbdd59447..53f990ffd1f 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -353,8 +353,10 @@ bool dbug_user_var_equals_int(THD *thd, const char *name, int value) static void trace_table_dependencies(THD *thd, JOIN_TAB *join_tabs, uint table_count) { + DBUG_ASSERT(thd->trace_started()); Json_writer_object trace_wrapper(thd); Json_writer_array trace_dep(thd, "table_dependencies"); + for (uint i= 0; i < table_count; i++) { TABLE_LIST *table_ref= join_tabs[i].tab_list; @@ -1469,6 +1471,7 @@ JOIN::prepare(TABLE_LIST *tables_init, } } + if (thd->trace_started()) { Json_writer_object trace_wrapper(thd); opt_trace_print_expanded_query(thd, select_lex, &trace_wrapper); @@ -5352,6 +5355,7 @@ make_join_statistics(JOIN *join, List &tables_list, { Json_writer_object rows_estimation_wrapper(thd); Json_writer_array rows_estimation(thd, "rows_estimation"); + for (s=stat ; s < stat_end ; s++) { s->startup_cost= 0; @@ -5496,10 +5500,16 @@ make_join_statistics(JOIN *join, List &tables_list, if (select) delete select; else - add_table_scan_values_to_trace(thd, s); + { + if (thd->trace_started()) + add_table_scan_values_to_trace(thd, s); + } } else - add_table_scan_values_to_trace(thd, s); + { + if (thd->trace_started()) + add_table_scan_values_to_trace(thd, s); + } } } @@ -7402,7 +7412,7 @@ best_access_path(JOIN *join, Json_writer_object trace_access_idx(thd); /* - ft-keys require special treatment + full text keys require special treatment */ if (ft_key) { @@ -7414,7 +7424,7 @@ best_access_path(JOIN *join, records= 1.0; type= JT_FT; trace_access_idx.add("access_type", join_type_str[type]) - .add("index", keyinfo->name); + .add("full-text index", keyinfo->name); } else { @@ -11866,18 +11876,21 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) i++; } - trace_attached_comp.end(); - Json_writer_array trace_attached_summary(thd, - "attached_conditions_summary"); - for (tab= first_depth_first_tab(join); tab; - tab= next_depth_first_tab(join, tab)) + if (unlikely(thd->trace_started())) { - if (!tab->table) - continue; - Item *const cond = tab->select_cond; - Json_writer_object trace_one_table(thd); - trace_one_table.add_table_name(tab); - trace_one_table.add("attached", cond); + trace_attached_comp.end(); + Json_writer_array trace_attached_summary(thd, + "attached_conditions_summary"); + for (tab= first_depth_first_tab(join); tab; + tab= next_depth_first_tab(join, tab)) + { + if (!tab->table) + continue; + Item *const cond = tab->select_cond; + Json_writer_object trace_one_table(thd); + trace_one_table.add_table_name(tab); + trace_one_table.add("attached", cond); + } } } DBUG_RETURN(0); diff --git a/sql/sql_test.cc b/sql/sql_test.cc index 68d30d5fecb..a3506687a72 100644 --- a/sql/sql_test.cc +++ b/sql/sql_test.cc @@ -658,9 +658,12 @@ Memory allocated by threads: %s\n", void print_keyuse_array_for_trace(THD *thd, DYNAMIC_ARRAY *keyuse_array) { + DBUG_ASSERT(thd->trace_started()); + Json_writer_object wrapper(thd); Json_writer_array trace_key_uses(thd, "ref_optimizer_key_uses"); - for(uint i=0; i < keyuse_array->elements; i++) + + for (uint i=0; i < keyuse_array->elements; i++) { KEYUSE *keyuse= (KEYUSE*)dynamic_array_ptr(keyuse_array, i); Json_writer_object keyuse_elem(thd); From a24d0926b9459d715709d86a84a172cdce3b1bec Mon Sep 17 00:00:00 2001 From: Monty Date: Fri, 6 Mar 2020 14:21:20 +0200 Subject: [PATCH 59/66] Second stage of optimizer_trace optimizations - Move testing of my_writer to inline functions to avoid calls - Made more functions inline. Especially thd->thread_started() is now very optimized! - Moved Opt_trace_stmt classe to opt_trace_context.h to get critical functions inline --- sql/my_json_writer.cc | 44 ---------- sql/my_json_writer.h | 186 +++++++++++++++++++++++++++------------- sql/opt_trace.cc | 76 +++++----------- sql/opt_trace.h | 2 - sql/opt_trace_context.h | 54 +++++++++++- 5 files changed, 198 insertions(+), 164 deletions(-) diff --git a/sql/my_json_writer.cc b/sql/my_json_writer.cc index 0c059d18a23..f4cf8204d61 100644 --- a/sql/my_json_writer.cc +++ b/sql/my_json_writer.cc @@ -260,50 +260,6 @@ void Json_writer::add_str(const String &str) add_str(str.ptr(), str.length()); } -Json_writer_object::Json_writer_object(THD *thd) : - Json_writer_struct(thd) -{ - if (unlikely(my_writer)) - my_writer->start_object(); -} - -Json_writer_object::Json_writer_object(THD* thd, const char *str) : - Json_writer_struct(thd) -{ - if (unlikely(my_writer)) - my_writer->add_member(str).start_object(); -} - -Json_writer_object::~Json_writer_object() -{ - if (my_writer && !closed) - my_writer->end_object(); - closed= TRUE; -} - -Json_writer_array::Json_writer_array(THD *thd) : - Json_writer_struct(thd) -{ - if (unlikely(my_writer)) - my_writer->start_array(); -} - -Json_writer_array::Json_writer_array(THD *thd, const char *str) : - Json_writer_struct(thd) -{ - if (unlikely(my_writer)) - my_writer->add_member(str).start_array(); - -} -Json_writer_array::~Json_writer_array() -{ - if (unlikely(my_writer && !closed)) - { - my_writer->end_array(); - closed= TRUE; - } -} - Json_writer_temp_disable::Json_writer_temp_disable(THD *thd_arg) { thd= thd_arg; diff --git a/sql/my_json_writer.h b/sql/my_json_writer.h index f7ae58d9bc8..bc8002de529 100644 --- a/sql/my_json_writer.h +++ b/sql/my_json_writer.h @@ -256,63 +256,51 @@ public: void init(Json_writer *my_writer) { writer= my_writer; } void add_str(const char* val) { - if (unlikely(writer)) writer->add_str(val); } void add_str(const char* val, size_t length) { - if (unlikely(writer)) writer->add_str(val, length); } void add_str(const String &str) { - if (unlikely(writer)) writer->add_str(str.ptr(), str.length()); } void add_str(const LEX_CSTRING &str) { - if (unlikely(writer)) writer->add_str(str.str, str.length); } void add_str(Item *item) { - if (unlikely(writer)) writer->add_str(item); } void add_ll(longlong val) { - if (unlikely(writer)) writer->add_ll(val); } void add_size(longlong val) { - if (unlikely(writer)) writer->add_size(val); } void add_double(double val) { - if (unlikely(writer)) writer->add_double(val); } void add_bool(bool val) { - if (unlikely(writer)) writer->add_bool(val); } void add_null() { - if (unlikely(writer)) writer->add_null(); } void add_table_name(const JOIN_TAB *tab) { - if (unlikely(writer)) writer->add_table_name(tab); } void add_table_name(const TABLE* table) { - if (unlikely(writer)) writer->add_table_name(table); } }; @@ -355,55 +343,90 @@ class Json_writer_object : public Json_writer_struct private: void add_member(const char *name) { - if (unlikely(my_writer)) - my_writer->add_member(name); + my_writer->add_member(name); } public: - explicit Json_writer_object(THD *thd); - explicit Json_writer_object(THD *thd, const char *str); + explicit Json_writer_object(THD *thd) + : Json_writer_struct(thd) + { + if (unlikely(my_writer)) + my_writer->start_object(); + } + + explicit Json_writer_object(THD* thd, const char *str) + : Json_writer_struct(thd) + { + if (unlikely(my_writer)) + my_writer->add_member(str).start_object(); + } + + ~Json_writer_object() + { + if (my_writer && !closed) + my_writer->end_object(); + closed= TRUE; + } Json_writer_object& add(const char *name, bool value) { DBUG_ASSERT(!closed); - add_member(name); - context.add_bool(value); + if (my_writer) + { + add_member(name); + context.add_bool(value); + } return *this; } Json_writer_object& add(const char *name, ulonglong value) { DBUG_ASSERT(!closed); - add_member(name); - context.add_ll(static_cast(value)); + if (my_writer) + { + add_member(name); + context.add_ll(static_cast(value)); + } return *this; } Json_writer_object& add(const char *name, longlong value) { DBUG_ASSERT(!closed); - add_member(name); - context.add_ll(value); + if (my_writer) + { + add_member(name); + context.add_ll(value); + } return *this; } Json_writer_object& add(const char *name, double value) { DBUG_ASSERT(!closed); - add_member(name); - context.add_double(value); + if (my_writer) + { + add_member(name); + context.add_double(value); + } return *this; } #ifndef _WIN64 Json_writer_object& add(const char *name, size_t value) { DBUG_ASSERT(!closed); - add_member(name); - context.add_ll(static_cast(value)); + if (my_writer) + { + add_member(name); + context.add_ll(static_cast(value)); + } return *this; } #endif Json_writer_object& add(const char *name, const char *value) { DBUG_ASSERT(!closed); - add_member(name); - context.add_str(value); + if (my_writer) + { + add_member(name); + context.add_str(value); + } return *this; } Json_writer_object& add(const char *name, const char *value, size_t num_bytes) @@ -415,46 +438,64 @@ public: Json_writer_object& add(const char *name, const LEX_CSTRING &value) { DBUG_ASSERT(!closed); - add_member(name); - context.add_str(value.str, value.length); + if (my_writer) + { + add_member(name); + context.add_str(value.str, value.length); + } return *this; } Json_writer_object& add(const char *name, Item *value) { DBUG_ASSERT(!closed); - add_member(name); - context.add_str(value); + if (my_writer) + { + add_member(name); + context.add_str(value); + } return *this; } Json_writer_object& add_null(const char*name) { DBUG_ASSERT(!closed); - add_member(name); - context.add_null(); + if (my_writer) + { + add_member(name); + context.add_null(); + } return *this; } Json_writer_object& add_table_name(const JOIN_TAB *tab) { DBUG_ASSERT(!closed); - add_member("table"); - context.add_table_name(tab); + if (my_writer) + { + add_member("table"); + context.add_table_name(tab); + } return *this; } Json_writer_object& add_table_name(const TABLE *table) { DBUG_ASSERT(!closed); - add_member("table"); - context.add_table_name(table); + if (my_writer) + { + add_member("table"); + context.add_table_name(table); + } return *this; } Json_writer_object& add_select_number(uint select_number) { DBUG_ASSERT(!closed); - add_member("select_id"); - if (unlikely(select_number >= INT_MAX)) - context.add_str("fake"); - else - context.add_ll(static_cast(select_number)); + if (my_writer) + { + add_member("select_id"); + if (unlikely(select_number >= INT_MAX)) + context.add_str("fake"); + else + context.add_ll(static_cast(select_number)); + } return *this; } void end() @@ -464,7 +505,6 @@ public: my_writer->end_object(); closed= TRUE; } - ~Json_writer_object(); }; @@ -479,8 +519,25 @@ public: class Json_writer_array : public Json_writer_struct { public: - Json_writer_array(THD *thd); - Json_writer_array(THD *thd, const char *str); + Json_writer_array(THD *thd): Json_writer_struct(thd) + { + if (unlikely(my_writer)) + my_writer->start_array(); + } + + Json_writer_array(THD *thd, const char *str) : Json_writer_struct(thd) + { + if (unlikely(my_writer)) + my_writer->add_member(str).start_array(); + } + ~Json_writer_array() + { + if (unlikely(my_writer && !closed)) + { + my_writer->end_array(); + closed= TRUE; + } + } void end() { DBUG_ASSERT(!closed); @@ -492,78 +549,89 @@ public: Json_writer_array& add(bool value) { DBUG_ASSERT(!closed); - context.add_bool(value); + if (my_writer) + context.add_bool(value); return *this; } Json_writer_array& add(ulonglong value) { DBUG_ASSERT(!closed); - context.add_ll(static_cast(value)); + if (my_writer) + context.add_ll(static_cast(value)); return *this; } Json_writer_array& add(longlong value) { DBUG_ASSERT(!closed); - context.add_ll(value); + if (my_writer) + context.add_ll(value); return *this; } Json_writer_array& add(double value) { DBUG_ASSERT(!closed); - context.add_double(value); + if (my_writer) + context.add_double(value); return *this; } #ifndef _WIN64 Json_writer_array& add(size_t value) { DBUG_ASSERT(!closed); - context.add_ll(static_cast(value)); + if (my_writer) + context.add_ll(static_cast(value)); return *this; } #endif Json_writer_array& add(const char *value) { DBUG_ASSERT(!closed); - context.add_str(value); + if (my_writer) + context.add_str(value); return *this; } Json_writer_array& add(const char *value, size_t num_bytes) { DBUG_ASSERT(!closed); - context.add_str(value, num_bytes); + if (my_writer) + context.add_str(value, num_bytes); return *this; } Json_writer_array& add(const LEX_CSTRING &value) { DBUG_ASSERT(!closed); - context.add_str(value.str, value.length); + if (my_writer) + context.add_str(value.str, value.length); return *this; } Json_writer_array& add(Item *value) { DBUG_ASSERT(!closed); - context.add_str(value); + if (my_writer) + context.add_str(value); return *this; } Json_writer_array& add_null() { DBUG_ASSERT(!closed); - context.add_null(); + if (my_writer) + context.add_null(); return *this; } Json_writer_array& add_table_name(const JOIN_TAB *tab) { DBUG_ASSERT(!closed); - context.add_table_name(tab); + if (my_writer) + context.add_table_name(tab); return *this; } Json_writer_array& add_table_name(const TABLE *table) { DBUG_ASSERT(!closed); - context.add_table_name(table); + if (my_writer) + context.add_table_name(table); return *this; } - ~Json_writer_array(); }; /* diff --git a/sql/opt_trace.cc b/sql/opt_trace.cc index 50274f06fbc..afb188ceeb0 100644 --- a/sql/opt_trace.cc +++ b/sql/opt_trace.cc @@ -328,52 +328,28 @@ void opt_trace_disable_if_no_view_access(THD *thd, TABLE_LIST *view, The trace of one statement. */ -class Opt_trace_stmt { - public: - /** - Constructor, starts a trace for information_schema and dbug. - @param ctx_arg context - */ - Opt_trace_stmt(Opt_trace_context *ctx_arg) - { - ctx= ctx_arg; - current_json= new Json_writer(); - missing_priv= false; - I_S_disabled= 0; - } - ~Opt_trace_stmt() - { - delete current_json; - } - void set_query(const char *query_ptr, size_t length, const CHARSET_INFO *charset); - void open_struct(const char *key, char opening_bracket); - void close_struct(const char *saved_key, char closing_bracket); - void fill_info(Opt_trace_info* info); - void add(const char *key, char *opening_bracket, size_t val_length); - Json_writer* get_current_json() {return current_json;} - void missing_privilege(); - void disable_tracing_for_children(); - void enable_tracing_for_children(); - bool is_enabled(); +Opt_trace_stmt::Opt_trace_stmt(Opt_trace_context *ctx_arg) +{ + ctx= ctx_arg; + current_json= new Json_writer(); + missing_priv= false; + I_S_disabled= 0; +} - void set_allowed_mem_size(size_t mem_size); - size_t get_length() { return current_json->output.length(); } - size_t get_truncated_bytes() { return current_json->get_truncated_bytes(); } - bool get_missing_priv() { return missing_priv; } +Opt_trace_stmt::~Opt_trace_stmt() +{ + delete current_json; +} -private: - Opt_trace_context *ctx; - String query; // store the query sent by the user - Json_writer *current_json; // stores the trace - bool missing_priv; ///< whether user lacks privilege to see this trace - /* - 0 <=> this trace should be in information_schema. - !=0 tracing is disabled, this currently happens when we want to trace a - sub-statement. For now traces are only collect for the top statement - not for the sub-statments. - */ - uint I_S_disabled; -}; +size_t Opt_trace_stmt::get_length() +{ + return current_json->output.length(); +} + +size_t Opt_trace_stmt::get_truncated_bytes() +{ + return current_json->get_truncated_bytes(); +} void Opt_trace_stmt::set_query(const char *query_ptr, size_t length, const CHARSET_INFO *charset) @@ -381,13 +357,6 @@ void Opt_trace_stmt::set_query(const char *query_ptr, size_t length, query.append(query_ptr, length, charset); } -Json_writer* Opt_trace_context::get_current_json() -{ - if (!is_started()) - return NULL; - return current_trace->get_current_json(); -} - void Opt_trace_context::missing_privilege() { if (current_trace) @@ -573,11 +542,6 @@ void Opt_trace_stmt::enable_tracing_for_children() --I_S_disabled; } -bool Opt_trace_stmt::is_enabled() -{ - return I_S_disabled == 0; -} - void Opt_trace_stmt::set_allowed_mem_size(size_t mem_size) { current_json->set_size_limit(mem_size); diff --git a/sql/opt_trace.h b/sql/opt_trace.h index 46adbec2c3c..550f18c0797 100644 --- a/sql/opt_trace.h +++ b/sql/opt_trace.h @@ -21,8 +21,6 @@ class Item; class THD; struct TABLE_LIST; -class Opt_trace_stmt; - /* User-visible information about a trace. */ diff --git a/sql/opt_trace_context.h b/sql/opt_trace_context.h index e5df16b1e3b..2bcbbfdc536 100644 --- a/sql/opt_trace_context.h +++ b/sql/opt_trace_context.h @@ -3,7 +3,50 @@ #include "sql_array.h" -class Opt_trace_stmt; +class Opt_trace_context; +class Opt_trace_info; +class Json_writer; + +class Opt_trace_stmt { + public: + /** + Constructor, starts a trace for information_schema and dbug. + @param ctx_arg context + */ + Opt_trace_stmt(Opt_trace_context *ctx_arg); + ~Opt_trace_stmt(); + void set_query(const char *query_ptr, size_t length, const CHARSET_INFO *charset); + void open_struct(const char *key, char opening_bracket); + void close_struct(const char *saved_key, char closing_bracket); + void fill_info(Opt_trace_info* info); + void add(const char *key, char *opening_bracket, size_t val_length); + Json_writer* get_current_json() {return current_json;} + void missing_privilege(); + void disable_tracing_for_children(); + void enable_tracing_for_children(); + bool is_enabled() + { + return I_S_disabled == 0; + } + void set_allowed_mem_size(size_t mem_size); + size_t get_length(); + size_t get_truncated_bytes(); + bool get_missing_priv() { return missing_priv; } + +private: + Opt_trace_context *ctx; + String query; // store the query sent by the user + Json_writer *current_json; // stores the trace + bool missing_priv; ///< whether user lacks privilege to see this trace + /* + 0 <=> this trace should be in information_schema. + !=0 tracing is disabled, this currently happens when we want to trace a + sub-statement. For now traces are only collect for the top statement + not for the sub-statments. + */ + uint I_S_disabled; +}; + class Opt_trace_context { @@ -48,7 +91,12 @@ public: This returns the current trace, to which we are still writing and has not been finished */ - Json_writer* get_current_json(); + Json_writer* get_current_json() + { + if (!is_started()) + return NULL; + return current_trace->get_current_json(); + } bool empty() { @@ -57,7 +105,7 @@ public: bool is_started() { - return current_trace && is_enabled(); + return current_trace && current_trace->is_enabled(); } bool disable_tracing_if_required(); From c037cdadf47fc6dd0546ddade9f9168bed8a3690 Mon Sep 17 00:00:00 2001 From: Monty Date: Thu, 5 Mar 2020 14:10:03 +0200 Subject: [PATCH 60/66] Added keyread_time() to HEAP The default keyread_time() was optimized for blocks and not suitable for HEAP. The effect was the HEAP prefered table scans over ranges for btree indexes. Fixed also get_sweep_read_cost() for HEAP tables. --- mysql-test/main/endspace.result | 2 +- mysql-test/suite/heap/heap_btree.result | 2 +- mysql-test/suite/heap/heap_hash.result | 8 ++++---- sql/handler.cc | 6 ++++-- sql/opt_range.cc | 3 ++- storage/heap/ha_heap.h | 5 +++-- 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/mysql-test/main/endspace.result b/mysql-test/main/endspace.result index a0f53167148..f9619db7e64 100644 --- a/mysql-test/main/endspace.result +++ b/mysql-test/main/endspace.result @@ -145,8 +145,8 @@ teststring teststring select * from t1 where text1='teststring' or text1 >= 'teststring\t'; text1 -teststring teststring +teststring select * from t1 order by text1; text1 nothing diff --git a/mysql-test/suite/heap/heap_btree.result b/mysql-test/suite/heap/heap_btree.result index 5985350a213..0f749386756 100644 --- a/mysql-test/suite/heap/heap_btree.result +++ b/mysql-test/suite/heap/heap_btree.result @@ -178,7 +178,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range btn btn 10 NULL 1 Using where explain select * from t1 where btn like "h%"; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL btn NULL NULL NULL # Using where +1 SIMPLE t1 range btn btn 10 NULL # Using where explain select * from t1 where btn like "a%"; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range btn btn 10 NULL 1 Using where diff --git a/mysql-test/suite/heap/heap_hash.result b/mysql-test/suite/heap/heap_hash.result index 1fbfa99c61f..df1acdae506 100644 --- a/mysql-test/suite/heap/heap_hash.result +++ b/mysql-test/suite/heap/heap_hash.result @@ -428,14 +428,14 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range uniq_id uniq_id 8 NULL 2 Using where select 0+a from t1 where a in (869751,736494,226312,802616,728912); 0+a -869751 -736494 226312 -802616 728912 +736494 +802616 +869751 explain select 0+a from t1 where a in (869751,736494,226312,802616,728912); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL uniq_id NULL NULL NULL 5 Using where +1 SIMPLE t1 range uniq_id uniq_id 8 NULL 5 Using where drop table t1; End of 5.3 tests # diff --git a/sql/handler.cc b/sql/handler.cc index 77b7f490590..5f69a70d5e2 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -2675,11 +2675,13 @@ double handler::keyread_time(uint index, uint ranges, ha_rows rows) size_t len= table->key_info[index].key_length + ref_length; if (index == table->s->primary_key && table->file->primary_key_is_clustered()) len= table->s->stored_rec_length; - uint keys_per_block= (uint) (stats.block_size/2.0/len+1); - ulonglong blocks= !rows ? 0 : (rows-1) / keys_per_block + 1; double cost= (double)rows*len/(stats.block_size+1)*IDX_BLOCK_COPY_COST; if (ranges) + { + uint keys_per_block= (uint) (stats.block_size/2.0/len+1); + ulonglong blocks= !rows ? 0 : (rows-1) / keys_per_block + 1; cost+= blocks; + } return cost; } diff --git a/sql/opt_range.cc b/sql/opt_range.cc index a1982e246a7..4a7bbd9770b 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -4897,7 +4897,8 @@ double get_sweep_read_cost(const PARAM *param, ha_rows records) { double result; DBUG_ENTER("get_sweep_read_cost"); - if (param->table->file->primary_key_is_clustered()) + if (param->table->file->primary_key_is_clustered() || + param->table->file->stats.block_size == 0 /* HEAP */) { /* We are using the primary key to find the rows. diff --git a/storage/heap/ha_heap.h b/storage/heap/ha_heap.h index 3440c8fd205..370906bd1f6 100644 --- a/storage/heap/ha_heap.h +++ b/storage/heap/ha_heap.h @@ -65,8 +65,9 @@ public: double scan_time() { return (double) (stats.records+stats.deleted) / 20.0+10; } double read_time(uint index, uint ranges, ha_rows rows) - { return (double) rows / 20.0+1; } - + { return (double) rows / 20.0+1; } + double keyread_time(uint index, uint ranges, ha_rows rows) + { return (double) rows / 20.0+1; } int open(const char *name, int mode, uint test_if_locked); int close(void); void set_keys_for_scanning(void); From 5c6c4b13952b0b832b3480bbb1cc9c9889244d33 Mon Sep 17 00:00:00 2001 From: Monty Date: Mon, 9 Mar 2020 14:53:35 +0200 Subject: [PATCH 61/66] Fixes for previous not-complete-push --- mysql-test/suite/heap/heap_btree.result | 14 +++++++------- sql/opt_trace_context.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mysql-test/suite/heap/heap_btree.result b/mysql-test/suite/heap/heap_btree.result index 0f749386756..8c1c8217b6a 100644 --- a/mysql-test/suite/heap/heap_btree.result +++ b/mysql-test/suite/heap/heap_btree.result @@ -59,10 +59,10 @@ a 869751 select * from t1 where a in (869751,736494,226312,802616); a -869751 -736494 226312 +736494 802616 +869751 alter table t1 engine=myisam; explain select * from t1 where a in (869751,736494,226312,802616); id select_type table type possible_keys key key_len ref rows Extra @@ -350,11 +350,11 @@ insert into t1 values (869751),(736494),(226312),(802616),(728912); alter table t1 add unique uniq_id using BTREE (a); select 0+a from t1 where a > 736494; 0+a -869751 802616 +869751 explain select 0+a from t1 where a > 736494; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL uniq_id NULL NULL NULL 5 Using where +1 SIMPLE t1 range uniq_id uniq_id 8 NULL 3 Using where select 0+a from t1 where a = 736494; 0+a 736494 @@ -370,13 +370,13 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range uniq_id uniq_id 8 NULL 2 Using where select 0+a from t1 where a in (869751,736494,226312,802616); 0+a -869751 -736494 226312 +736494 802616 +869751 explain select 0+a from t1 where a in (869751,736494,226312,802616); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL uniq_id NULL NULL NULL 5 Using where +1 SIMPLE t1 range uniq_id uniq_id 8 NULL 4 Using where drop table t1; End of 5.3 tests create table t1 (id int, a varchar(300) not null, key using btree(a)) engine=heap; diff --git a/sql/opt_trace_context.h b/sql/opt_trace_context.h index 2bcbbfdc536..f578a0c67ec 100644 --- a/sql/opt_trace_context.h +++ b/sql/opt_trace_context.h @@ -4,7 +4,7 @@ #include "sql_array.h" class Opt_trace_context; -class Opt_trace_info; +struct Opt_trace_info; class Json_writer; class Opt_trace_stmt { From 1c40cb6877c35cceebe59384998df58264997d39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 10 Mar 2020 13:26:57 +0200 Subject: [PATCH 62/66] Do not bother to disable non-existing tests --- mysql-test/disabled.def | 2 -- 1 file changed, 2 deletions(-) diff --git a/mysql-test/disabled.def b/mysql-test/disabled.def index b6991cc1d37..ee30c4f4d3c 100644 --- a/mysql-test/disabled.def +++ b/mysql-test/disabled.def @@ -17,8 +17,6 @@ mysql_embedded : Bug#12561297 2011-05-14 Anitha Dependent on PB2 chang ssl_crl_clients_valid : broken upstream ssl_crl : broken upstream ssl_crl_clrpath : broken upstream -innodb-wl5522-debug-zip : broken upstream -innodb_bug12902967 : broken upstream file_contents : MDEV-6526 these files are not installed anymore max_statement_time : cannot possibly work, depends on timing partition_open_files_limit : open_files_limit check broken by MDEV-18360 From 69e4c74e079fc78812a75b1e2c050890161826bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 10 Mar 2020 13:31:20 +0200 Subject: [PATCH 63/66] Make main.mysql_client_test non-great again Re-enable main.mysql_client_test on all builders, because at the moment we do not run any --big-test on buildbot due to resource constraints. A number of tests were declared big in commit eeee1832d792ac296e1cebeeed1f7a7ce4ce4551 in an attempt to save resources on buildbot. --- mysql-test/t/mysql_client_test.test | 2 -- 1 file changed, 2 deletions(-) diff --git a/mysql-test/t/mysql_client_test.test b/mysql-test/t/mysql_client_test.test index 8fbbbc1602e..8c2f5e2c32b 100644 --- a/mysql-test/t/mysql_client_test.test +++ b/mysql-test/t/mysql_client_test.test @@ -2,8 +2,6 @@ -- source include/not_embedded.inc # need to have the dynamic loading turned on for the client plugin tests --source include/have_plugin_auth.inc -# This test is slow on buildbot. ---source include/big_test.inc # Run test with default character set --source include/default_charset.inc From 2b8b85bd0a916f68dbe0af2af71569c81605242f Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Tue, 10 Mar 2020 15:14:53 +0300 Subject: [PATCH 64/66] fix use-after-free --- extra/mariabackup/xtrabackup.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index d5e5fc49e75..828c2e06fc2 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -3132,13 +3132,13 @@ xb_load_single_table_tablespace( } } - ut_free(name); - delete file; if (err != DB_SUCCESS && xtrabackup_backup && !is_empty_file) { die("Failed to not validate first page of the file %s, error %d",name, (int)err); } + + ut_free(name); } /** Scan the database directories under the MySQL datadir, looking for From 02343c4a54b055ea3483075219bb3ce010c33671 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 10 Mar 2020 15:46:29 +0200 Subject: [PATCH 65/66] MDEV-19740: Correct a type mismatch WITH_INNODB_EXTRA_DEBUG --- storage/innobase/page/page0zip.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/storage/innobase/page/page0zip.cc b/storage/innobase/page/page0zip.cc index 7a017913dfe..aec6bcc38da 100644 --- a/storage/innobase/page/page0zip.cc +++ b/storage/innobase/page/page0zip.cc @@ -3431,11 +3431,12 @@ page_zip_validate_low( differed. Let us ignore it. */ page_zip_fail(("page_zip_validate:" " min_rec_flag" - " (%s%lu,%lu,0x%02lx)\n", + " (%s" ULINTPF "," ULINTPF + ",0x%02x)\n", sloppy ? "ignored, " : "", page_get_space_id(page), page_get_page_no(page), - (ulong) page[offset])); + page[offset])); /* We don't check for spatial index, since the "minimum record" could be deleted when doing rtr_update_mbr_field. From 8fa1b6bb88be39001b98bab071b957da3c271a17 Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Tue, 20 Feb 2018 15:35:09 +0300 Subject: [PATCH 66/66] MDEV-15724 - Possible crash in parser Parser: uninitialized Lex->create_last_non_select_table under mysql_unpack_partition() fix. Tested with main, parts suites. --- sql/sql_lex.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 6e6c79c0e6c..58c91ab21e7 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -203,6 +203,7 @@ init_lex_with_single_table(THD *thd, TABLE *table, LEX *lex) table->map= 1; //To ensure correct calculation of const item table_list->table= table; table_list->cacheable_table= false; + lex->create_last_non_select_table= table_list; return FALSE; }