From dc680d2119d3cc4ad642e5c1f11f38ab072b3032 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 11 Mar 2022 16:14:06 +0200 Subject: [PATCH 1/4] Avoid shutdown timeout in innodb.undo_truncate Let us explicitly wait for purge before invoking a slow shutdown, so that instrumented builds (such as ASAN or UBSAN) will not exceed the 60-second timeout during shutdown. --- mysql-test/suite/innodb/r/undo_truncate.result | 2 ++ mysql-test/suite/innodb/t/undo_truncate.test | 2 ++ 2 files changed, 4 insertions(+) diff --git a/mysql-test/suite/innodb/r/undo_truncate.result b/mysql-test/suite/innodb/r/undo_truncate.result index 4b185a58d2c..1cc4fb2857c 100644 --- a/mysql-test/suite/innodb/r/undo_truncate.result +++ b/mysql-test/suite/innodb/r/undo_truncate.result @@ -31,5 +31,7 @@ connection con2; commit; disconnect con2; connection default; +SET GLOBAL innodb_purge_rseg_truncate_frequency=1; +SET GLOBAL innodb_max_purge_lag_wait=0; set global innodb_fast_shutdown=0; drop table t1, t2; diff --git a/mysql-test/suite/innodb/t/undo_truncate.test b/mysql-test/suite/innodb/t/undo_truncate.test index 51bb4f4b9fc..2ca4f67d0bf 100644 --- a/mysql-test/suite/innodb/t/undo_truncate.test +++ b/mysql-test/suite/innodb/t/undo_truncate.test @@ -45,6 +45,8 @@ connection default; let $trx_before= `SHOW ENGINE INNODB STATUS`; let $trx_before= `select substr('$trx_before',9)+2`; +SET GLOBAL innodb_purge_rseg_truncate_frequency=1; +SET GLOBAL innodb_max_purge_lag_wait=0; set global innodb_fast_shutdown=0; --source include/restart_mysqld.inc --replace_regex /.*Trx id counter ([0-9]+).*/\1/ From 6789f2cfabb6a92b17ce822921cb522098ef3ff7 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 12 Oct 2021 18:34:51 +0200 Subject: [PATCH 2/4] MDEV-18304 sql_safe_updates does not work with OR clauses not every index-using plan sets bits in table->quick_keys. QUICK_ROR_INTERSECT_SELECT, for example, doesn't. Use the fact that select->quick is set instead. Also allow EXPLAIN to work. --- mysql-test/main/sql_safe_updates.result | 24 ++++++++++++++++++++++++ mysql-test/main/sql_safe_updates.test | 25 ++++++++++++++++++++++--- sql/sql_delete.cc | 5 +++-- sql/sql_update.cc | 5 +++-- 4 files changed, 52 insertions(+), 7 deletions(-) diff --git a/mysql-test/main/sql_safe_updates.result b/mysql-test/main/sql_safe_updates.result index 356cd36bad9..f2944e60489 100644 --- a/mysql-test/main/sql_safe_updates.result +++ b/mysql-test/main/sql_safe_updates.result @@ -1,3 +1,27 @@ +# +# MDEV-14429 sql_safe_updates in my.cnf not work +# select @@sql_safe_updates; @@sql_safe_updates 1 +# +# MDEV-18304 sql_safe_updates does not work with OR clauses +# +create table t1 (a int, b int, primary key (a), key (b)); +update t1 set b=2 where a=1 or b=2; +ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column +explain update t1 set b=2 where a=1 or b=2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 1 Using where +delete from t1 where a=1 or b=2; +ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column +explain delete from t1 where a=1 or b=2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 1 Using where +insert into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8); +update t1 set b=2 where a=1 or b=2; +delete from t1 where a=1 or b=2; +drop table t1; +# +# End of 10.3 tests +# diff --git a/mysql-test/main/sql_safe_updates.test b/mysql-test/main/sql_safe_updates.test index 18decd0ff2c..25fe4a15ca2 100644 --- a/mysql-test/main/sql_safe_updates.test +++ b/mysql-test/main/sql_safe_updates.test @@ -1,4 +1,23 @@ -# -# MDEV-14429 sql_safe_updates in my.cnf not work -# +--echo # +--echo # MDEV-14429 sql_safe_updates in my.cnf not work +--echo # select @@sql_safe_updates; + +--echo # +--echo # MDEV-18304 sql_safe_updates does not work with OR clauses +--echo # +create table t1 (a int, b int, primary key (a), key (b)); +--error ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE +update t1 set b=2 where a=1 or b=2; +explain update t1 set b=2 where a=1 or b=2; +--error ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE +delete from t1 where a=1 or b=2; +explain delete from t1 where a=1 or b=2; +insert into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8); +update t1 set b=2 where a=1 or b=2; +delete from t1 where a=1 or b=2; +drop table t1; + +--echo # +--echo # End of 10.3 tests +--echo # diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index f6c05da9445..a0d8feb61e8 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -371,7 +371,8 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, DBUG_RETURN(TRUE); const_cond= (!conds || conds->const_item()); - safe_update= MY_TEST(thd->variables.option_bits & OPTION_SAFE_UPDATES); + safe_update= (thd->variables.option_bits & OPTION_SAFE_UPDATES) && + !thd->lex->describe; if (safe_update && const_cond) { my_message(ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE, @@ -497,7 +498,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, } /* If running in safe sql mode, don't allow updates without keys */ - if (table->quick_keys.is_clear_all()) + if (!select || !select->quick) { thd->set_status_no_index_used(); if (safe_update && !using_limit) diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 6065d03402f..1e997b75c7d 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -314,7 +314,8 @@ int mysql_update(THD *thd, ha_rows *found_return, ha_rows *updated_return) { bool using_limit= limit != HA_POS_ERROR; - bool safe_update= thd->variables.option_bits & OPTION_SAFE_UPDATES; + bool safe_update= (thd->variables.option_bits & OPTION_SAFE_UPDATES) + && !thd->lex->describe; bool used_key_is_modified= FALSE, transactional_table; bool will_batch= FALSE; bool can_compare_record; @@ -517,7 +518,7 @@ int mysql_update(THD *thd, } /* If running in safe sql mode, don't allow updates without keys */ - if (table->quick_keys.is_clear_all()) + if (!select || !select->quick) { thd->set_status_no_index_used(); if (safe_update && !using_limit) From f217c761892683403b65da75b2f2abb8ebd295b2 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 21 Feb 2022 18:16:17 +0100 Subject: [PATCH 3/4] mtr: fix --source lines detection mysqltest allows leading spaces before `--`, so mtr should too --- mysql-test/lib/mtr_cases.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/lib/mtr_cases.pm b/mysql-test/lib/mtr_cases.pm index 52872fa610f..dc385cb6c78 100644 --- a/mysql-test/lib/mtr_cases.pm +++ b/mysql-test/lib/mtr_cases.pm @@ -1036,7 +1036,7 @@ sub get_tags_from_file($$) { } # Check for a sourced include file. - if ($line =~ /^(--)?[[:space:]]*source[[:space:]]+([^;[:space:]]+)/) + if ($line =~ /^[[:space:]]*(--)?[[:space:]]*source[[:space:]]+([^;[:space:]]+)/) { my $include= $2; # The rules below must match open_file() function of mysqltest.cc From 1c43660aea349a92c13e04994941ded1b91714ff Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Mon, 14 Mar 2022 22:35:11 +0530 Subject: [PATCH 4/4] MDEV-28060 Online DDL fails while checking for instant alter condition - InnoDB fails to skip newly created column while checking for change column when table is in redundant row format. This issue is caused the MDEV-18035 (ccb1acbd3c15f0d99d1ea3cd1b206da38fa1c17f) --- mysql-test/suite/innodb/r/instant_alter_bugs.result | 9 +++++++++ mysql-test/suite/innodb/t/instant_alter_bugs.test | 9 +++++++++ storage/innobase/handler/handler0alter.cc | 7 ++++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/innodb/r/instant_alter_bugs.result b/mysql-test/suite/innodb/r/instant_alter_bugs.result index e0457155d6a..0c82ee8f070 100644 --- a/mysql-test/suite/innodb/r/instant_alter_bugs.result +++ b/mysql-test/suite/innodb/r/instant_alter_bugs.result @@ -448,4 +448,13 @@ ALTER TABLE t ADD d INT; affected rows: 0 info: Records: 0 Duplicates: 0 Warnings: 0 DROP TABLE t; +# +# MDEV-28060 Online DDL fails while checking for instant +# alter condition +# +CREATE TABLE t1(f1 CHAR(10) NOT NULL)ROW_FORMAT=REDUNDANT,ENGINE=InnoDB; +ALTER TABLE t1 ADD COLUMN(f2 INT NOT NULL, f3 INT NOT NULL, +f4 INT NOT NULL, f5 INT NOT NULL), +CHANGE COLUMN f1 f1 CHAR(10) DEFAULT NULL; +DROP TABLE t1; SET GLOBAL innodb_purge_rseg_truncate_frequency=@save_frequency; diff --git a/mysql-test/suite/innodb/t/instant_alter_bugs.test b/mysql-test/suite/innodb/t/instant_alter_bugs.test index 1ba6442c860..b22d4bbbae1 100644 --- a/mysql-test/suite/innodb/t/instant_alter_bugs.test +++ b/mysql-test/suite/innodb/t/instant_alter_bugs.test @@ -466,4 +466,13 @@ ALTER TABLE t ADD d INT; --disable_info DROP TABLE t; +--echo # +--echo # MDEV-28060 Online DDL fails while checking for instant +--echo # alter condition +--echo # +CREATE TABLE t1(f1 CHAR(10) NOT NULL)ROW_FORMAT=REDUNDANT,ENGINE=InnoDB; +ALTER TABLE t1 ADD COLUMN(f2 INT NOT NULL, f3 INT NOT NULL, + f4 INT NOT NULL, f5 INT NOT NULL), + CHANGE COLUMN f1 f1 CHAR(10) DEFAULT NULL; +DROP TABLE t1; SET GLOBAL innodb_purge_rseg_truncate_frequency=@save_frequency; diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index e812bfc4928..e79d9d67dbf 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -1795,8 +1795,13 @@ set_max_size: Field** af = altered_table->field; Field** const end = altered_table->field + altered_table->s->fields; + List_iterator_fast cf_it( + ha_alter_info->alter_info->create_list); for (unsigned c = 0; af < end; af++) { - if (!(*af)->stored_in_db()) { + const Create_field* cf = cf_it++; + if (!cf->field || !(*af)->stored_in_db()) { + /* Ignore virtual or newly created + column */ continue; }